babylon.module.d.ts 6.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968
  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. * Represens 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: DeepImmutable<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. /**
  2448. * Defines the first coordinates (on X axis)
  2449. */
  2450. x: number;
  2451. /**
  2452. * Defines the second coordinates (on Y axis)
  2453. */
  2454. y: number;
  2455. /**
  2456. * Defines the third coordinates (on Z axis)
  2457. */
  2458. z: number;
  2459. private static _UpReadOnly;
  2460. private static _ZeroReadOnly;
  2461. /**
  2462. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2463. * @param x defines the first coordinates (on X axis)
  2464. * @param y defines the second coordinates (on Y axis)
  2465. * @param z defines the third coordinates (on Z axis)
  2466. */
  2467. constructor(
  2468. /**
  2469. * Defines the first coordinates (on X axis)
  2470. */
  2471. x?: number,
  2472. /**
  2473. * Defines the second coordinates (on Y axis)
  2474. */
  2475. y?: number,
  2476. /**
  2477. * Defines the third coordinates (on Z axis)
  2478. */
  2479. z?: number);
  2480. /**
  2481. * Creates a string representation of the Vector3
  2482. * @returns a string with the Vector3 coordinates.
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name
  2487. * @returns the string "Vector3"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Creates the Vector3 hash code
  2492. * @returns a number which tends to be unique between Vector3 instances
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Creates an array containing three elements : the coordinates of the Vector3
  2497. * @returns a new array of numbers
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2502. * @param array defines the destination array
  2503. * @param index defines the offset in the destination array
  2504. * @returns the current Vector3
  2505. */
  2506. toArray(array: FloatArray, index?: number): Vector3;
  2507. /**
  2508. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2509. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2510. */
  2511. toQuaternion(): Quaternion;
  2512. /**
  2513. * Adds the given vector to the current Vector3
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Adds the given coordinates to the current Vector3
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the current updated Vector3
  2524. */
  2525. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2528. * @param otherVector defines the second operand
  2529. * @returns the resulting Vector3
  2530. */
  2531. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Subtract the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2547. * @param otherVector defines the second operand
  2548. * @returns the resulting Vector3
  2549. */
  2550. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2553. * @param otherVector defines the second operand
  2554. * @param result defines the Vector3 object where to store the result
  2555. * @returns the current Vector3
  2556. */
  2557. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2558. /**
  2559. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2566. /**
  2567. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2568. * @param x defines the x coordinate of the operand
  2569. * @param y defines the y coordinate of the operand
  2570. * @param z defines the z coordinate of the operand
  2571. * @param result defines the Vector3 object where to store the result
  2572. * @returns the current Vector3
  2573. */
  2574. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2575. /**
  2576. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2577. * @returns a new Vector3
  2578. */
  2579. negate(): Vector3;
  2580. /**
  2581. * Negate this vector in place
  2582. * @returns this
  2583. */
  2584. negateInPlace(): Vector3;
  2585. /**
  2586. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2587. * @param result defines the Vector3 object where to store the result
  2588. * @returns the current Vector3
  2589. */
  2590. negateToRef(result: Vector3): Vector3;
  2591. /**
  2592. * Multiplies the Vector3 coordinates by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns the current updated Vector3
  2595. */
  2596. scaleInPlace(scale: number): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2599. * @param scale defines the multiplier factor
  2600. * @returns a new Vector3
  2601. */
  2602. scale(scale: number): Vector3;
  2603. /**
  2604. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2605. * @param scale defines the multiplier factor
  2606. * @param result defines the Vector3 object where to store the result
  2607. * @returns the current Vector3
  2608. */
  2609. scaleToRef(scale: number, result: Vector3): Vector3;
  2610. /**
  2611. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2612. * @param scale defines the scale factor
  2613. * @param result defines the Vector3 object where to store the result
  2614. * @returns the unmodified current Vector3
  2615. */
  2616. scaleAndAddToRef(scale: number, result: 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. * @returns the projected vector3
  2622. */
  2623. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2624. /**
  2625. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2626. * @param origin defines the origin of the projection ray
  2627. * @param plane defines the plane to project to
  2628. * @param result defines the Vector3 where to store the result
  2629. */
  2630. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2633. * @param otherVector defines the second operand
  2634. * @returns true if both vectors are equals
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2637. /**
  2638. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2639. * @param otherVector defines the second operand
  2640. * @param epsilon defines the minimal distance to define values as equals
  2641. * @returns true if both vectors are distant less than epsilon
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2644. /**
  2645. * Returns true if the current Vector3 coordinates equals the given floats
  2646. * @param x defines the x coordinate of the operand
  2647. * @param y defines the y coordinate of the operand
  2648. * @param z defines the z coordinate of the operand
  2649. * @returns true if both vectors are equals
  2650. */
  2651. equalsToFloats(x: number, y: number, z: number): boolean;
  2652. /**
  2653. * Multiplies the current Vector3 coordinates by the given ones
  2654. * @param otherVector defines the second operand
  2655. * @returns the current updated Vector3
  2656. */
  2657. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2660. * @param otherVector defines the second operand
  2661. * @returns the new Vector3
  2662. */
  2663. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2664. /**
  2665. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2666. * @param otherVector defines the second operand
  2667. * @param result defines the Vector3 object where to store the result
  2668. * @returns the current Vector3
  2669. */
  2670. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the new Vector3
  2677. */
  2678. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2681. * @param otherVector defines the second operand
  2682. * @returns the new Vector3
  2683. */
  2684. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2687. * @param otherVector defines the second operand
  2688. * @param result defines the Vector3 object where to store the result
  2689. * @returns the current Vector3
  2690. */
  2691. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2692. /**
  2693. * Divides the current Vector3 coordinates by the given ones.
  2694. * @param otherVector defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. divideInPlace(otherVector: Vector3): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2706. * @param other defines the second operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2720. * @param x defines the x coordinate of the operand
  2721. * @param y defines the y coordinate of the operand
  2722. * @param z defines the z coordinate of the operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2726. /**
  2727. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2728. * Check if is non uniform within a certain amount of decimal places to account for this
  2729. * @param epsilon the amount the values can differ
  2730. * @returns if the the vector is non uniform to a certain number of decimal places
  2731. */
  2732. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2733. /**
  2734. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2735. */
  2736. get isNonUniform(): boolean;
  2737. /**
  2738. * Gets a new Vector3 from current Vector3 floored values
  2739. * @returns a new Vector3
  2740. */
  2741. floor(): Vector3;
  2742. /**
  2743. * Gets a new Vector3 from current Vector3 floored values
  2744. * @returns a new Vector3
  2745. */
  2746. fract(): Vector3;
  2747. /**
  2748. * Gets the length of the Vector3
  2749. * @returns the length of the Vector3
  2750. */
  2751. length(): number;
  2752. /**
  2753. * Gets the squared length of the Vector3
  2754. * @returns squared length of the Vector3
  2755. */
  2756. lengthSquared(): number;
  2757. /**
  2758. * Normalize the current Vector3.
  2759. * Please note that this is an in place operation.
  2760. * @returns the current updated Vector3
  2761. */
  2762. normalize(): Vector3;
  2763. /**
  2764. * Reorders the x y z properties of the vector in place
  2765. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2766. * @returns the current updated vector
  2767. */
  2768. reorderInPlace(order: string): this;
  2769. /**
  2770. * Rotates the vector around 0,0,0 by a quaternion
  2771. * @param quaternion the rotation quaternion
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2776. /**
  2777. * Rotates a vector around a given point
  2778. * @param quaternion the rotation quaternion
  2779. * @param point the point to rotate around
  2780. * @param result vector to store the result
  2781. * @returns the resulting vector
  2782. */
  2783. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2784. /**
  2785. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2786. * The cross product is then orthogonal to both current and "other"
  2787. * @param other defines the right operand
  2788. * @returns the cross product
  2789. */
  2790. cross(other: Vector3): Vector3;
  2791. /**
  2792. * Normalize the current Vector3 with the given input length.
  2793. * Please note that this is an in place operation.
  2794. * @param len the length of the vector
  2795. * @returns the current updated Vector3
  2796. */
  2797. normalizeFromLength(len: number): Vector3;
  2798. /**
  2799. * Normalize the current Vector3 to a new vector
  2800. * @returns the new Vector3
  2801. */
  2802. normalizeToNew(): Vector3;
  2803. /**
  2804. * Normalize the current Vector3 to the reference
  2805. * @param reference define the Vector3 to update
  2806. * @returns the updated Vector3
  2807. */
  2808. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2809. /**
  2810. * Creates a new Vector3 copied from the current Vector3
  2811. * @returns the new Vector3
  2812. */
  2813. clone(): Vector3;
  2814. /**
  2815. * Copies the given vector coordinates to the current Vector3 ones
  2816. * @param source defines the source Vector3
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. copyFromFloats(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given floats to the current Vector3 coordinates
  2830. * @param x defines the x coordinate of the operand
  2831. * @param y defines the y coordinate of the operand
  2832. * @param z defines the z coordinate of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. set(x: number, y: number, z: number): Vector3;
  2836. /**
  2837. * Copies the given float to the current Vector3 coordinates
  2838. * @param v defines the x, y and z coordinates of the operand
  2839. * @returns the current updated Vector3
  2840. */
  2841. setAll(v: number): Vector3;
  2842. /**
  2843. * Get the clip factor between two vectors
  2844. * @param vector0 defines the first operand
  2845. * @param vector1 defines the second operand
  2846. * @param axis defines the axis to use
  2847. * @param size defines the size along the axis
  2848. * @returns the clip factor
  2849. */
  2850. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2851. /**
  2852. * Get angle between two vectors
  2853. * @param vector0 angle between vector0 and vector1
  2854. * @param vector1 angle between vector0 and vector1
  2855. * @param normal direction of the normal
  2856. * @return the angle between vector0 and vector1
  2857. */
  2858. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2859. /**
  2860. * Returns a new Vector3 set from the index "offset" of the given array
  2861. * @param array defines the source array
  2862. * @param offset defines the offset in the source array
  2863. * @returns the new Vector3
  2864. */
  2865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @returns the new Vector3
  2871. * @deprecated Please use FromArray instead.
  2872. */
  2873. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2874. /**
  2875. * Sets the given vector "result" with the element values from the index "offset" of the given array
  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. */
  2880. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2883. * @param array defines the source array
  2884. * @param offset defines the offset in the source array
  2885. * @param result defines the Vector3 where to store the result
  2886. * @deprecated Please use FromArrayToRef instead.
  2887. */
  2888. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2889. /**
  2890. * Sets the given vector "result" with the given floats.
  2891. * @param x defines the x coordinate of the source
  2892. * @param y defines the y coordinate of the source
  2893. * @param z defines the z coordinate of the source
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2899. * @returns a new empty Vector3
  2900. */
  2901. static Zero(): Vector3;
  2902. /**
  2903. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2904. * @returns a new unit Vector3
  2905. */
  2906. static One(): Vector3;
  2907. /**
  2908. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2909. * @returns a new up Vector3
  2910. */
  2911. static Up(): Vector3;
  2912. /**
  2913. * Gets a up Vector3 that must not be updated
  2914. */
  2915. static get UpReadOnly(): DeepImmutable<Vector3>;
  2916. /**
  2917. * Gets a zero Vector3 that must not be updated
  2918. */
  2919. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2920. /**
  2921. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2922. * @returns a new down Vector3
  2923. */
  2924. static Down(): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Forward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2933. * @param rightHandedSystem is the scene right-handed (negative-z)
  2934. * @returns a new forward Vector3
  2935. */
  2936. static Backward(rightHandedSystem?: boolean): Vector3;
  2937. /**
  2938. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2939. * @returns a new right Vector3
  2940. */
  2941. static Right(): Vector3;
  2942. /**
  2943. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2944. * @returns a new left Vector3
  2945. */
  2946. static Left(): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @returns the transformed Vector3
  2953. */
  2954. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2957. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2958. * @param vector defines the Vector3 to transform
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2965. * This method computes tranformed coordinates only, not transformed direction vectors
  2966. * @param x define the x coordinate of the source vector
  2967. * @param y define the y coordinate of the source vector
  2968. * @param z define the z coordinate of the source vector
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @returns the new Vector3
  2979. */
  2980. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2991. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2992. * @param x define the x coordinate of the source vector
  2993. * @param y define the y coordinate of the source vector
  2994. * @param z define the z coordinate of the source vector
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3001. * @param value1 defines the first control point
  3002. * @param value2 defines the second control point
  3003. * @param value3 defines the third control point
  3004. * @param value4 defines the fourth control point
  3005. * @param amount defines the amount on the spline to use
  3006. * @returns the new Vector3
  3007. */
  3008. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3009. /**
  3010. * 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"
  3011. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3012. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3013. * @param value defines the current value
  3014. * @param min defines the lower range value
  3015. * @param max defines the upper range value
  3016. * @returns the new Vector3
  3017. */
  3018. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3019. /**
  3020. * 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"
  3021. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3022. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3023. * @param value defines the current value
  3024. * @param min defines the lower range value
  3025. * @param max defines the upper range value
  3026. * @param result defines the Vector3 where to store the result
  3027. */
  3028. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3029. /**
  3030. * Checks if a given vector is inside a specific range
  3031. * @param v defines the vector to test
  3032. * @param min defines the minimum range
  3033. * @param max defines the maximum range
  3034. */
  3035. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3036. /**
  3037. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3038. * @param value1 defines the first control point
  3039. * @param tangent1 defines the first tangent vector
  3040. * @param value2 defines the second control point
  3041. * @param tangent2 defines the second tangent vector
  3042. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @returns the new Vector3
  3052. */
  3053. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3054. /**
  3055. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3056. * @param start defines the start value
  3057. * @param end defines the end value
  3058. * @param amount max defines amount between both (between 0 and 1)
  3059. * @param result defines the Vector3 where to store the result
  3060. */
  3061. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3062. /**
  3063. * Returns the dot product (float) between the vectors "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the dot product
  3067. */
  3068. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3069. /**
  3070. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @returns the cross product
  3075. */
  3076. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * Sets the given vector "result" with the cross product of "left" and "right"
  3079. * The cross product is then orthogonal to both "left" and "right"
  3080. * @param left defines the left operand
  3081. * @param right defines the right operand
  3082. * @param result defines the Vector3 where to store the result
  3083. */
  3084. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3085. /**
  3086. * Returns a new Vector3 as the normalization of the given vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @returns the new Vector3
  3089. */
  3090. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * Sets the given vector "result" with the normalization of the given first vector
  3093. * @param vector defines the Vector3 to normalize
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Project a Vector3 onto screen space
  3099. * @param vector defines the Vector3 to project
  3100. * @param world defines the world matrix to use
  3101. * @param transform defines the transform (view x projection) matrix to use
  3102. * @param viewport defines the screen viewport to use
  3103. * @returns the new Vector3
  3104. */
  3105. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3106. /** @hidden */
  3107. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3108. /**
  3109. * Unproject from screen space to object space
  3110. * @param source defines the screen space Vector3 to use
  3111. * @param viewportWidth defines the current width of the viewport
  3112. * @param viewportHeight defines the current height of the viewport
  3113. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3114. * @param transform defines the transform (view x projection) matrix to use
  3115. * @returns the new Vector3
  3116. */
  3117. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param view defines the view matrix to use
  3125. * @param projection defines the projection matrix to use
  3126. * @returns the new Vector3
  3127. */
  3128. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3129. /**
  3130. * Unproject from screen space to object space
  3131. * @param source defines the screen space Vector3 to use
  3132. * @param viewportWidth defines the current width of the viewport
  3133. * @param viewportHeight defines the current height of the viewport
  3134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3135. * @param view defines the view matrix to use
  3136. * @param projection defines the projection matrix to use
  3137. * @param result defines the Vector3 where to store the result
  3138. */
  3139. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param sourceX defines the screen space x coordinate to use
  3143. * @param sourceY defines the screen space y coordinate to use
  3144. * @param sourceZ defines the screen space z coordinate to use
  3145. * @param viewportWidth defines the current width of the viewport
  3146. * @param viewportHeight defines the current height of the viewport
  3147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3148. * @param view defines the view matrix to use
  3149. * @param projection defines the projection matrix to use
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3153. /**
  3154. * Gets the minimal 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 Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3160. /**
  3161. * Gets the maximal coordinate values between two Vector3
  3162. * @param left defines the first operand
  3163. * @param right defines the second operand
  3164. * @returns the new Vector3
  3165. */
  3166. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3167. /**
  3168. * Returns the distance between the vectors "value1" and "value2"
  3169. * @param value1 defines the first operand
  3170. * @param value2 defines the second operand
  3171. * @returns the distance
  3172. */
  3173. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3174. /**
  3175. * Returns the squared distance between the vectors "value1" and "value2"
  3176. * @param value1 defines the first operand
  3177. * @param value2 defines the second operand
  3178. * @returns the squared distance
  3179. */
  3180. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3181. /**
  3182. * Returns a new Vector3 located at the center between "value1" and "value2"
  3183. * @param value1 defines the first operand
  3184. * @param value2 defines the second operand
  3185. * @returns the new Vector3
  3186. */
  3187. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3190. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3191. * to something in order to rotate it from its local system to the given target system
  3192. * Note: axis1, axis2 and axis3 are normalized during this operation
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @returns a new Vector3
  3197. */
  3198. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3201. * @param axis1 defines the first axis
  3202. * @param axis2 defines the second axis
  3203. * @param axis3 defines the third axis
  3204. * @param ref defines the Vector3 where to store the result
  3205. */
  3206. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3207. }
  3208. /**
  3209. * Vector4 class created for EulerAngle class conversion to Quaternion
  3210. */
  3211. export class Vector4 {
  3212. /** x value of the vector */
  3213. x: number;
  3214. /** y value of the vector */
  3215. y: number;
  3216. /** z value of the vector */
  3217. z: number;
  3218. /** w value of the vector */
  3219. w: number;
  3220. /**
  3221. * Creates a Vector4 object from the given floats.
  3222. * @param x x value of the vector
  3223. * @param y y value of the vector
  3224. * @param z z value of the vector
  3225. * @param w w value of the vector
  3226. */
  3227. constructor(
  3228. /** x value of the vector */
  3229. x: number,
  3230. /** y value of the vector */
  3231. y: number,
  3232. /** z value of the vector */
  3233. z: number,
  3234. /** w value of the vector */
  3235. w: number);
  3236. /**
  3237. * Returns the string with the Vector4 coordinates.
  3238. * @returns a string containing all the vector values
  3239. */
  3240. toString(): string;
  3241. /**
  3242. * Returns the string "Vector4".
  3243. * @returns "Vector4"
  3244. */
  3245. getClassName(): string;
  3246. /**
  3247. * Returns the Vector4 hash code.
  3248. * @returns a unique hash code
  3249. */
  3250. getHashCode(): number;
  3251. /**
  3252. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3253. * @returns the resulting array
  3254. */
  3255. asArray(): number[];
  3256. /**
  3257. * Populates the given array from the given index with the Vector4 coordinates.
  3258. * @param array array to populate
  3259. * @param index index of the array to start at (default: 0)
  3260. * @returns the Vector4.
  3261. */
  3262. toArray(array: FloatArray, index?: number): Vector4;
  3263. /**
  3264. * Adds the given vector to the current Vector4.
  3265. * @param otherVector the vector to add
  3266. * @returns the updated Vector4.
  3267. */
  3268. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @returns the resulting vector
  3273. */
  3274. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3275. /**
  3276. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3277. * @param otherVector the vector to add
  3278. * @param result the vector to store the result
  3279. * @returns the current Vector4.
  3280. */
  3281. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3282. /**
  3283. * Subtract in place the given vector from the current Vector4.
  3284. * @param otherVector the vector to subtract
  3285. * @returns the updated Vector4.
  3286. */
  3287. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to add
  3291. * @returns the new vector with the result
  3292. */
  3293. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3296. * @param otherVector the vector to subtract
  3297. * @param result the vector to store the result
  3298. * @returns the current Vector4.
  3299. */
  3300. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3303. */
  3304. /**
  3305. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3306. * @param x value to subtract
  3307. * @param y value to subtract
  3308. * @param z value to subtract
  3309. * @param w value to subtract
  3310. * @returns new vector containing the result
  3311. */
  3312. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3313. /**
  3314. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3315. * @param x value to subtract
  3316. * @param y value to subtract
  3317. * @param z value to subtract
  3318. * @param w value to subtract
  3319. * @param result the vector to store the result in
  3320. * @returns the current Vector4.
  3321. */
  3322. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3325. * @returns a new vector with the negated values
  3326. */
  3327. negate(): Vector4;
  3328. /**
  3329. * Negate this vector in place
  3330. * @returns this
  3331. */
  3332. negateInPlace(): Vector4;
  3333. /**
  3334. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3335. * @param result defines the Vector3 object where to store the result
  3336. * @returns the current Vector4
  3337. */
  3338. negateToRef(result: Vector4): Vector4;
  3339. /**
  3340. * Multiplies the current Vector4 coordinates by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns the updated Vector4.
  3343. */
  3344. scaleInPlace(scale: number): Vector4;
  3345. /**
  3346. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @returns a new vector with the result
  3349. */
  3350. scale(scale: number): Vector4;
  3351. /**
  3352. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3353. * @param scale the number to scale with
  3354. * @param result a vector to store the result in
  3355. * @returns the current Vector4.
  3356. */
  3357. scaleToRef(scale: number, result: Vector4): Vector4;
  3358. /**
  3359. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3360. * @param scale defines the scale factor
  3361. * @param result defines the Vector4 object where to store the result
  3362. * @returns the unmodified current Vector4
  3363. */
  3364. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3367. * @param otherVector the vector to compare against
  3368. * @returns true if they are equal
  3369. */
  3370. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3371. /**
  3372. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3373. * @param otherVector vector to compare against
  3374. * @param epsilon (Default: very small number)
  3375. * @returns true if they are equal
  3376. */
  3377. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3378. /**
  3379. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3380. * @param x x value to compare against
  3381. * @param y y value to compare against
  3382. * @param z z value to compare against
  3383. * @param w w value to compare against
  3384. * @returns true if equal
  3385. */
  3386. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3387. /**
  3388. * Multiplies in place the current Vector4 by the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns the updated Vector4.
  3391. */
  3392. multiplyInPlace(otherVector: Vector4): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @returns resulting new vector
  3397. */
  3398. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3399. /**
  3400. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3401. * @param otherVector vector to multiple with
  3402. * @param result vector to store the result
  3403. * @returns the current Vector4.
  3404. */
  3405. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3408. * @param x x value multiply with
  3409. * @param y y value multiply with
  3410. * @param z z value multiply with
  3411. * @param w w value multiply with
  3412. * @returns resulting new vector
  3413. */
  3414. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3415. /**
  3416. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @returns resulting new vector
  3419. */
  3420. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3423. * @param otherVector vector to devide with
  3424. * @param result vector to store the result
  3425. * @returns the current Vector4.
  3426. */
  3427. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3428. /**
  3429. * Divides the current Vector3 coordinates by the given ones.
  3430. * @param otherVector vector to devide with
  3431. * @returns the updated Vector3.
  3432. */
  3433. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3442. * @param other defines the second operand
  3443. * @returns the current updated Vector4
  3444. */
  3445. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3446. /**
  3447. * Gets a new Vector4 from current Vector4 floored values
  3448. * @returns a new Vector4
  3449. */
  3450. floor(): Vector4;
  3451. /**
  3452. * Gets a new Vector4 from current Vector3 floored values
  3453. * @returns a new Vector4
  3454. */
  3455. fract(): Vector4;
  3456. /**
  3457. * Returns the Vector4 length (float).
  3458. * @returns the length
  3459. */
  3460. length(): number;
  3461. /**
  3462. * Returns the Vector4 squared length (float).
  3463. * @returns the length squared
  3464. */
  3465. lengthSquared(): number;
  3466. /**
  3467. * Normalizes in place the Vector4.
  3468. * @returns the updated Vector4.
  3469. */
  3470. normalize(): Vector4;
  3471. /**
  3472. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3473. * @returns this converted to a new vector3
  3474. */
  3475. toVector3(): Vector3;
  3476. /**
  3477. * Returns a new Vector4 copied from the current one.
  3478. * @returns the new cloned vector
  3479. */
  3480. clone(): Vector4;
  3481. /**
  3482. * Updates the current Vector4 with the given one coordinates.
  3483. * @param source the source vector to copy from
  3484. * @returns the updated Vector4.
  3485. */
  3486. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3487. /**
  3488. * Updates the current Vector4 coordinates with the given floats.
  3489. * @param x float to copy from
  3490. * @param y float to copy from
  3491. * @param z float to copy from
  3492. * @param w float to copy from
  3493. * @returns the updated Vector4.
  3494. */
  3495. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3496. /**
  3497. * Updates the current Vector4 coordinates with the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @returns the updated Vector4.
  3503. */
  3504. set(x: number, y: number, z: number, w: number): Vector4;
  3505. /**
  3506. * Copies the given float to the current Vector3 coordinates
  3507. * @param v defines the x, y, z and w coordinates of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. setAll(v: number): Vector4;
  3511. /**
  3512. * Returns a new Vector4 set 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. * @returns the new vector
  3516. */
  3517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3518. /**
  3519. * Updates the given vector "result" from the starting index of the given array.
  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 FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3525. /**
  3526. * Updates the given vector "result" from the starting index of the given Float32Array.
  3527. * @param array the array to pull values from
  3528. * @param offset the offset into the array to start at
  3529. * @param result the vector to store the result in
  3530. */
  3531. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3532. /**
  3533. * Updates the given vector "result" coordinates from the given floats.
  3534. * @param x float to set from
  3535. * @param y float to set from
  3536. * @param z float to set from
  3537. * @param w float to set from
  3538. * @param result the vector to the floats in
  3539. */
  3540. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3541. /**
  3542. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3543. * @returns the new vector
  3544. */
  3545. static Zero(): Vector4;
  3546. /**
  3547. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3548. * @returns the new vector
  3549. */
  3550. static One(): Vector4;
  3551. /**
  3552. * Returns a new normalized Vector4 from the given one.
  3553. * @param vector the vector to normalize
  3554. * @returns the vector
  3555. */
  3556. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3557. /**
  3558. * Updates the given vector "result" from the normalization of the given one.
  3559. * @param vector the vector to normalize
  3560. * @param result the vector to store the result in
  3561. */
  3562. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3563. /**
  3564. * Returns a vector with the minimum values from the left and right vectors
  3565. * @param left left vector to minimize
  3566. * @param right right vector to minimize
  3567. * @returns a new vector with the minimum of the left and right vector values
  3568. */
  3569. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3570. /**
  3571. * Returns a vector with the maximum values from the left and right vectors
  3572. * @param left left vector to maximize
  3573. * @param right right vector to maximize
  3574. * @returns a new vector with the maximum of the left and right vector values
  3575. */
  3576. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3577. /**
  3578. * Returns the 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
  3582. */
  3583. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3584. /**
  3585. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3586. * @param value1 value to calulate the distance between
  3587. * @param value2 value to calulate the distance between
  3588. * @return the distance between the two vectors squared
  3589. */
  3590. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3591. /**
  3592. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3593. * @param value1 value to calulate the center between
  3594. * @param value2 value to calulate the center between
  3595. * @return the center between the two vectors
  3596. */
  3597. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3598. /**
  3599. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @returns the new vector
  3604. */
  3605. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param vector the vector to transform
  3610. * @param transformation the transformation matrix to apply
  3611. * @param result the vector to store the result in
  3612. */
  3613. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3614. /**
  3615. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3616. * This methods computes transformed normalized direction vectors only.
  3617. * @param x value to transform
  3618. * @param y value to transform
  3619. * @param z value to transform
  3620. * @param w value to transform
  3621. * @param transformation the transformation matrix to apply
  3622. * @param result the vector to store the results in
  3623. */
  3624. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3625. /**
  3626. * Creates a new Vector4 from a Vector3
  3627. * @param source defines the source data
  3628. * @param w defines the 4th component (default is 0)
  3629. * @returns a new Vector4
  3630. */
  3631. static FromVector3(source: Vector3, w?: number): Vector4;
  3632. }
  3633. /**
  3634. * Class used to store quaternion data
  3635. * @see https://en.wikipedia.org/wiki/Quaternion
  3636. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3637. */
  3638. export class Quaternion {
  3639. /** defines the first component (0 by default) */
  3640. x: number;
  3641. /** defines the second component (0 by default) */
  3642. y: number;
  3643. /** defines the third component (0 by default) */
  3644. z: number;
  3645. /** defines the fourth component (1.0 by default) */
  3646. w: number;
  3647. /**
  3648. * Creates a new Quaternion from the given floats
  3649. * @param x defines the first component (0 by default)
  3650. * @param y defines the second component (0 by default)
  3651. * @param z defines the third component (0 by default)
  3652. * @param w defines the fourth component (1.0 by default)
  3653. */
  3654. constructor(
  3655. /** defines the first component (0 by default) */
  3656. x?: number,
  3657. /** defines the second component (0 by default) */
  3658. y?: number,
  3659. /** defines the third component (0 by default) */
  3660. z?: number,
  3661. /** defines the fourth component (1.0 by default) */
  3662. w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * 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)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * 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
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. 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;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. 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;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * 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"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * 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".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * 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"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * 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".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * 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.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * 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)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @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
  5102. * @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
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. 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);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. 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;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. 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;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. 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;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. 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);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * 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;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * 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).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * 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).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * 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.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * 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.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * 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.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * 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.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * 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.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * 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).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * 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).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * 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.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * 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.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * 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.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * 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.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * 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.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * 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).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * 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).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * 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.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * 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.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * 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.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * 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.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * 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.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * 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.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * 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).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * 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).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * 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.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * 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.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * 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.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * 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.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * 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.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * 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.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { ActionManager } from "babylonjs/Actions/actionManager";
  9454. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9455. /**
  9456. * Interface used to define Action
  9457. */
  9458. export interface IAction {
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /** Options of the trigger */
  9464. triggerOptions: any;
  9465. /**
  9466. * Gets the trigger parameters
  9467. * @returns the trigger parameters
  9468. */
  9469. getTriggerParameter(): any;
  9470. /**
  9471. * Internal only - executes current action event
  9472. * @hidden
  9473. */
  9474. _executeCurrent(evt?: ActionEvent): void;
  9475. /**
  9476. * Serialize placeholder for child classes
  9477. * @param parent of child
  9478. * @returns the serialized object
  9479. */
  9480. serialize(parent: any): any;
  9481. /**
  9482. * Internal only
  9483. * @hidden
  9484. */
  9485. _prepare(): void;
  9486. /**
  9487. * Internal only - manager for action
  9488. * @hidden
  9489. */
  9490. _actionManager: AbstractActionManager;
  9491. /**
  9492. * Adds action to chain of actions, may be a DoNothingAction
  9493. * @param action defines the next action to execute
  9494. * @returns The action passed in
  9495. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9496. */
  9497. then(action: IAction): IAction;
  9498. }
  9499. /**
  9500. * The action to be carried out following a trigger
  9501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9502. */
  9503. export class Action implements IAction {
  9504. /** the trigger, with or without parameters, for the action */
  9505. triggerOptions: any;
  9506. /**
  9507. * Trigger for the action
  9508. */
  9509. trigger: number;
  9510. /**
  9511. * Internal only - manager for action
  9512. * @hidden
  9513. */
  9514. _actionManager: ActionManager;
  9515. private _nextActiveAction;
  9516. private _child;
  9517. private _condition?;
  9518. private _triggerParameter;
  9519. /**
  9520. * An event triggered prior to action being executed.
  9521. */
  9522. onBeforeExecuteObservable: Observable<Action>;
  9523. /**
  9524. * Creates a new Action
  9525. * @param triggerOptions the trigger, with or without parameters, for the action
  9526. * @param condition an optional determinant of action
  9527. */
  9528. constructor(
  9529. /** the trigger, with or without parameters, for the action */
  9530. triggerOptions: any, condition?: Condition);
  9531. /**
  9532. * Internal only
  9533. * @hidden
  9534. */
  9535. _prepare(): void;
  9536. /**
  9537. * Gets the trigger parameters
  9538. * @returns the trigger parameters
  9539. */
  9540. getTriggerParameter(): any;
  9541. /**
  9542. * Internal only - executes current action event
  9543. * @hidden
  9544. */
  9545. _executeCurrent(evt?: ActionEvent): void;
  9546. /**
  9547. * Execute placeholder for child classes
  9548. * @param evt optional action event
  9549. */
  9550. execute(evt?: ActionEvent): void;
  9551. /**
  9552. * Skips to next active action
  9553. */
  9554. skipToNextActiveAction(): void;
  9555. /**
  9556. * Adds action to chain of actions, may be a DoNothingAction
  9557. * @param action defines the next action to execute
  9558. * @returns The action passed in
  9559. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9560. */
  9561. then(action: Action): Action;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _getProperty(propertyPath: string): string;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _getEffectiveTarget(target: any, propertyPath: string): any;
  9572. /**
  9573. * Serialize placeholder for child classes
  9574. * @param parent of child
  9575. * @returns the serialized object
  9576. */
  9577. serialize(parent: any): any;
  9578. /**
  9579. * Internal only called by serialize
  9580. * @hidden
  9581. */
  9582. protected _serialize(serializedAction: any, parent?: any): any;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. static _SerializeValueAsString: (value: any) => string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9593. name: string;
  9594. targetType: string;
  9595. value: string;
  9596. };
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/condition" {
  9600. import { ActionManager } from "babylonjs/Actions/actionManager";
  9601. /**
  9602. * A Condition applied to an Action
  9603. */
  9604. export class Condition {
  9605. /**
  9606. * Internal only - manager for action
  9607. * @hidden
  9608. */
  9609. _actionManager: ActionManager;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _evaluationId: number;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _currentResult: boolean;
  9620. /**
  9621. * Creates a new Condition
  9622. * @param actionManager the manager of the action the condition is applied to
  9623. */
  9624. constructor(actionManager: ActionManager);
  9625. /**
  9626. * Check if the current condition is valid
  9627. * @returns a boolean
  9628. */
  9629. isValid(): boolean;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _getProperty(propertyPath: string): string;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _getEffectiveTarget(target: any, propertyPath: string): any;
  9640. /**
  9641. * Serialize placeholder for child classes
  9642. * @returns the serialized object
  9643. */
  9644. serialize(): any;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. protected _serialize(serializedCondition: any): any;
  9650. }
  9651. /**
  9652. * Defines specific conditional operators as extensions of Condition
  9653. */
  9654. export class ValueCondition extends Condition {
  9655. /** path to specify the property of the target the conditional operator uses */
  9656. propertyPath: string;
  9657. /** the value compared by the conditional operator against the current value of the property */
  9658. value: any;
  9659. /** the conditional operator, default ValueCondition.IsEqual */
  9660. operator: number;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsEqual;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsDifferent;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. private static _IsGreater;
  9676. /**
  9677. * Internal only
  9678. * @hidden
  9679. */
  9680. private static _IsLesser;
  9681. /**
  9682. * returns the number for IsEqual
  9683. */
  9684. static get IsEqual(): number;
  9685. /**
  9686. * Returns the number for IsDifferent
  9687. */
  9688. static get IsDifferent(): number;
  9689. /**
  9690. * Returns the number for IsGreater
  9691. */
  9692. static get IsGreater(): number;
  9693. /**
  9694. * Returns the number for IsLesser
  9695. */
  9696. static get IsLesser(): number;
  9697. /**
  9698. * Internal only The action manager for the condition
  9699. * @hidden
  9700. */
  9701. _actionManager: ActionManager;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _target;
  9707. /**
  9708. * Internal only
  9709. * @hidden
  9710. */
  9711. private _effectiveTarget;
  9712. /**
  9713. * Internal only
  9714. * @hidden
  9715. */
  9716. private _property;
  9717. /**
  9718. * Creates a new ValueCondition
  9719. * @param actionManager manager for the action the condition applies to
  9720. * @param target for the action
  9721. * @param propertyPath path to specify the property of the target the conditional operator uses
  9722. * @param value the value compared by the conditional operator against the current value of the property
  9723. * @param operator the conditional operator, default ValueCondition.IsEqual
  9724. */
  9725. constructor(actionManager: ActionManager, target: any,
  9726. /** path to specify the property of the target the conditional operator uses */
  9727. propertyPath: string,
  9728. /** the value compared by the conditional operator against the current value of the property */
  9729. value: any,
  9730. /** the conditional operator, default ValueCondition.IsEqual */
  9731. operator?: number);
  9732. /**
  9733. * Compares the given value with the property value for the specified conditional operator
  9734. * @returns the result of the comparison
  9735. */
  9736. isValid(): boolean;
  9737. /**
  9738. * Serialize the ValueCondition into a JSON compatible object
  9739. * @returns serialization object
  9740. */
  9741. serialize(): any;
  9742. /**
  9743. * Gets the name of the conditional operator for the ValueCondition
  9744. * @param operator the conditional operator
  9745. * @returns the name
  9746. */
  9747. static GetOperatorName(operator: number): string;
  9748. }
  9749. /**
  9750. * Defines a predicate condition as an extension of Condition
  9751. */
  9752. export class PredicateCondition extends Condition {
  9753. /** defines the predicate function used to validate the condition */
  9754. predicate: () => boolean;
  9755. /**
  9756. * Internal only - manager for action
  9757. * @hidden
  9758. */
  9759. _actionManager: ActionManager;
  9760. /**
  9761. * Creates a new PredicateCondition
  9762. * @param actionManager manager for the action the condition applies to
  9763. * @param predicate defines the predicate function used to validate the condition
  9764. */
  9765. constructor(actionManager: ActionManager,
  9766. /** defines the predicate function used to validate the condition */
  9767. predicate: () => boolean);
  9768. /**
  9769. * @returns the validity of the predicate condition
  9770. */
  9771. isValid(): boolean;
  9772. }
  9773. /**
  9774. * Defines a state condition as an extension of Condition
  9775. */
  9776. export class StateCondition extends Condition {
  9777. /** Value to compare with target state */
  9778. value: string;
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. private _target;
  9789. /**
  9790. * Creates a new StateCondition
  9791. * @param actionManager manager for the action the condition applies to
  9792. * @param target of the condition
  9793. * @param value to compare with target state
  9794. */
  9795. constructor(actionManager: ActionManager, target: any,
  9796. /** Value to compare with target state */
  9797. value: string);
  9798. /**
  9799. * Gets a boolean indicating if the current condition is met
  9800. * @returns the validity of the state
  9801. */
  9802. isValid(): boolean;
  9803. /**
  9804. * Serialize the StateCondition into a JSON compatible object
  9805. * @returns serialization object
  9806. */
  9807. serialize(): any;
  9808. }
  9809. }
  9810. declare module "babylonjs/Actions/directActions" {
  9811. import { Action } from "babylonjs/Actions/action";
  9812. import { Condition } from "babylonjs/Actions/condition";
  9813. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9814. /**
  9815. * This defines an action responsible to toggle a boolean once triggered.
  9816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9817. */
  9818. export class SwitchBooleanAction extends Action {
  9819. /**
  9820. * The path to the boolean property in the target object
  9821. */
  9822. propertyPath: string;
  9823. private _target;
  9824. private _effectiveTarget;
  9825. private _property;
  9826. /**
  9827. * Instantiate the action
  9828. * @param triggerOptions defines the trigger options
  9829. * @param target defines the object containing the boolean
  9830. * @param propertyPath defines the path to the boolean property in the target object
  9831. * @param condition defines the trigger related conditions
  9832. */
  9833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9834. /** @hidden */
  9835. _prepare(): void;
  9836. /**
  9837. * Execute the action toggle the boolean value.
  9838. */
  9839. execute(): void;
  9840. /**
  9841. * Serializes the actions and its related information.
  9842. * @param parent defines the object to serialize in
  9843. * @returns the serialized object
  9844. */
  9845. serialize(parent: any): any;
  9846. }
  9847. /**
  9848. * This defines an action responsible to set a the state field of the target
  9849. * to a desired value once triggered.
  9850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9851. */
  9852. export class SetStateAction extends Action {
  9853. /**
  9854. * The value to store in the state field.
  9855. */
  9856. value: string;
  9857. private _target;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the state property
  9862. * @param value defines the value to store in the state field
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9866. /**
  9867. * Execute the action and store the value on the target state property.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible to set a property of the target
  9879. * to a desired value once triggered.
  9880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class SetValueAction extends Action {
  9883. /**
  9884. * The path of the property to set in the target.
  9885. */
  9886. propertyPath: string;
  9887. /**
  9888. * The value to set in the property
  9889. */
  9890. value: any;
  9891. private _target;
  9892. private _effectiveTarget;
  9893. private _property;
  9894. /**
  9895. * Instantiate the action
  9896. * @param triggerOptions defines the trigger options
  9897. * @param target defines the object containing the property
  9898. * @param propertyPath defines the path of the property to set in the target
  9899. * @param value defines the value to set in the property
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9903. /** @hidden */
  9904. _prepare(): void;
  9905. /**
  9906. * Execute the action and set the targetted property to the desired value.
  9907. */
  9908. execute(): void;
  9909. /**
  9910. * Serializes the actions and its related information.
  9911. * @param parent defines the object to serialize in
  9912. * @returns the serialized object
  9913. */
  9914. serialize(parent: any): any;
  9915. }
  9916. /**
  9917. * This defines an action responsible to increment the target value
  9918. * to a desired value once triggered.
  9919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9920. */
  9921. export class IncrementValueAction extends Action {
  9922. /**
  9923. * The path of the property to increment in the target.
  9924. */
  9925. propertyPath: string;
  9926. /**
  9927. * The value we should increment the property by.
  9928. */
  9929. value: any;
  9930. private _target;
  9931. private _effectiveTarget;
  9932. private _property;
  9933. /**
  9934. * Instantiate the action
  9935. * @param triggerOptions defines the trigger options
  9936. * @param target defines the object containing the property
  9937. * @param propertyPath defines the path of the property to increment in the target
  9938. * @param value defines the value value we should increment the property by
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and increment the target of the value amount.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to start an animation once triggered.
  9957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class PlayAnimationAction extends Action {
  9960. /**
  9961. * Where the animation should start (animation frame)
  9962. */
  9963. from: number;
  9964. /**
  9965. * Where the animation should stop (animation frame)
  9966. */
  9967. to: number;
  9968. /**
  9969. * Define if the animation should loop or stop after the first play.
  9970. */
  9971. loop?: boolean;
  9972. private _target;
  9973. /**
  9974. * Instantiate the action
  9975. * @param triggerOptions defines the trigger options
  9976. * @param target defines the target animation or animation name
  9977. * @param from defines from where the animation should start (animation frame)
  9978. * @param end defines where the animation should stop (animation frame)
  9979. * @param loop defines if the animation should loop or stop after the first play
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and play the animation.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to stop an animation once triggered.
  9998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class StopAnimationAction extends Action {
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the target animation or animation name
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and stop the animation.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible that does nothing once triggered.
  10024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class DoNothingAction extends Action {
  10027. /**
  10028. * Instantiate the action
  10029. * @param triggerOptions defines the trigger options
  10030. * @param condition defines the trigger related conditions
  10031. */
  10032. constructor(triggerOptions?: any, condition?: Condition);
  10033. /**
  10034. * Execute the action and do nothing.
  10035. */
  10036. execute(): void;
  10037. /**
  10038. * Serializes the actions and its related information.
  10039. * @param parent defines the object to serialize in
  10040. * @returns the serialized object
  10041. */
  10042. serialize(parent: any): any;
  10043. }
  10044. /**
  10045. * This defines an action responsible to trigger several actions once triggered.
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10047. */
  10048. export class CombineAction extends Action {
  10049. /**
  10050. * The list of aggregated animations to run.
  10051. */
  10052. children: Action[];
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param children defines the list of aggregated animations to run
  10057. * @param condition defines the trigger related conditions
  10058. */
  10059. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10060. /** @hidden */
  10061. _prepare(): void;
  10062. /**
  10063. * Execute the action and executes all the aggregated actions.
  10064. */
  10065. execute(evt: ActionEvent): void;
  10066. /**
  10067. * Serializes the actions and its related information.
  10068. * @param parent defines the object to serialize in
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. }
  10073. /**
  10074. * This defines an action responsible to run code (external event) once triggered.
  10075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10076. */
  10077. export class ExecuteCodeAction extends Action {
  10078. /**
  10079. * The callback function to run.
  10080. */
  10081. func: (evt: ActionEvent) => void;
  10082. /**
  10083. * Instantiate the action
  10084. * @param triggerOptions defines the trigger options
  10085. * @param func defines the callback function to run
  10086. * @param condition defines the trigger related conditions
  10087. */
  10088. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10089. /**
  10090. * Execute the action and run the attached code.
  10091. */
  10092. execute(evt: ActionEvent): void;
  10093. }
  10094. /**
  10095. * This defines an action responsible to set the parent property of the target once triggered.
  10096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10097. */
  10098. export class SetParentAction extends Action {
  10099. private _parent;
  10100. private _target;
  10101. /**
  10102. * Instantiate the action
  10103. * @param triggerOptions defines the trigger options
  10104. * @param target defines the target containing the parent property
  10105. * @param parent defines from where the animation should start (animation frame)
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10109. /** @hidden */
  10110. _prepare(): void;
  10111. /**
  10112. * Execute the action and set the parent property.
  10113. */
  10114. execute(): void;
  10115. /**
  10116. * Serializes the actions and its related information.
  10117. * @param parent defines the object to serialize in
  10118. * @returns the serialized object
  10119. */
  10120. serialize(parent: any): any;
  10121. }
  10122. }
  10123. declare module "babylonjs/Actions/actionManager" {
  10124. import { Nullable } from "babylonjs/types";
  10125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10126. import { Scene } from "babylonjs/scene";
  10127. import { IAction } from "babylonjs/Actions/action";
  10128. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10129. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10130. /**
  10131. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10132. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class ActionManager extends AbstractActionManager {
  10136. /**
  10137. * Nothing
  10138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10139. */
  10140. static readonly NothingTrigger: number;
  10141. /**
  10142. * On pick
  10143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10144. */
  10145. static readonly OnPickTrigger: number;
  10146. /**
  10147. * On left pick
  10148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10149. */
  10150. static readonly OnLeftPickTrigger: number;
  10151. /**
  10152. * On right pick
  10153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10154. */
  10155. static readonly OnRightPickTrigger: number;
  10156. /**
  10157. * On center pick
  10158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10159. */
  10160. static readonly OnCenterPickTrigger: number;
  10161. /**
  10162. * On pick down
  10163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10164. */
  10165. static readonly OnPickDownTrigger: number;
  10166. /**
  10167. * On double pick
  10168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10169. */
  10170. static readonly OnDoublePickTrigger: number;
  10171. /**
  10172. * On pick up
  10173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10174. */
  10175. static readonly OnPickUpTrigger: number;
  10176. /**
  10177. * On pick out.
  10178. * This trigger will only be raised if you also declared a OnPickDown
  10179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnPickOutTrigger: number;
  10182. /**
  10183. * On long press
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnLongPressTrigger: number;
  10187. /**
  10188. * On pointer over
  10189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPointerOverTrigger: number;
  10192. /**
  10193. * On pointer out
  10194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnPointerOutTrigger: number;
  10197. /**
  10198. * On every frame
  10199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnEveryFrameTrigger: number;
  10202. /**
  10203. * On intersection enter
  10204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10205. */
  10206. static readonly OnIntersectionEnterTrigger: number;
  10207. /**
  10208. * On intersection exit
  10209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10210. */
  10211. static readonly OnIntersectionExitTrigger: number;
  10212. /**
  10213. * On key down
  10214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly OnKeyDownTrigger: number;
  10217. /**
  10218. * On key up
  10219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnKeyUpTrigger: number;
  10222. private _scene;
  10223. /**
  10224. * Creates a new action manager
  10225. * @param scene defines the hosting scene
  10226. */
  10227. constructor(scene: Scene);
  10228. /**
  10229. * Releases all associated resources
  10230. */
  10231. dispose(): void;
  10232. /**
  10233. * Gets hosting scene
  10234. * @returns the hosting scene
  10235. */
  10236. getScene(): Scene;
  10237. /**
  10238. * Does this action manager handles actions of any of the given triggers
  10239. * @param triggers defines the triggers to be tested
  10240. * @return a boolean indicating whether one (or more) of the triggers is handled
  10241. */
  10242. hasSpecificTriggers(triggers: number[]): boolean;
  10243. /**
  10244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10245. * speed.
  10246. * @param triggerA defines the trigger to be tested
  10247. * @param triggerB defines the trigger to be tested
  10248. * @return a boolean indicating whether one (or more) of the triggers is handled
  10249. */
  10250. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10251. /**
  10252. * Does this action manager handles actions of a given trigger
  10253. * @param trigger defines the trigger to be tested
  10254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10255. * @return whether the trigger is handled
  10256. */
  10257. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10258. /**
  10259. * Does this action manager has pointer triggers
  10260. */
  10261. get hasPointerTriggers(): boolean;
  10262. /**
  10263. * Does this action manager has pick triggers
  10264. */
  10265. get hasPickTriggers(): boolean;
  10266. /**
  10267. * Registers an action to this action manager
  10268. * @param action defines the action to be registered
  10269. * @return the action amended (prepared) after registration
  10270. */
  10271. registerAction(action: IAction): Nullable<IAction>;
  10272. /**
  10273. * Unregisters an action to this action manager
  10274. * @param action defines the action to be unregistered
  10275. * @return a boolean indicating whether the action has been unregistered
  10276. */
  10277. unregisterAction(action: IAction): Boolean;
  10278. /**
  10279. * Process a specific trigger
  10280. * @param trigger defines the trigger to process
  10281. * @param evt defines the event details to be processed
  10282. */
  10283. processTrigger(trigger: number, evt?: IActionEvent): void;
  10284. /** @hidden */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /** @hidden */
  10287. _getProperty(propertyPath: string): string;
  10288. /**
  10289. * Serialize this manager to a JSON object
  10290. * @param name defines the property name to store this manager
  10291. * @returns a JSON representation of this manager
  10292. */
  10293. serialize(name: string): any;
  10294. /**
  10295. * Creates a new ActionManager from a JSON data
  10296. * @param parsedActions defines the JSON data to read from
  10297. * @param object defines the hosting mesh
  10298. * @param scene defines the hosting scene
  10299. */
  10300. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10301. /**
  10302. * Get a trigger name by index
  10303. * @param trigger defines the trigger index
  10304. * @returns a trigger name
  10305. */
  10306. static GetTriggerName(trigger: number): string;
  10307. }
  10308. }
  10309. declare module "babylonjs/Sprites/sprite" {
  10310. import { Vector3 } from "babylonjs/Maths/math.vector";
  10311. import { Nullable } from "babylonjs/types";
  10312. import { ActionManager } from "babylonjs/Actions/actionManager";
  10313. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10314. import { Color4 } from "babylonjs/Maths/math.color";
  10315. import { Observable } from "babylonjs/Misc/observable";
  10316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10317. import { Animation } from "babylonjs/Animations/animation";
  10318. /**
  10319. * Class used to represent a sprite
  10320. * @see http://doc.babylonjs.com/babylon101/sprites
  10321. */
  10322. export class Sprite implements IAnimatable {
  10323. /** defines the name */
  10324. name: string;
  10325. /** Gets or sets the current world position */
  10326. position: Vector3;
  10327. /** Gets or sets the main color */
  10328. color: Color4;
  10329. /** Gets or sets the width */
  10330. width: number;
  10331. /** Gets or sets the height */
  10332. height: number;
  10333. /** Gets or sets rotation angle */
  10334. angle: number;
  10335. /** Gets or sets the cell index in the sprite sheet */
  10336. cellIndex: number;
  10337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10338. cellRef: string;
  10339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10340. invertU: boolean;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10342. invertV: boolean;
  10343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10344. disposeWhenFinishedAnimating: boolean;
  10345. /** Gets the list of attached animations */
  10346. animations: Nullable<Array<Animation>>;
  10347. /** Gets or sets a boolean indicating if the sprite can be picked */
  10348. isPickable: boolean;
  10349. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10350. useAlphaForPicking: boolean;
  10351. /** @hidden */
  10352. _xOffset: number;
  10353. /** @hidden */
  10354. _yOffset: number;
  10355. /** @hidden */
  10356. _xSize: number;
  10357. /** @hidden */
  10358. _ySize: number;
  10359. /**
  10360. * Gets or sets the associated action manager
  10361. */
  10362. actionManager: Nullable<ActionManager>;
  10363. /**
  10364. * An event triggered when the control has been disposed
  10365. */
  10366. onDisposeObservable: Observable<Sprite>;
  10367. private _animationStarted;
  10368. private _loopAnimation;
  10369. private _fromIndex;
  10370. private _toIndex;
  10371. private _delay;
  10372. private _direction;
  10373. private _manager;
  10374. private _time;
  10375. private _onAnimationEnd;
  10376. /**
  10377. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10378. */
  10379. isVisible: boolean;
  10380. /**
  10381. * Gets or sets the sprite size
  10382. */
  10383. get size(): number;
  10384. set size(value: number);
  10385. /**
  10386. * Returns a boolean indicating if the animation is started
  10387. */
  10388. get animationStarted(): boolean;
  10389. /**
  10390. * Gets or sets the unique id of the sprite
  10391. */
  10392. uniqueId: number;
  10393. /**
  10394. * Gets the manager of this sprite
  10395. */
  10396. get manager(): ISpriteManager;
  10397. /**
  10398. * Creates a new Sprite
  10399. * @param name defines the name
  10400. * @param manager defines the manager
  10401. */
  10402. constructor(
  10403. /** defines the name */
  10404. name: string, manager: ISpriteManager);
  10405. /**
  10406. * Returns the string "Sprite"
  10407. * @returns "Sprite"
  10408. */
  10409. getClassName(): string;
  10410. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10411. get fromIndex(): number;
  10412. set fromIndex(value: number);
  10413. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10414. get toIndex(): number;
  10415. set toIndex(value: number);
  10416. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10417. get loopAnimation(): boolean;
  10418. set loopAnimation(value: boolean);
  10419. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10420. get delay(): number;
  10421. set delay(value: number);
  10422. /**
  10423. * Starts an animation
  10424. * @param from defines the initial key
  10425. * @param to defines the end key
  10426. * @param loop defines if the animation must loop
  10427. * @param delay defines the start delay (in ms)
  10428. * @param onAnimationEnd defines a callback to call when animation ends
  10429. */
  10430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10431. /** Stops current animation (if any) */
  10432. stopAnimation(): void;
  10433. /** @hidden */
  10434. _animate(deltaTime: number): void;
  10435. /** Release associated resources */
  10436. dispose(): void;
  10437. /**
  10438. * Serializes the sprite to a JSON object
  10439. * @returns the JSON object
  10440. */
  10441. serialize(): any;
  10442. /**
  10443. * Parses a JSON object to create a new sprite
  10444. * @param parsedSprite The JSON object to parse
  10445. * @param manager defines the hosting manager
  10446. * @returns the new sprite
  10447. */
  10448. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10449. }
  10450. }
  10451. declare module "babylonjs/Collisions/pickingInfo" {
  10452. import { Nullable } from "babylonjs/types";
  10453. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10455. import { Sprite } from "babylonjs/Sprites/sprite";
  10456. import { Ray } from "babylonjs/Culling/ray";
  10457. /**
  10458. * Information about the result of picking within a scene
  10459. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10460. */
  10461. export class PickingInfo {
  10462. /** @hidden */
  10463. _pickingUnavailable: boolean;
  10464. /**
  10465. * If the pick collided with an object
  10466. */
  10467. hit: boolean;
  10468. /**
  10469. * Distance away where the pick collided
  10470. */
  10471. distance: number;
  10472. /**
  10473. * The location of pick collision
  10474. */
  10475. pickedPoint: Nullable<Vector3>;
  10476. /**
  10477. * The mesh corresponding the the pick collision
  10478. */
  10479. pickedMesh: Nullable<AbstractMesh>;
  10480. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bu: number;
  10482. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bv: number;
  10484. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. faceId: number;
  10486. /** Id of the the submesh that was picked */
  10487. subMeshId: number;
  10488. /** If a sprite was picked, this will be the sprite the pick collided with */
  10489. pickedSprite: Nullable<Sprite>;
  10490. /**
  10491. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10492. */
  10493. originMesh: Nullable<AbstractMesh>;
  10494. /**
  10495. * The ray that was used to perform the picking.
  10496. */
  10497. ray: Nullable<Ray>;
  10498. /**
  10499. * Gets the normal correspodning to the face the pick collided with
  10500. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10501. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10502. * @returns The normal correspodning to the face the pick collided with
  10503. */
  10504. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10505. /**
  10506. * Gets the texture coordinates of where the pick occured
  10507. * @returns the vector containing the coordnates of the texture
  10508. */
  10509. getTextureCoordinates(): Nullable<Vector2>;
  10510. }
  10511. }
  10512. declare module "babylonjs/Culling/ray" {
  10513. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10516. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10517. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10518. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10519. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10520. import { Plane } from "babylonjs/Maths/math.plane";
  10521. /**
  10522. * Class representing a ray with position and direction
  10523. */
  10524. export class Ray {
  10525. /** origin point */
  10526. origin: Vector3;
  10527. /** direction */
  10528. direction: Vector3;
  10529. /** length of the ray */
  10530. length: number;
  10531. private static readonly TmpVector3;
  10532. private _tmpRay;
  10533. /**
  10534. * Creates a new ray
  10535. * @param origin origin point
  10536. * @param direction direction
  10537. * @param length length of the ray
  10538. */
  10539. constructor(
  10540. /** origin point */
  10541. origin: Vector3,
  10542. /** direction */
  10543. direction: Vector3,
  10544. /** length of the ray */
  10545. length?: number);
  10546. /**
  10547. * Checks if the ray intersects a box
  10548. * This does not account for the ray lenght by design to improve perfs.
  10549. * @param minimum bound of the box
  10550. * @param maximum bound of the box
  10551. * @param intersectionTreshold extra extend to be added to the box in all direction
  10552. * @returns if the box was hit
  10553. */
  10554. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param box the bounding box to check
  10559. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10560. * @returns if the box was hit
  10561. */
  10562. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10563. /**
  10564. * If the ray hits a sphere
  10565. * @param sphere the bounding sphere to check
  10566. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10567. * @returns true if it hits the sphere
  10568. */
  10569. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10570. /**
  10571. * If the ray hits a triange
  10572. * @param vertex0 triangle vertex
  10573. * @param vertex1 triangle vertex
  10574. * @param vertex2 triangle vertex
  10575. * @returns intersection information if hit
  10576. */
  10577. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10578. /**
  10579. * Checks if ray intersects a plane
  10580. * @param plane the plane to check
  10581. * @returns the distance away it was hit
  10582. */
  10583. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10584. /**
  10585. * Calculate the intercept of a ray on a given axis
  10586. * @param axis to check 'x' | 'y' | 'z'
  10587. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10588. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10589. */
  10590. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10591. /**
  10592. * Checks if ray intersects a mesh
  10593. * @param mesh the mesh to check
  10594. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10595. * @returns picking info of the intersecton
  10596. */
  10597. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10598. /**
  10599. * Checks if ray intersects a mesh
  10600. * @param meshes the meshes to check
  10601. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10602. * @param results array to store result in
  10603. * @returns Array of picking infos
  10604. */
  10605. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10606. private _comparePickingInfo;
  10607. private static smallnum;
  10608. private static rayl;
  10609. /**
  10610. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10611. * @param sega the first point of the segment to test the intersection against
  10612. * @param segb the second point of the segment to test the intersection against
  10613. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10614. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10615. */
  10616. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10617. /**
  10618. * Update the ray from viewport position
  10619. * @param x position
  10620. * @param y y position
  10621. * @param viewportWidth viewport width
  10622. * @param viewportHeight viewport height
  10623. * @param world world matrix
  10624. * @param view view matrix
  10625. * @param projection projection matrix
  10626. * @returns this ray updated
  10627. */
  10628. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10629. /**
  10630. * Creates a ray with origin and direction of 0,0,0
  10631. * @returns the new ray
  10632. */
  10633. static Zero(): Ray;
  10634. /**
  10635. * Creates a new ray from screen space and viewport
  10636. * @param x position
  10637. * @param y y position
  10638. * @param viewportWidth viewport width
  10639. * @param viewportHeight viewport height
  10640. * @param world world matrix
  10641. * @param view view matrix
  10642. * @param projection projection matrix
  10643. * @returns new ray
  10644. */
  10645. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10646. /**
  10647. * 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
  10648. * transformed to the given world matrix.
  10649. * @param origin The origin point
  10650. * @param end The end point
  10651. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10652. * @returns the new ray
  10653. */
  10654. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Transforms a ray by a matrix
  10657. * @param ray ray to transform
  10658. * @param matrix matrix to apply
  10659. * @returns the resulting new ray
  10660. */
  10661. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10662. /**
  10663. * Transforms a ray by a matrix
  10664. * @param ray ray to transform
  10665. * @param matrix matrix to apply
  10666. * @param result ray to store result in
  10667. */
  10668. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10669. /**
  10670. * Unproject a ray from screen space to object space
  10671. * @param sourceX defines the screen space x coordinate to use
  10672. * @param sourceY defines the screen space y coordinate to use
  10673. * @param viewportWidth defines the current width of the viewport
  10674. * @param viewportHeight defines the current height of the viewport
  10675. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10676. * @param view defines the view matrix to use
  10677. * @param projection defines the projection matrix to use
  10678. */
  10679. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10680. }
  10681. /**
  10682. * Type used to define predicate used to select faces when a mesh intersection is detected
  10683. */
  10684. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10685. module "babylonjs/scene" {
  10686. interface Scene {
  10687. /** @hidden */
  10688. _tempPickingRay: Nullable<Ray>;
  10689. /** @hidden */
  10690. _cachedRayForTransform: Ray;
  10691. /** @hidden */
  10692. _pickWithRayInverseMatrix: Matrix;
  10693. /** @hidden */
  10694. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10695. /** @hidden */
  10696. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10697. }
  10698. }
  10699. }
  10700. declare module "babylonjs/sceneComponent" {
  10701. import { Scene } from "babylonjs/scene";
  10702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10704. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10705. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10706. import { Nullable } from "babylonjs/types";
  10707. import { Camera } from "babylonjs/Cameras/camera";
  10708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10709. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10710. import { AbstractScene } from "babylonjs/abstractScene";
  10711. import { Mesh } from "babylonjs/Meshes/mesh";
  10712. /**
  10713. * Groups all the scene component constants in one place to ease maintenance.
  10714. * @hidden
  10715. */
  10716. export class SceneComponentConstants {
  10717. static readonly NAME_EFFECTLAYER: string;
  10718. static readonly NAME_LAYER: string;
  10719. static readonly NAME_LENSFLARESYSTEM: string;
  10720. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10721. static readonly NAME_PARTICLESYSTEM: string;
  10722. static readonly NAME_GAMEPAD: string;
  10723. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10724. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10725. static readonly NAME_DEPTHRENDERER: string;
  10726. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10727. static readonly NAME_SPRITE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10742. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10743. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10746. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10748. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10749. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10750. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10754. static readonly STEP_AFTERRENDER_AUDIO: number;
  10755. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10756. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10759. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10760. static readonly STEP_POINTERMOVE_SPRITE: number;
  10761. static readonly STEP_POINTERDOWN_SPRITE: number;
  10762. static readonly STEP_POINTERUP_SPRITE: number;
  10763. }
  10764. /**
  10765. * This represents a scene component.
  10766. *
  10767. * This is used to decouple the dependency the scene is having on the different workloads like
  10768. * layers, post processes...
  10769. */
  10770. export interface ISceneComponent {
  10771. /**
  10772. * The name of the component. Each component must have a unique name.
  10773. */
  10774. name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /**
  10780. * Register the component to one instance of a scene.
  10781. */
  10782. register(): void;
  10783. /**
  10784. * Rebuilds the elements related to this component in case of
  10785. * context lost for instance.
  10786. */
  10787. rebuild(): void;
  10788. /**
  10789. * Disposes the component and the associated ressources.
  10790. */
  10791. dispose(): void;
  10792. }
  10793. /**
  10794. * This represents a SERIALIZABLE scene component.
  10795. *
  10796. * This extends Scene Component to add Serialization methods on top.
  10797. */
  10798. export interface ISceneSerializableComponent extends ISceneComponent {
  10799. /**
  10800. * Adds all the elements from the container to the scene
  10801. * @param container the container holding the elements
  10802. */
  10803. addFromContainer(container: AbstractScene): void;
  10804. /**
  10805. * Removes all the elements in the container from the scene
  10806. * @param container contains the elements to remove
  10807. * @param dispose if the removed element should be disposed (default: false)
  10808. */
  10809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10810. /**
  10811. * Serializes the component data to the specified json object
  10812. * @param serializationObject The object to serialize to
  10813. */
  10814. serialize(serializationObject: any): void;
  10815. }
  10816. /**
  10817. * Strong typing of a Mesh related stage step action
  10818. */
  10819. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10820. /**
  10821. * Strong typing of a Evaluate Sub Mesh related stage step action
  10822. */
  10823. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10824. /**
  10825. * Strong typing of a Active Mesh related stage step action
  10826. */
  10827. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10828. /**
  10829. * Strong typing of a Camera related stage step action
  10830. */
  10831. export type CameraStageAction = (camera: Camera) => void;
  10832. /**
  10833. * Strong typing of a Camera Frame buffer related stage step action
  10834. */
  10835. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10836. /**
  10837. * Strong typing of a Render Target related stage step action
  10838. */
  10839. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10840. /**
  10841. * Strong typing of a RenderingGroup related stage step action
  10842. */
  10843. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10844. /**
  10845. * Strong typing of a Mesh Render related stage step action
  10846. */
  10847. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10848. /**
  10849. * Strong typing of a simple stage step action
  10850. */
  10851. export type SimpleStageAction = () => void;
  10852. /**
  10853. * Strong typing of a render target action.
  10854. */
  10855. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10856. /**
  10857. * Strong typing of a pointer move action.
  10858. */
  10859. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10860. /**
  10861. * Strong typing of a pointer up/down action.
  10862. */
  10863. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10864. /**
  10865. * Representation of a stage in the scene (Basically a list of ordered steps)
  10866. * @hidden
  10867. */
  10868. export class Stage<T extends Function> extends Array<{
  10869. index: number;
  10870. component: ISceneComponent;
  10871. action: T;
  10872. }> {
  10873. /**
  10874. * Hide ctor from the rest of the world.
  10875. * @param items The items to add.
  10876. */
  10877. private constructor();
  10878. /**
  10879. * Creates a new Stage.
  10880. * @returns A new instance of a Stage
  10881. */
  10882. static Create<T extends Function>(): Stage<T>;
  10883. /**
  10884. * Registers a step in an ordered way in the targeted stage.
  10885. * @param index Defines the position to register the step in
  10886. * @param component Defines the component attached to the step
  10887. * @param action Defines the action to launch during the step
  10888. */
  10889. registerStep(index: number, component: ISceneComponent, action: T): void;
  10890. /**
  10891. * Clears all the steps from the stage.
  10892. */
  10893. clear(): void;
  10894. }
  10895. }
  10896. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10897. import { Nullable } from "babylonjs/types";
  10898. import { Observable } from "babylonjs/Misc/observable";
  10899. import { Scene } from "babylonjs/scene";
  10900. import { Sprite } from "babylonjs/Sprites/sprite";
  10901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10902. import { Ray } from "babylonjs/Culling/ray";
  10903. import { Camera } from "babylonjs/Cameras/camera";
  10904. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10905. import { ISceneComponent } from "babylonjs/sceneComponent";
  10906. module "babylonjs/scene" {
  10907. interface Scene {
  10908. /** @hidden */
  10909. _pointerOverSprite: Nullable<Sprite>;
  10910. /** @hidden */
  10911. _pickedDownSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _tempSpritePickingRay: Nullable<Ray>;
  10914. /**
  10915. * All of the sprite managers added to this scene
  10916. * @see http://doc.babylonjs.com/babylon101/sprites
  10917. */
  10918. spriteManagers: Array<ISpriteManager>;
  10919. /**
  10920. * An event triggered when sprites rendering is about to start
  10921. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10922. */
  10923. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10924. /**
  10925. * An event triggered when sprites rendering is done
  10926. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10927. */
  10928. onAfterSpritesRenderingObservable: Observable<Scene>;
  10929. /** @hidden */
  10930. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10931. /** Launch a ray to try to pick a sprite in the scene
  10932. * @param x position on screen
  10933. * @param y position on screen
  10934. * @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
  10935. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10936. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10937. * @returns a PickingInfo
  10938. */
  10939. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10940. /** Use the given ray to pick a sprite in the scene
  10941. * @param ray The ray (in world space) to use to pick meshes
  10942. * @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
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** @hidden */
  10949. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10950. /** Launch a ray to try to pick sprites in the scene
  10951. * @param x position on screen
  10952. * @param y position on screen
  10953. * @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
  10954. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Use the given ray to pick sprites in the scene
  10959. * @param ray The ray (in world space) to use to pick meshes
  10960. * @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
  10961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10962. * @returns a PickingInfo array
  10963. */
  10964. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10965. /**
  10966. * Force the sprite under the pointer
  10967. * @param sprite defines the sprite to use
  10968. */
  10969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10970. /**
  10971. * Gets the sprite under the pointer
  10972. * @returns a Sprite or null if no sprite is under the pointer
  10973. */
  10974. getPointerOverSprite(): Nullable<Sprite>;
  10975. }
  10976. }
  10977. /**
  10978. * Defines the sprite scene component responsible to manage sprites
  10979. * in a given scene.
  10980. */
  10981. export class SpriteSceneComponent implements ISceneComponent {
  10982. /**
  10983. * The component name helpfull to identify the component in the list of scene components.
  10984. */
  10985. readonly name: string;
  10986. /**
  10987. * The scene the component belongs to.
  10988. */
  10989. scene: Scene;
  10990. /** @hidden */
  10991. private _spritePredicate;
  10992. /**
  10993. * Creates a new instance of the component for the given scene
  10994. * @param scene Defines the scene to register the component in
  10995. */
  10996. constructor(scene: Scene);
  10997. /**
  10998. * Registers the component in a given scene
  10999. */
  11000. register(): void;
  11001. /**
  11002. * Rebuilds the elements related to this component in case of
  11003. * context lost for instance.
  11004. */
  11005. rebuild(): void;
  11006. /**
  11007. * Disposes the component and the associated ressources.
  11008. */
  11009. dispose(): void;
  11010. private _pickSpriteButKeepRay;
  11011. private _pointerMove;
  11012. private _pointerDown;
  11013. private _pointerUp;
  11014. }
  11015. }
  11016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11017. /** @hidden */
  11018. export var fogFragmentDeclaration: {
  11019. name: string;
  11020. shader: string;
  11021. };
  11022. }
  11023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11024. /** @hidden */
  11025. export var fogFragment: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module "babylonjs/Shaders/sprites.fragment" {
  11031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11033. /** @hidden */
  11034. export var spritesPixelShader: {
  11035. name: string;
  11036. shader: string;
  11037. };
  11038. }
  11039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11040. /** @hidden */
  11041. export var fogVertexDeclaration: {
  11042. name: string;
  11043. shader: string;
  11044. };
  11045. }
  11046. declare module "babylonjs/Shaders/sprites.vertex" {
  11047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11048. /** @hidden */
  11049. export var spritesVertexShader: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Sprites/spriteManager" {
  11055. import { IDisposable, Scene } from "babylonjs/scene";
  11056. import { Nullable } from "babylonjs/types";
  11057. import { Observable } from "babylonjs/Misc/observable";
  11058. import { Sprite } from "babylonjs/Sprites/sprite";
  11059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11060. import { Camera } from "babylonjs/Cameras/camera";
  11061. import { Texture } from "babylonjs/Materials/Textures/texture";
  11062. import "babylonjs/Shaders/sprites.fragment";
  11063. import "babylonjs/Shaders/sprites.vertex";
  11064. import { Ray } from "babylonjs/Culling/ray";
  11065. /**
  11066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11067. */
  11068. export interface ISpriteManager extends IDisposable {
  11069. /**
  11070. * Gets manager's name
  11071. */
  11072. name: string;
  11073. /**
  11074. * Restricts the camera to viewing objects with the same layerMask.
  11075. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11076. */
  11077. layerMask: number;
  11078. /**
  11079. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11080. */
  11081. isPickable: boolean;
  11082. /**
  11083. * Gets the hosting scene
  11084. */
  11085. scene: Scene;
  11086. /**
  11087. * Specifies the rendering group id for this mesh (0 by default)
  11088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11089. */
  11090. renderingGroupId: number;
  11091. /**
  11092. * Defines the list of sprites managed by the manager.
  11093. */
  11094. sprites: Array<Sprite>;
  11095. /**
  11096. * Gets or sets the spritesheet texture
  11097. */
  11098. texture: Texture;
  11099. /** Defines the default width of a cell in the spritesheet */
  11100. cellWidth: number;
  11101. /** Defines the default height of a cell in the spritesheet */
  11102. cellHeight: number;
  11103. /**
  11104. * Tests the intersection of a sprite with a specific ray.
  11105. * @param ray The ray we are sending to test the collision
  11106. * @param camera The camera space we are sending rays in
  11107. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11108. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11109. * @returns picking info or null.
  11110. */
  11111. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11112. /**
  11113. * Intersects the sprites with a ray
  11114. * @param ray defines the ray to intersect with
  11115. * @param camera defines the current active camera
  11116. * @param predicate defines a predicate used to select candidate sprites
  11117. * @returns null if no hit or a PickingInfo array
  11118. */
  11119. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Renders the list of sprites on screen.
  11122. */
  11123. render(): void;
  11124. }
  11125. /**
  11126. * Class used to manage multiple sprites on the same spritesheet
  11127. * @see http://doc.babylonjs.com/babylon101/sprites
  11128. */
  11129. export class SpriteManager implements ISpriteManager {
  11130. /** defines the manager's name */
  11131. name: string;
  11132. /** Define the Url to load snippets */
  11133. static SnippetUrl: string;
  11134. /** Snippet ID if the manager was created from the snippet server */
  11135. snippetId: string;
  11136. /** Gets the list of sprites */
  11137. sprites: Sprite[];
  11138. /** Gets or sets the rendering group id (0 by default) */
  11139. renderingGroupId: number;
  11140. /** Gets or sets camera layer mask */
  11141. layerMask: number;
  11142. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11143. fogEnabled: boolean;
  11144. /** Gets or sets a boolean indicating if the sprites are pickable */
  11145. isPickable: boolean;
  11146. /** Defines the default width of a cell in the spritesheet */
  11147. cellWidth: number;
  11148. /** Defines the default height of a cell in the spritesheet */
  11149. cellHeight: number;
  11150. /** Associative array from JSON sprite data file */
  11151. private _cellData;
  11152. /** Array of sprite names from JSON sprite data file */
  11153. private _spriteMap;
  11154. /** True when packed cell data from JSON file is ready*/
  11155. private _packedAndReady;
  11156. private _textureContent;
  11157. /**
  11158. * An event triggered when the manager is disposed.
  11159. */
  11160. onDisposeObservable: Observable<SpriteManager>;
  11161. private _onDisposeObserver;
  11162. /**
  11163. * Callback called when the manager is disposed
  11164. */
  11165. set onDispose(callback: () => void);
  11166. private _capacity;
  11167. private _fromPacked;
  11168. private _spriteTexture;
  11169. private _epsilon;
  11170. private _scene;
  11171. private _vertexData;
  11172. private _buffer;
  11173. private _vertexBuffers;
  11174. private _indexBuffer;
  11175. private _effectBase;
  11176. private _effectFog;
  11177. /**
  11178. * Gets or sets the unique id of the sprite
  11179. */
  11180. uniqueId: number;
  11181. /**
  11182. * Gets the array of sprites
  11183. */
  11184. get children(): Sprite[];
  11185. /**
  11186. * Gets the hosting scene
  11187. */
  11188. get scene(): Scene;
  11189. /**
  11190. * Gets the capacity of the manager
  11191. */
  11192. get capacity(): number;
  11193. /**
  11194. * Gets or sets the spritesheet texture
  11195. */
  11196. get texture(): Texture;
  11197. set texture(value: Texture);
  11198. private _blendMode;
  11199. /**
  11200. * Blend mode use to render the particle, it can be any of
  11201. * the static Constants.ALPHA_x properties provided in this class.
  11202. * Default value is Constants.ALPHA_COMBINE
  11203. */
  11204. get blendMode(): number;
  11205. set blendMode(blendMode: number);
  11206. /** Disables writing to the depth buffer when rendering the sprites.
  11207. * It can be handy to disable depth writing when using textures without alpha channel
  11208. * and setting some specific blend modes.
  11209. */
  11210. disableDepthWrite: boolean;
  11211. /**
  11212. * Creates a new sprite manager
  11213. * @param name defines the manager's name
  11214. * @param imgUrl defines the sprite sheet url
  11215. * @param capacity defines the maximum allowed number of sprites
  11216. * @param cellSize defines the size of a sprite cell
  11217. * @param scene defines the hosting scene
  11218. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11219. * @param samplingMode defines the smapling mode to use with spritesheet
  11220. * @param fromPacked set to false; do not alter
  11221. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11222. */
  11223. constructor(
  11224. /** defines the manager's name */
  11225. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11226. /**
  11227. * Returns the string "SpriteManager"
  11228. * @returns "SpriteManager"
  11229. */
  11230. getClassName(): string;
  11231. private _makePacked;
  11232. private _appendSpriteVertex;
  11233. private _checkTextureAlpha;
  11234. /**
  11235. * Intersects the sprites with a ray
  11236. * @param ray defines the ray to intersect with
  11237. * @param camera defines the current active camera
  11238. * @param predicate defines a predicate used to select candidate sprites
  11239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11240. * @returns null if no hit or a PickingInfo
  11241. */
  11242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11243. /**
  11244. * Intersects the sprites with a ray
  11245. * @param ray defines the ray to intersect with
  11246. * @param camera defines the current active camera
  11247. * @param predicate defines a predicate used to select candidate sprites
  11248. * @returns null if no hit or a PickingInfo array
  11249. */
  11250. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11251. /**
  11252. * Render all child sprites
  11253. */
  11254. render(): void;
  11255. /**
  11256. * Release associated resources
  11257. */
  11258. dispose(): void;
  11259. /**
  11260. * Serializes the sprite manager to a JSON object
  11261. * @param serializeTexture defines if the texture must be serialized as well
  11262. * @returns the JSON object
  11263. */
  11264. serialize(serializeTexture?: boolean): any;
  11265. /**
  11266. * Parses a JSON object to create a new sprite manager.
  11267. * @param parsedManager The JSON object to parse
  11268. * @param scene The scene to create the sprite managerin
  11269. * @param rootUrl The root url to use to load external dependencies like texture
  11270. * @returns the new sprite manager
  11271. */
  11272. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11273. /**
  11274. * Creates a sprite manager from a snippet saved in a remote file
  11275. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11276. * @param url defines the url to load from
  11277. * @param scene defines the hosting scene
  11278. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11279. * @returns a promise that will resolve to the new sprite manager
  11280. */
  11281. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11282. /**
  11283. * Creates a sprite manager from a snippet saved by the sprite editor
  11284. * @param snippetId defines the snippet to load
  11285. * @param scene defines the hosting scene
  11286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11287. * @returns a promise that will resolve to the new sprite manager
  11288. */
  11289. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11290. }
  11291. }
  11292. declare module "babylonjs/Misc/gradients" {
  11293. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11294. /** Interface used by value gradients (color, factor, ...) */
  11295. export interface IValueGradient {
  11296. /**
  11297. * Gets or sets the gradient value (between 0 and 1)
  11298. */
  11299. gradient: number;
  11300. }
  11301. /** Class used to store color4 gradient */
  11302. export class ColorGradient implements IValueGradient {
  11303. /**
  11304. * Gets or sets the gradient value (between 0 and 1)
  11305. */
  11306. gradient: number;
  11307. /**
  11308. * Gets or sets first associated color
  11309. */
  11310. color1: Color4;
  11311. /**
  11312. * Gets or sets second associated color
  11313. */
  11314. color2?: Color4 | undefined;
  11315. /**
  11316. * Creates a new color4 gradient
  11317. * @param gradient gets or sets the gradient value (between 0 and 1)
  11318. * @param color1 gets or sets first associated color
  11319. * @param color2 gets or sets first second color
  11320. */
  11321. constructor(
  11322. /**
  11323. * Gets or sets the gradient value (between 0 and 1)
  11324. */
  11325. gradient: number,
  11326. /**
  11327. * Gets or sets first associated color
  11328. */
  11329. color1: Color4,
  11330. /**
  11331. * Gets or sets second associated color
  11332. */
  11333. color2?: Color4 | undefined);
  11334. /**
  11335. * Will get a color picked randomly between color1 and color2.
  11336. * If color2 is undefined then color1 will be used
  11337. * @param result defines the target Color4 to store the result in
  11338. */
  11339. getColorToRef(result: Color4): void;
  11340. }
  11341. /** Class used to store color 3 gradient */
  11342. export class Color3Gradient implements IValueGradient {
  11343. /**
  11344. * Gets or sets the gradient value (between 0 and 1)
  11345. */
  11346. gradient: number;
  11347. /**
  11348. * Gets or sets the associated color
  11349. */
  11350. color: Color3;
  11351. /**
  11352. * Creates a new color3 gradient
  11353. * @param gradient gets or sets the gradient value (between 0 and 1)
  11354. * @param color gets or sets associated color
  11355. */
  11356. constructor(
  11357. /**
  11358. * Gets or sets the gradient value (between 0 and 1)
  11359. */
  11360. gradient: number,
  11361. /**
  11362. * Gets or sets the associated color
  11363. */
  11364. color: Color3);
  11365. }
  11366. /** Class used to store factor gradient */
  11367. export class FactorGradient implements IValueGradient {
  11368. /**
  11369. * Gets or sets the gradient value (between 0 and 1)
  11370. */
  11371. gradient: number;
  11372. /**
  11373. * Gets or sets first associated factor
  11374. */
  11375. factor1: number;
  11376. /**
  11377. * Gets or sets second associated factor
  11378. */
  11379. factor2?: number | undefined;
  11380. /**
  11381. * Creates a new factor gradient
  11382. * @param gradient gets or sets the gradient value (between 0 and 1)
  11383. * @param factor1 gets or sets first associated factor
  11384. * @param factor2 gets or sets second associated factor
  11385. */
  11386. constructor(
  11387. /**
  11388. * Gets or sets the gradient value (between 0 and 1)
  11389. */
  11390. gradient: number,
  11391. /**
  11392. * Gets or sets first associated factor
  11393. */
  11394. factor1: number,
  11395. /**
  11396. * Gets or sets second associated factor
  11397. */
  11398. factor2?: number | undefined);
  11399. /**
  11400. * Will get a number picked randomly between factor1 and factor2.
  11401. * If factor2 is undefined then factor1 will be used
  11402. * @returns the picked number
  11403. */
  11404. getFactor(): number;
  11405. }
  11406. /**
  11407. * Helper used to simplify some generic gradient tasks
  11408. */
  11409. export class GradientHelper {
  11410. /**
  11411. * Gets the current gradient from an array of IValueGradient
  11412. * @param ratio defines the current ratio to get
  11413. * @param gradients defines the array of IValueGradient
  11414. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11415. */
  11416. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11417. }
  11418. }
  11419. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11421. import { Nullable } from "babylonjs/types";
  11422. module "babylonjs/Engines/thinEngine" {
  11423. interface ThinEngine {
  11424. /**
  11425. * Creates a dynamic texture
  11426. * @param width defines the width of the texture
  11427. * @param height defines the height of the texture
  11428. * @param generateMipMaps defines if the engine should generate the mip levels
  11429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11430. * @returns the dynamic texture inside an InternalTexture
  11431. */
  11432. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11433. /**
  11434. * Update the content of a dynamic texture
  11435. * @param texture defines the texture to update
  11436. * @param canvas defines the canvas containing the source
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. * @param premulAlpha defines if alpha is stored as premultiplied
  11439. * @param format defines the format of the data
  11440. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11441. */
  11442. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11443. }
  11444. }
  11445. }
  11446. declare module "babylonjs/Misc/canvasGenerator" {
  11447. /**
  11448. * Helper class used to generate a canvas to manipulate images
  11449. */
  11450. export class CanvasGenerator {
  11451. /**
  11452. * Create a new canvas (or offscreen canvas depending on the context)
  11453. * @param width defines the expected width
  11454. * @param height defines the expected height
  11455. * @return a new canvas or offscreen canvas
  11456. */
  11457. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11458. }
  11459. }
  11460. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11461. import { Scene } from "babylonjs/scene";
  11462. import { Texture } from "babylonjs/Materials/Textures/texture";
  11463. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11464. /**
  11465. * A class extending Texture allowing drawing on a texture
  11466. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11467. */
  11468. export class DynamicTexture extends Texture {
  11469. private _generateMipMaps;
  11470. private _canvas;
  11471. private _context;
  11472. /**
  11473. * Creates a DynamicTexture
  11474. * @param name defines the name of the texture
  11475. * @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
  11476. * @param scene defines the scene where you want the texture
  11477. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11478. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11479. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11480. */
  11481. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11482. /**
  11483. * Get the current class name of the texture useful for serialization or dynamic coding.
  11484. * @returns "DynamicTexture"
  11485. */
  11486. getClassName(): string;
  11487. /**
  11488. * Gets the current state of canRescale
  11489. */
  11490. get canRescale(): boolean;
  11491. private _recreate;
  11492. /**
  11493. * Scales the texture
  11494. * @param ratio the scale factor to apply to both width and height
  11495. */
  11496. scale(ratio: number): void;
  11497. /**
  11498. * Resizes the texture
  11499. * @param width the new width
  11500. * @param height the new height
  11501. */
  11502. scaleTo(width: number, height: number): void;
  11503. /**
  11504. * Gets the context of the canvas used by the texture
  11505. * @returns the canvas context of the dynamic texture
  11506. */
  11507. getContext(): CanvasRenderingContext2D;
  11508. /**
  11509. * Clears the texture
  11510. */
  11511. clear(): void;
  11512. /**
  11513. * Updates the texture
  11514. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11515. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11516. */
  11517. update(invertY?: boolean, premulAlpha?: boolean): void;
  11518. /**
  11519. * Draws text onto the texture
  11520. * @param text defines the text to be drawn
  11521. * @param x defines the placement of the text from the left
  11522. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11523. * @param font defines the font to be used with font-style, font-size, font-name
  11524. * @param color defines the color used for the text
  11525. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11526. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11527. * @param update defines whether texture is immediately update (default is true)
  11528. */
  11529. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11530. /**
  11531. * Clones the texture
  11532. * @returns the clone of the texture.
  11533. */
  11534. clone(): DynamicTexture;
  11535. /**
  11536. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11537. * @returns a serialized dynamic texture object
  11538. */
  11539. serialize(): any;
  11540. /** @hidden */
  11541. _rebuild(): void;
  11542. }
  11543. }
  11544. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11545. import { Nullable } from "babylonjs/types";
  11546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11547. import { Scene } from "babylonjs/scene";
  11548. module "babylonjs/Engines/thinEngine" {
  11549. interface ThinEngine {
  11550. /**
  11551. * Creates a raw texture
  11552. * @param data defines the data to store in the texture
  11553. * @param width defines the width of the texture
  11554. * @param height defines the height of the texture
  11555. * @param format defines the format of the data
  11556. * @param generateMipMaps defines if the engine should generate the mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11559. * @param compression defines the compression used (null by default)
  11560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11561. * @returns the raw texture inside an InternalTexture
  11562. */
  11563. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11564. /**
  11565. * Update a raw texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store in the texture
  11568. * @param format defines the format of the data
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store in the texture
  11576. * @param format defines the format of the data
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the compression used (null by default)
  11579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11580. */
  11581. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11582. /**
  11583. * Creates a new raw cube texture
  11584. * @param data defines the array of data to use to create each face
  11585. * @param size defines the size of the textures
  11586. * @param format defines the format of the data
  11587. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11591. * @param compression defines the compression used (null by default)
  11592. * @returns the cube texture as an InternalTexture
  11593. */
  11594. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11595. /**
  11596. * Update a raw cube texture
  11597. * @param texture defines the texture to udpdate
  11598. * @param data defines the data to store
  11599. * @param format defines the data format
  11600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw cube texture
  11606. * @param texture defines the texture to udpdate
  11607. * @param data defines the data to store
  11608. * @param format defines the data format
  11609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11610. * @param invertY defines if data must be stored with Y axis inverted
  11611. * @param compression defines the compression used (null by default)
  11612. */
  11613. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11614. /**
  11615. * Update a raw cube texture
  11616. * @param texture defines the texture to udpdate
  11617. * @param data defines the data to store
  11618. * @param format defines the data format
  11619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11620. * @param invertY defines if data must be stored with Y axis inverted
  11621. * @param compression defines the compression used (null by default)
  11622. * @param level defines which level of the texture to update
  11623. */
  11624. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11625. /**
  11626. * Creates a new raw cube texture from a specified url
  11627. * @param url defines the url where the data is located
  11628. * @param scene defines the current scene
  11629. * @param size defines the size of the textures
  11630. * @param format defines the format of the data
  11631. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11632. * @param noMipmap defines if the engine should avoid generating the mip levels
  11633. * @param callback defines a callback used to extract texture data from loaded data
  11634. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11635. * @param onLoad defines a callback called when texture is loaded
  11636. * @param onError defines a callback called if there is an error
  11637. * @returns the cube texture as an InternalTexture
  11638. */
  11639. 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;
  11640. /**
  11641. * Creates a new raw cube texture from a specified url
  11642. * @param url defines the url where the data is located
  11643. * @param scene defines the current scene
  11644. * @param size defines the size of the textures
  11645. * @param format defines the format of the data
  11646. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11647. * @param noMipmap defines if the engine should avoid generating the mip levels
  11648. * @param callback defines a callback used to extract texture data from loaded data
  11649. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11650. * @param onLoad defines a callback called when texture is loaded
  11651. * @param onError defines a callback called if there is an error
  11652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @returns the cube texture as an InternalTexture
  11655. */
  11656. 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;
  11657. /**
  11658. * Creates a new raw 3D texture
  11659. * @param data defines the data used to create the texture
  11660. * @param width defines the width of the texture
  11661. * @param height defines the height of the texture
  11662. * @param depth defines the depth of the texture
  11663. * @param format defines the format of the texture
  11664. * @param generateMipMaps defines if the engine must generate mip levels
  11665. * @param invertY defines if data must be stored with Y axis inverted
  11666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11667. * @param compression defines the compressed used (can be null)
  11668. * @param textureType defines the compressed used (can be null)
  11669. * @returns a new raw 3D texture (stored in an InternalTexture)
  11670. */
  11671. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11672. /**
  11673. * Update a raw 3D texture
  11674. * @param texture defines the texture to update
  11675. * @param data defines the data to store
  11676. * @param format defines the data format
  11677. * @param invertY defines if data must be stored with Y axis inverted
  11678. */
  11679. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11680. /**
  11681. * Update a raw 3D texture
  11682. * @param texture defines the texture to update
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @param compression defines the used compression (can be null)
  11687. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11688. */
  11689. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11690. /**
  11691. * Creates a new raw 2D array texture
  11692. * @param data defines the data used to create the texture
  11693. * @param width defines the width of the texture
  11694. * @param height defines the height of the texture
  11695. * @param depth defines the number of layers of the texture
  11696. * @param format defines the format of the texture
  11697. * @param generateMipMaps defines if the engine must generate mip levels
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11700. * @param compression defines the compressed used (can be null)
  11701. * @param textureType defines the compressed used (can be null)
  11702. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11703. */
  11704. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11705. /**
  11706. * Update a raw 2D array texture
  11707. * @param texture defines the texture to update
  11708. * @param data defines the data to store
  11709. * @param format defines the data format
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. */
  11712. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11713. /**
  11714. * Update a raw 2D array texture
  11715. * @param texture defines the texture to update
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param invertY defines if data must be stored with Y axis inverted
  11719. * @param compression defines the used compression (can be null)
  11720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11721. */
  11722. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11723. }
  11724. }
  11725. }
  11726. declare module "babylonjs/Materials/Textures/rawTexture" {
  11727. import { Scene } from "babylonjs/scene";
  11728. import { Texture } from "babylonjs/Materials/Textures/texture";
  11729. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11730. /**
  11731. * Raw texture can help creating a texture directly from an array of data.
  11732. * This can be super useful if you either get the data from an uncompressed source or
  11733. * if you wish to create your texture pixel by pixel.
  11734. */
  11735. export class RawTexture extends Texture {
  11736. /**
  11737. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11738. */
  11739. format: number;
  11740. /**
  11741. * Instantiates a new RawTexture.
  11742. * Raw texture can help creating a texture directly from an array of data.
  11743. * This can be super useful if you either get the data from an uncompressed source or
  11744. * if you wish to create your texture pixel by pixel.
  11745. * @param data define the array of data to use to create the texture
  11746. * @param width define the width of the texture
  11747. * @param height define the height of the texture
  11748. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11749. * @param scene define the scene the texture belongs to
  11750. * @param generateMipMaps define whether mip maps should be generated or not
  11751. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11752. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11753. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11754. */
  11755. constructor(data: ArrayBufferView, width: number, height: number,
  11756. /**
  11757. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11758. */
  11759. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11760. /**
  11761. * Updates the texture underlying data.
  11762. * @param data Define the new data of the texture
  11763. */
  11764. update(data: ArrayBufferView): void;
  11765. /**
  11766. * Creates a luminance texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param scene Define the scene the texture belongs to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the luminance texture
  11775. */
  11776. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a luminance alpha texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param scene Define the scene the texture belongs to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @returns the luminance alpha texture
  11787. */
  11788. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11789. /**
  11790. * Creates an alpha texture from some data.
  11791. * @param data Define the texture data
  11792. * @param width Define the width of the texture
  11793. * @param height Define the height of the texture
  11794. * @param scene Define the scene the texture belongs to
  11795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11798. * @returns the alpha texture
  11799. */
  11800. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11801. /**
  11802. * Creates a RGB texture from some data.
  11803. * @param data Define the texture data
  11804. * @param width Define the width of the texture
  11805. * @param height Define the height of the texture
  11806. * @param scene Define the scene the texture belongs to
  11807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11811. * @returns the RGB alpha texture
  11812. */
  11813. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11814. /**
  11815. * Creates a RGBA texture from some data.
  11816. * @param data Define the texture data
  11817. * @param width Define the width of the texture
  11818. * @param height Define the height of the texture
  11819. * @param scene Define the scene the texture belongs to
  11820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11824. * @returns the RGBA texture
  11825. */
  11826. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11827. /**
  11828. * Creates a R texture from some data.
  11829. * @param data Define the texture data
  11830. * @param width Define the width of the texture
  11831. * @param height Define the height of the texture
  11832. * @param scene Define the scene the texture belongs to
  11833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11836. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11837. * @returns the R texture
  11838. */
  11839. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11840. }
  11841. }
  11842. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11843. import { Scene } from "babylonjs/scene";
  11844. import { ISceneComponent } from "babylonjs/sceneComponent";
  11845. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11846. module "babylonjs/abstractScene" {
  11847. interface AbstractScene {
  11848. /**
  11849. * The list of procedural textures added to the scene
  11850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11851. */
  11852. proceduralTextures: Array<ProceduralTexture>;
  11853. }
  11854. }
  11855. /**
  11856. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11857. * in a given scene.
  11858. */
  11859. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11860. /**
  11861. * The component name helpfull to identify the component in the list of scene components.
  11862. */
  11863. readonly name: string;
  11864. /**
  11865. * The scene the component belongs to.
  11866. */
  11867. scene: Scene;
  11868. /**
  11869. * Creates a new instance of the component for the given scene
  11870. * @param scene Defines the scene to register the component in
  11871. */
  11872. constructor(scene: Scene);
  11873. /**
  11874. * Registers the component in a given scene
  11875. */
  11876. register(): void;
  11877. /**
  11878. * Rebuilds the elements related to this component in case of
  11879. * context lost for instance.
  11880. */
  11881. rebuild(): void;
  11882. /**
  11883. * Disposes the component and the associated ressources.
  11884. */
  11885. dispose(): void;
  11886. private _beforeClear;
  11887. }
  11888. }
  11889. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11891. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11892. module "babylonjs/Engines/thinEngine" {
  11893. interface ThinEngine {
  11894. /**
  11895. * Creates a new render target cube texture
  11896. * @param size defines the size of the texture
  11897. * @param options defines the options used to create the texture
  11898. * @returns a new render target cube texture stored in an InternalTexture
  11899. */
  11900. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11901. }
  11902. }
  11903. }
  11904. declare module "babylonjs/Shaders/procedural.vertex" {
  11905. /** @hidden */
  11906. export var proceduralVertexShader: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11912. import { Observable } from "babylonjs/Misc/observable";
  11913. import { Nullable } from "babylonjs/types";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11916. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11917. import { Effect } from "babylonjs/Materials/effect";
  11918. import { Texture } from "babylonjs/Materials/Textures/texture";
  11919. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11920. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11921. import "babylonjs/Shaders/procedural.vertex";
  11922. /**
  11923. * 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.
  11924. * This is the base class of any Procedural texture and contains most of the shareable code.
  11925. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11926. */
  11927. export class ProceduralTexture extends Texture {
  11928. isCube: boolean;
  11929. /**
  11930. * Define if the texture is enabled or not (disabled texture will not render)
  11931. */
  11932. isEnabled: boolean;
  11933. /**
  11934. * Define if the texture must be cleared before rendering (default is true)
  11935. */
  11936. autoClear: boolean;
  11937. /**
  11938. * Callback called when the texture is generated
  11939. */
  11940. onGenerated: () => void;
  11941. /**
  11942. * Event raised when the texture is generated
  11943. */
  11944. onGeneratedObservable: Observable<ProceduralTexture>;
  11945. /** @hidden */
  11946. _generateMipMaps: boolean;
  11947. /** @hidden **/
  11948. _effect: Effect;
  11949. /** @hidden */
  11950. _textures: {
  11951. [key: string]: Texture;
  11952. };
  11953. /** @hidden */
  11954. protected _fallbackTexture: Nullable<Texture>;
  11955. private _size;
  11956. private _currentRefreshId;
  11957. private _frameId;
  11958. private _refreshRate;
  11959. private _vertexBuffers;
  11960. private _indexBuffer;
  11961. private _uniforms;
  11962. private _samplers;
  11963. private _fragment;
  11964. private _floats;
  11965. private _ints;
  11966. private _floatsArrays;
  11967. private _colors3;
  11968. private _colors4;
  11969. private _vectors2;
  11970. private _vectors3;
  11971. private _matrices;
  11972. private _fallbackTextureUsed;
  11973. private _fullEngine;
  11974. private _cachedDefines;
  11975. private _contentUpdateId;
  11976. private _contentData;
  11977. /**
  11978. * Instantiates a new procedural texture.
  11979. * 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.
  11980. * This is the base class of any Procedural texture and contains most of the shareable code.
  11981. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11982. * @param name Define the name of the texture
  11983. * @param size Define the size of the texture to create
  11984. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11985. * @param scene Define the scene the texture belongs to
  11986. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11987. * @param generateMipMaps Define if the texture should creates mip maps or not
  11988. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11989. */
  11990. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11991. /**
  11992. * The effect that is created when initializing the post process.
  11993. * @returns The created effect corresponding the the postprocess.
  11994. */
  11995. getEffect(): Effect;
  11996. /**
  11997. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11998. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11999. */
  12000. getContent(): Nullable<ArrayBufferView>;
  12001. private _createIndexBuffer;
  12002. /** @hidden */
  12003. _rebuild(): void;
  12004. /**
  12005. * Resets the texture in order to recreate its associated resources.
  12006. * This can be called in case of context loss
  12007. */
  12008. reset(): void;
  12009. protected _getDefines(): string;
  12010. /**
  12011. * Is the texture ready to be used ? (rendered at least once)
  12012. * @returns true if ready, otherwise, false.
  12013. */
  12014. isReady(): boolean;
  12015. /**
  12016. * Resets the refresh counter of the texture and start bak from scratch.
  12017. * Could be useful to regenerate the texture if it is setup to render only once.
  12018. */
  12019. resetRefreshCounter(): void;
  12020. /**
  12021. * Set the fragment shader to use in order to render the texture.
  12022. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12023. */
  12024. setFragment(fragment: any): void;
  12025. /**
  12026. * Define the refresh rate of the texture or the rendering frequency.
  12027. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12028. */
  12029. get refreshRate(): number;
  12030. set refreshRate(value: number);
  12031. /** @hidden */
  12032. _shouldRender(): boolean;
  12033. /**
  12034. * Get the size the texture is rendering at.
  12035. * @returns the size (texture is always squared)
  12036. */
  12037. getRenderSize(): number;
  12038. /**
  12039. * Resize the texture to new value.
  12040. * @param size Define the new size the texture should have
  12041. * @param generateMipMaps Define whether the new texture should create mip maps
  12042. */
  12043. resize(size: number, generateMipMaps: boolean): void;
  12044. private _checkUniform;
  12045. /**
  12046. * Set a texture in the shader program used to render.
  12047. * @param name Define the name of the uniform samplers as defined in the shader
  12048. * @param texture Define the texture to bind to this sampler
  12049. * @return the texture itself allowing "fluent" like uniform updates
  12050. */
  12051. setTexture(name: string, texture: Texture): ProceduralTexture;
  12052. /**
  12053. * Set a float in the shader.
  12054. * @param name Define the name of the uniform as defined in the shader
  12055. * @param value Define the value to give to the uniform
  12056. * @return the texture itself allowing "fluent" like uniform updates
  12057. */
  12058. setFloat(name: string, value: number): ProceduralTexture;
  12059. /**
  12060. * Set a int in the shader.
  12061. * @param name Define the name of the uniform as defined in the shader
  12062. * @param value Define the value to give to the uniform
  12063. * @return the texture itself allowing "fluent" like uniform updates
  12064. */
  12065. setInt(name: string, value: number): ProceduralTexture;
  12066. /**
  12067. * Set an array of floats in the shader.
  12068. * @param name Define the name of the uniform as defined in the shader
  12069. * @param value Define the value to give to the uniform
  12070. * @return the texture itself allowing "fluent" like uniform updates
  12071. */
  12072. setFloats(name: string, value: number[]): ProceduralTexture;
  12073. /**
  12074. * Set a vec3 in the shader from a Color3.
  12075. * @param name Define the name of the uniform as defined in the shader
  12076. * @param value Define the value to give to the uniform
  12077. * @return the texture itself allowing "fluent" like uniform updates
  12078. */
  12079. setColor3(name: string, value: Color3): ProceduralTexture;
  12080. /**
  12081. * Set a vec4 in the shader from a Color4.
  12082. * @param name Define the name of the uniform as defined in the shader
  12083. * @param value Define the value to give to the uniform
  12084. * @return the texture itself allowing "fluent" like uniform updates
  12085. */
  12086. setColor4(name: string, value: Color4): ProceduralTexture;
  12087. /**
  12088. * Set a vec2 in the shader from a Vector2.
  12089. * @param name Define the name of the uniform as defined in the shader
  12090. * @param value Define the value to give to the uniform
  12091. * @return the texture itself allowing "fluent" like uniform updates
  12092. */
  12093. setVector2(name: string, value: Vector2): ProceduralTexture;
  12094. /**
  12095. * Set a vec3 in the shader from a Vector3.
  12096. * @param name Define the name of the uniform as defined in the shader
  12097. * @param value Define the value to give to the uniform
  12098. * @return the texture itself allowing "fluent" like uniform updates
  12099. */
  12100. setVector3(name: string, value: Vector3): ProceduralTexture;
  12101. /**
  12102. * Set a mat4 in the shader from a MAtrix.
  12103. * @param name Define the name of the uniform as defined in the shader
  12104. * @param value Define the value to give to the uniform
  12105. * @return the texture itself allowing "fluent" like uniform updates
  12106. */
  12107. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12108. /**
  12109. * Render the texture to its associated render target.
  12110. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12111. */
  12112. render(useCameraPostProcess?: boolean): void;
  12113. /**
  12114. * Clone the texture.
  12115. * @returns the cloned texture
  12116. */
  12117. clone(): ProceduralTexture;
  12118. /**
  12119. * Dispose the texture and release its asoociated resources.
  12120. */
  12121. dispose(): void;
  12122. }
  12123. }
  12124. declare module "babylonjs/Particles/baseParticleSystem" {
  12125. import { Nullable } from "babylonjs/types";
  12126. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12128. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12129. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12130. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12131. import { Scene } from "babylonjs/scene";
  12132. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12133. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12134. import { Texture } from "babylonjs/Materials/Textures/texture";
  12135. import { Color4 } from "babylonjs/Maths/math.color";
  12136. import { Animation } from "babylonjs/Animations/animation";
  12137. /**
  12138. * This represents the base class for particle system in Babylon.
  12139. * 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.
  12140. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12141. * @example https://doc.babylonjs.com/babylon101/particles
  12142. */
  12143. export class BaseParticleSystem {
  12144. /**
  12145. * Source color is added to the destination color without alpha affecting the result
  12146. */
  12147. static BLENDMODE_ONEONE: number;
  12148. /**
  12149. * Blend current color and particle color using particle’s alpha
  12150. */
  12151. static BLENDMODE_STANDARD: number;
  12152. /**
  12153. * Add current color and particle color multiplied by particle’s alpha
  12154. */
  12155. static BLENDMODE_ADD: number;
  12156. /**
  12157. * Multiply current color with particle color
  12158. */
  12159. static BLENDMODE_MULTIPLY: number;
  12160. /**
  12161. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12162. */
  12163. static BLENDMODE_MULTIPLYADD: number;
  12164. /**
  12165. * List of animations used by the particle system.
  12166. */
  12167. animations: Animation[];
  12168. /**
  12169. * Gets or sets the unique id of the particle system
  12170. */
  12171. uniqueId: number;
  12172. /**
  12173. * The id of the Particle system.
  12174. */
  12175. id: string;
  12176. /**
  12177. * The friendly name of the Particle system.
  12178. */
  12179. name: string;
  12180. /**
  12181. * Snippet ID if the particle system was created from the snippet server
  12182. */
  12183. snippetId: string;
  12184. /**
  12185. * The rendering group used by the Particle system to chose when to render.
  12186. */
  12187. renderingGroupId: number;
  12188. /**
  12189. * The emitter represents the Mesh or position we are attaching the particle system to.
  12190. */
  12191. emitter: Nullable<AbstractMesh | Vector3>;
  12192. /**
  12193. * The maximum number of particles to emit per frame
  12194. */
  12195. emitRate: number;
  12196. /**
  12197. * If you want to launch only a few particles at once, that can be done, as well.
  12198. */
  12199. manualEmitCount: number;
  12200. /**
  12201. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12202. */
  12203. updateSpeed: number;
  12204. /**
  12205. * The amount of time the particle system is running (depends of the overall update speed).
  12206. */
  12207. targetStopDuration: number;
  12208. /**
  12209. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12210. */
  12211. disposeOnStop: boolean;
  12212. /**
  12213. * Minimum power of emitting particles.
  12214. */
  12215. minEmitPower: number;
  12216. /**
  12217. * Maximum power of emitting particles.
  12218. */
  12219. maxEmitPower: number;
  12220. /**
  12221. * Minimum life time of emitting particles.
  12222. */
  12223. minLifeTime: number;
  12224. /**
  12225. * Maximum life time of emitting particles.
  12226. */
  12227. maxLifeTime: number;
  12228. /**
  12229. * Minimum Size of emitting particles.
  12230. */
  12231. minSize: number;
  12232. /**
  12233. * Maximum Size of emitting particles.
  12234. */
  12235. maxSize: number;
  12236. /**
  12237. * Minimum scale of emitting particles on X axis.
  12238. */
  12239. minScaleX: number;
  12240. /**
  12241. * Maximum scale of emitting particles on X axis.
  12242. */
  12243. maxScaleX: number;
  12244. /**
  12245. * Minimum scale of emitting particles on Y axis.
  12246. */
  12247. minScaleY: number;
  12248. /**
  12249. * Maximum scale of emitting particles on Y axis.
  12250. */
  12251. maxScaleY: number;
  12252. /**
  12253. * Gets or sets the minimal initial rotation in radians.
  12254. */
  12255. minInitialRotation: number;
  12256. /**
  12257. * Gets or sets the maximal initial rotation in radians.
  12258. */
  12259. maxInitialRotation: number;
  12260. /**
  12261. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12262. */
  12263. minAngularSpeed: number;
  12264. /**
  12265. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12266. */
  12267. maxAngularSpeed: number;
  12268. /**
  12269. * The texture used to render each particle. (this can be a spritesheet)
  12270. */
  12271. particleTexture: Nullable<Texture>;
  12272. /**
  12273. * The layer mask we are rendering the particles through.
  12274. */
  12275. layerMask: number;
  12276. /**
  12277. * This can help using your own shader to render the particle system.
  12278. * The according effect will be created
  12279. */
  12280. customShader: any;
  12281. /**
  12282. * By default particle system starts as soon as they are created. This prevents the
  12283. * automatic start to happen and let you decide when to start emitting particles.
  12284. */
  12285. preventAutoStart: boolean;
  12286. private _noiseTexture;
  12287. /**
  12288. * Gets or sets a texture used to add random noise to particle positions
  12289. */
  12290. get noiseTexture(): Nullable<ProceduralTexture>;
  12291. set noiseTexture(value: Nullable<ProceduralTexture>);
  12292. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12293. noiseStrength: Vector3;
  12294. /**
  12295. * Callback triggered when the particle animation is ending.
  12296. */
  12297. onAnimationEnd: Nullable<() => void>;
  12298. /**
  12299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12300. */
  12301. blendMode: number;
  12302. /**
  12303. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12304. * to override the particles.
  12305. */
  12306. forceDepthWrite: boolean;
  12307. /** 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 */
  12308. preWarmCycles: number;
  12309. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12310. preWarmStepOffset: number;
  12311. /**
  12312. * 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)
  12313. */
  12314. spriteCellChangeSpeed: number;
  12315. /**
  12316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12317. */
  12318. startSpriteCellID: number;
  12319. /**
  12320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12321. */
  12322. endSpriteCellID: number;
  12323. /**
  12324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12325. */
  12326. spriteCellWidth: number;
  12327. /**
  12328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12329. */
  12330. spriteCellHeight: number;
  12331. /**
  12332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12333. */
  12334. spriteRandomStartCell: boolean;
  12335. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12336. translationPivot: Vector2;
  12337. /** @hidden */
  12338. protected _isAnimationSheetEnabled: boolean;
  12339. /**
  12340. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12341. */
  12342. beginAnimationOnStart: boolean;
  12343. /**
  12344. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12345. */
  12346. beginAnimationFrom: number;
  12347. /**
  12348. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12349. */
  12350. beginAnimationTo: number;
  12351. /**
  12352. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12353. */
  12354. beginAnimationLoop: boolean;
  12355. /**
  12356. * Gets or sets a world offset applied to all particles
  12357. */
  12358. worldOffset: Vector3;
  12359. /**
  12360. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12361. */
  12362. get isAnimationSheetEnabled(): boolean;
  12363. set isAnimationSheetEnabled(value: boolean);
  12364. /**
  12365. * Get hosting scene
  12366. * @returns the scene
  12367. */
  12368. getScene(): Scene;
  12369. /**
  12370. * You can use gravity if you want to give an orientation to your particles.
  12371. */
  12372. gravity: Vector3;
  12373. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12374. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12375. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12377. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12378. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12380. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12381. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12382. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12383. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12384. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12386. /**
  12387. * Defines the delay in milliseconds before starting the system (0 by default)
  12388. */
  12389. startDelay: number;
  12390. /**
  12391. * Gets the current list of drag gradients.
  12392. * You must use addDragGradient and removeDragGradient to udpate this list
  12393. * @returns the list of drag gradients
  12394. */
  12395. getDragGradients(): Nullable<Array<FactorGradient>>;
  12396. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12397. limitVelocityDamping: number;
  12398. /**
  12399. * Gets the current list of limit velocity gradients.
  12400. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12401. * @returns the list of limit velocity gradients
  12402. */
  12403. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12404. /**
  12405. * Gets the current list of color gradients.
  12406. * You must use addColorGradient and removeColorGradient to udpate this list
  12407. * @returns the list of color gradients
  12408. */
  12409. getColorGradients(): Nullable<Array<ColorGradient>>;
  12410. /**
  12411. * Gets the current list of size gradients.
  12412. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12413. * @returns the list of size gradients
  12414. */
  12415. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12416. /**
  12417. * Gets the current list of color remap gradients.
  12418. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12419. * @returns the list of color remap gradients
  12420. */
  12421. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12422. /**
  12423. * Gets the current list of alpha remap gradients.
  12424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12425. * @returns the list of alpha remap gradients
  12426. */
  12427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12428. /**
  12429. * Gets the current list of life time gradients.
  12430. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12431. * @returns the list of life time gradients
  12432. */
  12433. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12434. /**
  12435. * Gets the current list of angular speed gradients.
  12436. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12437. * @returns the list of angular speed gradients
  12438. */
  12439. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12440. /**
  12441. * Gets the current list of velocity gradients.
  12442. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12443. * @returns the list of velocity gradients
  12444. */
  12445. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12446. /**
  12447. * Gets the current list of start size gradients.
  12448. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12449. * @returns the list of start size gradients
  12450. */
  12451. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12452. /**
  12453. * Gets the current list of emit rate gradients.
  12454. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12455. * @returns the list of emit rate gradients
  12456. */
  12457. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12458. /**
  12459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12461. */
  12462. get direction1(): Vector3;
  12463. set direction1(value: Vector3);
  12464. /**
  12465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12466. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12467. */
  12468. get direction2(): Vector3;
  12469. set direction2(value: Vector3);
  12470. /**
  12471. * 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.
  12472. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12473. */
  12474. get minEmitBox(): Vector3;
  12475. set minEmitBox(value: Vector3);
  12476. /**
  12477. * 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.
  12478. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12479. */
  12480. get maxEmitBox(): Vector3;
  12481. set maxEmitBox(value: Vector3);
  12482. /**
  12483. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12484. */
  12485. color1: Color4;
  12486. /**
  12487. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12488. */
  12489. color2: Color4;
  12490. /**
  12491. * Color the particle will have at the end of its lifetime
  12492. */
  12493. colorDead: Color4;
  12494. /**
  12495. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12496. */
  12497. textureMask: Color4;
  12498. /**
  12499. * The particle emitter type defines the emitter used by the particle system.
  12500. * It can be for example box, sphere, or cone...
  12501. */
  12502. particleEmitterType: IParticleEmitterType;
  12503. /** @hidden */
  12504. _isSubEmitter: boolean;
  12505. /**
  12506. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12507. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12508. */
  12509. billboardMode: number;
  12510. protected _isBillboardBased: boolean;
  12511. /**
  12512. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12513. */
  12514. get isBillboardBased(): boolean;
  12515. set isBillboardBased(value: boolean);
  12516. /**
  12517. * The scene the particle system belongs to.
  12518. */
  12519. protected _scene: Scene;
  12520. /**
  12521. * Local cache of defines for image processing.
  12522. */
  12523. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12524. /**
  12525. * Default configuration related to image processing available in the standard Material.
  12526. */
  12527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12528. /**
  12529. * Gets the image processing configuration used either in this material.
  12530. */
  12531. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12532. /**
  12533. * Sets the Default image processing configuration used either in the this material.
  12534. *
  12535. * If sets to null, the scene one is in use.
  12536. */
  12537. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12538. /**
  12539. * Attaches a new image processing configuration to the Standard Material.
  12540. * @param configuration
  12541. */
  12542. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12543. /** @hidden */
  12544. protected _reset(): void;
  12545. /** @hidden */
  12546. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12547. /**
  12548. * Instantiates a particle system.
  12549. * 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.
  12550. * @param name The name of the particle system
  12551. */
  12552. constructor(name: string);
  12553. /**
  12554. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12557. * @returns the emitter
  12558. */
  12559. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12560. /**
  12561. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12562. * @param radius The radius of the hemisphere to emit from
  12563. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12564. * @returns the emitter
  12565. */
  12566. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12567. /**
  12568. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12569. * @param radius The radius of the sphere to emit from
  12570. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12571. * @returns the emitter
  12572. */
  12573. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12574. /**
  12575. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12576. * @param radius The radius of the sphere to emit from
  12577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12579. * @returns the emitter
  12580. */
  12581. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12582. /**
  12583. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12584. * @param radius The radius of the emission cylinder
  12585. * @param height The height of the emission cylinder
  12586. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12587. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12588. * @returns the emitter
  12589. */
  12590. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12591. /**
  12592. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12593. * @param radius The radius of the cylinder to emit from
  12594. * @param height The height of the emission cylinder
  12595. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12598. * @returns the emitter
  12599. */
  12600. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12601. /**
  12602. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12603. * @param radius The radius of the cone to emit from
  12604. * @param angle The base angle of the cone
  12605. * @returns the emitter
  12606. */
  12607. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12608. /**
  12609. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12612. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12613. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12614. * @returns the emitter
  12615. */
  12616. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12617. }
  12618. }
  12619. declare module "babylonjs/Particles/subEmitter" {
  12620. import { Scene } from "babylonjs/scene";
  12621. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12622. /**
  12623. * Type of sub emitter
  12624. */
  12625. export enum SubEmitterType {
  12626. /**
  12627. * Attached to the particle over it's lifetime
  12628. */
  12629. ATTACHED = 0,
  12630. /**
  12631. * Created when the particle dies
  12632. */
  12633. END = 1
  12634. }
  12635. /**
  12636. * Sub emitter class used to emit particles from an existing particle
  12637. */
  12638. export class SubEmitter {
  12639. /**
  12640. * the particle system to be used by the sub emitter
  12641. */
  12642. particleSystem: ParticleSystem;
  12643. /**
  12644. * Type of the submitter (Default: END)
  12645. */
  12646. type: SubEmitterType;
  12647. /**
  12648. * 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)
  12649. * Note: This only is supported when using an emitter of type Mesh
  12650. */
  12651. inheritDirection: boolean;
  12652. /**
  12653. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12654. */
  12655. inheritedVelocityAmount: number;
  12656. /**
  12657. * Creates a sub emitter
  12658. * @param particleSystem the particle system to be used by the sub emitter
  12659. */
  12660. constructor(
  12661. /**
  12662. * the particle system to be used by the sub emitter
  12663. */
  12664. particleSystem: ParticleSystem);
  12665. /**
  12666. * Clones the sub emitter
  12667. * @returns the cloned sub emitter
  12668. */
  12669. clone(): SubEmitter;
  12670. /**
  12671. * Serialize current object to a JSON object
  12672. * @returns the serialized object
  12673. */
  12674. serialize(): any;
  12675. /** @hidden */
  12676. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12677. /**
  12678. * Creates a new SubEmitter from a serialized JSON version
  12679. * @param serializationObject defines the JSON object to read from
  12680. * @param scene defines the hosting scene
  12681. * @param rootUrl defines the rootUrl for data loading
  12682. * @returns a new SubEmitter
  12683. */
  12684. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12685. /** Release associated resources */
  12686. dispose(): void;
  12687. }
  12688. }
  12689. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12690. /** @hidden */
  12691. export var imageProcessingDeclaration: {
  12692. name: string;
  12693. shader: string;
  12694. };
  12695. }
  12696. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12697. /** @hidden */
  12698. export var imageProcessingFunctions: {
  12699. name: string;
  12700. shader: string;
  12701. };
  12702. }
  12703. declare module "babylonjs/Shaders/particles.fragment" {
  12704. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12705. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12706. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12707. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12708. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12709. /** @hidden */
  12710. export var particlesPixelShader: {
  12711. name: string;
  12712. shader: string;
  12713. };
  12714. }
  12715. declare module "babylonjs/Shaders/particles.vertex" {
  12716. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12717. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12718. /** @hidden */
  12719. export var particlesVertexShader: {
  12720. name: string;
  12721. shader: string;
  12722. };
  12723. }
  12724. declare module "babylonjs/Particles/particleSystem" {
  12725. import { Nullable } from "babylonjs/types";
  12726. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12727. import { Observable } from "babylonjs/Misc/observable";
  12728. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12729. import { Effect } from "babylonjs/Materials/effect";
  12730. import { Scene, IDisposable } from "babylonjs/scene";
  12731. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12732. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12733. import { Particle } from "babylonjs/Particles/particle";
  12734. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12735. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12736. import "babylonjs/Shaders/particles.fragment";
  12737. import "babylonjs/Shaders/particles.vertex";
  12738. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12739. /**
  12740. * This represents a particle system in Babylon.
  12741. * 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.
  12742. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12743. * @example https://doc.babylonjs.com/babylon101/particles
  12744. */
  12745. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12746. /**
  12747. * Billboard mode will only apply to Y axis
  12748. */
  12749. static readonly BILLBOARDMODE_Y: number;
  12750. /**
  12751. * Billboard mode will apply to all axes
  12752. */
  12753. static readonly BILLBOARDMODE_ALL: number;
  12754. /**
  12755. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12756. */
  12757. static readonly BILLBOARDMODE_STRETCHED: number;
  12758. /**
  12759. * This function can be defined to provide custom update for active particles.
  12760. * This function will be called instead of regular update (age, position, color, etc.).
  12761. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12762. */
  12763. updateFunction: (particles: Particle[]) => void;
  12764. private _emitterWorldMatrix;
  12765. /**
  12766. * This function can be defined to specify initial direction for every new particle.
  12767. * It by default use the emitterType defined function
  12768. */
  12769. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12770. /**
  12771. * This function can be defined to specify initial position for every new particle.
  12772. * It by default use the emitterType defined function
  12773. */
  12774. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12775. /**
  12776. * @hidden
  12777. */
  12778. _inheritedVelocityOffset: Vector3;
  12779. /**
  12780. * An event triggered when the system is disposed
  12781. */
  12782. onDisposeObservable: Observable<IParticleSystem>;
  12783. private _onDisposeObserver;
  12784. /**
  12785. * Sets a callback that will be triggered when the system is disposed
  12786. */
  12787. set onDispose(callback: () => void);
  12788. private _particles;
  12789. private _epsilon;
  12790. private _capacity;
  12791. private _stockParticles;
  12792. private _newPartsExcess;
  12793. private _vertexData;
  12794. private _vertexBuffer;
  12795. private _vertexBuffers;
  12796. private _spriteBuffer;
  12797. private _indexBuffer;
  12798. private _effect;
  12799. private _customEffect;
  12800. private _cachedDefines;
  12801. private _scaledColorStep;
  12802. private _colorDiff;
  12803. private _scaledDirection;
  12804. private _scaledGravity;
  12805. private _currentRenderId;
  12806. private _alive;
  12807. private _useInstancing;
  12808. private _started;
  12809. private _stopped;
  12810. private _actualFrame;
  12811. private _scaledUpdateSpeed;
  12812. private _vertexBufferSize;
  12813. /** @hidden */
  12814. _currentEmitRateGradient: Nullable<FactorGradient>;
  12815. /** @hidden */
  12816. _currentEmitRate1: number;
  12817. /** @hidden */
  12818. _currentEmitRate2: number;
  12819. /** @hidden */
  12820. _currentStartSizeGradient: Nullable<FactorGradient>;
  12821. /** @hidden */
  12822. _currentStartSize1: number;
  12823. /** @hidden */
  12824. _currentStartSize2: number;
  12825. private readonly _rawTextureWidth;
  12826. private _rampGradientsTexture;
  12827. private _useRampGradients;
  12828. /** Gets or sets a boolean indicating that ramp gradients must be used
  12829. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12830. */
  12831. get useRampGradients(): boolean;
  12832. set useRampGradients(value: boolean);
  12833. /**
  12834. * 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.
  12835. * 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: [])
  12836. */
  12837. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12838. private _subEmitters;
  12839. /**
  12840. * @hidden
  12841. * If the particle systems emitter should be disposed when the particle system is disposed
  12842. */
  12843. _disposeEmitterOnDispose: boolean;
  12844. /**
  12845. * The current active Sub-systems, this property is used by the root particle system only.
  12846. */
  12847. activeSubSystems: Array<ParticleSystem>;
  12848. /**
  12849. * Specifies if the particles are updated in emitter local space or world space
  12850. */
  12851. isLocal: boolean;
  12852. private _rootParticleSystem;
  12853. /**
  12854. * Gets the current list of active particles
  12855. */
  12856. get particles(): Particle[];
  12857. /**
  12858. * Gets the number of particles active at the same time.
  12859. * @returns The number of active particles.
  12860. */
  12861. getActiveCount(): number;
  12862. /**
  12863. * Returns the string "ParticleSystem"
  12864. * @returns a string containing the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Gets a boolean indicating that the system is stopping
  12869. * @returns true if the system is currently stopping
  12870. */
  12871. isStopping(): boolean;
  12872. /**
  12873. * Gets the custom effect used to render the particles
  12874. * @param blendMode Blend mode for which the effect should be retrieved
  12875. * @returns The effect
  12876. */
  12877. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12878. /**
  12879. * Sets the custom effect used to render the particles
  12880. * @param effect The effect to set
  12881. * @param blendMode Blend mode for which the effect should be set
  12882. */
  12883. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12884. /** @hidden */
  12885. private _onBeforeDrawParticlesObservable;
  12886. /**
  12887. * Observable that will be called just before the particles are drawn
  12888. */
  12889. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12890. /**
  12891. * Gets the name of the particle vertex shader
  12892. */
  12893. get vertexShaderName(): string;
  12894. /**
  12895. * Instantiates a particle system.
  12896. * 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.
  12897. * @param name The name of the particle system
  12898. * @param capacity The max number of particles alive at the same time
  12899. * @param scene The scene the particle system belongs to
  12900. * @param customEffect a custom effect used to change the way particles are rendered by default
  12901. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12902. * @param epsilon Offset used to render the particles
  12903. */
  12904. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12905. private _addFactorGradient;
  12906. private _removeFactorGradient;
  12907. /**
  12908. * Adds a new life time gradient
  12909. * @param gradient defines the gradient to use (between 0 and 1)
  12910. * @param factor defines the life time factor to affect to the specified gradient
  12911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12912. * @returns the current particle system
  12913. */
  12914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12915. /**
  12916. * Remove a specific life time gradient
  12917. * @param gradient defines the gradient to remove
  12918. * @returns the current particle system
  12919. */
  12920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12921. /**
  12922. * Adds a new size gradient
  12923. * @param gradient defines the gradient to use (between 0 and 1)
  12924. * @param factor defines the size factor to affect to the specified gradient
  12925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12926. * @returns the current particle system
  12927. */
  12928. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12929. /**
  12930. * Remove a specific size gradient
  12931. * @param gradient defines the gradient to remove
  12932. * @returns the current particle system
  12933. */
  12934. removeSizeGradient(gradient: number): IParticleSystem;
  12935. /**
  12936. * Adds a new color remap gradient
  12937. * @param gradient defines the gradient to use (between 0 and 1)
  12938. * @param min defines the color remap minimal range
  12939. * @param max defines the color remap maximal range
  12940. * @returns the current particle system
  12941. */
  12942. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12943. /**
  12944. * Remove a specific color remap gradient
  12945. * @param gradient defines the gradient to remove
  12946. * @returns the current particle system
  12947. */
  12948. removeColorRemapGradient(gradient: number): IParticleSystem;
  12949. /**
  12950. * Adds a new alpha remap gradient
  12951. * @param gradient defines the gradient to use (between 0 and 1)
  12952. * @param min defines the alpha remap minimal range
  12953. * @param max defines the alpha remap maximal range
  12954. * @returns the current particle system
  12955. */
  12956. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12957. /**
  12958. * Remove a specific alpha remap gradient
  12959. * @param gradient defines the gradient to remove
  12960. * @returns the current particle system
  12961. */
  12962. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12963. /**
  12964. * Adds a new angular speed gradient
  12965. * @param gradient defines the gradient to use (between 0 and 1)
  12966. * @param factor defines the angular speed to affect to the specified gradient
  12967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12968. * @returns the current particle system
  12969. */
  12970. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12971. /**
  12972. * Remove a specific angular speed gradient
  12973. * @param gradient defines the gradient to remove
  12974. * @returns the current particle system
  12975. */
  12976. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12977. /**
  12978. * Adds a new velocity gradient
  12979. * @param gradient defines the gradient to use (between 0 and 1)
  12980. * @param factor defines the velocity to affect to the specified gradient
  12981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12982. * @returns the current particle system
  12983. */
  12984. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12985. /**
  12986. * Remove a specific velocity gradient
  12987. * @param gradient defines the gradient to remove
  12988. * @returns the current particle system
  12989. */
  12990. removeVelocityGradient(gradient: number): IParticleSystem;
  12991. /**
  12992. * Adds a new limit velocity gradient
  12993. * @param gradient defines the gradient to use (between 0 and 1)
  12994. * @param factor defines the limit velocity value to affect to the specified gradient
  12995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12996. * @returns the current particle system
  12997. */
  12998. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12999. /**
  13000. * Remove a specific limit velocity gradient
  13001. * @param gradient defines the gradient to remove
  13002. * @returns the current particle system
  13003. */
  13004. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13005. /**
  13006. * Adds a new drag gradient
  13007. * @param gradient defines the gradient to use (between 0 and 1)
  13008. * @param factor defines the drag value to affect to the specified gradient
  13009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13010. * @returns the current particle system
  13011. */
  13012. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13013. /**
  13014. * Remove a specific drag gradient
  13015. * @param gradient defines the gradient to remove
  13016. * @returns the current particle system
  13017. */
  13018. removeDragGradient(gradient: number): IParticleSystem;
  13019. /**
  13020. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13021. * @param gradient defines the gradient to use (between 0 and 1)
  13022. * @param factor defines the emit rate value to affect to the specified gradient
  13023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13024. * @returns the current particle system
  13025. */
  13026. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13027. /**
  13028. * Remove a specific emit rate gradient
  13029. * @param gradient defines the gradient to remove
  13030. * @returns the current particle system
  13031. */
  13032. removeEmitRateGradient(gradient: number): IParticleSystem;
  13033. /**
  13034. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13035. * @param gradient defines the gradient to use (between 0 and 1)
  13036. * @param factor defines the start size value to affect to the specified gradient
  13037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13038. * @returns the current particle system
  13039. */
  13040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13041. /**
  13042. * Remove a specific start size gradient
  13043. * @param gradient defines the gradient to remove
  13044. * @returns the current particle system
  13045. */
  13046. removeStartSizeGradient(gradient: number): IParticleSystem;
  13047. private _createRampGradientTexture;
  13048. /**
  13049. * Gets the current list of ramp gradients.
  13050. * You must use addRampGradient and removeRampGradient to udpate this list
  13051. * @returns the list of ramp gradients
  13052. */
  13053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13054. /** Force the system to rebuild all gradients that need to be resync */
  13055. forceRefreshGradients(): void;
  13056. private _syncRampGradientTexture;
  13057. /**
  13058. * Adds a new ramp gradient used to remap particle colors
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param color defines the color to affect to the specified gradient
  13061. * @returns the current particle system
  13062. */
  13063. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13064. /**
  13065. * Remove a specific ramp gradient
  13066. * @param gradient defines the gradient to remove
  13067. * @returns the current particle system
  13068. */
  13069. removeRampGradient(gradient: number): ParticleSystem;
  13070. /**
  13071. * Adds a new color gradient
  13072. * @param gradient defines the gradient to use (between 0 and 1)
  13073. * @param color1 defines the color to affect to the specified gradient
  13074. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13075. * @returns this particle system
  13076. */
  13077. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13078. /**
  13079. * Remove a specific color gradient
  13080. * @param gradient defines the gradient to remove
  13081. * @returns this particle system
  13082. */
  13083. removeColorGradient(gradient: number): IParticleSystem;
  13084. private _fetchR;
  13085. protected _reset(): void;
  13086. private _resetEffect;
  13087. private _createVertexBuffers;
  13088. private _createIndexBuffer;
  13089. /**
  13090. * Gets the maximum number of particles active at the same time.
  13091. * @returns The max number of active particles.
  13092. */
  13093. getCapacity(): number;
  13094. /**
  13095. * Gets whether there are still active particles in the system.
  13096. * @returns True if it is alive, otherwise false.
  13097. */
  13098. isAlive(): boolean;
  13099. /**
  13100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13101. * @returns True if it has been started, otherwise false.
  13102. */
  13103. isStarted(): boolean;
  13104. private _prepareSubEmitterInternalArray;
  13105. /**
  13106. * Starts the particle system and begins to emit
  13107. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13108. */
  13109. start(delay?: number): void;
  13110. /**
  13111. * Stops the particle system.
  13112. * @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.
  13113. */
  13114. stop(stopSubEmitters?: boolean): void;
  13115. /**
  13116. * Remove all active particles
  13117. */
  13118. reset(): void;
  13119. /**
  13120. * @hidden (for internal use only)
  13121. */
  13122. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13123. /**
  13124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13125. * Its lifetime will start back at 0.
  13126. */
  13127. recycleParticle: (particle: Particle) => void;
  13128. private _stopSubEmitters;
  13129. private _createParticle;
  13130. private _removeFromRoot;
  13131. private _emitFromParticle;
  13132. private _update;
  13133. /** @hidden */
  13134. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13135. /** @hidden */
  13136. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13137. /**
  13138. * Fill the defines array according to the current settings of the particle system
  13139. * @param defines Array to be updated
  13140. * @param blendMode blend mode to take into account when updating the array
  13141. */
  13142. fillDefines(defines: Array<string>, blendMode: number): void;
  13143. /**
  13144. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13145. * @param uniforms Uniforms array to fill
  13146. * @param attributes Attributes array to fill
  13147. * @param samplers Samplers array to fill
  13148. */
  13149. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13150. /** @hidden */
  13151. private _getEffect;
  13152. /**
  13153. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13154. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13155. */
  13156. animate(preWarmOnly?: boolean): void;
  13157. private _appendParticleVertices;
  13158. /**
  13159. * Rebuilds the particle system.
  13160. */
  13161. rebuild(): void;
  13162. /**
  13163. * Is this system ready to be used/rendered
  13164. * @return true if the system is ready
  13165. */
  13166. isReady(): boolean;
  13167. private _render;
  13168. /**
  13169. * Renders the particle system in its current state.
  13170. * @returns the current number of particles
  13171. */
  13172. render(): number;
  13173. /**
  13174. * Disposes the particle system and free the associated resources
  13175. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13176. */
  13177. dispose(disposeTexture?: boolean): void;
  13178. /**
  13179. * Clones the particle system.
  13180. * @param name The name of the cloned object
  13181. * @param newEmitter The new emitter to use
  13182. * @returns the cloned particle system
  13183. */
  13184. clone(name: string, newEmitter: any): ParticleSystem;
  13185. /**
  13186. * Serializes the particle system to a JSON object
  13187. * @param serializeTexture defines if the texture must be serialized as well
  13188. * @returns the JSON object
  13189. */
  13190. serialize(serializeTexture?: boolean): any;
  13191. /** @hidden */
  13192. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13193. /** @hidden */
  13194. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13195. /**
  13196. * Parses a JSON object to create a particle system.
  13197. * @param parsedParticleSystem The JSON object to parse
  13198. * @param scene The scene to create the particle system in
  13199. * @param rootUrl The root url to use to load external dependencies like texture
  13200. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13201. * @returns the Parsed particle system
  13202. */
  13203. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13204. }
  13205. }
  13206. declare module "babylonjs/Particles/particle" {
  13207. import { Nullable } from "babylonjs/types";
  13208. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13209. import { Color4 } from "babylonjs/Maths/math.color";
  13210. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13211. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13212. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13213. /**
  13214. * A particle represents one of the element emitted by a particle system.
  13215. * This is mainly define by its coordinates, direction, velocity and age.
  13216. */
  13217. export class Particle {
  13218. /**
  13219. * The particle system the particle belongs to.
  13220. */
  13221. particleSystem: ParticleSystem;
  13222. private static _Count;
  13223. /**
  13224. * Unique ID of the particle
  13225. */
  13226. id: number;
  13227. /**
  13228. * The world position of the particle in the scene.
  13229. */
  13230. position: Vector3;
  13231. /**
  13232. * The world direction of the particle in the scene.
  13233. */
  13234. direction: Vector3;
  13235. /**
  13236. * The color of the particle.
  13237. */
  13238. color: Color4;
  13239. /**
  13240. * The color change of the particle per step.
  13241. */
  13242. colorStep: Color4;
  13243. /**
  13244. * Defines how long will the life of the particle be.
  13245. */
  13246. lifeTime: number;
  13247. /**
  13248. * The current age of the particle.
  13249. */
  13250. age: number;
  13251. /**
  13252. * The current size of the particle.
  13253. */
  13254. size: number;
  13255. /**
  13256. * The current scale of the particle.
  13257. */
  13258. scale: Vector2;
  13259. /**
  13260. * The current angle of the particle.
  13261. */
  13262. angle: number;
  13263. /**
  13264. * Defines how fast is the angle changing.
  13265. */
  13266. angularSpeed: number;
  13267. /**
  13268. * Defines the cell index used by the particle to be rendered from a sprite.
  13269. */
  13270. cellIndex: number;
  13271. /**
  13272. * The information required to support color remapping
  13273. */
  13274. remapData: Vector4;
  13275. /** @hidden */
  13276. _randomCellOffset?: number;
  13277. /** @hidden */
  13278. _initialDirection: Nullable<Vector3>;
  13279. /** @hidden */
  13280. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13281. /** @hidden */
  13282. _initialStartSpriteCellID: number;
  13283. /** @hidden */
  13284. _initialEndSpriteCellID: number;
  13285. /** @hidden */
  13286. _currentColorGradient: Nullable<ColorGradient>;
  13287. /** @hidden */
  13288. _currentColor1: Color4;
  13289. /** @hidden */
  13290. _currentColor2: Color4;
  13291. /** @hidden */
  13292. _currentSizeGradient: Nullable<FactorGradient>;
  13293. /** @hidden */
  13294. _currentSize1: number;
  13295. /** @hidden */
  13296. _currentSize2: number;
  13297. /** @hidden */
  13298. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13299. /** @hidden */
  13300. _currentAngularSpeed1: number;
  13301. /** @hidden */
  13302. _currentAngularSpeed2: number;
  13303. /** @hidden */
  13304. _currentVelocityGradient: Nullable<FactorGradient>;
  13305. /** @hidden */
  13306. _currentVelocity1: number;
  13307. /** @hidden */
  13308. _currentVelocity2: number;
  13309. /** @hidden */
  13310. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13311. /** @hidden */
  13312. _currentLimitVelocity1: number;
  13313. /** @hidden */
  13314. _currentLimitVelocity2: number;
  13315. /** @hidden */
  13316. _currentDragGradient: Nullable<FactorGradient>;
  13317. /** @hidden */
  13318. _currentDrag1: number;
  13319. /** @hidden */
  13320. _currentDrag2: number;
  13321. /** @hidden */
  13322. _randomNoiseCoordinates1: Vector3;
  13323. /** @hidden */
  13324. _randomNoiseCoordinates2: Vector3;
  13325. /** @hidden */
  13326. _localPosition?: Vector3;
  13327. /**
  13328. * Creates a new instance Particle
  13329. * @param particleSystem the particle system the particle belongs to
  13330. */
  13331. constructor(
  13332. /**
  13333. * The particle system the particle belongs to.
  13334. */
  13335. particleSystem: ParticleSystem);
  13336. private updateCellInfoFromSystem;
  13337. /**
  13338. * Defines how the sprite cell index is updated for the particle
  13339. */
  13340. updateCellIndex(): void;
  13341. /** @hidden */
  13342. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13343. /** @hidden */
  13344. _inheritParticleInfoToSubEmitters(): void;
  13345. /** @hidden */
  13346. _reset(): void;
  13347. /**
  13348. * Copy the properties of particle to another one.
  13349. * @param other the particle to copy the information to.
  13350. */
  13351. copyTo(other: Particle): void;
  13352. }
  13353. }
  13354. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13355. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13356. import { Effect } from "babylonjs/Materials/effect";
  13357. import { Particle } from "babylonjs/Particles/particle";
  13358. import { Scene } from "babylonjs/scene";
  13359. /**
  13360. * Particle emitter represents a volume emitting particles.
  13361. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13362. */
  13363. export interface IParticleEmitterType {
  13364. /**
  13365. * Called by the particle System when the direction is computed for the created particle.
  13366. * @param worldMatrix is the world matrix of the particle system
  13367. * @param directionToUpdate is the direction vector to update with the result
  13368. * @param particle is the particle we are computed the direction for
  13369. * @param isLocal defines if the direction should be set in local space
  13370. */
  13371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13372. /**
  13373. * Called by the particle System when the position is computed for the created particle.
  13374. * @param worldMatrix is the world matrix of the particle system
  13375. * @param positionToUpdate is the position vector to update with the result
  13376. * @param particle is the particle we are computed the position for
  13377. * @param isLocal defines if the position should be set in local space
  13378. */
  13379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13380. /**
  13381. * Clones the current emitter and returns a copy of it
  13382. * @returns the new emitter
  13383. */
  13384. clone(): IParticleEmitterType;
  13385. /**
  13386. * Called by the GPUParticleSystem to setup the update shader
  13387. * @param effect defines the update shader
  13388. */
  13389. applyToShader(effect: Effect): void;
  13390. /**
  13391. * Returns a string to use to update the GPU particles update shader
  13392. * @returns the effect defines string
  13393. */
  13394. getEffectDefines(): string;
  13395. /**
  13396. * Returns a string representing the class name
  13397. * @returns a string containing the class name
  13398. */
  13399. getClassName(): string;
  13400. /**
  13401. * Serializes the particle system to a JSON object.
  13402. * @returns the JSON object
  13403. */
  13404. serialize(): any;
  13405. /**
  13406. * Parse properties from a JSON object
  13407. * @param serializationObject defines the JSON object
  13408. * @param scene defines the hosting scene
  13409. */
  13410. parse(serializationObject: any, scene: Scene): void;
  13411. }
  13412. }
  13413. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13414. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13415. import { Effect } from "babylonjs/Materials/effect";
  13416. import { Particle } from "babylonjs/Particles/particle";
  13417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13418. /**
  13419. * Particle emitter emitting particles from the inside of a box.
  13420. * It emits the particles randomly between 2 given directions.
  13421. */
  13422. export class BoxParticleEmitter implements IParticleEmitterType {
  13423. /**
  13424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13425. */
  13426. direction1: Vector3;
  13427. /**
  13428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13429. */
  13430. direction2: Vector3;
  13431. /**
  13432. * 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.
  13433. */
  13434. minEmitBox: Vector3;
  13435. /**
  13436. * 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.
  13437. */
  13438. maxEmitBox: Vector3;
  13439. /**
  13440. * Creates a new instance BoxParticleEmitter
  13441. */
  13442. constructor();
  13443. /**
  13444. * Called by the particle System when the direction is computed for the created particle.
  13445. * @param worldMatrix is the world matrix of the particle system
  13446. * @param directionToUpdate is the direction vector to update with the result
  13447. * @param particle is the particle we are computed the direction for
  13448. * @param isLocal defines if the direction should be set in local space
  13449. */
  13450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13451. /**
  13452. * Called by the particle System when the position is computed for the created particle.
  13453. * @param worldMatrix is the world matrix of the particle system
  13454. * @param positionToUpdate is the position vector to update with the result
  13455. * @param particle is the particle we are computed the position for
  13456. * @param isLocal defines if the position should be set in local space
  13457. */
  13458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13459. /**
  13460. * Clones the current emitter and returns a copy of it
  13461. * @returns the new emitter
  13462. */
  13463. clone(): BoxParticleEmitter;
  13464. /**
  13465. * Called by the GPUParticleSystem to setup the update shader
  13466. * @param effect defines the update shader
  13467. */
  13468. applyToShader(effect: Effect): void;
  13469. /**
  13470. * Returns a string to use to update the GPU particles update shader
  13471. * @returns a string containng the defines string
  13472. */
  13473. getEffectDefines(): string;
  13474. /**
  13475. * Returns the string "BoxParticleEmitter"
  13476. * @returns a string containing the class name
  13477. */
  13478. getClassName(): string;
  13479. /**
  13480. * Serializes the particle system to a JSON object.
  13481. * @returns the JSON object
  13482. */
  13483. serialize(): any;
  13484. /**
  13485. * Parse properties from a JSON object
  13486. * @param serializationObject defines the JSON object
  13487. */
  13488. parse(serializationObject: any): void;
  13489. }
  13490. }
  13491. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13492. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13493. import { Effect } from "babylonjs/Materials/effect";
  13494. import { Particle } from "babylonjs/Particles/particle";
  13495. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13496. /**
  13497. * Particle emitter emitting particles from the inside of a cone.
  13498. * It emits the particles alongside the cone volume from the base to the particle.
  13499. * The emission direction might be randomized.
  13500. */
  13501. export class ConeParticleEmitter implements IParticleEmitterType {
  13502. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13503. directionRandomizer: number;
  13504. private _radius;
  13505. private _angle;
  13506. private _height;
  13507. /**
  13508. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13513. */
  13514. heightRange: number;
  13515. /**
  13516. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13517. */
  13518. emitFromSpawnPointOnly: boolean;
  13519. /**
  13520. * Gets or sets the radius of the emission cone
  13521. */
  13522. get radius(): number;
  13523. set radius(value: number);
  13524. /**
  13525. * Gets or sets the angle of the emission cone
  13526. */
  13527. get angle(): number;
  13528. set angle(value: number);
  13529. private _buildHeight;
  13530. /**
  13531. * Creates a new instance ConeParticleEmitter
  13532. * @param radius the radius of the emission cone (1 by default)
  13533. * @param angle the cone base angle (PI by default)
  13534. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13535. */
  13536. constructor(radius?: number, angle?: number,
  13537. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): ConeParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "ConeParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13588. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Effect } from "babylonjs/Materials/effect";
  13590. import { Particle } from "babylonjs/Particles/particle";
  13591. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13592. /**
  13593. * Particle emitter emitting particles from the inside of a cylinder.
  13594. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13595. */
  13596. export class CylinderParticleEmitter implements IParticleEmitterType {
  13597. /**
  13598. * The radius of the emission cylinder.
  13599. */
  13600. radius: number;
  13601. /**
  13602. * The height of the emission cylinder.
  13603. */
  13604. height: number;
  13605. /**
  13606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13607. */
  13608. radiusRange: number;
  13609. /**
  13610. * How much to randomize the particle direction [0-1].
  13611. */
  13612. directionRandomizer: number;
  13613. /**
  13614. * Creates a new instance CylinderParticleEmitter
  13615. * @param radius the radius of the emission cylinder (1 by default)
  13616. * @param height the height of the emission cylinder (1 by default)
  13617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13618. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13619. */
  13620. constructor(
  13621. /**
  13622. * The radius of the emission cylinder.
  13623. */
  13624. radius?: number,
  13625. /**
  13626. * The height of the emission cylinder.
  13627. */
  13628. height?: number,
  13629. /**
  13630. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13631. */
  13632. radiusRange?: number,
  13633. /**
  13634. * How much to randomize the particle direction [0-1].
  13635. */
  13636. directionRandomizer?: number);
  13637. /**
  13638. * Called by the particle System when the direction is computed for the created particle.
  13639. * @param worldMatrix is the world matrix of the particle system
  13640. * @param directionToUpdate is the direction vector to update with the result
  13641. * @param particle is the particle we are computed the direction for
  13642. * @param isLocal defines if the direction should be set in local space
  13643. */
  13644. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13645. /**
  13646. * Called by the particle System when the position is computed for the created particle.
  13647. * @param worldMatrix is the world matrix of the particle system
  13648. * @param positionToUpdate is the position vector to update with the result
  13649. * @param particle is the particle we are computed the position for
  13650. * @param isLocal defines if the position should be set in local space
  13651. */
  13652. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13653. /**
  13654. * Clones the current emitter and returns a copy of it
  13655. * @returns the new emitter
  13656. */
  13657. clone(): CylinderParticleEmitter;
  13658. /**
  13659. * Called by the GPUParticleSystem to setup the update shader
  13660. * @param effect defines the update shader
  13661. */
  13662. applyToShader(effect: Effect): void;
  13663. /**
  13664. * Returns a string to use to update the GPU particles update shader
  13665. * @returns a string containng the defines string
  13666. */
  13667. getEffectDefines(): string;
  13668. /**
  13669. * Returns the string "CylinderParticleEmitter"
  13670. * @returns a string containing the class name
  13671. */
  13672. getClassName(): string;
  13673. /**
  13674. * Serializes the particle system to a JSON object.
  13675. * @returns the JSON object
  13676. */
  13677. serialize(): any;
  13678. /**
  13679. * Parse properties from a JSON object
  13680. * @param serializationObject defines the JSON object
  13681. */
  13682. parse(serializationObject: any): void;
  13683. }
  13684. /**
  13685. * Particle emitter emitting particles from the inside of a cylinder.
  13686. * It emits the particles randomly between two vectors.
  13687. */
  13688. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13689. /**
  13690. * The min limit of the emission direction.
  13691. */
  13692. direction1: Vector3;
  13693. /**
  13694. * The max limit of the emission direction.
  13695. */
  13696. direction2: Vector3;
  13697. /**
  13698. * Creates a new instance CylinderDirectedParticleEmitter
  13699. * @param radius the radius of the emission cylinder (1 by default)
  13700. * @param height the height of the emission cylinder (1 by default)
  13701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13702. * @param direction1 the min limit of the emission direction (up vector by default)
  13703. * @param direction2 the max limit of the emission direction (up vector by default)
  13704. */
  13705. constructor(radius?: number, height?: number, radiusRange?: number,
  13706. /**
  13707. * The min limit of the emission direction.
  13708. */
  13709. direction1?: Vector3,
  13710. /**
  13711. * The max limit of the emission direction.
  13712. */
  13713. direction2?: Vector3);
  13714. /**
  13715. * Called by the particle System when the direction is computed for the created particle.
  13716. * @param worldMatrix is the world matrix of the particle system
  13717. * @param directionToUpdate is the direction vector to update with the result
  13718. * @param particle is the particle we are computed the direction for
  13719. */
  13720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13721. /**
  13722. * Clones the current emitter and returns a copy of it
  13723. * @returns the new emitter
  13724. */
  13725. clone(): CylinderDirectedParticleEmitter;
  13726. /**
  13727. * Called by the GPUParticleSystem to setup the update shader
  13728. * @param effect defines the update shader
  13729. */
  13730. applyToShader(effect: Effect): void;
  13731. /**
  13732. * Returns a string to use to update the GPU particles update shader
  13733. * @returns a string containng the defines string
  13734. */
  13735. getEffectDefines(): string;
  13736. /**
  13737. * Returns the string "CylinderDirectedParticleEmitter"
  13738. * @returns a string containing the class name
  13739. */
  13740. getClassName(): string;
  13741. /**
  13742. * Serializes the particle system to a JSON object.
  13743. * @returns the JSON object
  13744. */
  13745. serialize(): any;
  13746. /**
  13747. * Parse properties from a JSON object
  13748. * @param serializationObject defines the JSON object
  13749. */
  13750. parse(serializationObject: any): void;
  13751. }
  13752. }
  13753. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13755. import { Effect } from "babylonjs/Materials/effect";
  13756. import { Particle } from "babylonjs/Particles/particle";
  13757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13758. /**
  13759. * Particle emitter emitting particles from the inside of a hemisphere.
  13760. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13761. */
  13762. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13763. /**
  13764. * The radius of the emission hemisphere.
  13765. */
  13766. radius: number;
  13767. /**
  13768. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13769. */
  13770. radiusRange: number;
  13771. /**
  13772. * How much to randomize the particle direction [0-1].
  13773. */
  13774. directionRandomizer: number;
  13775. /**
  13776. * Creates a new instance HemisphericParticleEmitter
  13777. * @param radius the radius of the emission hemisphere (1 by default)
  13778. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13779. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13780. */
  13781. constructor(
  13782. /**
  13783. * The radius of the emission hemisphere.
  13784. */
  13785. radius?: number,
  13786. /**
  13787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13788. */
  13789. radiusRange?: number,
  13790. /**
  13791. * How much to randomize the particle direction [0-1].
  13792. */
  13793. directionRandomizer?: number);
  13794. /**
  13795. * Called by the particle System when the direction is computed for the created particle.
  13796. * @param worldMatrix is the world matrix of the particle system
  13797. * @param directionToUpdate is the direction vector to update with the result
  13798. * @param particle is the particle we are computed the direction for
  13799. * @param isLocal defines if the direction should be set in local space
  13800. */
  13801. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13802. /**
  13803. * Called by the particle System when the position is computed for the created particle.
  13804. * @param worldMatrix is the world matrix of the particle system
  13805. * @param positionToUpdate is the position vector to update with the result
  13806. * @param particle is the particle we are computed the position for
  13807. * @param isLocal defines if the position should be set in local space
  13808. */
  13809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13810. /**
  13811. * Clones the current emitter and returns a copy of it
  13812. * @returns the new emitter
  13813. */
  13814. clone(): HemisphericParticleEmitter;
  13815. /**
  13816. * Called by the GPUParticleSystem to setup the update shader
  13817. * @param effect defines the update shader
  13818. */
  13819. applyToShader(effect: Effect): void;
  13820. /**
  13821. * Returns a string to use to update the GPU particles update shader
  13822. * @returns a string containng the defines string
  13823. */
  13824. getEffectDefines(): string;
  13825. /**
  13826. * Returns the string "HemisphericParticleEmitter"
  13827. * @returns a string containing the class name
  13828. */
  13829. getClassName(): string;
  13830. /**
  13831. * Serializes the particle system to a JSON object.
  13832. * @returns the JSON object
  13833. */
  13834. serialize(): any;
  13835. /**
  13836. * Parse properties from a JSON object
  13837. * @param serializationObject defines the JSON object
  13838. */
  13839. parse(serializationObject: any): void;
  13840. }
  13841. }
  13842. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13843. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13844. import { Effect } from "babylonjs/Materials/effect";
  13845. import { Particle } from "babylonjs/Particles/particle";
  13846. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13847. /**
  13848. * Particle emitter emitting particles from a point.
  13849. * It emits the particles randomly between 2 given directions.
  13850. */
  13851. export class PointParticleEmitter implements IParticleEmitterType {
  13852. /**
  13853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13854. */
  13855. direction1: Vector3;
  13856. /**
  13857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13858. */
  13859. direction2: Vector3;
  13860. /**
  13861. * Creates a new instance PointParticleEmitter
  13862. */
  13863. constructor();
  13864. /**
  13865. * Called by the particle System when the direction is computed for the created particle.
  13866. * @param worldMatrix is the world matrix of the particle system
  13867. * @param directionToUpdate is the direction vector to update with the result
  13868. * @param particle is the particle we are computed the direction for
  13869. * @param isLocal defines if the direction should be set in local space
  13870. */
  13871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13872. /**
  13873. * Called by the particle System when the position is computed for the created particle.
  13874. * @param worldMatrix is the world matrix of the particle system
  13875. * @param positionToUpdate is the position vector to update with the result
  13876. * @param particle is the particle we are computed the position for
  13877. * @param isLocal defines if the position should be set in local space
  13878. */
  13879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13880. /**
  13881. * Clones the current emitter and returns a copy of it
  13882. * @returns the new emitter
  13883. */
  13884. clone(): PointParticleEmitter;
  13885. /**
  13886. * Called by the GPUParticleSystem to setup the update shader
  13887. * @param effect defines the update shader
  13888. */
  13889. applyToShader(effect: Effect): void;
  13890. /**
  13891. * Returns a string to use to update the GPU particles update shader
  13892. * @returns a string containng the defines string
  13893. */
  13894. getEffectDefines(): string;
  13895. /**
  13896. * Returns the string "PointParticleEmitter"
  13897. * @returns a string containing the class name
  13898. */
  13899. getClassName(): string;
  13900. /**
  13901. * Serializes the particle system to a JSON object.
  13902. * @returns the JSON object
  13903. */
  13904. serialize(): any;
  13905. /**
  13906. * Parse properties from a JSON object
  13907. * @param serializationObject defines the JSON object
  13908. */
  13909. parse(serializationObject: any): void;
  13910. }
  13911. }
  13912. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13913. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13914. import { Effect } from "babylonjs/Materials/effect";
  13915. import { Particle } from "babylonjs/Particles/particle";
  13916. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13917. /**
  13918. * Particle emitter emitting particles from the inside of a sphere.
  13919. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13920. */
  13921. export class SphereParticleEmitter implements IParticleEmitterType {
  13922. /**
  13923. * The radius of the emission sphere.
  13924. */
  13925. radius: number;
  13926. /**
  13927. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13928. */
  13929. radiusRange: number;
  13930. /**
  13931. * How much to randomize the particle direction [0-1].
  13932. */
  13933. directionRandomizer: number;
  13934. /**
  13935. * Creates a new instance SphereParticleEmitter
  13936. * @param radius the radius of the emission sphere (1 by default)
  13937. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13938. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13939. */
  13940. constructor(
  13941. /**
  13942. * The radius of the emission sphere.
  13943. */
  13944. radius?: number,
  13945. /**
  13946. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13947. */
  13948. radiusRange?: number,
  13949. /**
  13950. * How much to randomize the particle direction [0-1].
  13951. */
  13952. directionRandomizer?: number);
  13953. /**
  13954. * Called by the particle System when the direction is computed for the created particle.
  13955. * @param worldMatrix is the world matrix of the particle system
  13956. * @param directionToUpdate is the direction vector to update with the result
  13957. * @param particle is the particle we are computed the direction for
  13958. * @param isLocal defines if the direction should be set in local space
  13959. */
  13960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13961. /**
  13962. * Called by the particle System when the position is computed for the created particle.
  13963. * @param worldMatrix is the world matrix of the particle system
  13964. * @param positionToUpdate is the position vector to update with the result
  13965. * @param particle is the particle we are computed the position for
  13966. * @param isLocal defines if the position should be set in local space
  13967. */
  13968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13969. /**
  13970. * Clones the current emitter and returns a copy of it
  13971. * @returns the new emitter
  13972. */
  13973. clone(): SphereParticleEmitter;
  13974. /**
  13975. * Called by the GPUParticleSystem to setup the update shader
  13976. * @param effect defines the update shader
  13977. */
  13978. applyToShader(effect: Effect): void;
  13979. /**
  13980. * Returns a string to use to update the GPU particles update shader
  13981. * @returns a string containng the defines string
  13982. */
  13983. getEffectDefines(): string;
  13984. /**
  13985. * Returns the string "SphereParticleEmitter"
  13986. * @returns a string containing the class name
  13987. */
  13988. getClassName(): string;
  13989. /**
  13990. * Serializes the particle system to a JSON object.
  13991. * @returns the JSON object
  13992. */
  13993. serialize(): any;
  13994. /**
  13995. * Parse properties from a JSON object
  13996. * @param serializationObject defines the JSON object
  13997. */
  13998. parse(serializationObject: any): void;
  13999. }
  14000. /**
  14001. * Particle emitter emitting particles from the inside of a sphere.
  14002. * It emits the particles randomly between two vectors.
  14003. */
  14004. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14005. /**
  14006. * The min limit of the emission direction.
  14007. */
  14008. direction1: Vector3;
  14009. /**
  14010. * The max limit of the emission direction.
  14011. */
  14012. direction2: Vector3;
  14013. /**
  14014. * Creates a new instance SphereDirectedParticleEmitter
  14015. * @param radius the radius of the emission sphere (1 by default)
  14016. * @param direction1 the min limit of the emission direction (up vector by default)
  14017. * @param direction2 the max limit of the emission direction (up vector by default)
  14018. */
  14019. constructor(radius?: number,
  14020. /**
  14021. * The min limit of the emission direction.
  14022. */
  14023. direction1?: Vector3,
  14024. /**
  14025. * The max limit of the emission direction.
  14026. */
  14027. direction2?: Vector3);
  14028. /**
  14029. * Called by the particle System when the direction is computed for the created particle.
  14030. * @param worldMatrix is the world matrix of the particle system
  14031. * @param directionToUpdate is the direction vector to update with the result
  14032. * @param particle is the particle we are computed the direction for
  14033. */
  14034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14035. /**
  14036. * Clones the current emitter and returns a copy of it
  14037. * @returns the new emitter
  14038. */
  14039. clone(): SphereDirectedParticleEmitter;
  14040. /**
  14041. * Called by the GPUParticleSystem to setup the update shader
  14042. * @param effect defines the update shader
  14043. */
  14044. applyToShader(effect: Effect): void;
  14045. /**
  14046. * Returns a string to use to update the GPU particles update shader
  14047. * @returns a string containng the defines string
  14048. */
  14049. getEffectDefines(): string;
  14050. /**
  14051. * Returns the string "SphereDirectedParticleEmitter"
  14052. * @returns a string containing the class name
  14053. */
  14054. getClassName(): string;
  14055. /**
  14056. * Serializes the particle system to a JSON object.
  14057. * @returns the JSON object
  14058. */
  14059. serialize(): any;
  14060. /**
  14061. * Parse properties from a JSON object
  14062. * @param serializationObject defines the JSON object
  14063. */
  14064. parse(serializationObject: any): void;
  14065. }
  14066. }
  14067. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14068. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14069. import { Effect } from "babylonjs/Materials/effect";
  14070. import { Particle } from "babylonjs/Particles/particle";
  14071. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14072. import { Nullable } from "babylonjs/types";
  14073. /**
  14074. * Particle emitter emitting particles from a custom list of positions.
  14075. */
  14076. export class CustomParticleEmitter implements IParticleEmitterType {
  14077. /**
  14078. * Gets or sets the position generator that will create the inital position of each particle.
  14079. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14080. */
  14081. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14082. /**
  14083. * Gets or sets the destination generator that will create the final destination of each particle.
  14084. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14085. */
  14086. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14087. /**
  14088. * Creates a new instance CustomParticleEmitter
  14089. */
  14090. constructor();
  14091. /**
  14092. * Called by the particle System when the direction is computed for the created particle.
  14093. * @param worldMatrix is the world matrix of the particle system
  14094. * @param directionToUpdate is the direction vector to update with the result
  14095. * @param particle is the particle we are computed the direction for
  14096. * @param isLocal defines if the direction should be set in local space
  14097. */
  14098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14099. /**
  14100. * Called by the particle System when the position is computed for the created particle.
  14101. * @param worldMatrix is the world matrix of the particle system
  14102. * @param positionToUpdate is the position vector to update with the result
  14103. * @param particle is the particle we are computed the position for
  14104. * @param isLocal defines if the position should be set in local space
  14105. */
  14106. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14107. /**
  14108. * Clones the current emitter and returns a copy of it
  14109. * @returns the new emitter
  14110. */
  14111. clone(): CustomParticleEmitter;
  14112. /**
  14113. * Called by the GPUParticleSystem to setup the update shader
  14114. * @param effect defines the update shader
  14115. */
  14116. applyToShader(effect: Effect): void;
  14117. /**
  14118. * Returns a string to use to update the GPU particles update shader
  14119. * @returns a string containng the defines string
  14120. */
  14121. getEffectDefines(): string;
  14122. /**
  14123. * Returns the string "PointParticleEmitter"
  14124. * @returns a string containing the class name
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Serializes the particle system to a JSON object.
  14129. * @returns the JSON object
  14130. */
  14131. serialize(): any;
  14132. /**
  14133. * Parse properties from a JSON object
  14134. * @param serializationObject defines the JSON object
  14135. */
  14136. parse(serializationObject: any): void;
  14137. }
  14138. }
  14139. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14140. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14141. import { Effect } from "babylonjs/Materials/effect";
  14142. import { Particle } from "babylonjs/Particles/particle";
  14143. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14144. import { Nullable } from "babylonjs/types";
  14145. import { Scene } from "babylonjs/scene";
  14146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14147. /**
  14148. * Particle emitter emitting particles from the inside of a box.
  14149. * It emits the particles randomly between 2 given directions.
  14150. */
  14151. export class MeshParticleEmitter implements IParticleEmitterType {
  14152. private _indices;
  14153. private _positions;
  14154. private _normals;
  14155. private _storedNormal;
  14156. private _mesh;
  14157. /**
  14158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14159. */
  14160. direction1: Vector3;
  14161. /**
  14162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14163. */
  14164. direction2: Vector3;
  14165. /**
  14166. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14167. */
  14168. useMeshNormalsForDirection: boolean;
  14169. /** Defines the mesh to use as source */
  14170. get mesh(): Nullable<AbstractMesh>;
  14171. set mesh(value: Nullable<AbstractMesh>);
  14172. /**
  14173. * Creates a new instance MeshParticleEmitter
  14174. * @param mesh defines the mesh to use as source
  14175. */
  14176. constructor(mesh?: Nullable<AbstractMesh>);
  14177. /**
  14178. * Called by the particle System when the direction is computed for the created particle.
  14179. * @param worldMatrix is the world matrix of the particle system
  14180. * @param directionToUpdate is the direction vector to update with the result
  14181. * @param particle is the particle we are computed the direction for
  14182. * @param isLocal defines if the direction should be set in local space
  14183. */
  14184. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14185. /**
  14186. * Called by the particle System when the position is computed for the created particle.
  14187. * @param worldMatrix is the world matrix of the particle system
  14188. * @param positionToUpdate is the position vector to update with the result
  14189. * @param particle is the particle we are computed the position for
  14190. * @param isLocal defines if the position should be set in local space
  14191. */
  14192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14193. /**
  14194. * Clones the current emitter and returns a copy of it
  14195. * @returns the new emitter
  14196. */
  14197. clone(): MeshParticleEmitter;
  14198. /**
  14199. * Called by the GPUParticleSystem to setup the update shader
  14200. * @param effect defines the update shader
  14201. */
  14202. applyToShader(effect: Effect): void;
  14203. /**
  14204. * Returns a string to use to update the GPU particles update shader
  14205. * @returns a string containng the defines string
  14206. */
  14207. getEffectDefines(): string;
  14208. /**
  14209. * Returns the string "BoxParticleEmitter"
  14210. * @returns a string containing the class name
  14211. */
  14212. getClassName(): string;
  14213. /**
  14214. * Serializes the particle system to a JSON object.
  14215. * @returns the JSON object
  14216. */
  14217. serialize(): any;
  14218. /**
  14219. * Parse properties from a JSON object
  14220. * @param serializationObject defines the JSON object
  14221. * @param scene defines the hosting scene
  14222. */
  14223. parse(serializationObject: any, scene: Scene): void;
  14224. }
  14225. }
  14226. declare module "babylonjs/Particles/EmitterTypes/index" {
  14227. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14228. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14229. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14230. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14231. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14232. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14233. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14234. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14235. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14236. }
  14237. declare module "babylonjs/Particles/IParticleSystem" {
  14238. import { Nullable } from "babylonjs/types";
  14239. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14240. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14243. import { Texture } from "babylonjs/Materials/Textures/texture";
  14244. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14245. import { Scene } from "babylonjs/scene";
  14246. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14247. import { Effect } from "babylonjs/Materials/effect";
  14248. import { Observable } from "babylonjs/Misc/observable";
  14249. import { Animation } from "babylonjs/Animations/animation";
  14250. /**
  14251. * Interface representing a particle system in Babylon.js.
  14252. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14253. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14254. */
  14255. export interface IParticleSystem {
  14256. /**
  14257. * List of animations used by the particle system.
  14258. */
  14259. animations: Animation[];
  14260. /**
  14261. * The id of the Particle system.
  14262. */
  14263. id: string;
  14264. /**
  14265. * The name of the Particle system.
  14266. */
  14267. name: string;
  14268. /**
  14269. * The emitter represents the Mesh or position we are attaching the particle system to.
  14270. */
  14271. emitter: Nullable<AbstractMesh | Vector3>;
  14272. /**
  14273. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14274. */
  14275. isBillboardBased: boolean;
  14276. /**
  14277. * The rendering group used by the Particle system to chose when to render.
  14278. */
  14279. renderingGroupId: number;
  14280. /**
  14281. * The layer mask we are rendering the particles through.
  14282. */
  14283. layerMask: number;
  14284. /**
  14285. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14286. */
  14287. updateSpeed: number;
  14288. /**
  14289. * The amount of time the particle system is running (depends of the overall update speed).
  14290. */
  14291. targetStopDuration: number;
  14292. /**
  14293. * The texture used to render each particle. (this can be a spritesheet)
  14294. */
  14295. particleTexture: Nullable<Texture>;
  14296. /**
  14297. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14298. */
  14299. blendMode: number;
  14300. /**
  14301. * Minimum life time of emitting particles.
  14302. */
  14303. minLifeTime: number;
  14304. /**
  14305. * Maximum life time of emitting particles.
  14306. */
  14307. maxLifeTime: number;
  14308. /**
  14309. * Minimum Size of emitting particles.
  14310. */
  14311. minSize: number;
  14312. /**
  14313. * Maximum Size of emitting particles.
  14314. */
  14315. maxSize: number;
  14316. /**
  14317. * Minimum scale of emitting particles on X axis.
  14318. */
  14319. minScaleX: number;
  14320. /**
  14321. * Maximum scale of emitting particles on X axis.
  14322. */
  14323. maxScaleX: number;
  14324. /**
  14325. * Minimum scale of emitting particles on Y axis.
  14326. */
  14327. minScaleY: number;
  14328. /**
  14329. * Maximum scale of emitting particles on Y axis.
  14330. */
  14331. maxScaleY: number;
  14332. /**
  14333. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14334. */
  14335. color1: Color4;
  14336. /**
  14337. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14338. */
  14339. color2: Color4;
  14340. /**
  14341. * Color the particle will have at the end of its lifetime.
  14342. */
  14343. colorDead: Color4;
  14344. /**
  14345. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14346. */
  14347. emitRate: number;
  14348. /**
  14349. * You can use gravity if you want to give an orientation to your particles.
  14350. */
  14351. gravity: Vector3;
  14352. /**
  14353. * Minimum power of emitting particles.
  14354. */
  14355. minEmitPower: number;
  14356. /**
  14357. * Maximum power of emitting particles.
  14358. */
  14359. maxEmitPower: number;
  14360. /**
  14361. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14362. */
  14363. minAngularSpeed: number;
  14364. /**
  14365. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14366. */
  14367. maxAngularSpeed: number;
  14368. /**
  14369. * Gets or sets the minimal initial rotation in radians.
  14370. */
  14371. minInitialRotation: number;
  14372. /**
  14373. * Gets or sets the maximal initial rotation in radians.
  14374. */
  14375. maxInitialRotation: number;
  14376. /**
  14377. * The particle emitter type defines the emitter used by the particle system.
  14378. * It can be for example box, sphere, or cone...
  14379. */
  14380. particleEmitterType: Nullable<IParticleEmitterType>;
  14381. /**
  14382. * Defines the delay in milliseconds before starting the system (0 by default)
  14383. */
  14384. startDelay: number;
  14385. /**
  14386. * 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
  14387. */
  14388. preWarmCycles: number;
  14389. /**
  14390. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14391. */
  14392. preWarmStepOffset: number;
  14393. /**
  14394. * 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)
  14395. */
  14396. spriteCellChangeSpeed: number;
  14397. /**
  14398. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14399. */
  14400. startSpriteCellID: number;
  14401. /**
  14402. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14403. */
  14404. endSpriteCellID: number;
  14405. /**
  14406. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14407. */
  14408. spriteCellWidth: number;
  14409. /**
  14410. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14411. */
  14412. spriteCellHeight: number;
  14413. /**
  14414. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14415. */
  14416. spriteRandomStartCell: boolean;
  14417. /**
  14418. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14419. */
  14420. isAnimationSheetEnabled: boolean;
  14421. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14422. translationPivot: Vector2;
  14423. /**
  14424. * Gets or sets a texture used to add random noise to particle positions
  14425. */
  14426. noiseTexture: Nullable<BaseTexture>;
  14427. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14428. noiseStrength: Vector3;
  14429. /**
  14430. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14431. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14432. */
  14433. billboardMode: number;
  14434. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14435. limitVelocityDamping: number;
  14436. /**
  14437. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14438. */
  14439. beginAnimationOnStart: boolean;
  14440. /**
  14441. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14442. */
  14443. beginAnimationFrom: number;
  14444. /**
  14445. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14446. */
  14447. beginAnimationTo: number;
  14448. /**
  14449. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14450. */
  14451. beginAnimationLoop: boolean;
  14452. /**
  14453. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14454. */
  14455. disposeOnStop: boolean;
  14456. /**
  14457. * Specifies if the particles are updated in emitter local space or world space
  14458. */
  14459. isLocal: boolean;
  14460. /** Snippet ID if the particle system was created from the snippet server */
  14461. snippetId: string;
  14462. /**
  14463. * Gets the maximum number of particles active at the same time.
  14464. * @returns The max number of active particles.
  14465. */
  14466. getCapacity(): number;
  14467. /**
  14468. * Gets the number of particles active at the same time.
  14469. * @returns The number of active particles.
  14470. */
  14471. getActiveCount(): number;
  14472. /**
  14473. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14474. * @returns True if it has been started, otherwise false.
  14475. */
  14476. isStarted(): boolean;
  14477. /**
  14478. * Animates the particle system for this frame.
  14479. */
  14480. animate(): void;
  14481. /**
  14482. * Renders the particle system in its current state.
  14483. * @returns the current number of particles
  14484. */
  14485. render(): number;
  14486. /**
  14487. * Dispose the particle system and frees its associated resources.
  14488. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14489. */
  14490. dispose(disposeTexture?: boolean): void;
  14491. /**
  14492. * An event triggered when the system is disposed
  14493. */
  14494. onDisposeObservable: Observable<IParticleSystem>;
  14495. /**
  14496. * Clones the particle system.
  14497. * @param name The name of the cloned object
  14498. * @param newEmitter The new emitter to use
  14499. * @returns the cloned particle system
  14500. */
  14501. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14502. /**
  14503. * Serializes the particle system to a JSON object
  14504. * @param serializeTexture defines if the texture must be serialized as well
  14505. * @returns the JSON object
  14506. */
  14507. serialize(serializeTexture: boolean): any;
  14508. /**
  14509. * Rebuild the particle system
  14510. */
  14511. rebuild(): void;
  14512. /** Force the system to rebuild all gradients that need to be resync */
  14513. forceRefreshGradients(): void;
  14514. /**
  14515. * Starts the particle system and begins to emit
  14516. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14517. */
  14518. start(delay?: number): void;
  14519. /**
  14520. * Stops the particle system.
  14521. */
  14522. stop(): void;
  14523. /**
  14524. * Remove all active particles
  14525. */
  14526. reset(): void;
  14527. /**
  14528. * Gets a boolean indicating that the system is stopping
  14529. * @returns true if the system is currently stopping
  14530. */
  14531. isStopping(): boolean;
  14532. /**
  14533. * Is this system ready to be used/rendered
  14534. * @return true if the system is ready
  14535. */
  14536. isReady(): boolean;
  14537. /**
  14538. * Returns the string "ParticleSystem"
  14539. * @returns a string containing the class name
  14540. */
  14541. getClassName(): string;
  14542. /**
  14543. * Gets the custom effect used to render the particles
  14544. * @param blendMode Blend mode for which the effect should be retrieved
  14545. * @returns The effect
  14546. */
  14547. getCustomEffect(blendMode: number): Nullable<Effect>;
  14548. /**
  14549. * Sets the custom effect used to render the particles
  14550. * @param effect The effect to set
  14551. * @param blendMode Blend mode for which the effect should be set
  14552. */
  14553. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14554. /**
  14555. * Fill the defines array according to the current settings of the particle system
  14556. * @param defines Array to be updated
  14557. * @param blendMode blend mode to take into account when updating the array
  14558. */
  14559. fillDefines(defines: Array<string>, blendMode: number): void;
  14560. /**
  14561. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14562. * @param uniforms Uniforms array to fill
  14563. * @param attributes Attributes array to fill
  14564. * @param samplers Samplers array to fill
  14565. */
  14566. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14567. /**
  14568. * Observable that will be called just before the particles are drawn
  14569. */
  14570. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14571. /**
  14572. * Gets the name of the particle vertex shader
  14573. */
  14574. vertexShaderName: string;
  14575. /**
  14576. * Adds a new color gradient
  14577. * @param gradient defines the gradient to use (between 0 and 1)
  14578. * @param color1 defines the color to affect to the specified gradient
  14579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14580. * @returns the current particle system
  14581. */
  14582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14583. /**
  14584. * Remove a specific color gradient
  14585. * @param gradient defines the gradient to remove
  14586. * @returns the current particle system
  14587. */
  14588. removeColorGradient(gradient: number): IParticleSystem;
  14589. /**
  14590. * Adds a new size gradient
  14591. * @param gradient defines the gradient to use (between 0 and 1)
  14592. * @param factor defines the size factor to affect to the specified gradient
  14593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14594. * @returns the current particle system
  14595. */
  14596. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14597. /**
  14598. * Remove a specific size gradient
  14599. * @param gradient defines the gradient to remove
  14600. * @returns the current particle system
  14601. */
  14602. removeSizeGradient(gradient: number): IParticleSystem;
  14603. /**
  14604. * Gets the current list of color gradients.
  14605. * You must use addColorGradient and removeColorGradient to udpate this list
  14606. * @returns the list of color gradients
  14607. */
  14608. getColorGradients(): Nullable<Array<ColorGradient>>;
  14609. /**
  14610. * Gets the current list of size gradients.
  14611. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14612. * @returns the list of size gradients
  14613. */
  14614. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14615. /**
  14616. * Gets the current list of angular speed gradients.
  14617. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14618. * @returns the list of angular speed gradients
  14619. */
  14620. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14621. /**
  14622. * Adds a new angular speed gradient
  14623. * @param gradient defines the gradient to use (between 0 and 1)
  14624. * @param factor defines the angular speed to affect to the specified gradient
  14625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14626. * @returns the current particle system
  14627. */
  14628. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14629. /**
  14630. * Remove a specific angular speed gradient
  14631. * @param gradient defines the gradient to remove
  14632. * @returns the current particle system
  14633. */
  14634. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14635. /**
  14636. * Gets the current list of velocity gradients.
  14637. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14638. * @returns the list of velocity gradients
  14639. */
  14640. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14641. /**
  14642. * Adds a new velocity gradient
  14643. * @param gradient defines the gradient to use (between 0 and 1)
  14644. * @param factor defines the velocity to affect to the specified gradient
  14645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14646. * @returns the current particle system
  14647. */
  14648. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14649. /**
  14650. * Remove a specific velocity gradient
  14651. * @param gradient defines the gradient to remove
  14652. * @returns the current particle system
  14653. */
  14654. removeVelocityGradient(gradient: number): IParticleSystem;
  14655. /**
  14656. * Gets the current list of limit velocity gradients.
  14657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14658. * @returns the list of limit velocity gradients
  14659. */
  14660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Adds a new limit velocity gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param factor defines the limit velocity to affect to the specified gradient
  14665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14666. * @returns the current particle system
  14667. */
  14668. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14669. /**
  14670. * Remove a specific limit velocity gradient
  14671. * @param gradient defines the gradient to remove
  14672. * @returns the current particle system
  14673. */
  14674. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14675. /**
  14676. * Adds a new drag gradient
  14677. * @param gradient defines the gradient to use (between 0 and 1)
  14678. * @param factor defines the drag to affect to the specified gradient
  14679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14680. * @returns the current particle system
  14681. */
  14682. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14683. /**
  14684. * Remove a specific drag gradient
  14685. * @param gradient defines the gradient to remove
  14686. * @returns the current particle system
  14687. */
  14688. removeDragGradient(gradient: number): IParticleSystem;
  14689. /**
  14690. * Gets the current list of drag gradients.
  14691. * You must use addDragGradient and removeDragGradient to udpate this list
  14692. * @returns the list of drag gradients
  14693. */
  14694. getDragGradients(): Nullable<Array<FactorGradient>>;
  14695. /**
  14696. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14697. * @param gradient defines the gradient to use (between 0 and 1)
  14698. * @param factor defines the emit rate to affect to the specified gradient
  14699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14700. * @returns the current particle system
  14701. */
  14702. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14703. /**
  14704. * Remove a specific emit rate gradient
  14705. * @param gradient defines the gradient to remove
  14706. * @returns the current particle system
  14707. */
  14708. removeEmitRateGradient(gradient: number): IParticleSystem;
  14709. /**
  14710. * Gets the current list of emit rate gradients.
  14711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14712. * @returns the list of emit rate gradients
  14713. */
  14714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14715. /**
  14716. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14717. * @param gradient defines the gradient to use (between 0 and 1)
  14718. * @param factor defines the start size to affect to the specified gradient
  14719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14720. * @returns the current particle system
  14721. */
  14722. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14723. /**
  14724. * Remove a specific start size gradient
  14725. * @param gradient defines the gradient to remove
  14726. * @returns the current particle system
  14727. */
  14728. removeStartSizeGradient(gradient: number): IParticleSystem;
  14729. /**
  14730. * Gets the current list of start size gradients.
  14731. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14732. * @returns the list of start size gradients
  14733. */
  14734. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14735. /**
  14736. * Adds a new life time gradient
  14737. * @param gradient defines the gradient to use (between 0 and 1)
  14738. * @param factor defines the life time factor to affect to the specified gradient
  14739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14740. * @returns the current particle system
  14741. */
  14742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14743. /**
  14744. * Remove a specific life time gradient
  14745. * @param gradient defines the gradient to remove
  14746. * @returns the current particle system
  14747. */
  14748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14749. /**
  14750. * Gets the current list of life time gradients.
  14751. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14752. * @returns the list of life time gradients
  14753. */
  14754. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14755. /**
  14756. * Gets the current list of color gradients.
  14757. * You must use addColorGradient and removeColorGradient to udpate this list
  14758. * @returns the list of color gradients
  14759. */
  14760. getColorGradients(): Nullable<Array<ColorGradient>>;
  14761. /**
  14762. * Adds a new ramp gradient used to remap particle colors
  14763. * @param gradient defines the gradient to use (between 0 and 1)
  14764. * @param color defines the color to affect to the specified gradient
  14765. * @returns the current particle system
  14766. */
  14767. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14768. /**
  14769. * Gets the current list of ramp gradients.
  14770. * You must use addRampGradient and removeRampGradient to udpate this list
  14771. * @returns the list of ramp gradients
  14772. */
  14773. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14774. /** Gets or sets a boolean indicating that ramp gradients must be used
  14775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14776. */
  14777. useRampGradients: boolean;
  14778. /**
  14779. * Adds a new color remap gradient
  14780. * @param gradient defines the gradient to use (between 0 and 1)
  14781. * @param min defines the color remap minimal range
  14782. * @param max defines the color remap maximal range
  14783. * @returns the current particle system
  14784. */
  14785. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14786. /**
  14787. * Gets the current list of color remap gradients.
  14788. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14789. * @returns the list of color remap gradients
  14790. */
  14791. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new alpha remap gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param min defines the alpha remap minimal range
  14796. * @param max defines the alpha remap maximal range
  14797. * @returns the current particle system
  14798. */
  14799. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14800. /**
  14801. * Gets the current list of alpha remap gradients.
  14802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14803. * @returns the list of alpha remap gradients
  14804. */
  14805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14806. /**
  14807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14810. * @returns the emitter
  14811. */
  14812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14813. /**
  14814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14815. * @param radius The radius of the hemisphere to emit from
  14816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14817. * @returns the emitter
  14818. */
  14819. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14820. /**
  14821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14822. * @param radius The radius of the sphere to emit from
  14823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14824. * @returns the emitter
  14825. */
  14826. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14827. /**
  14828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14829. * @param radius The radius of the sphere to emit from
  14830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14832. * @returns the emitter
  14833. */
  14834. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14835. /**
  14836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14837. * @param radius The radius of the emission cylinder
  14838. * @param height The height of the emission cylinder
  14839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14841. * @returns the emitter
  14842. */
  14843. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14844. /**
  14845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14846. * @param radius The radius of the cylinder to emit from
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14851. * @returns the emitter
  14852. */
  14853. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14854. /**
  14855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14856. * @param radius The radius of the cone to emit from
  14857. * @param angle The base angle of the cone
  14858. * @returns the emitter
  14859. */
  14860. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14861. /**
  14862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14867. * @returns the emitter
  14868. */
  14869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14870. /**
  14871. * Get hosting scene
  14872. * @returns the scene
  14873. */
  14874. getScene(): Scene;
  14875. }
  14876. }
  14877. declare module "babylonjs/Meshes/transformNode" {
  14878. import { DeepImmutable } from "babylonjs/types";
  14879. import { Observable } from "babylonjs/Misc/observable";
  14880. import { Nullable } from "babylonjs/types";
  14881. import { Camera } from "babylonjs/Cameras/camera";
  14882. import { Scene } from "babylonjs/scene";
  14883. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14884. import { Node } from "babylonjs/node";
  14885. import { Bone } from "babylonjs/Bones/bone";
  14886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14887. import { Space } from "babylonjs/Maths/math.axis";
  14888. /**
  14889. * 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.
  14890. * @see https://doc.babylonjs.com/how_to/transformnode
  14891. */
  14892. export class TransformNode extends Node {
  14893. /**
  14894. * Object will not rotate to face the camera
  14895. */
  14896. static BILLBOARDMODE_NONE: number;
  14897. /**
  14898. * Object will rotate to face the camera but only on the x axis
  14899. */
  14900. static BILLBOARDMODE_X: number;
  14901. /**
  14902. * Object will rotate to face the camera but only on the y axis
  14903. */
  14904. static BILLBOARDMODE_Y: number;
  14905. /**
  14906. * Object will rotate to face the camera but only on the z axis
  14907. */
  14908. static BILLBOARDMODE_Z: number;
  14909. /**
  14910. * Object will rotate to face the camera
  14911. */
  14912. static BILLBOARDMODE_ALL: number;
  14913. /**
  14914. * Object will rotate to face the camera's position instead of orientation
  14915. */
  14916. static BILLBOARDMODE_USE_POSITION: number;
  14917. private _forward;
  14918. private _forwardInverted;
  14919. private _up;
  14920. private _right;
  14921. private _rightInverted;
  14922. private _position;
  14923. private _rotation;
  14924. private _rotationQuaternion;
  14925. protected _scaling: Vector3;
  14926. protected _isDirty: boolean;
  14927. private _transformToBoneReferal;
  14928. private _isAbsoluteSynced;
  14929. private _billboardMode;
  14930. /**
  14931. * Gets or sets the billboard mode. Default is 0.
  14932. *
  14933. * | Value | Type | Description |
  14934. * | --- | --- | --- |
  14935. * | 0 | BILLBOARDMODE_NONE | |
  14936. * | 1 | BILLBOARDMODE_X | |
  14937. * | 2 | BILLBOARDMODE_Y | |
  14938. * | 4 | BILLBOARDMODE_Z | |
  14939. * | 7 | BILLBOARDMODE_ALL | |
  14940. *
  14941. */
  14942. get billboardMode(): number;
  14943. set billboardMode(value: number);
  14944. private _preserveParentRotationForBillboard;
  14945. /**
  14946. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14947. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14948. */
  14949. get preserveParentRotationForBillboard(): boolean;
  14950. set preserveParentRotationForBillboard(value: boolean);
  14951. /**
  14952. * 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
  14953. */
  14954. scalingDeterminant: number;
  14955. private _infiniteDistance;
  14956. /**
  14957. * Gets or sets the distance of the object to max, often used by skybox
  14958. */
  14959. get infiniteDistance(): boolean;
  14960. set infiniteDistance(value: boolean);
  14961. /**
  14962. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14963. * By default the system will update normals to compensate
  14964. */
  14965. ignoreNonUniformScaling: boolean;
  14966. /**
  14967. * 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
  14968. */
  14969. reIntegrateRotationIntoRotationQuaternion: boolean;
  14970. /** @hidden */
  14971. _poseMatrix: Nullable<Matrix>;
  14972. /** @hidden */
  14973. _localMatrix: Matrix;
  14974. private _usePivotMatrix;
  14975. private _absolutePosition;
  14976. private _absoluteScaling;
  14977. private _absoluteRotationQuaternion;
  14978. private _pivotMatrix;
  14979. private _pivotMatrixInverse;
  14980. protected _postMultiplyPivotMatrix: boolean;
  14981. protected _isWorldMatrixFrozen: boolean;
  14982. /** @hidden */
  14983. _indexInSceneTransformNodesArray: number;
  14984. /**
  14985. * An event triggered after the world matrix is updated
  14986. */
  14987. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14988. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14989. /**
  14990. * Gets a string identifying the name of the class
  14991. * @returns "TransformNode" string
  14992. */
  14993. getClassName(): string;
  14994. /**
  14995. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14996. */
  14997. get position(): Vector3;
  14998. set position(newPosition: Vector3);
  14999. /**
  15000. * 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)).
  15001. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15002. */
  15003. get rotation(): Vector3;
  15004. set rotation(newRotation: Vector3);
  15005. /**
  15006. * 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)).
  15007. */
  15008. get scaling(): Vector3;
  15009. set scaling(newScaling: Vector3);
  15010. /**
  15011. * 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).
  15012. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15013. */
  15014. get rotationQuaternion(): Nullable<Quaternion>;
  15015. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15016. /**
  15017. * The forward direction of that transform in world space.
  15018. */
  15019. get forward(): Vector3;
  15020. /**
  15021. * The up direction of that transform in world space.
  15022. */
  15023. get up(): Vector3;
  15024. /**
  15025. * The right direction of that transform in world space.
  15026. */
  15027. get right(): Vector3;
  15028. /**
  15029. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15030. * @param matrix the matrix to copy the pose from
  15031. * @returns this TransformNode.
  15032. */
  15033. updatePoseMatrix(matrix: Matrix): TransformNode;
  15034. /**
  15035. * Returns the mesh Pose matrix.
  15036. * @returns the pose matrix
  15037. */
  15038. getPoseMatrix(): Matrix;
  15039. /** @hidden */
  15040. _isSynchronized(): boolean;
  15041. /** @hidden */
  15042. _initCache(): void;
  15043. /**
  15044. * Flag the transform node as dirty (Forcing it to update everything)
  15045. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15046. * @returns this transform node
  15047. */
  15048. markAsDirty(property: string): TransformNode;
  15049. /**
  15050. * Returns the current mesh absolute position.
  15051. * Returns a Vector3.
  15052. */
  15053. get absolutePosition(): Vector3;
  15054. /**
  15055. * Returns the current mesh absolute scaling.
  15056. * Returns a Vector3.
  15057. */
  15058. get absoluteScaling(): Vector3;
  15059. /**
  15060. * Returns the current mesh absolute rotation.
  15061. * Returns a Quaternion.
  15062. */
  15063. get absoluteRotationQuaternion(): Quaternion;
  15064. /**
  15065. * Sets a new matrix to apply before all other transformation
  15066. * @param matrix defines the transform matrix
  15067. * @returns the current TransformNode
  15068. */
  15069. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15070. /**
  15071. * Sets a new pivot matrix to the current node
  15072. * @param matrix defines the new pivot matrix to use
  15073. * @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
  15074. * @returns the current TransformNode
  15075. */
  15076. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15077. /**
  15078. * Returns the mesh pivot matrix.
  15079. * Default : Identity.
  15080. * @returns the matrix
  15081. */
  15082. getPivotMatrix(): Matrix;
  15083. /**
  15084. * Instantiate (when possible) or clone that node with its hierarchy
  15085. * @param newParent defines the new parent to use for the instance (or clone)
  15086. * @param options defines options to configure how copy is done
  15087. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15088. * @returns an instance (or a clone) of the current node with its hiearchy
  15089. */
  15090. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15091. doNotInstantiate: boolean;
  15092. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15093. /**
  15094. * Prevents the World matrix to be computed any longer
  15095. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15096. * @returns the TransformNode.
  15097. */
  15098. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15099. /**
  15100. * Allows back the World matrix computation.
  15101. * @returns the TransformNode.
  15102. */
  15103. unfreezeWorldMatrix(): this;
  15104. /**
  15105. * True if the World matrix has been frozen.
  15106. */
  15107. get isWorldMatrixFrozen(): boolean;
  15108. /**
  15109. * Retuns the mesh absolute position in the World.
  15110. * @returns a Vector3.
  15111. */
  15112. getAbsolutePosition(): Vector3;
  15113. /**
  15114. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15115. * @param absolutePosition the absolute position to set
  15116. * @returns the TransformNode.
  15117. */
  15118. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15119. /**
  15120. * Sets the mesh position in its local space.
  15121. * @param vector3 the position to set in localspace
  15122. * @returns the TransformNode.
  15123. */
  15124. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15125. /**
  15126. * Returns the mesh position in the local space from the current World matrix values.
  15127. * @returns a new Vector3.
  15128. */
  15129. getPositionExpressedInLocalSpace(): Vector3;
  15130. /**
  15131. * Translates the mesh along the passed Vector3 in its local space.
  15132. * @param vector3 the distance to translate in localspace
  15133. * @returns the TransformNode.
  15134. */
  15135. locallyTranslate(vector3: Vector3): TransformNode;
  15136. private static _lookAtVectorCache;
  15137. /**
  15138. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15139. * @param targetPoint the position (must be in same space as current mesh) to look at
  15140. * @param yawCor optional yaw (y-axis) correction in radians
  15141. * @param pitchCor optional pitch (x-axis) correction in radians
  15142. * @param rollCor optional roll (z-axis) correction in radians
  15143. * @param space the choosen space of the target
  15144. * @returns the TransformNode.
  15145. */
  15146. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15147. /**
  15148. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15149. * This Vector3 is expressed in the World space.
  15150. * @param localAxis axis to rotate
  15151. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15152. */
  15153. getDirection(localAxis: Vector3): Vector3;
  15154. /**
  15155. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15156. * localAxis is expressed in the mesh local space.
  15157. * result is computed in the Wordl space from the mesh World matrix.
  15158. * @param localAxis axis to rotate
  15159. * @param result the resulting transformnode
  15160. * @returns this TransformNode.
  15161. */
  15162. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15163. /**
  15164. * Sets this transform node rotation to the given local axis.
  15165. * @param localAxis the axis in local space
  15166. * @param yawCor optional yaw (y-axis) correction in radians
  15167. * @param pitchCor optional pitch (x-axis) correction in radians
  15168. * @param rollCor optional roll (z-axis) correction in radians
  15169. * @returns this TransformNode
  15170. */
  15171. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15172. /**
  15173. * Sets a new pivot point to the current node
  15174. * @param point defines the new pivot point to use
  15175. * @param space defines if the point is in world or local space (local by default)
  15176. * @returns the current TransformNode
  15177. */
  15178. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15179. /**
  15180. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15181. * @returns the pivot point
  15182. */
  15183. getPivotPoint(): Vector3;
  15184. /**
  15185. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15186. * @param result the vector3 to store the result
  15187. * @returns this TransformNode.
  15188. */
  15189. getPivotPointToRef(result: Vector3): TransformNode;
  15190. /**
  15191. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15192. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15193. */
  15194. getAbsolutePivotPoint(): Vector3;
  15195. /**
  15196. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15197. * @param result vector3 to store the result
  15198. * @returns this TransformNode.
  15199. */
  15200. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15201. /**
  15202. * Defines the passed node as the parent of the current node.
  15203. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15204. * @see https://doc.babylonjs.com/how_to/parenting
  15205. * @param node the node ot set as the parent
  15206. * @returns this TransformNode.
  15207. */
  15208. setParent(node: Nullable<Node>): TransformNode;
  15209. private _nonUniformScaling;
  15210. /**
  15211. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15212. */
  15213. get nonUniformScaling(): boolean;
  15214. /** @hidden */
  15215. _updateNonUniformScalingState(value: boolean): boolean;
  15216. /**
  15217. * Attach the current TransformNode to another TransformNode associated with a bone
  15218. * @param bone Bone affecting the TransformNode
  15219. * @param affectedTransformNode TransformNode associated with the bone
  15220. * @returns this object
  15221. */
  15222. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15223. /**
  15224. * Detach the transform node if its associated with a bone
  15225. * @returns this object
  15226. */
  15227. detachFromBone(): TransformNode;
  15228. private static _rotationAxisCache;
  15229. /**
  15230. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15231. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15232. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15233. * The passed axis is also normalized.
  15234. * @param axis the axis to rotate around
  15235. * @param amount the amount to rotate in radians
  15236. * @param space Space to rotate in (Default: local)
  15237. * @returns the TransformNode.
  15238. */
  15239. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15240. /**
  15241. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15242. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15243. * The passed axis is also normalized. .
  15244. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15245. * @param point the point to rotate around
  15246. * @param axis the axis to rotate around
  15247. * @param amount the amount to rotate in radians
  15248. * @returns the TransformNode
  15249. */
  15250. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15251. /**
  15252. * Translates the mesh along the axis vector for the passed distance in the given space.
  15253. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15254. * @param axis the axis to translate in
  15255. * @param distance the distance to translate
  15256. * @param space Space to rotate in (Default: local)
  15257. * @returns the TransformNode.
  15258. */
  15259. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15260. /**
  15261. * Adds a rotation step to the mesh current rotation.
  15262. * x, y, z are Euler angles expressed in radians.
  15263. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15264. * This means this rotation is made in the mesh local space only.
  15265. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15266. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15267. * ```javascript
  15268. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15269. * ```
  15270. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15271. * 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.
  15272. * @param x Rotation to add
  15273. * @param y Rotation to add
  15274. * @param z Rotation to add
  15275. * @returns the TransformNode.
  15276. */
  15277. addRotation(x: number, y: number, z: number): TransformNode;
  15278. /**
  15279. * @hidden
  15280. */
  15281. protected _getEffectiveParent(): Nullable<Node>;
  15282. /**
  15283. * Computes the world matrix of the node
  15284. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15285. * @returns the world matrix
  15286. */
  15287. computeWorldMatrix(force?: boolean): Matrix;
  15288. /**
  15289. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15290. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15291. */
  15292. resetLocalMatrix(independentOfChildren?: boolean): void;
  15293. protected _afterComputeWorldMatrix(): void;
  15294. /**
  15295. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15296. * @param func callback function to add
  15297. *
  15298. * @returns the TransformNode.
  15299. */
  15300. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15301. /**
  15302. * Removes a registered callback function.
  15303. * @param func callback function to remove
  15304. * @returns the TransformNode.
  15305. */
  15306. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15307. /**
  15308. * Gets the position of the current mesh in camera space
  15309. * @param camera defines the camera to use
  15310. * @returns a position
  15311. */
  15312. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15313. /**
  15314. * Returns the distance from the mesh to the active camera
  15315. * @param camera defines the camera to use
  15316. * @returns the distance
  15317. */
  15318. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15319. /**
  15320. * Clone the current transform node
  15321. * @param name Name of the new clone
  15322. * @param newParent New parent for the clone
  15323. * @param doNotCloneChildren Do not clone children hierarchy
  15324. * @returns the new transform node
  15325. */
  15326. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15327. /**
  15328. * Serializes the objects information.
  15329. * @param currentSerializationObject defines the object to serialize in
  15330. * @returns the serialized object
  15331. */
  15332. serialize(currentSerializationObject?: any): any;
  15333. /**
  15334. * Returns a new TransformNode object parsed from the source provided.
  15335. * @param parsedTransformNode is the source.
  15336. * @param scene the scne the object belongs to
  15337. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15338. * @returns a new TransformNode object parsed from the source provided.
  15339. */
  15340. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15341. /**
  15342. * Get all child-transformNodes of this node
  15343. * @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
  15344. * @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
  15345. * @returns an array of TransformNode
  15346. */
  15347. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15348. /**
  15349. * Releases resources associated with this transform node.
  15350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15352. */
  15353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15354. /**
  15355. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15356. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15357. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15358. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15359. * @returns the current mesh
  15360. */
  15361. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15362. private _syncAbsoluteScalingAndRotation;
  15363. }
  15364. }
  15365. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15366. /**
  15367. * Class used to override all child animations of a given target
  15368. */
  15369. export class AnimationPropertiesOverride {
  15370. /**
  15371. * Gets or sets a value indicating if animation blending must be used
  15372. */
  15373. enableBlending: boolean;
  15374. /**
  15375. * Gets or sets the blending speed to use when enableBlending is true
  15376. */
  15377. blendingSpeed: number;
  15378. /**
  15379. * Gets or sets the default loop mode to use
  15380. */
  15381. loopMode: number;
  15382. }
  15383. }
  15384. declare module "babylonjs/Bones/bone" {
  15385. import { Skeleton } from "babylonjs/Bones/skeleton";
  15386. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Nullable } from "babylonjs/types";
  15388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15390. import { Node } from "babylonjs/node";
  15391. import { Space } from "babylonjs/Maths/math.axis";
  15392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15393. /**
  15394. * Class used to store bone information
  15395. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15396. */
  15397. export class Bone extends Node {
  15398. /**
  15399. * defines the bone name
  15400. */
  15401. name: string;
  15402. private static _tmpVecs;
  15403. private static _tmpQuat;
  15404. private static _tmpMats;
  15405. /**
  15406. * Gets the list of child bones
  15407. */
  15408. children: Bone[];
  15409. /** Gets the animations associated with this bone */
  15410. animations: import("babylonjs/Animations/animation").Animation[];
  15411. /**
  15412. * Gets or sets bone length
  15413. */
  15414. length: number;
  15415. /**
  15416. * @hidden Internal only
  15417. * Set this value to map this bone to a different index in the transform matrices
  15418. * Set this value to -1 to exclude the bone from the transform matrices
  15419. */
  15420. _index: Nullable<number>;
  15421. private _skeleton;
  15422. private _localMatrix;
  15423. private _restPose;
  15424. private _baseMatrix;
  15425. private _absoluteTransform;
  15426. private _invertedAbsoluteTransform;
  15427. private _parent;
  15428. private _scalingDeterminant;
  15429. private _worldTransform;
  15430. private _localScaling;
  15431. private _localRotation;
  15432. private _localPosition;
  15433. private _needToDecompose;
  15434. private _needToCompose;
  15435. /** @hidden */
  15436. _linkedTransformNode: Nullable<TransformNode>;
  15437. /** @hidden */
  15438. _waitingTransformNodeId: Nullable<string>;
  15439. /** @hidden */
  15440. get _matrix(): Matrix;
  15441. /** @hidden */
  15442. set _matrix(value: Matrix);
  15443. /**
  15444. * Create a new bone
  15445. * @param name defines the bone name
  15446. * @param skeleton defines the parent skeleton
  15447. * @param parentBone defines the parent (can be null if the bone is the root)
  15448. * @param localMatrix defines the local matrix
  15449. * @param restPose defines the rest pose matrix
  15450. * @param baseMatrix defines the base matrix
  15451. * @param index defines index of the bone in the hiearchy
  15452. */
  15453. constructor(
  15454. /**
  15455. * defines the bone name
  15456. */
  15457. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15458. /**
  15459. * Gets the current object class name.
  15460. * @return the class name
  15461. */
  15462. getClassName(): string;
  15463. /**
  15464. * Gets the parent skeleton
  15465. * @returns a skeleton
  15466. */
  15467. getSkeleton(): Skeleton;
  15468. /**
  15469. * Gets parent bone
  15470. * @returns a bone or null if the bone is the root of the bone hierarchy
  15471. */
  15472. getParent(): Nullable<Bone>;
  15473. /**
  15474. * Returns an array containing the root bones
  15475. * @returns an array containing the root bones
  15476. */
  15477. getChildren(): Array<Bone>;
  15478. /**
  15479. * Gets the node index in matrix array generated for rendering
  15480. * @returns the node index
  15481. */
  15482. getIndex(): number;
  15483. /**
  15484. * Sets the parent bone
  15485. * @param parent defines the parent (can be null if the bone is the root)
  15486. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15487. */
  15488. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15489. /**
  15490. * Gets the local matrix
  15491. * @returns a matrix
  15492. */
  15493. getLocalMatrix(): Matrix;
  15494. /**
  15495. * Gets the base matrix (initial matrix which remains unchanged)
  15496. * @returns a matrix
  15497. */
  15498. getBaseMatrix(): Matrix;
  15499. /**
  15500. * Gets the rest pose matrix
  15501. * @returns a matrix
  15502. */
  15503. getRestPose(): Matrix;
  15504. /**
  15505. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15506. */
  15507. getWorldMatrix(): Matrix;
  15508. /**
  15509. * Sets the local matrix to rest pose matrix
  15510. */
  15511. returnToRest(): void;
  15512. /**
  15513. * Gets the inverse of the absolute transform matrix.
  15514. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15515. * @returns a matrix
  15516. */
  15517. getInvertedAbsoluteTransform(): Matrix;
  15518. /**
  15519. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15520. * @returns a matrix
  15521. */
  15522. getAbsoluteTransform(): Matrix;
  15523. /**
  15524. * Links with the given transform node.
  15525. * The local matrix of this bone is copied from the transform node every frame.
  15526. * @param transformNode defines the transform node to link to
  15527. */
  15528. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15529. /**
  15530. * Gets the node used to drive the bone's transformation
  15531. * @returns a transform node or null
  15532. */
  15533. getTransformNode(): Nullable<TransformNode>;
  15534. /** Gets or sets current position (in local space) */
  15535. get position(): Vector3;
  15536. set position(newPosition: Vector3);
  15537. /** Gets or sets current rotation (in local space) */
  15538. get rotation(): Vector3;
  15539. set rotation(newRotation: Vector3);
  15540. /** Gets or sets current rotation quaternion (in local space) */
  15541. get rotationQuaternion(): Quaternion;
  15542. set rotationQuaternion(newRotation: Quaternion);
  15543. /** Gets or sets current scaling (in local space) */
  15544. get scaling(): Vector3;
  15545. set scaling(newScaling: Vector3);
  15546. /**
  15547. * Gets the animation properties override
  15548. */
  15549. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15550. private _decompose;
  15551. private _compose;
  15552. /**
  15553. * Update the base and local matrices
  15554. * @param matrix defines the new base or local matrix
  15555. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15556. * @param updateLocalMatrix defines if the local matrix should be updated
  15557. */
  15558. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15559. /** @hidden */
  15560. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15561. /**
  15562. * Flag the bone as dirty (Forcing it to update everything)
  15563. */
  15564. markAsDirty(): void;
  15565. /** @hidden */
  15566. _markAsDirtyAndCompose(): void;
  15567. private _markAsDirtyAndDecompose;
  15568. /**
  15569. * Translate the bone in local or world space
  15570. * @param vec The amount to translate the bone
  15571. * @param space The space that the translation is in
  15572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15573. */
  15574. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15575. /**
  15576. * Set the postion of the bone in local or world space
  15577. * @param position The position to set the bone
  15578. * @param space The space that the position is in
  15579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15580. */
  15581. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15582. /**
  15583. * Set the absolute position of the bone (world space)
  15584. * @param position The position to set the bone
  15585. * @param mesh The mesh that this bone is attached to
  15586. */
  15587. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15588. /**
  15589. * Scale the bone on the x, y and z axes (in local space)
  15590. * @param x The amount to scale the bone on the x axis
  15591. * @param y The amount to scale the bone on the y axis
  15592. * @param z The amount to scale the bone on the z axis
  15593. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15594. */
  15595. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15596. /**
  15597. * Set the bone scaling in local space
  15598. * @param scale defines the scaling vector
  15599. */
  15600. setScale(scale: Vector3): void;
  15601. /**
  15602. * Gets the current scaling in local space
  15603. * @returns the current scaling vector
  15604. */
  15605. getScale(): Vector3;
  15606. /**
  15607. * Gets the current scaling in local space and stores it in a target vector
  15608. * @param result defines the target vector
  15609. */
  15610. getScaleToRef(result: Vector3): void;
  15611. /**
  15612. * Set the yaw, pitch, and roll of the bone in local or world space
  15613. * @param yaw The rotation of the bone on the y axis
  15614. * @param pitch The rotation of the bone on the x axis
  15615. * @param roll The rotation of the bone on the z axis
  15616. * @param space The space that the axes of rotation are in
  15617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15618. */
  15619. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15620. /**
  15621. * Add a rotation to the bone on an axis in local or world space
  15622. * @param axis The axis to rotate the bone on
  15623. * @param amount The amount to rotate the bone
  15624. * @param space The space that the axis is in
  15625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15626. */
  15627. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15628. /**
  15629. * Set the rotation of the bone to a particular axis angle in local or world space
  15630. * @param axis The axis to rotate the bone on
  15631. * @param angle The angle that the bone should be rotated to
  15632. * @param space The space that the axis is in
  15633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15634. */
  15635. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15636. /**
  15637. * Set the euler rotation of the bone in local of world space
  15638. * @param rotation The euler rotation that the bone should be set to
  15639. * @param space The space that the rotation is in
  15640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15641. */
  15642. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15643. /**
  15644. * Set the quaternion rotation of the bone in local of world space
  15645. * @param quat The quaternion rotation that the bone should be set to
  15646. * @param space The space that the rotation is in
  15647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15648. */
  15649. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15650. /**
  15651. * Set the rotation matrix of the bone in local of world space
  15652. * @param rotMat The rotation matrix that the bone should be set to
  15653. * @param space The space that the rotation is in
  15654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15655. */
  15656. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15657. private _rotateWithMatrix;
  15658. private _getNegativeRotationToRef;
  15659. /**
  15660. * Get the position of the bone in local or world space
  15661. * @param space The space that the returned position is in
  15662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15663. * @returns The position of the bone
  15664. */
  15665. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15666. /**
  15667. * Copy the position of the bone to a vector3 in local or world space
  15668. * @param space The space that the returned position is in
  15669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15670. * @param result The vector3 to copy the position to
  15671. */
  15672. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15673. /**
  15674. * Get the absolute position of the bone (world space)
  15675. * @param mesh The mesh that this bone is attached to
  15676. * @returns The absolute position of the bone
  15677. */
  15678. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15679. /**
  15680. * Copy the absolute position of the bone (world space) to the result param
  15681. * @param mesh The mesh that this bone is attached to
  15682. * @param result The vector3 to copy the absolute position to
  15683. */
  15684. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15685. /**
  15686. * Compute the absolute transforms of this bone and its children
  15687. */
  15688. computeAbsoluteTransforms(): void;
  15689. /**
  15690. * Get the world direction from an axis that is in the local space of the bone
  15691. * @param localAxis The local direction that is used to compute the world direction
  15692. * @param mesh The mesh that this bone is attached to
  15693. * @returns The world direction
  15694. */
  15695. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15696. /**
  15697. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15698. * @param localAxis The local direction that is used to compute the world direction
  15699. * @param mesh The mesh that this bone is attached to
  15700. * @param result The vector3 that the world direction will be copied to
  15701. */
  15702. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15703. /**
  15704. * Get the euler rotation of the bone in local or world space
  15705. * @param space The space that the rotation should be in
  15706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15707. * @returns The euler rotation
  15708. */
  15709. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15710. /**
  15711. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15712. * @param space The space that the rotation should be in
  15713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15714. * @param result The vector3 that the rotation should be copied to
  15715. */
  15716. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15717. /**
  15718. * Get the quaternion rotation of the bone in either local or world space
  15719. * @param space The space that the rotation should be in
  15720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15721. * @returns The quaternion rotation
  15722. */
  15723. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15724. /**
  15725. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15726. * @param space The space that the rotation should be in
  15727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15728. * @param result The quaternion that the rotation should be copied to
  15729. */
  15730. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15731. /**
  15732. * Get the rotation matrix of the bone in local or world space
  15733. * @param space The space that the rotation should be in
  15734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15735. * @returns The rotation matrix
  15736. */
  15737. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15738. /**
  15739. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15740. * @param space The space that the rotation should be in
  15741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15742. * @param result The quaternion that the rotation should be copied to
  15743. */
  15744. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15745. /**
  15746. * Get the world position of a point that is in the local space of the bone
  15747. * @param position The local position
  15748. * @param mesh The mesh that this bone is attached to
  15749. * @returns The world position
  15750. */
  15751. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15752. /**
  15753. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15754. * @param position The local position
  15755. * @param mesh The mesh that this bone is attached to
  15756. * @param result The vector3 that the world position should be copied to
  15757. */
  15758. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15759. /**
  15760. * Get the local position of a point that is in world space
  15761. * @param position The world position
  15762. * @param mesh The mesh that this bone is attached to
  15763. * @returns The local position
  15764. */
  15765. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15766. /**
  15767. * Get the local position of a point that is in world space and copy it to the result param
  15768. * @param position The world position
  15769. * @param mesh The mesh that this bone is attached to
  15770. * @param result The vector3 that the local position should be copied to
  15771. */
  15772. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15773. }
  15774. }
  15775. declare module "babylonjs/Animations/runtimeAnimation" {
  15776. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15777. import { Animatable } from "babylonjs/Animations/animatable";
  15778. import { Scene } from "babylonjs/scene";
  15779. /**
  15780. * Defines a runtime animation
  15781. */
  15782. export class RuntimeAnimation {
  15783. private _events;
  15784. /**
  15785. * The current frame of the runtime animation
  15786. */
  15787. private _currentFrame;
  15788. /**
  15789. * The animation used by the runtime animation
  15790. */
  15791. private _animation;
  15792. /**
  15793. * The target of the runtime animation
  15794. */
  15795. private _target;
  15796. /**
  15797. * The initiating animatable
  15798. */
  15799. private _host;
  15800. /**
  15801. * The original value of the runtime animation
  15802. */
  15803. private _originalValue;
  15804. /**
  15805. * The original blend value of the runtime animation
  15806. */
  15807. private _originalBlendValue;
  15808. /**
  15809. * The offsets cache of the runtime animation
  15810. */
  15811. private _offsetsCache;
  15812. /**
  15813. * The high limits cache of the runtime animation
  15814. */
  15815. private _highLimitsCache;
  15816. /**
  15817. * Specifies if the runtime animation has been stopped
  15818. */
  15819. private _stopped;
  15820. /**
  15821. * The blending factor of the runtime animation
  15822. */
  15823. private _blendingFactor;
  15824. /**
  15825. * The BabylonJS scene
  15826. */
  15827. private _scene;
  15828. /**
  15829. * The current value of the runtime animation
  15830. */
  15831. private _currentValue;
  15832. /** @hidden */
  15833. _animationState: _IAnimationState;
  15834. /**
  15835. * The active target of the runtime animation
  15836. */
  15837. private _activeTargets;
  15838. private _currentActiveTarget;
  15839. private _directTarget;
  15840. /**
  15841. * The target path of the runtime animation
  15842. */
  15843. private _targetPath;
  15844. /**
  15845. * The weight of the runtime animation
  15846. */
  15847. private _weight;
  15848. /**
  15849. * The ratio offset of the runtime animation
  15850. */
  15851. private _ratioOffset;
  15852. /**
  15853. * The previous delay of the runtime animation
  15854. */
  15855. private _previousDelay;
  15856. /**
  15857. * The previous ratio of the runtime animation
  15858. */
  15859. private _previousRatio;
  15860. private _enableBlending;
  15861. private _keys;
  15862. private _minFrame;
  15863. private _maxFrame;
  15864. private _minValue;
  15865. private _maxValue;
  15866. private _targetIsArray;
  15867. /**
  15868. * Gets the current frame of the runtime animation
  15869. */
  15870. get currentFrame(): number;
  15871. /**
  15872. * Gets the weight of the runtime animation
  15873. */
  15874. get weight(): number;
  15875. /**
  15876. * Gets the current value of the runtime animation
  15877. */
  15878. get currentValue(): any;
  15879. /**
  15880. * Gets the target path of the runtime animation
  15881. */
  15882. get targetPath(): string;
  15883. /**
  15884. * Gets the actual target of the runtime animation
  15885. */
  15886. get target(): any;
  15887. /**
  15888. * Gets the additive state of the runtime animation
  15889. */
  15890. get isAdditive(): boolean;
  15891. /** @hidden */
  15892. _onLoop: () => void;
  15893. /**
  15894. * Create a new RuntimeAnimation object
  15895. * @param target defines the target of the animation
  15896. * @param animation defines the source animation object
  15897. * @param scene defines the hosting scene
  15898. * @param host defines the initiating Animatable
  15899. */
  15900. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15901. private _preparePath;
  15902. /**
  15903. * Gets the animation from the runtime animation
  15904. */
  15905. get animation(): Animation;
  15906. /**
  15907. * Resets the runtime animation to the beginning
  15908. * @param restoreOriginal defines whether to restore the target property to the original value
  15909. */
  15910. reset(restoreOriginal?: boolean): void;
  15911. /**
  15912. * Specifies if the runtime animation is stopped
  15913. * @returns Boolean specifying if the runtime animation is stopped
  15914. */
  15915. isStopped(): boolean;
  15916. /**
  15917. * Disposes of the runtime animation
  15918. */
  15919. dispose(): void;
  15920. /**
  15921. * Apply the interpolated value to the target
  15922. * @param currentValue defines the value computed by the animation
  15923. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15924. */
  15925. setValue(currentValue: any, weight: number): void;
  15926. private _getOriginalValues;
  15927. private _setValue;
  15928. /**
  15929. * Gets the loop pmode of the runtime animation
  15930. * @returns Loop Mode
  15931. */
  15932. private _getCorrectLoopMode;
  15933. /**
  15934. * Move the current animation to a given frame
  15935. * @param frame defines the frame to move to
  15936. */
  15937. goToFrame(frame: number): void;
  15938. /**
  15939. * @hidden Internal use only
  15940. */
  15941. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15942. /**
  15943. * Execute the current animation
  15944. * @param delay defines the delay to add to the current frame
  15945. * @param from defines the lower bound of the animation range
  15946. * @param to defines the upper bound of the animation range
  15947. * @param loop defines if the current animation must loop
  15948. * @param speedRatio defines the current speed ratio
  15949. * @param weight defines the weight of the animation (default is -1 so no weight)
  15950. * @param onLoop optional callback called when animation loops
  15951. * @returns a boolean indicating if the animation is running
  15952. */
  15953. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15954. }
  15955. }
  15956. declare module "babylonjs/Animations/animatable" {
  15957. import { Animation } from "babylonjs/Animations/animation";
  15958. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15959. import { Nullable } from "babylonjs/types";
  15960. import { Observable } from "babylonjs/Misc/observable";
  15961. import { Scene } from "babylonjs/scene";
  15962. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15963. import { Node } from "babylonjs/node";
  15964. /**
  15965. * Class used to store an actual running animation
  15966. */
  15967. export class Animatable {
  15968. /** defines the target object */
  15969. target: any;
  15970. /** defines the starting frame number (default is 0) */
  15971. fromFrame: number;
  15972. /** defines the ending frame number (default is 100) */
  15973. toFrame: number;
  15974. /** defines if the animation must loop (default is false) */
  15975. loopAnimation: boolean;
  15976. /** defines a callback to call when animation ends if it is not looping */
  15977. onAnimationEnd?: (() => void) | null | undefined;
  15978. /** defines a callback to call when animation loops */
  15979. onAnimationLoop?: (() => void) | null | undefined;
  15980. /** defines whether the animation should be evaluated additively */
  15981. isAdditive: boolean;
  15982. private _localDelayOffset;
  15983. private _pausedDelay;
  15984. private _runtimeAnimations;
  15985. private _paused;
  15986. private _scene;
  15987. private _speedRatio;
  15988. private _weight;
  15989. private _syncRoot;
  15990. /**
  15991. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15992. * This will only apply for non looping animation (default is true)
  15993. */
  15994. disposeOnEnd: boolean;
  15995. /**
  15996. * Gets a boolean indicating if the animation has started
  15997. */
  15998. animationStarted: boolean;
  15999. /**
  16000. * Observer raised when the animation ends
  16001. */
  16002. onAnimationEndObservable: Observable<Animatable>;
  16003. /**
  16004. * Observer raised when the animation loops
  16005. */
  16006. onAnimationLoopObservable: Observable<Animatable>;
  16007. /**
  16008. * Gets the root Animatable used to synchronize and normalize animations
  16009. */
  16010. get syncRoot(): Nullable<Animatable>;
  16011. /**
  16012. * Gets the current frame of the first RuntimeAnimation
  16013. * Used to synchronize Animatables
  16014. */
  16015. get masterFrame(): number;
  16016. /**
  16017. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16018. */
  16019. get weight(): number;
  16020. set weight(value: number);
  16021. /**
  16022. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16023. */
  16024. get speedRatio(): number;
  16025. set speedRatio(value: number);
  16026. /**
  16027. * Creates a new Animatable
  16028. * @param scene defines the hosting scene
  16029. * @param target defines the target object
  16030. * @param fromFrame defines the starting frame number (default is 0)
  16031. * @param toFrame defines the ending frame number (default is 100)
  16032. * @param loopAnimation defines if the animation must loop (default is false)
  16033. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16034. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16035. * @param animations defines a group of animation to add to the new Animatable
  16036. * @param onAnimationLoop defines a callback to call when animation loops
  16037. * @param isAdditive defines whether the animation should be evaluated additively
  16038. */
  16039. constructor(scene: Scene,
  16040. /** defines the target object */
  16041. target: any,
  16042. /** defines the starting frame number (default is 0) */
  16043. fromFrame?: number,
  16044. /** defines the ending frame number (default is 100) */
  16045. toFrame?: number,
  16046. /** defines if the animation must loop (default is false) */
  16047. loopAnimation?: boolean, speedRatio?: number,
  16048. /** defines a callback to call when animation ends if it is not looping */
  16049. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16050. /** defines a callback to call when animation loops */
  16051. onAnimationLoop?: (() => void) | null | undefined,
  16052. /** defines whether the animation should be evaluated additively */
  16053. isAdditive?: boolean);
  16054. /**
  16055. * Synchronize and normalize current Animatable with a source Animatable
  16056. * This is useful when using animation weights and when animations are not of the same length
  16057. * @param root defines the root Animatable to synchronize with
  16058. * @returns the current Animatable
  16059. */
  16060. syncWith(root: Animatable): Animatable;
  16061. /**
  16062. * Gets the list of runtime animations
  16063. * @returns an array of RuntimeAnimation
  16064. */
  16065. getAnimations(): RuntimeAnimation[];
  16066. /**
  16067. * Adds more animations to the current animatable
  16068. * @param target defines the target of the animations
  16069. * @param animations defines the new animations to add
  16070. */
  16071. appendAnimations(target: any, animations: Animation[]): void;
  16072. /**
  16073. * Gets the source animation for a specific property
  16074. * @param property defines the propertyu to look for
  16075. * @returns null or the source animation for the given property
  16076. */
  16077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16078. /**
  16079. * Gets the runtime animation for a specific property
  16080. * @param property defines the propertyu to look for
  16081. * @returns null or the runtime animation for the given property
  16082. */
  16083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16084. /**
  16085. * Resets the animatable to its original state
  16086. */
  16087. reset(): void;
  16088. /**
  16089. * Allows the animatable to blend with current running animations
  16090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16091. * @param blendingSpeed defines the blending speed to use
  16092. */
  16093. enableBlending(blendingSpeed: number): void;
  16094. /**
  16095. * Disable animation blending
  16096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16097. */
  16098. disableBlending(): void;
  16099. /**
  16100. * Jump directly to a given frame
  16101. * @param frame defines the frame to jump to
  16102. */
  16103. goToFrame(frame: number): void;
  16104. /**
  16105. * Pause the animation
  16106. */
  16107. pause(): void;
  16108. /**
  16109. * Restart the animation
  16110. */
  16111. restart(): void;
  16112. private _raiseOnAnimationEnd;
  16113. /**
  16114. * Stop and delete the current animation
  16115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16116. * @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)
  16117. */
  16118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16119. /**
  16120. * Wait asynchronously for the animation to end
  16121. * @returns a promise which will be fullfilled when the animation ends
  16122. */
  16123. waitAsync(): Promise<Animatable>;
  16124. /** @hidden */
  16125. _animate(delay: number): boolean;
  16126. }
  16127. module "babylonjs/scene" {
  16128. interface Scene {
  16129. /** @hidden */
  16130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16131. /** @hidden */
  16132. _processLateAnimationBindingsForMatrices(holder: {
  16133. totalWeight: number;
  16134. totalAdditiveWeight: number;
  16135. animations: RuntimeAnimation[];
  16136. additiveAnimations: RuntimeAnimation[];
  16137. originalValue: Matrix;
  16138. }): any;
  16139. /** @hidden */
  16140. _processLateAnimationBindingsForQuaternions(holder: {
  16141. totalWeight: number;
  16142. totalAdditiveWeight: number;
  16143. animations: RuntimeAnimation[];
  16144. additiveAnimations: RuntimeAnimation[];
  16145. originalValue: Quaternion;
  16146. }, refQuaternion: Quaternion): Quaternion;
  16147. /** @hidden */
  16148. _processLateAnimationBindings(): void;
  16149. /**
  16150. * Will start the animation sequence of a given target
  16151. * @param target defines the target
  16152. * @param from defines from which frame should animation start
  16153. * @param to defines until which frame should animation run.
  16154. * @param weight defines the weight to apply to the animation (1.0 by default)
  16155. * @param loop defines if the animation loops
  16156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16157. * @param onAnimationEnd defines the function to be executed when the animation ends
  16158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16160. * @param onAnimationLoop defines the callback to call when an animation loops
  16161. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16162. * @returns the animatable object created for this animation
  16163. */
  16164. 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;
  16165. /**
  16166. * Will start the animation sequence of a given target
  16167. * @param target defines the target
  16168. * @param from defines from which frame should animation start
  16169. * @param to defines until which frame should animation run.
  16170. * @param loop defines if the animation loops
  16171. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16172. * @param onAnimationEnd defines the function to be executed when the animation ends
  16173. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16174. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16175. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16176. * @param onAnimationLoop defines the callback to call when an animation loops
  16177. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16178. * @returns the animatable object created for this animation
  16179. */
  16180. 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;
  16181. /**
  16182. * Will start the animation sequence of a given target and its hierarchy
  16183. * @param target defines the target
  16184. * @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.
  16185. * @param from defines from which frame should animation start
  16186. * @param to defines until which frame should animation run.
  16187. * @param loop defines if the animation loops
  16188. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16189. * @param onAnimationEnd defines the function to be executed when the animation ends
  16190. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16191. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16192. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16193. * @param onAnimationLoop defines the callback to call when an animation loops
  16194. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16195. * @returns the list of created animatables
  16196. */
  16197. 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[];
  16198. /**
  16199. * Begin a new animation on a given node
  16200. * @param target defines the target where the animation will take place
  16201. * @param animations defines the list of animations to start
  16202. * @param from defines the initial value
  16203. * @param to defines the final value
  16204. * @param loop defines if you want animation to loop (off by default)
  16205. * @param speedRatio defines the speed ratio to apply to all animations
  16206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16207. * @param onAnimationLoop defines the callback to call when an animation loops
  16208. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16209. * @returns the list of created animatables
  16210. */
  16211. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16212. /**
  16213. * Begin a new animation on a given node and its hierarchy
  16214. * @param target defines the root node where the animation will take place
  16215. * @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.
  16216. * @param animations defines the list of animations to start
  16217. * @param from defines the initial value
  16218. * @param to defines the final value
  16219. * @param loop defines if you want animation to loop (off by default)
  16220. * @param speedRatio defines the speed ratio to apply to all animations
  16221. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16222. * @param onAnimationLoop defines the callback to call when an animation loops
  16223. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16224. * @returns the list of animatables created for all nodes
  16225. */
  16226. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16227. /**
  16228. * Gets the animatable associated with a specific target
  16229. * @param target defines the target of the animatable
  16230. * @returns the required animatable if found
  16231. */
  16232. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16233. /**
  16234. * Gets all animatables associated with a given target
  16235. * @param target defines the target to look animatables for
  16236. * @returns an array of Animatables
  16237. */
  16238. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16239. /**
  16240. * Stops and removes all animations that have been applied to the scene
  16241. */
  16242. stopAllAnimations(): void;
  16243. /**
  16244. * Gets the current delta time used by animation engine
  16245. */
  16246. deltaTime: number;
  16247. }
  16248. }
  16249. module "babylonjs/Bones/bone" {
  16250. interface Bone {
  16251. /**
  16252. * Copy an animation range from another bone
  16253. * @param source defines the source bone
  16254. * @param rangeName defines the range name to copy
  16255. * @param frameOffset defines the frame offset
  16256. * @param rescaleAsRequired defines if rescaling must be applied if required
  16257. * @param skelDimensionsRatio defines the scaling ratio
  16258. * @returns true if operation was successful
  16259. */
  16260. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16261. }
  16262. }
  16263. }
  16264. declare module "babylonjs/Bones/skeleton" {
  16265. import { Bone } from "babylonjs/Bones/bone";
  16266. import { Observable } from "babylonjs/Misc/observable";
  16267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16268. import { Scene } from "babylonjs/scene";
  16269. import { Nullable } from "babylonjs/types";
  16270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16271. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16272. import { Animatable } from "babylonjs/Animations/animatable";
  16273. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16274. import { Animation } from "babylonjs/Animations/animation";
  16275. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16276. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16278. /**
  16279. * Class used to handle skinning animations
  16280. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16281. */
  16282. export class Skeleton implements IAnimatable {
  16283. /** defines the skeleton name */
  16284. name: string;
  16285. /** defines the skeleton Id */
  16286. id: string;
  16287. /**
  16288. * Defines the list of child bones
  16289. */
  16290. bones: Bone[];
  16291. /**
  16292. * Defines an estimate of the dimension of the skeleton at rest
  16293. */
  16294. dimensionsAtRest: Vector3;
  16295. /**
  16296. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16297. */
  16298. needInitialSkinMatrix: boolean;
  16299. /**
  16300. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16301. */
  16302. overrideMesh: Nullable<AbstractMesh>;
  16303. /**
  16304. * Gets the list of animations attached to this skeleton
  16305. */
  16306. animations: Array<Animation>;
  16307. private _scene;
  16308. private _isDirty;
  16309. private _transformMatrices;
  16310. private _transformMatrixTexture;
  16311. private _meshesWithPoseMatrix;
  16312. private _animatables;
  16313. private _identity;
  16314. private _synchronizedWithMesh;
  16315. private _ranges;
  16316. private _lastAbsoluteTransformsUpdateId;
  16317. private _canUseTextureForBones;
  16318. private _uniqueId;
  16319. /** @hidden */
  16320. _numBonesWithLinkedTransformNode: number;
  16321. /** @hidden */
  16322. _hasWaitingData: Nullable<boolean>;
  16323. /**
  16324. * Specifies if the skeleton should be serialized
  16325. */
  16326. doNotSerialize: boolean;
  16327. private _useTextureToStoreBoneMatrices;
  16328. /**
  16329. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16330. * Please note that this option is not available if the hardware does not support it
  16331. */
  16332. get useTextureToStoreBoneMatrices(): boolean;
  16333. set useTextureToStoreBoneMatrices(value: boolean);
  16334. private _animationPropertiesOverride;
  16335. /**
  16336. * Gets or sets the animation properties override
  16337. */
  16338. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16339. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16340. /**
  16341. * List of inspectable custom properties (used by the Inspector)
  16342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16343. */
  16344. inspectableCustomProperties: IInspectable[];
  16345. /**
  16346. * An observable triggered before computing the skeleton's matrices
  16347. */
  16348. onBeforeComputeObservable: Observable<Skeleton>;
  16349. /**
  16350. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16351. */
  16352. get isUsingTextureForMatrices(): boolean;
  16353. /**
  16354. * Gets the unique ID of this skeleton
  16355. */
  16356. get uniqueId(): number;
  16357. /**
  16358. * Creates a new skeleton
  16359. * @param name defines the skeleton name
  16360. * @param id defines the skeleton Id
  16361. * @param scene defines the hosting scene
  16362. */
  16363. constructor(
  16364. /** defines the skeleton name */
  16365. name: string,
  16366. /** defines the skeleton Id */
  16367. id: string, scene: Scene);
  16368. /**
  16369. * Gets the current object class name.
  16370. * @return the class name
  16371. */
  16372. getClassName(): string;
  16373. /**
  16374. * Returns an array containing the root bones
  16375. * @returns an array containing the root bones
  16376. */
  16377. getChildren(): Array<Bone>;
  16378. /**
  16379. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16380. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16381. * @returns a Float32Array containing matrices data
  16382. */
  16383. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16384. /**
  16385. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16386. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16387. * @returns a raw texture containing the data
  16388. */
  16389. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16390. /**
  16391. * Gets the current hosting scene
  16392. * @returns a scene object
  16393. */
  16394. getScene(): Scene;
  16395. /**
  16396. * Gets a string representing the current skeleton data
  16397. * @param fullDetails defines a boolean indicating if we want a verbose version
  16398. * @returns a string representing the current skeleton data
  16399. */
  16400. toString(fullDetails?: boolean): string;
  16401. /**
  16402. * Get bone's index searching by name
  16403. * @param name defines bone's name to search for
  16404. * @return the indice of the bone. Returns -1 if not found
  16405. */
  16406. getBoneIndexByName(name: string): number;
  16407. /**
  16408. * Creater a new animation range
  16409. * @param name defines the name of the range
  16410. * @param from defines the start key
  16411. * @param to defines the end key
  16412. */
  16413. createAnimationRange(name: string, from: number, to: number): void;
  16414. /**
  16415. * Delete a specific animation range
  16416. * @param name defines the name of the range
  16417. * @param deleteFrames defines if frames must be removed as well
  16418. */
  16419. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16420. /**
  16421. * Gets a specific animation range
  16422. * @param name defines the name of the range to look for
  16423. * @returns the requested animation range or null if not found
  16424. */
  16425. getAnimationRange(name: string): Nullable<AnimationRange>;
  16426. /**
  16427. * Gets the list of all animation ranges defined on this skeleton
  16428. * @returns an array
  16429. */
  16430. getAnimationRanges(): Nullable<AnimationRange>[];
  16431. /**
  16432. * Copy animation range from a source skeleton.
  16433. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16434. * @param source defines the source skeleton
  16435. * @param name defines the name of the range to copy
  16436. * @param rescaleAsRequired defines if rescaling must be applied if required
  16437. * @returns true if operation was successful
  16438. */
  16439. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16440. /**
  16441. * Forces the skeleton to go to rest pose
  16442. */
  16443. returnToRest(): void;
  16444. private _getHighestAnimationFrame;
  16445. /**
  16446. * Begin a specific animation range
  16447. * @param name defines the name of the range to start
  16448. * @param loop defines if looping must be turned on (false by default)
  16449. * @param speedRatio defines the speed ratio to apply (1 by default)
  16450. * @param onAnimationEnd defines a callback which will be called when animation will end
  16451. * @returns a new animatable
  16452. */
  16453. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16454. /**
  16455. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16456. * @param skeleton defines the Skeleton containing the animation range to convert
  16457. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16458. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16459. * @returns the original skeleton
  16460. */
  16461. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16462. /** @hidden */
  16463. _markAsDirty(): void;
  16464. /** @hidden */
  16465. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16466. /** @hidden */
  16467. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16468. private _computeTransformMatrices;
  16469. /**
  16470. * Build all resources required to render a skeleton
  16471. */
  16472. prepare(): void;
  16473. /**
  16474. * Gets the list of animatables currently running for this skeleton
  16475. * @returns an array of animatables
  16476. */
  16477. getAnimatables(): IAnimatable[];
  16478. /**
  16479. * Clone the current skeleton
  16480. * @param name defines the name of the new skeleton
  16481. * @param id defines the id of the new skeleton
  16482. * @returns the new skeleton
  16483. */
  16484. clone(name: string, id?: string): Skeleton;
  16485. /**
  16486. * Enable animation blending for this skeleton
  16487. * @param blendingSpeed defines the blending speed to apply
  16488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16489. */
  16490. enableBlending(blendingSpeed?: number): void;
  16491. /**
  16492. * Releases all resources associated with the current skeleton
  16493. */
  16494. dispose(): void;
  16495. /**
  16496. * Serialize the skeleton in a JSON object
  16497. * @returns a JSON object
  16498. */
  16499. serialize(): any;
  16500. /**
  16501. * Creates a new skeleton from serialized data
  16502. * @param parsedSkeleton defines the serialized data
  16503. * @param scene defines the hosting scene
  16504. * @returns a new skeleton
  16505. */
  16506. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16507. /**
  16508. * Compute all node absolute transforms
  16509. * @param forceUpdate defines if computation must be done even if cache is up to date
  16510. */
  16511. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16512. /**
  16513. * Gets the root pose matrix
  16514. * @returns a matrix
  16515. */
  16516. getPoseMatrix(): Nullable<Matrix>;
  16517. /**
  16518. * Sorts bones per internal index
  16519. */
  16520. sortBones(): void;
  16521. private _sortBones;
  16522. }
  16523. }
  16524. declare module "babylonjs/Meshes/instancedMesh" {
  16525. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16526. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16527. import { Camera } from "babylonjs/Cameras/camera";
  16528. import { Node } from "babylonjs/node";
  16529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16530. import { Mesh } from "babylonjs/Meshes/mesh";
  16531. import { Material } from "babylonjs/Materials/material";
  16532. import { Skeleton } from "babylonjs/Bones/skeleton";
  16533. import { Light } from "babylonjs/Lights/light";
  16534. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16535. /**
  16536. * Creates an instance based on a source mesh.
  16537. */
  16538. export class InstancedMesh extends AbstractMesh {
  16539. private _sourceMesh;
  16540. private _currentLOD;
  16541. /** @hidden */
  16542. _indexInSourceMeshInstanceArray: number;
  16543. constructor(name: string, source: Mesh);
  16544. /**
  16545. * Returns the string "InstancedMesh".
  16546. */
  16547. getClassName(): string;
  16548. /** Gets the list of lights affecting that mesh */
  16549. get lightSources(): Light[];
  16550. _resyncLightSources(): void;
  16551. _resyncLightSource(light: Light): void;
  16552. _removeLightSource(light: Light, dispose: boolean): void;
  16553. /**
  16554. * If the source mesh receives shadows
  16555. */
  16556. get receiveShadows(): boolean;
  16557. /**
  16558. * The material of the source mesh
  16559. */
  16560. get material(): Nullable<Material>;
  16561. /**
  16562. * Visibility of the source mesh
  16563. */
  16564. get visibility(): number;
  16565. /**
  16566. * Skeleton of the source mesh
  16567. */
  16568. get skeleton(): Nullable<Skeleton>;
  16569. /**
  16570. * Rendering ground id of the source mesh
  16571. */
  16572. get renderingGroupId(): number;
  16573. set renderingGroupId(value: number);
  16574. /**
  16575. * Returns the total number of vertices (integer).
  16576. */
  16577. getTotalVertices(): number;
  16578. /**
  16579. * Returns a positive integer : the total number of indices in this mesh geometry.
  16580. * @returns the numner of indices or zero if the mesh has no geometry.
  16581. */
  16582. getTotalIndices(): number;
  16583. /**
  16584. * The source mesh of the instance
  16585. */
  16586. get sourceMesh(): Mesh;
  16587. /**
  16588. * Creates a new InstancedMesh object from the mesh model.
  16589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16590. * @param name defines the name of the new instance
  16591. * @returns a new InstancedMesh
  16592. */
  16593. createInstance(name: string): InstancedMesh;
  16594. /**
  16595. * Is this node ready to be used/rendered
  16596. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16597. * @return {boolean} is it ready
  16598. */
  16599. isReady(completeCheck?: boolean): boolean;
  16600. /**
  16601. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16602. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16603. * @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.
  16604. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16605. */
  16606. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16607. /**
  16608. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16609. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16610. * The `data` are either a numeric array either a Float32Array.
  16611. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16612. * 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).
  16613. * Note that a new underlying VertexBuffer object is created each call.
  16614. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16615. *
  16616. * Possible `kind` values :
  16617. * - VertexBuffer.PositionKind
  16618. * - VertexBuffer.UVKind
  16619. * - VertexBuffer.UV2Kind
  16620. * - VertexBuffer.UV3Kind
  16621. * - VertexBuffer.UV4Kind
  16622. * - VertexBuffer.UV5Kind
  16623. * - VertexBuffer.UV6Kind
  16624. * - VertexBuffer.ColorKind
  16625. * - VertexBuffer.MatricesIndicesKind
  16626. * - VertexBuffer.MatricesIndicesExtraKind
  16627. * - VertexBuffer.MatricesWeightsKind
  16628. * - VertexBuffer.MatricesWeightsExtraKind
  16629. *
  16630. * Returns the Mesh.
  16631. */
  16632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16633. /**
  16634. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16635. * If the mesh has no geometry, it is simply returned as it is.
  16636. * The `data` are either a numeric array either a Float32Array.
  16637. * No new underlying VertexBuffer object is created.
  16638. * 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.
  16639. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16640. *
  16641. * Possible `kind` values :
  16642. * - VertexBuffer.PositionKind
  16643. * - VertexBuffer.UVKind
  16644. * - VertexBuffer.UV2Kind
  16645. * - VertexBuffer.UV3Kind
  16646. * - VertexBuffer.UV4Kind
  16647. * - VertexBuffer.UV5Kind
  16648. * - VertexBuffer.UV6Kind
  16649. * - VertexBuffer.ColorKind
  16650. * - VertexBuffer.MatricesIndicesKind
  16651. * - VertexBuffer.MatricesIndicesExtraKind
  16652. * - VertexBuffer.MatricesWeightsKind
  16653. * - VertexBuffer.MatricesWeightsExtraKind
  16654. *
  16655. * Returns the Mesh.
  16656. */
  16657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16658. /**
  16659. * Sets the mesh indices.
  16660. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16661. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16662. * This method creates a new index buffer each call.
  16663. * Returns the Mesh.
  16664. */
  16665. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16666. /**
  16667. * Boolean : True if the mesh owns the requested kind of data.
  16668. */
  16669. isVerticesDataPresent(kind: string): boolean;
  16670. /**
  16671. * Returns an array of indices (IndicesArray).
  16672. */
  16673. getIndices(): Nullable<IndicesArray>;
  16674. get _positions(): Nullable<Vector3[]>;
  16675. /**
  16676. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16677. * This means the mesh underlying bounding box and sphere are recomputed.
  16678. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16679. * @returns the current mesh
  16680. */
  16681. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16682. /** @hidden */
  16683. _preActivate(): InstancedMesh;
  16684. /** @hidden */
  16685. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16686. /** @hidden */
  16687. _postActivate(): void;
  16688. getWorldMatrix(): Matrix;
  16689. get isAnInstance(): boolean;
  16690. /**
  16691. * Returns the current associated LOD AbstractMesh.
  16692. */
  16693. getLOD(camera: Camera): AbstractMesh;
  16694. /** @hidden */
  16695. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16696. /** @hidden */
  16697. _syncSubMeshes(): InstancedMesh;
  16698. /** @hidden */
  16699. _generatePointsArray(): boolean;
  16700. /**
  16701. * Creates a new InstancedMesh from the current mesh.
  16702. * - name (string) : the cloned mesh name
  16703. * - newParent (optional Node) : the optional Node to parent the clone to.
  16704. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16705. *
  16706. * Returns the clone.
  16707. */
  16708. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16709. /**
  16710. * Disposes the InstancedMesh.
  16711. * Returns nothing.
  16712. */
  16713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16714. }
  16715. module "babylonjs/Meshes/mesh" {
  16716. interface Mesh {
  16717. /**
  16718. * Register a custom buffer that will be instanced
  16719. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16720. * @param kind defines the buffer kind
  16721. * @param stride defines the stride in floats
  16722. */
  16723. registerInstancedBuffer(kind: string, stride: number): void;
  16724. /** @hidden */
  16725. _userInstancedBuffersStorage: {
  16726. data: {
  16727. [key: string]: Float32Array;
  16728. };
  16729. sizes: {
  16730. [key: string]: number;
  16731. };
  16732. vertexBuffers: {
  16733. [key: string]: Nullable<VertexBuffer>;
  16734. };
  16735. strides: {
  16736. [key: string]: number;
  16737. };
  16738. };
  16739. }
  16740. }
  16741. module "babylonjs/Meshes/abstractMesh" {
  16742. interface AbstractMesh {
  16743. /**
  16744. * Object used to store instanced buffers defined by user
  16745. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16746. */
  16747. instancedBuffers: {
  16748. [key: string]: any;
  16749. };
  16750. }
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/shaderMaterial" {
  16754. import { Nullable } from "babylonjs/types";
  16755. import { Scene } from "babylonjs/scene";
  16756. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16758. import { Mesh } from "babylonjs/Meshes/mesh";
  16759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16761. import { Effect } from "babylonjs/Materials/effect";
  16762. import { Material } from "babylonjs/Materials/material";
  16763. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16764. /**
  16765. * Defines the options associated with the creation of a shader material.
  16766. */
  16767. export interface IShaderMaterialOptions {
  16768. /**
  16769. * Does the material work in alpha blend mode
  16770. */
  16771. needAlphaBlending: boolean;
  16772. /**
  16773. * Does the material work in alpha test mode
  16774. */
  16775. needAlphaTesting: boolean;
  16776. /**
  16777. * The list of attribute names used in the shader
  16778. */
  16779. attributes: string[];
  16780. /**
  16781. * The list of unifrom names used in the shader
  16782. */
  16783. uniforms: string[];
  16784. /**
  16785. * The list of UBO names used in the shader
  16786. */
  16787. uniformBuffers: string[];
  16788. /**
  16789. * The list of sampler names used in the shader
  16790. */
  16791. samplers: string[];
  16792. /**
  16793. * The list of defines used in the shader
  16794. */
  16795. defines: string[];
  16796. }
  16797. /**
  16798. * 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.
  16799. *
  16800. * This returned material effects how the mesh will look based on the code in the shaders.
  16801. *
  16802. * @see http://doc.babylonjs.com/how_to/shader_material
  16803. */
  16804. export class ShaderMaterial extends Material {
  16805. private _shaderPath;
  16806. private _options;
  16807. private _textures;
  16808. private _textureArrays;
  16809. private _floats;
  16810. private _ints;
  16811. private _floatsArrays;
  16812. private _colors3;
  16813. private _colors3Arrays;
  16814. private _colors4;
  16815. private _colors4Arrays;
  16816. private _vectors2;
  16817. private _vectors3;
  16818. private _vectors4;
  16819. private _matrices;
  16820. private _matrixArrays;
  16821. private _matrices3x3;
  16822. private _matrices2x2;
  16823. private _vectors2Arrays;
  16824. private _vectors3Arrays;
  16825. private _vectors4Arrays;
  16826. private _cachedWorldViewMatrix;
  16827. private _cachedWorldViewProjectionMatrix;
  16828. private _renderId;
  16829. private _multiview;
  16830. private _cachedDefines;
  16831. /**
  16832. * Instantiate a new shader material.
  16833. * 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.
  16834. * This returned material effects how the mesh will look based on the code in the shaders.
  16835. * @see http://doc.babylonjs.com/how_to/shader_material
  16836. * @param name Define the name of the material in the scene
  16837. * @param scene Define the scene the material belongs to
  16838. * @param shaderPath Defines the route to the shader code in one of three ways:
  16839. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16840. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16841. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16842. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16843. * @param options Define the options used to create the shader
  16844. */
  16845. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16846. /**
  16847. * Gets the shader path used to define the shader code
  16848. * It can be modified to trigger a new compilation
  16849. */
  16850. get shaderPath(): any;
  16851. /**
  16852. * Sets the shader path used to define the shader code
  16853. * It can be modified to trigger a new compilation
  16854. */
  16855. set shaderPath(shaderPath: any);
  16856. /**
  16857. * Gets the options used to compile the shader.
  16858. * They can be modified to trigger a new compilation
  16859. */
  16860. get options(): IShaderMaterialOptions;
  16861. /**
  16862. * Gets the current class name of the material e.g. "ShaderMaterial"
  16863. * Mainly use in serialization.
  16864. * @returns the class name
  16865. */
  16866. getClassName(): string;
  16867. /**
  16868. * Specifies if the material will require alpha blending
  16869. * @returns a boolean specifying if alpha blending is needed
  16870. */
  16871. needAlphaBlending(): boolean;
  16872. /**
  16873. * Specifies if this material should be rendered in alpha test mode
  16874. * @returns a boolean specifying if an alpha test is needed.
  16875. */
  16876. needAlphaTesting(): boolean;
  16877. private _checkUniform;
  16878. /**
  16879. * Set a texture in the shader.
  16880. * @param name Define the name of the uniform samplers as defined in the shader
  16881. * @param texture Define the texture to bind to this sampler
  16882. * @return the material itself allowing "fluent" like uniform updates
  16883. */
  16884. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16885. /**
  16886. * Set a texture array in the shader.
  16887. * @param name Define the name of the uniform sampler array as defined in the shader
  16888. * @param textures Define the list of textures to bind to this sampler
  16889. * @return the material itself allowing "fluent" like uniform updates
  16890. */
  16891. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16892. /**
  16893. * Set a float in the shader.
  16894. * @param name Define the name of the uniform as defined in the shader
  16895. * @param value Define the value to give to the uniform
  16896. * @return the material itself allowing "fluent" like uniform updates
  16897. */
  16898. setFloat(name: string, value: number): ShaderMaterial;
  16899. /**
  16900. * Set a int in the shader.
  16901. * @param name Define the name of the uniform as defined in the shader
  16902. * @param value Define the value to give to the uniform
  16903. * @return the material itself allowing "fluent" like uniform updates
  16904. */
  16905. setInt(name: string, value: number): ShaderMaterial;
  16906. /**
  16907. * Set an array of floats in the shader.
  16908. * @param name Define the name of the uniform as defined in the shader
  16909. * @param value Define the value to give to the uniform
  16910. * @return the material itself allowing "fluent" like uniform updates
  16911. */
  16912. setFloats(name: string, value: number[]): ShaderMaterial;
  16913. /**
  16914. * Set a vec3 in the shader from a Color3.
  16915. * @param name Define the name of the uniform as defined in the shader
  16916. * @param value Define the value to give to the uniform
  16917. * @return the material itself allowing "fluent" like uniform updates
  16918. */
  16919. setColor3(name: string, value: Color3): ShaderMaterial;
  16920. /**
  16921. * Set a vec3 array in the shader from a Color3 array.
  16922. * @param name Define the name of the uniform as defined in the shader
  16923. * @param value Define the value to give to the uniform
  16924. * @return the material itself allowing "fluent" like uniform updates
  16925. */
  16926. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16927. /**
  16928. * Set a vec4 in the shader from a Color4.
  16929. * @param name Define the name of the uniform as defined in the shader
  16930. * @param value Define the value to give to the uniform
  16931. * @return the material itself allowing "fluent" like uniform updates
  16932. */
  16933. setColor4(name: string, value: Color4): ShaderMaterial;
  16934. /**
  16935. * Set a vec4 array in the shader from a Color4 array.
  16936. * @param name Define the name of the uniform as defined in the shader
  16937. * @param value Define the value to give to the uniform
  16938. * @return the material itself allowing "fluent" like uniform updates
  16939. */
  16940. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16941. /**
  16942. * Set a vec2 in the shader from a Vector2.
  16943. * @param name Define the name of the uniform as defined in the shader
  16944. * @param value Define the value to give to the uniform
  16945. * @return the material itself allowing "fluent" like uniform updates
  16946. */
  16947. setVector2(name: string, value: Vector2): ShaderMaterial;
  16948. /**
  16949. * Set a vec3 in the shader from a Vector3.
  16950. * @param name Define the name of the uniform as defined in the shader
  16951. * @param value Define the value to give to the uniform
  16952. * @return the material itself allowing "fluent" like uniform updates
  16953. */
  16954. setVector3(name: string, value: Vector3): ShaderMaterial;
  16955. /**
  16956. * Set a vec4 in the shader from a Vector4.
  16957. * @param name Define the name of the uniform as defined in the shader
  16958. * @param value Define the value to give to the uniform
  16959. * @return the material itself allowing "fluent" like uniform updates
  16960. */
  16961. setVector4(name: string, value: Vector4): ShaderMaterial;
  16962. /**
  16963. * Set a mat4 in the shader from a Matrix.
  16964. * @param name Define the name of the uniform as defined in the shader
  16965. * @param value Define the value to give to the uniform
  16966. * @return the material itself allowing "fluent" like uniform updates
  16967. */
  16968. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16969. /**
  16970. * Set a float32Array in the shader from a matrix array.
  16971. * @param name Define the name of the uniform as defined in the shader
  16972. * @param value Define the value to give to the uniform
  16973. * @return the material itself allowing "fluent" like uniform updates
  16974. */
  16975. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16976. /**
  16977. * Set a mat3 in the shader from a Float32Array.
  16978. * @param name Define the name of the uniform as defined in the shader
  16979. * @param value Define the value to give to the uniform
  16980. * @return the material itself allowing "fluent" like uniform updates
  16981. */
  16982. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16983. /**
  16984. * Set a mat2 in the shader from a Float32Array.
  16985. * @param name Define the name of the uniform as defined in the shader
  16986. * @param value Define the value to give to the uniform
  16987. * @return the material itself allowing "fluent" like uniform updates
  16988. */
  16989. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16990. /**
  16991. * Set a vec2 array in the shader from a number array.
  16992. * @param name Define the name of the uniform as defined in the shader
  16993. * @param value Define the value to give to the uniform
  16994. * @return the material itself allowing "fluent" like uniform updates
  16995. */
  16996. setArray2(name: string, value: number[]): ShaderMaterial;
  16997. /**
  16998. * Set a vec3 array in the shader from a number array.
  16999. * @param name Define the name of the uniform as defined in the shader
  17000. * @param value Define the value to give to the uniform
  17001. * @return the material itself allowing "fluent" like uniform updates
  17002. */
  17003. setArray3(name: string, value: number[]): ShaderMaterial;
  17004. /**
  17005. * Set a vec4 array in the shader from a number array.
  17006. * @param name Define the name of the uniform as defined in the shader
  17007. * @param value Define the value to give to the uniform
  17008. * @return the material itself allowing "fluent" like uniform updates
  17009. */
  17010. setArray4(name: string, value: number[]): ShaderMaterial;
  17011. private _checkCache;
  17012. /**
  17013. * Specifies that the submesh is ready to be used
  17014. * @param mesh defines the mesh to check
  17015. * @param subMesh defines which submesh to check
  17016. * @param useInstances specifies that instances should be used
  17017. * @returns a boolean indicating that the submesh is ready or not
  17018. */
  17019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17020. /**
  17021. * Checks if the material is ready to render the requested mesh
  17022. * @param mesh Define the mesh to render
  17023. * @param useInstances Define whether or not the material is used with instances
  17024. * @returns true if ready, otherwise false
  17025. */
  17026. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17027. /**
  17028. * Binds the world matrix to the material
  17029. * @param world defines the world transformation matrix
  17030. * @param effectOverride - If provided, use this effect instead of internal effect
  17031. */
  17032. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17033. /**
  17034. * Binds the submesh to this material by preparing the effect and shader to draw
  17035. * @param world defines the world transformation matrix
  17036. * @param mesh defines the mesh containing the submesh
  17037. * @param subMesh defines the submesh to bind the material to
  17038. */
  17039. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17040. /**
  17041. * Binds the material to the mesh
  17042. * @param world defines the world transformation matrix
  17043. * @param mesh defines the mesh to bind the material to
  17044. * @param effectOverride - If provided, use this effect instead of internal effect
  17045. */
  17046. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17047. protected _afterBind(mesh?: Mesh): void;
  17048. /**
  17049. * Gets the active textures from the material
  17050. * @returns an array of textures
  17051. */
  17052. getActiveTextures(): BaseTexture[];
  17053. /**
  17054. * Specifies if the material uses a texture
  17055. * @param texture defines the texture to check against the material
  17056. * @returns a boolean specifying if the material uses the texture
  17057. */
  17058. hasTexture(texture: BaseTexture): boolean;
  17059. /**
  17060. * Makes a duplicate of the material, and gives it a new name
  17061. * @param name defines the new name for the duplicated material
  17062. * @returns the cloned material
  17063. */
  17064. clone(name: string): ShaderMaterial;
  17065. /**
  17066. * Disposes the material
  17067. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17068. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17069. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17070. */
  17071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17072. /**
  17073. * Serializes this material in a JSON representation
  17074. * @returns the serialized material object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Creates a shader material from parsed shader material data
  17079. * @param source defines the JSON represnetation of the material
  17080. * @param scene defines the hosting scene
  17081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17082. * @returns a new material
  17083. */
  17084. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17085. }
  17086. }
  17087. declare module "babylonjs/Shaders/color.fragment" {
  17088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17090. /** @hidden */
  17091. export var colorPixelShader: {
  17092. name: string;
  17093. shader: string;
  17094. };
  17095. }
  17096. declare module "babylonjs/Shaders/color.vertex" {
  17097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17103. /** @hidden */
  17104. export var colorVertexShader: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Meshes/linesMesh" {
  17110. import { Nullable } from "babylonjs/types";
  17111. import { Scene } from "babylonjs/scene";
  17112. import { Color3 } from "babylonjs/Maths/math.color";
  17113. import { Node } from "babylonjs/node";
  17114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17115. import { Mesh } from "babylonjs/Meshes/mesh";
  17116. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { Material } from "babylonjs/Materials/material";
  17119. import "babylonjs/Shaders/color.fragment";
  17120. import "babylonjs/Shaders/color.vertex";
  17121. /**
  17122. * Line mesh
  17123. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17124. */
  17125. export class LinesMesh extends Mesh {
  17126. /**
  17127. * If vertex color should be applied to the mesh
  17128. */
  17129. readonly useVertexColor?: boolean | undefined;
  17130. /**
  17131. * If vertex alpha should be applied to the mesh
  17132. */
  17133. readonly useVertexAlpha?: boolean | undefined;
  17134. /**
  17135. * Color of the line (Default: White)
  17136. */
  17137. color: Color3;
  17138. /**
  17139. * Alpha of the line (Default: 1)
  17140. */
  17141. alpha: number;
  17142. /**
  17143. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17144. * This margin is expressed in world space coordinates, so its value may vary.
  17145. * Default value is 0.1
  17146. */
  17147. intersectionThreshold: number;
  17148. private _colorShader;
  17149. private color4;
  17150. /**
  17151. * Creates a new LinesMesh
  17152. * @param name defines the name
  17153. * @param scene defines the hosting scene
  17154. * @param parent defines the parent mesh if any
  17155. * @param source defines the optional source LinesMesh used to clone data from
  17156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17157. * When false, achieved by calling a clone(), also passing False.
  17158. * This will make creation of children, recursive.
  17159. * @param useVertexColor defines if this LinesMesh supports vertex color
  17160. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17161. */
  17162. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17163. /**
  17164. * If vertex color should be applied to the mesh
  17165. */
  17166. useVertexColor?: boolean | undefined,
  17167. /**
  17168. * If vertex alpha should be applied to the mesh
  17169. */
  17170. useVertexAlpha?: boolean | undefined);
  17171. private _addClipPlaneDefine;
  17172. private _removeClipPlaneDefine;
  17173. isReady(): boolean;
  17174. /**
  17175. * Returns the string "LineMesh"
  17176. */
  17177. getClassName(): string;
  17178. /**
  17179. * @hidden
  17180. */
  17181. get material(): Material;
  17182. /**
  17183. * @hidden
  17184. */
  17185. set material(value: Material);
  17186. /**
  17187. * @hidden
  17188. */
  17189. get checkCollisions(): boolean;
  17190. /** @hidden */
  17191. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17192. /** @hidden */
  17193. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17194. /**
  17195. * Disposes of the line mesh
  17196. * @param doNotRecurse If children should be disposed
  17197. */
  17198. dispose(doNotRecurse?: boolean): void;
  17199. /**
  17200. * Returns a new LineMesh object cloned from the current one.
  17201. */
  17202. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17203. /**
  17204. * Creates a new InstancedLinesMesh object from the mesh model.
  17205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17206. * @param name defines the name of the new instance
  17207. * @returns a new InstancedLinesMesh
  17208. */
  17209. createInstance(name: string): InstancedLinesMesh;
  17210. }
  17211. /**
  17212. * Creates an instance based on a source LinesMesh
  17213. */
  17214. export class InstancedLinesMesh extends InstancedMesh {
  17215. /**
  17216. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17217. * This margin is expressed in world space coordinates, so its value may vary.
  17218. * Initilized with the intersectionThreshold value of the source LinesMesh
  17219. */
  17220. intersectionThreshold: number;
  17221. constructor(name: string, source: LinesMesh);
  17222. /**
  17223. * Returns the string "InstancedLinesMesh".
  17224. */
  17225. getClassName(): string;
  17226. }
  17227. }
  17228. declare module "babylonjs/Shaders/line.fragment" {
  17229. /** @hidden */
  17230. export var linePixelShader: {
  17231. name: string;
  17232. shader: string;
  17233. };
  17234. }
  17235. declare module "babylonjs/Shaders/line.vertex" {
  17236. /** @hidden */
  17237. export var lineVertexShader: {
  17238. name: string;
  17239. shader: string;
  17240. };
  17241. }
  17242. declare module "babylonjs/Rendering/edgesRenderer" {
  17243. import { Nullable } from "babylonjs/types";
  17244. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17246. import { Vector3 } from "babylonjs/Maths/math.vector";
  17247. import { IDisposable } from "babylonjs/scene";
  17248. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17249. import "babylonjs/Shaders/line.fragment";
  17250. import "babylonjs/Shaders/line.vertex";
  17251. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17252. module "babylonjs/Meshes/abstractMesh" {
  17253. interface AbstractMesh {
  17254. /**
  17255. * Gets the edgesRenderer associated with the mesh
  17256. */
  17257. edgesRenderer: Nullable<EdgesRenderer>;
  17258. }
  17259. }
  17260. module "babylonjs/Meshes/linesMesh" {
  17261. interface LinesMesh {
  17262. /**
  17263. * Enables the edge rendering mode on the mesh.
  17264. * This mode makes the mesh edges visible
  17265. * @param epsilon defines the maximal distance between two angles to detect a face
  17266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17267. * @returns the currentAbstractMesh
  17268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17269. */
  17270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17271. }
  17272. }
  17273. module "babylonjs/Meshes/linesMesh" {
  17274. interface InstancedLinesMesh {
  17275. /**
  17276. * Enables the edge rendering mode on the mesh.
  17277. * This mode makes the mesh edges visible
  17278. * @param epsilon defines the maximal distance between two angles to detect a face
  17279. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17280. * @returns the current InstancedLinesMesh
  17281. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17282. */
  17283. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17284. }
  17285. }
  17286. /**
  17287. * Defines the minimum contract an Edges renderer should follow.
  17288. */
  17289. export interface IEdgesRenderer extends IDisposable {
  17290. /**
  17291. * Gets or sets a boolean indicating if the edgesRenderer is active
  17292. */
  17293. isEnabled: boolean;
  17294. /**
  17295. * Renders the edges of the attached mesh,
  17296. */
  17297. render(): void;
  17298. /**
  17299. * Checks wether or not the edges renderer is ready to render.
  17300. * @return true if ready, otherwise false.
  17301. */
  17302. isReady(): boolean;
  17303. }
  17304. /**
  17305. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17306. */
  17307. export class EdgesRenderer implements IEdgesRenderer {
  17308. /**
  17309. * Define the size of the edges with an orthographic camera
  17310. */
  17311. edgesWidthScalerForOrthographic: number;
  17312. /**
  17313. * Define the size of the edges with a perspective camera
  17314. */
  17315. edgesWidthScalerForPerspective: number;
  17316. protected _source: AbstractMesh;
  17317. protected _linesPositions: number[];
  17318. protected _linesNormals: number[];
  17319. protected _linesIndices: number[];
  17320. protected _epsilon: number;
  17321. protected _indicesCount: number;
  17322. protected _lineShader: ShaderMaterial;
  17323. protected _ib: DataBuffer;
  17324. protected _buffers: {
  17325. [key: string]: Nullable<VertexBuffer>;
  17326. };
  17327. protected _checkVerticesInsteadOfIndices: boolean;
  17328. private _meshRebuildObserver;
  17329. private _meshDisposeObserver;
  17330. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17331. isEnabled: boolean;
  17332. /**
  17333. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17334. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17335. * @param source Mesh used to create edges
  17336. * @param epsilon sum of angles in adjacency to check for edge
  17337. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17338. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17339. */
  17340. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17341. protected _prepareRessources(): void;
  17342. /** @hidden */
  17343. _rebuild(): void;
  17344. /**
  17345. * Releases the required resources for the edges renderer
  17346. */
  17347. dispose(): void;
  17348. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17349. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17350. /**
  17351. * Checks if the pair of p0 and p1 is en edge
  17352. * @param faceIndex
  17353. * @param edge
  17354. * @param faceNormals
  17355. * @param p0
  17356. * @param p1
  17357. * @private
  17358. */
  17359. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17360. /**
  17361. * push line into the position, normal and index buffer
  17362. * @protected
  17363. */
  17364. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17365. /**
  17366. * Generates lines edges from adjacencjes
  17367. * @private
  17368. */
  17369. _generateEdgesLines(): void;
  17370. /**
  17371. * Checks wether or not the edges renderer is ready to render.
  17372. * @return true if ready, otherwise false.
  17373. */
  17374. isReady(): boolean;
  17375. /**
  17376. * Renders the edges of the attached mesh,
  17377. */
  17378. render(): void;
  17379. }
  17380. /**
  17381. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17382. */
  17383. export class LineEdgesRenderer extends EdgesRenderer {
  17384. /**
  17385. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17386. * @param source LineMesh used to generate edges
  17387. * @param epsilon not important (specified angle for edge detection)
  17388. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17389. */
  17390. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17391. /**
  17392. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17393. */
  17394. _generateEdgesLines(): void;
  17395. }
  17396. }
  17397. declare module "babylonjs/Rendering/renderingGroup" {
  17398. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17401. import { Nullable } from "babylonjs/types";
  17402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17403. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17404. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17405. import { Material } from "babylonjs/Materials/material";
  17406. import { Scene } from "babylonjs/scene";
  17407. /**
  17408. * This represents the object necessary to create a rendering group.
  17409. * This is exclusively used and created by the rendering manager.
  17410. * To modify the behavior, you use the available helpers in your scene or meshes.
  17411. * @hidden
  17412. */
  17413. export class RenderingGroup {
  17414. index: number;
  17415. private static _zeroVector;
  17416. private _scene;
  17417. private _opaqueSubMeshes;
  17418. private _transparentSubMeshes;
  17419. private _alphaTestSubMeshes;
  17420. private _depthOnlySubMeshes;
  17421. private _particleSystems;
  17422. private _spriteManagers;
  17423. private _opaqueSortCompareFn;
  17424. private _alphaTestSortCompareFn;
  17425. private _transparentSortCompareFn;
  17426. private _renderOpaque;
  17427. private _renderAlphaTest;
  17428. private _renderTransparent;
  17429. /** @hidden */
  17430. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17431. onBeforeTransparentRendering: () => void;
  17432. /**
  17433. * Set the opaque sort comparison function.
  17434. * If null the sub meshes will be render in the order they were created
  17435. */
  17436. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17437. /**
  17438. * Set the alpha test sort comparison function.
  17439. * If null the sub meshes will be render in the order they were created
  17440. */
  17441. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17442. /**
  17443. * Set the transparent sort comparison function.
  17444. * If null the sub meshes will be render in the order they were created
  17445. */
  17446. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17447. /**
  17448. * Creates a new rendering group.
  17449. * @param index The rendering group index
  17450. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17451. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17452. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17453. */
  17454. 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>);
  17455. /**
  17456. * Render all the sub meshes contained in the group.
  17457. * @param customRenderFunction Used to override the default render behaviour of the group.
  17458. * @returns true if rendered some submeshes.
  17459. */
  17460. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17461. /**
  17462. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17463. * @param subMeshes The submeshes to render
  17464. */
  17465. private renderOpaqueSorted;
  17466. /**
  17467. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17468. * @param subMeshes The submeshes to render
  17469. */
  17470. private renderAlphaTestSorted;
  17471. /**
  17472. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17473. * @param subMeshes The submeshes to render
  17474. */
  17475. private renderTransparentSorted;
  17476. /**
  17477. * Renders the submeshes in a specified order.
  17478. * @param subMeshes The submeshes to sort before render
  17479. * @param sortCompareFn The comparison function use to sort
  17480. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17481. * @param transparent Specifies to activate blending if true
  17482. */
  17483. private static renderSorted;
  17484. /**
  17485. * Renders the submeshes in the order they were dispatched (no sort applied).
  17486. * @param subMeshes The submeshes to render
  17487. */
  17488. private static renderUnsorted;
  17489. /**
  17490. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17491. * are rendered back to front if in the same alpha index.
  17492. *
  17493. * @param a The first submesh
  17494. * @param b The second submesh
  17495. * @returns The result of the comparison
  17496. */
  17497. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17498. /**
  17499. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17500. * are rendered back to front.
  17501. *
  17502. * @param a The first submesh
  17503. * @param b The second submesh
  17504. * @returns The result of the comparison
  17505. */
  17506. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17507. /**
  17508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17509. * are rendered front to back (prevent overdraw).
  17510. *
  17511. * @param a The first submesh
  17512. * @param b The second submesh
  17513. * @returns The result of the comparison
  17514. */
  17515. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17516. /**
  17517. * Resets the different lists of submeshes to prepare a new frame.
  17518. */
  17519. prepare(): void;
  17520. dispose(): void;
  17521. /**
  17522. * Inserts the submesh in its correct queue depending on its material.
  17523. * @param subMesh The submesh to dispatch
  17524. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17525. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17526. */
  17527. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17528. dispatchSprites(spriteManager: ISpriteManager): void;
  17529. dispatchParticles(particleSystem: IParticleSystem): void;
  17530. private _renderParticles;
  17531. private _renderSprites;
  17532. }
  17533. }
  17534. declare module "babylonjs/Rendering/renderingManager" {
  17535. import { Nullable } from "babylonjs/types";
  17536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17538. import { SmartArray } from "babylonjs/Misc/smartArray";
  17539. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { Material } from "babylonjs/Materials/material";
  17542. import { Scene } from "babylonjs/scene";
  17543. import { Camera } from "babylonjs/Cameras/camera";
  17544. /**
  17545. * Interface describing the different options available in the rendering manager
  17546. * regarding Auto Clear between groups.
  17547. */
  17548. export interface IRenderingManagerAutoClearSetup {
  17549. /**
  17550. * Defines whether or not autoclear is enable.
  17551. */
  17552. autoClear: boolean;
  17553. /**
  17554. * Defines whether or not to autoclear the depth buffer.
  17555. */
  17556. depth: boolean;
  17557. /**
  17558. * Defines whether or not to autoclear the stencil buffer.
  17559. */
  17560. stencil: boolean;
  17561. }
  17562. /**
  17563. * This class is used by the onRenderingGroupObservable
  17564. */
  17565. export class RenderingGroupInfo {
  17566. /**
  17567. * The Scene that being rendered
  17568. */
  17569. scene: Scene;
  17570. /**
  17571. * The camera currently used for the rendering pass
  17572. */
  17573. camera: Nullable<Camera>;
  17574. /**
  17575. * The ID of the renderingGroup being processed
  17576. */
  17577. renderingGroupId: number;
  17578. }
  17579. /**
  17580. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17581. * It is enable to manage the different groups as well as the different necessary sort functions.
  17582. * This should not be used directly aside of the few static configurations
  17583. */
  17584. export class RenderingManager {
  17585. /**
  17586. * The max id used for rendering groups (not included)
  17587. */
  17588. static MAX_RENDERINGGROUPS: number;
  17589. /**
  17590. * The min id used for rendering groups (included)
  17591. */
  17592. static MIN_RENDERINGGROUPS: number;
  17593. /**
  17594. * Used to globally prevent autoclearing scenes.
  17595. */
  17596. static AUTOCLEAR: boolean;
  17597. /**
  17598. * @hidden
  17599. */
  17600. _useSceneAutoClearSetup: boolean;
  17601. private _scene;
  17602. private _renderingGroups;
  17603. private _depthStencilBufferAlreadyCleaned;
  17604. private _autoClearDepthStencil;
  17605. private _customOpaqueSortCompareFn;
  17606. private _customAlphaTestSortCompareFn;
  17607. private _customTransparentSortCompareFn;
  17608. private _renderingGroupInfo;
  17609. /**
  17610. * Instantiates a new rendering group for a particular scene
  17611. * @param scene Defines the scene the groups belongs to
  17612. */
  17613. constructor(scene: Scene);
  17614. private _clearDepthStencilBuffer;
  17615. /**
  17616. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17617. * @hidden
  17618. */
  17619. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17620. /**
  17621. * Resets the different information of the group to prepare a new frame
  17622. * @hidden
  17623. */
  17624. reset(): void;
  17625. /**
  17626. * Dispose and release the group and its associated resources.
  17627. * @hidden
  17628. */
  17629. dispose(): void;
  17630. /**
  17631. * Clear the info related to rendering groups preventing retention points during dispose.
  17632. */
  17633. freeRenderingGroups(): void;
  17634. private _prepareRenderingGroup;
  17635. /**
  17636. * Add a sprite manager to the rendering manager in order to render it this frame.
  17637. * @param spriteManager Define the sprite manager to render
  17638. */
  17639. dispatchSprites(spriteManager: ISpriteManager): void;
  17640. /**
  17641. * Add a particle system to the rendering manager in order to render it this frame.
  17642. * @param particleSystem Define the particle system to render
  17643. */
  17644. dispatchParticles(particleSystem: IParticleSystem): void;
  17645. /**
  17646. * Add a submesh to the manager in order to render it this frame
  17647. * @param subMesh The submesh to dispatch
  17648. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17649. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17650. */
  17651. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17652. /**
  17653. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17654. * This allowed control for front to back rendering or reversly depending of the special needs.
  17655. *
  17656. * @param renderingGroupId The rendering group id corresponding to its index
  17657. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17658. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17659. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17660. */
  17661. 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;
  17662. /**
  17663. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17664. *
  17665. * @param renderingGroupId The rendering group id corresponding to its index
  17666. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17667. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17668. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17669. */
  17670. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17671. /**
  17672. * Gets the current auto clear configuration for one rendering group of the rendering
  17673. * manager.
  17674. * @param index the rendering group index to get the information for
  17675. * @returns The auto clear setup for the requested rendering group
  17676. */
  17677. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17678. }
  17679. }
  17680. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17681. import { SmartArray } from "babylonjs/Misc/smartArray";
  17682. import { Nullable } from "babylonjs/types";
  17683. import { Scene } from "babylonjs/scene";
  17684. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17685. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17687. import { Mesh } from "babylonjs/Meshes/mesh";
  17688. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17689. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17690. import { Effect } from "babylonjs/Materials/effect";
  17691. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17692. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17693. import "babylonjs/Shaders/shadowMap.fragment";
  17694. import "babylonjs/Shaders/shadowMap.vertex";
  17695. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17696. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17697. import { Observable } from "babylonjs/Misc/observable";
  17698. /**
  17699. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17700. */
  17701. export interface ICustomShaderOptions {
  17702. /**
  17703. * Gets or sets the custom shader name to use
  17704. */
  17705. shaderName: string;
  17706. /**
  17707. * The list of attribute names used in the shader
  17708. */
  17709. attributes?: string[];
  17710. /**
  17711. * The list of unifrom names used in the shader
  17712. */
  17713. uniforms?: string[];
  17714. /**
  17715. * The list of sampler names used in the shader
  17716. */
  17717. samplers?: string[];
  17718. /**
  17719. * The list of defines used in the shader
  17720. */
  17721. defines?: string[];
  17722. }
  17723. /**
  17724. * Interface to implement to create a shadow generator compatible with BJS.
  17725. */
  17726. export interface IShadowGenerator {
  17727. /**
  17728. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17729. * @returns The render target texture if present otherwise, null
  17730. */
  17731. getShadowMap(): Nullable<RenderTargetTexture>;
  17732. /**
  17733. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17734. * @param subMesh The submesh we want to render in the shadow map
  17735. * @param useInstances Defines wether will draw in the map using instances
  17736. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17737. * @returns true if ready otherwise, false
  17738. */
  17739. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17740. /**
  17741. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17742. * @param defines Defines of the material we want to update
  17743. * @param lightIndex Index of the light in the enabled light list of the material
  17744. */
  17745. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17746. /**
  17747. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17748. * defined in the generator but impacting the effect).
  17749. * It implies the unifroms available on the materials are the standard BJS ones.
  17750. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17751. * @param effect The effect we are binfing the information for
  17752. */
  17753. bindShadowLight(lightIndex: string, effect: Effect): void;
  17754. /**
  17755. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17756. * (eq to shadow prjection matrix * light transform matrix)
  17757. * @returns The transform matrix used to create the shadow map
  17758. */
  17759. getTransformMatrix(): Matrix;
  17760. /**
  17761. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17762. * Cube and 2D textures for instance.
  17763. */
  17764. recreateShadowMap(): void;
  17765. /**
  17766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17767. * @param onCompiled Callback triggered at the and of the effects compilation
  17768. * @param options Sets of optional options forcing the compilation with different modes
  17769. */
  17770. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17771. useInstances: boolean;
  17772. }>): void;
  17773. /**
  17774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17775. * @param options Sets of optional options forcing the compilation with different modes
  17776. * @returns A promise that resolves when the compilation completes
  17777. */
  17778. forceCompilationAsync(options?: Partial<{
  17779. useInstances: boolean;
  17780. }>): Promise<void>;
  17781. /**
  17782. * Serializes the shadow generator setup to a json object.
  17783. * @returns The serialized JSON object
  17784. */
  17785. serialize(): any;
  17786. /**
  17787. * Disposes the Shadow map and related Textures and effects.
  17788. */
  17789. dispose(): void;
  17790. }
  17791. /**
  17792. * Default implementation IShadowGenerator.
  17793. * This is the main object responsible of generating shadows in the framework.
  17794. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17795. */
  17796. export class ShadowGenerator implements IShadowGenerator {
  17797. /**
  17798. * Name of the shadow generator class
  17799. */
  17800. static CLASSNAME: string;
  17801. /**
  17802. * Shadow generator mode None: no filtering applied.
  17803. */
  17804. static readonly FILTER_NONE: number;
  17805. /**
  17806. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17807. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17808. */
  17809. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17810. /**
  17811. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17812. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17813. */
  17814. static readonly FILTER_POISSONSAMPLING: number;
  17815. /**
  17816. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17817. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17818. */
  17819. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17820. /**
  17821. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17822. * edge artifacts on steep falloff.
  17823. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17824. */
  17825. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17826. /**
  17827. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17828. * edge artifacts on steep falloff.
  17829. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17830. */
  17831. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17832. /**
  17833. * Shadow generator mode PCF: Percentage Closer Filtering
  17834. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17835. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17836. */
  17837. static readonly FILTER_PCF: number;
  17838. /**
  17839. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17840. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17841. * Contact Hardening
  17842. */
  17843. static readonly FILTER_PCSS: number;
  17844. /**
  17845. * Reserved for PCF and PCSS
  17846. * Highest Quality.
  17847. *
  17848. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17849. *
  17850. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17851. */
  17852. static readonly QUALITY_HIGH: number;
  17853. /**
  17854. * Reserved for PCF and PCSS
  17855. * Good tradeoff for quality/perf cross devices
  17856. *
  17857. * Execute PCF on a 3*3 kernel.
  17858. *
  17859. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17860. */
  17861. static readonly QUALITY_MEDIUM: number;
  17862. /**
  17863. * Reserved for PCF and PCSS
  17864. * The lowest quality but the fastest.
  17865. *
  17866. * Execute PCF on a 1*1 kernel.
  17867. *
  17868. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17869. */
  17870. static readonly QUALITY_LOW: number;
  17871. /** Gets or sets the custom shader name to use */
  17872. customShaderOptions: ICustomShaderOptions;
  17873. /**
  17874. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17875. */
  17876. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17877. /**
  17878. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17879. */
  17880. onAfterShadowMapRenderObservable: Observable<Effect>;
  17881. /**
  17882. * Observable triggered before a mesh is rendered in the shadow map.
  17883. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17884. */
  17885. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17886. /**
  17887. * Observable triggered after a mesh is rendered in the shadow map.
  17888. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17889. */
  17890. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17891. protected _bias: number;
  17892. /**
  17893. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17894. */
  17895. get bias(): number;
  17896. /**
  17897. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17898. */
  17899. set bias(bias: number);
  17900. protected _normalBias: number;
  17901. /**
  17902. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17903. */
  17904. get normalBias(): number;
  17905. /**
  17906. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17907. */
  17908. set normalBias(normalBias: number);
  17909. protected _blurBoxOffset: number;
  17910. /**
  17911. * Gets the blur box offset: offset applied during the blur pass.
  17912. * Only useful if useKernelBlur = false
  17913. */
  17914. get blurBoxOffset(): number;
  17915. /**
  17916. * Sets the blur box offset: offset applied during the blur pass.
  17917. * Only useful if useKernelBlur = false
  17918. */
  17919. set blurBoxOffset(value: number);
  17920. protected _blurScale: number;
  17921. /**
  17922. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17923. * 2 means half of the size.
  17924. */
  17925. get blurScale(): number;
  17926. /**
  17927. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17928. * 2 means half of the size.
  17929. */
  17930. set blurScale(value: number);
  17931. protected _blurKernel: number;
  17932. /**
  17933. * Gets the blur kernel: kernel size of the blur pass.
  17934. * Only useful if useKernelBlur = true
  17935. */
  17936. get blurKernel(): number;
  17937. /**
  17938. * Sets the blur kernel: kernel size of the blur pass.
  17939. * Only useful if useKernelBlur = true
  17940. */
  17941. set blurKernel(value: number);
  17942. protected _useKernelBlur: boolean;
  17943. /**
  17944. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17945. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17946. */
  17947. get useKernelBlur(): boolean;
  17948. /**
  17949. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17950. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17951. */
  17952. set useKernelBlur(value: boolean);
  17953. protected _depthScale: number;
  17954. /**
  17955. * Gets the depth scale used in ESM mode.
  17956. */
  17957. get depthScale(): number;
  17958. /**
  17959. * Sets the depth scale used in ESM mode.
  17960. * This can override the scale stored on the light.
  17961. */
  17962. set depthScale(value: number);
  17963. protected _validateFilter(filter: number): number;
  17964. protected _filter: number;
  17965. /**
  17966. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17967. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17968. */
  17969. get filter(): number;
  17970. /**
  17971. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17972. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17973. */
  17974. set filter(value: number);
  17975. /**
  17976. * Gets if the current filter is set to Poisson Sampling.
  17977. */
  17978. get usePoissonSampling(): boolean;
  17979. /**
  17980. * Sets the current filter to Poisson Sampling.
  17981. */
  17982. set usePoissonSampling(value: boolean);
  17983. /**
  17984. * Gets if the current filter is set to ESM.
  17985. */
  17986. get useExponentialShadowMap(): boolean;
  17987. /**
  17988. * Sets the current filter is to ESM.
  17989. */
  17990. set useExponentialShadowMap(value: boolean);
  17991. /**
  17992. * Gets if the current filter is set to filtered ESM.
  17993. */
  17994. get useBlurExponentialShadowMap(): boolean;
  17995. /**
  17996. * Gets if the current filter is set to filtered ESM.
  17997. */
  17998. set useBlurExponentialShadowMap(value: boolean);
  17999. /**
  18000. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18001. * exponential to prevent steep falloff artifacts).
  18002. */
  18003. get useCloseExponentialShadowMap(): boolean;
  18004. /**
  18005. * Sets the current filter to "close ESM" (using the inverse of the
  18006. * exponential to prevent steep falloff artifacts).
  18007. */
  18008. set useCloseExponentialShadowMap(value: boolean);
  18009. /**
  18010. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18011. * exponential to prevent steep falloff artifacts).
  18012. */
  18013. get useBlurCloseExponentialShadowMap(): boolean;
  18014. /**
  18015. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18016. * exponential to prevent steep falloff artifacts).
  18017. */
  18018. set useBlurCloseExponentialShadowMap(value: boolean);
  18019. /**
  18020. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18021. */
  18022. get usePercentageCloserFiltering(): boolean;
  18023. /**
  18024. * Sets the current filter to "PCF" (percentage closer filtering).
  18025. */
  18026. set usePercentageCloserFiltering(value: boolean);
  18027. protected _filteringQuality: number;
  18028. /**
  18029. * Gets the PCF or PCSS Quality.
  18030. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18031. */
  18032. get filteringQuality(): number;
  18033. /**
  18034. * Sets the PCF or PCSS Quality.
  18035. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18036. */
  18037. set filteringQuality(filteringQuality: number);
  18038. /**
  18039. * Gets if the current filter is set to "PCSS" (contact hardening).
  18040. */
  18041. get useContactHardeningShadow(): boolean;
  18042. /**
  18043. * Sets the current filter to "PCSS" (contact hardening).
  18044. */
  18045. set useContactHardeningShadow(value: boolean);
  18046. protected _contactHardeningLightSizeUVRatio: number;
  18047. /**
  18048. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18049. * Using a ratio helps keeping shape stability independently of the map size.
  18050. *
  18051. * It does not account for the light projection as it was having too much
  18052. * instability during the light setup or during light position changes.
  18053. *
  18054. * Only valid if useContactHardeningShadow is true.
  18055. */
  18056. get contactHardeningLightSizeUVRatio(): number;
  18057. /**
  18058. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18059. * Using a ratio helps keeping shape stability independently of the map size.
  18060. *
  18061. * It does not account for the light projection as it was having too much
  18062. * instability during the light setup or during light position changes.
  18063. *
  18064. * Only valid if useContactHardeningShadow is true.
  18065. */
  18066. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18067. protected _darkness: number;
  18068. /** Gets or sets the actual darkness of a shadow */
  18069. get darkness(): number;
  18070. set darkness(value: number);
  18071. /**
  18072. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18073. * 0 means strongest and 1 would means no shadow.
  18074. * @returns the darkness.
  18075. */
  18076. getDarkness(): number;
  18077. /**
  18078. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18079. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18080. * @returns the shadow generator allowing fluent coding.
  18081. */
  18082. setDarkness(darkness: number): ShadowGenerator;
  18083. protected _transparencyShadow: boolean;
  18084. /** Gets or sets the ability to have transparent shadow */
  18085. get transparencyShadow(): boolean;
  18086. set transparencyShadow(value: boolean);
  18087. /**
  18088. * Sets the ability to have transparent shadow (boolean).
  18089. * @param transparent True if transparent else False
  18090. * @returns the shadow generator allowing fluent coding
  18091. */
  18092. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18093. /**
  18094. * Enables or disables shadows with varying strength based on the transparency
  18095. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18096. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18097. * mesh.visibility * alphaTexture.a
  18098. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18099. */
  18100. enableSoftTransparentShadow: boolean;
  18101. protected _shadowMap: Nullable<RenderTargetTexture>;
  18102. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18103. /**
  18104. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18105. * @returns The render target texture if present otherwise, null
  18106. */
  18107. getShadowMap(): Nullable<RenderTargetTexture>;
  18108. /**
  18109. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18110. * @returns The render target texture if the shadow map is present otherwise, null
  18111. */
  18112. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18113. /**
  18114. * Gets the class name of that object
  18115. * @returns "ShadowGenerator"
  18116. */
  18117. getClassName(): string;
  18118. /**
  18119. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18120. * @param mesh Mesh to add
  18121. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18122. * @returns the Shadow Generator itself
  18123. */
  18124. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18125. /**
  18126. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18127. * @param mesh Mesh to remove
  18128. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18129. * @returns the Shadow Generator itself
  18130. */
  18131. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18132. /**
  18133. * Controls the extent to which the shadows fade out at the edge of the frustum
  18134. */
  18135. frustumEdgeFalloff: number;
  18136. protected _light: IShadowLight;
  18137. /**
  18138. * Returns the associated light object.
  18139. * @returns the light generating the shadow
  18140. */
  18141. getLight(): IShadowLight;
  18142. /**
  18143. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18144. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18145. * It might on the other hand introduce peter panning.
  18146. */
  18147. forceBackFacesOnly: boolean;
  18148. protected _scene: Scene;
  18149. protected _lightDirection: Vector3;
  18150. protected _effect: Effect;
  18151. protected _viewMatrix: Matrix;
  18152. protected _projectionMatrix: Matrix;
  18153. protected _transformMatrix: Matrix;
  18154. protected _cachedPosition: Vector3;
  18155. protected _cachedDirection: Vector3;
  18156. protected _cachedDefines: string;
  18157. protected _currentRenderID: number;
  18158. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18159. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18160. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18161. protected _blurPostProcesses: PostProcess[];
  18162. protected _mapSize: number;
  18163. protected _currentFaceIndex: number;
  18164. protected _currentFaceIndexCache: number;
  18165. protected _textureType: number;
  18166. protected _defaultTextureMatrix: Matrix;
  18167. protected _storedUniqueId: Nullable<number>;
  18168. /** @hidden */
  18169. static _SceneComponentInitialization: (scene: Scene) => void;
  18170. /**
  18171. * Creates a ShadowGenerator object.
  18172. * A ShadowGenerator is the required tool to use the shadows.
  18173. * Each light casting shadows needs to use its own ShadowGenerator.
  18174. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18175. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18176. * @param light The light object generating the shadows.
  18177. * @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.
  18178. */
  18179. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18180. protected _initializeGenerator(): void;
  18181. protected _createTargetRenderTexture(): void;
  18182. protected _initializeShadowMap(): void;
  18183. protected _initializeBlurRTTAndPostProcesses(): void;
  18184. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18185. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18186. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18187. protected _applyFilterValues(): void;
  18188. /**
  18189. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18190. * @param onCompiled Callback triggered at the and of the effects compilation
  18191. * @param options Sets of optional options forcing the compilation with different modes
  18192. */
  18193. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18194. useInstances: boolean;
  18195. }>): void;
  18196. /**
  18197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18198. * @param options Sets of optional options forcing the compilation with different modes
  18199. * @returns A promise that resolves when the compilation completes
  18200. */
  18201. forceCompilationAsync(options?: Partial<{
  18202. useInstances: boolean;
  18203. }>): Promise<void>;
  18204. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18205. private _prepareShadowDefines;
  18206. /**
  18207. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18208. * @param subMesh The submesh we want to render in the shadow map
  18209. * @param useInstances Defines wether will draw in the map using instances
  18210. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18211. * @returns true if ready otherwise, false
  18212. */
  18213. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18214. /**
  18215. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18216. * @param defines Defines of the material we want to update
  18217. * @param lightIndex Index of the light in the enabled light list of the material
  18218. */
  18219. prepareDefines(defines: any, lightIndex: number): void;
  18220. /**
  18221. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18222. * defined in the generator but impacting the effect).
  18223. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18224. * @param effect The effect we are binfing the information for
  18225. */
  18226. bindShadowLight(lightIndex: string, effect: Effect): void;
  18227. /**
  18228. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18229. * (eq to shadow prjection matrix * light transform matrix)
  18230. * @returns The transform matrix used to create the shadow map
  18231. */
  18232. getTransformMatrix(): Matrix;
  18233. /**
  18234. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18235. * Cube and 2D textures for instance.
  18236. */
  18237. recreateShadowMap(): void;
  18238. protected _disposeBlurPostProcesses(): void;
  18239. protected _disposeRTTandPostProcesses(): void;
  18240. /**
  18241. * Disposes the ShadowGenerator.
  18242. * Returns nothing.
  18243. */
  18244. dispose(): void;
  18245. /**
  18246. * Serializes the shadow generator setup to a json object.
  18247. * @returns The serialized JSON object
  18248. */
  18249. serialize(): any;
  18250. /**
  18251. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18252. * @param parsedShadowGenerator The JSON object to parse
  18253. * @param scene The scene to create the shadow map for
  18254. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18255. * @returns The parsed shadow generator
  18256. */
  18257. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18258. }
  18259. }
  18260. declare module "babylonjs/Lights/light" {
  18261. import { Nullable } from "babylonjs/types";
  18262. import { Scene } from "babylonjs/scene";
  18263. import { Vector3 } from "babylonjs/Maths/math.vector";
  18264. import { Color3 } from "babylonjs/Maths/math.color";
  18265. import { Node } from "babylonjs/node";
  18266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18267. import { Effect } from "babylonjs/Materials/effect";
  18268. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18269. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18270. /**
  18271. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18272. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18273. * 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.
  18274. */
  18275. export abstract class Light extends Node {
  18276. /**
  18277. * Falloff Default: light is falling off following the material specification:
  18278. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18279. */
  18280. static readonly FALLOFF_DEFAULT: number;
  18281. /**
  18282. * Falloff Physical: light is falling off following the inverse squared distance law.
  18283. */
  18284. static readonly FALLOFF_PHYSICAL: number;
  18285. /**
  18286. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18287. * to enhance interoperability with other engines.
  18288. */
  18289. static readonly FALLOFF_GLTF: number;
  18290. /**
  18291. * Falloff Standard: light is falling off like in the standard material
  18292. * to enhance interoperability with other materials.
  18293. */
  18294. static readonly FALLOFF_STANDARD: number;
  18295. /**
  18296. * If every light affecting the material is in this lightmapMode,
  18297. * material.lightmapTexture adds or multiplies
  18298. * (depends on material.useLightmapAsShadowmap)
  18299. * after every other light calculations.
  18300. */
  18301. static readonly LIGHTMAP_DEFAULT: number;
  18302. /**
  18303. * material.lightmapTexture as only diffuse lighting from this light
  18304. * adds only specular lighting from this light
  18305. * adds dynamic shadows
  18306. */
  18307. static readonly LIGHTMAP_SPECULAR: number;
  18308. /**
  18309. * material.lightmapTexture as only lighting
  18310. * no light calculation from this light
  18311. * only adds dynamic shadows from this light
  18312. */
  18313. static readonly LIGHTMAP_SHADOWSONLY: number;
  18314. /**
  18315. * Each light type uses the default quantity according to its type:
  18316. * point/spot lights use luminous intensity
  18317. * directional lights use illuminance
  18318. */
  18319. static readonly INTENSITYMODE_AUTOMATIC: number;
  18320. /**
  18321. * lumen (lm)
  18322. */
  18323. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18324. /**
  18325. * candela (lm/sr)
  18326. */
  18327. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18328. /**
  18329. * lux (lm/m^2)
  18330. */
  18331. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18332. /**
  18333. * nit (cd/m^2)
  18334. */
  18335. static readonly INTENSITYMODE_LUMINANCE: number;
  18336. /**
  18337. * Light type const id of the point light.
  18338. */
  18339. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18340. /**
  18341. * Light type const id of the directional light.
  18342. */
  18343. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18344. /**
  18345. * Light type const id of the spot light.
  18346. */
  18347. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18348. /**
  18349. * Light type const id of the hemispheric light.
  18350. */
  18351. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18352. /**
  18353. * Diffuse gives the basic color to an object.
  18354. */
  18355. diffuse: Color3;
  18356. /**
  18357. * Specular produces a highlight color on an object.
  18358. * Note: This is note affecting PBR materials.
  18359. */
  18360. specular: Color3;
  18361. /**
  18362. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18363. * falling off base on range or angle.
  18364. * This can be set to any values in Light.FALLOFF_x.
  18365. *
  18366. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18367. * other types of materials.
  18368. */
  18369. falloffType: number;
  18370. /**
  18371. * Strength of the light.
  18372. * Note: By default it is define in the framework own unit.
  18373. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18374. */
  18375. intensity: number;
  18376. private _range;
  18377. protected _inverseSquaredRange: number;
  18378. /**
  18379. * Defines how far from the source the light is impacting in scene units.
  18380. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18381. */
  18382. get range(): number;
  18383. /**
  18384. * Defines how far from the source the light is impacting in scene units.
  18385. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18386. */
  18387. set range(value: number);
  18388. /**
  18389. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18390. * of light.
  18391. */
  18392. private _photometricScale;
  18393. private _intensityMode;
  18394. /**
  18395. * Gets the photometric scale used to interpret the intensity.
  18396. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18397. */
  18398. get intensityMode(): number;
  18399. /**
  18400. * Sets the photometric scale used to interpret the intensity.
  18401. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18402. */
  18403. set intensityMode(value: number);
  18404. private _radius;
  18405. /**
  18406. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18407. */
  18408. get radius(): number;
  18409. /**
  18410. * sets the light radius used by PBR Materials to simulate soft area lights.
  18411. */
  18412. set radius(value: number);
  18413. private _renderPriority;
  18414. /**
  18415. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18416. * exceeding the number allowed of the materials.
  18417. */
  18418. renderPriority: number;
  18419. private _shadowEnabled;
  18420. /**
  18421. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18422. * the current shadow generator.
  18423. */
  18424. get shadowEnabled(): boolean;
  18425. /**
  18426. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18427. * the current shadow generator.
  18428. */
  18429. set shadowEnabled(value: boolean);
  18430. private _includedOnlyMeshes;
  18431. /**
  18432. * Gets the only meshes impacted by this light.
  18433. */
  18434. get includedOnlyMeshes(): AbstractMesh[];
  18435. /**
  18436. * Sets the only meshes impacted by this light.
  18437. */
  18438. set includedOnlyMeshes(value: AbstractMesh[]);
  18439. private _excludedMeshes;
  18440. /**
  18441. * Gets the meshes not impacted by this light.
  18442. */
  18443. get excludedMeshes(): AbstractMesh[];
  18444. /**
  18445. * Sets the meshes not impacted by this light.
  18446. */
  18447. set excludedMeshes(value: AbstractMesh[]);
  18448. private _excludeWithLayerMask;
  18449. /**
  18450. * Gets the layer id use to find what meshes are not impacted by the light.
  18451. * Inactive if 0
  18452. */
  18453. get excludeWithLayerMask(): number;
  18454. /**
  18455. * Sets the layer id use to find what meshes are not impacted by the light.
  18456. * Inactive if 0
  18457. */
  18458. set excludeWithLayerMask(value: number);
  18459. private _includeOnlyWithLayerMask;
  18460. /**
  18461. * Gets the layer id use to find what meshes are impacted by the light.
  18462. * Inactive if 0
  18463. */
  18464. get includeOnlyWithLayerMask(): number;
  18465. /**
  18466. * Sets the layer id use to find what meshes are impacted by the light.
  18467. * Inactive if 0
  18468. */
  18469. set includeOnlyWithLayerMask(value: number);
  18470. private _lightmapMode;
  18471. /**
  18472. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18473. */
  18474. get lightmapMode(): number;
  18475. /**
  18476. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18477. */
  18478. set lightmapMode(value: number);
  18479. /**
  18480. * Shadow generator associted to the light.
  18481. * @hidden Internal use only.
  18482. */
  18483. _shadowGenerator: Nullable<IShadowGenerator>;
  18484. /**
  18485. * @hidden Internal use only.
  18486. */
  18487. _excludedMeshesIds: string[];
  18488. /**
  18489. * @hidden Internal use only.
  18490. */
  18491. _includedOnlyMeshesIds: string[];
  18492. /**
  18493. * The current light unifom buffer.
  18494. * @hidden Internal use only.
  18495. */
  18496. _uniformBuffer: UniformBuffer;
  18497. /** @hidden */
  18498. _renderId: number;
  18499. /**
  18500. * Creates a Light object in the scene.
  18501. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18502. * @param name The firendly name of the light
  18503. * @param scene The scene the light belongs too
  18504. */
  18505. constructor(name: string, scene: Scene);
  18506. protected abstract _buildUniformLayout(): void;
  18507. /**
  18508. * Sets the passed Effect "effect" with the Light information.
  18509. * @param effect The effect to update
  18510. * @param lightIndex The index of the light in the effect to update
  18511. * @returns The light
  18512. */
  18513. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18514. /**
  18515. * Sets the passed Effect "effect" with the Light textures.
  18516. * @param effect The effect to update
  18517. * @param lightIndex The index of the light in the effect to update
  18518. * @returns The light
  18519. */
  18520. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18521. /**
  18522. * Binds the lights information from the scene to the effect for the given mesh.
  18523. * @param lightIndex Light index
  18524. * @param scene The scene where the light belongs to
  18525. * @param effect The effect we are binding the data to
  18526. * @param useSpecular Defines if specular is supported
  18527. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18528. */
  18529. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18530. /**
  18531. * Sets the passed Effect "effect" with the Light information.
  18532. * @param effect The effect to update
  18533. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18534. * @returns The light
  18535. */
  18536. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18537. /**
  18538. * Returns the string "Light".
  18539. * @returns the class name
  18540. */
  18541. getClassName(): string;
  18542. /** @hidden */
  18543. readonly _isLight: boolean;
  18544. /**
  18545. * Converts the light information to a readable string for debug purpose.
  18546. * @param fullDetails Supports for multiple levels of logging within scene loading
  18547. * @returns the human readable light info
  18548. */
  18549. toString(fullDetails?: boolean): string;
  18550. /** @hidden */
  18551. protected _syncParentEnabledState(): void;
  18552. /**
  18553. * Set the enabled state of this node.
  18554. * @param value - the new enabled state
  18555. */
  18556. setEnabled(value: boolean): void;
  18557. /**
  18558. * Returns the Light associated shadow generator if any.
  18559. * @return the associated shadow generator.
  18560. */
  18561. getShadowGenerator(): Nullable<IShadowGenerator>;
  18562. /**
  18563. * Returns a Vector3, the absolute light position in the World.
  18564. * @returns the world space position of the light
  18565. */
  18566. getAbsolutePosition(): Vector3;
  18567. /**
  18568. * Specifies if the light will affect the passed mesh.
  18569. * @param mesh The mesh to test against the light
  18570. * @return true the mesh is affected otherwise, false.
  18571. */
  18572. canAffectMesh(mesh: AbstractMesh): boolean;
  18573. /**
  18574. * Sort function to order lights for rendering.
  18575. * @param a First Light object to compare to second.
  18576. * @param b Second Light object to compare first.
  18577. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18578. */
  18579. static CompareLightsPriority(a: Light, b: Light): number;
  18580. /**
  18581. * Releases resources associated with this node.
  18582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18584. */
  18585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18586. /**
  18587. * Returns the light type ID (integer).
  18588. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18589. */
  18590. getTypeID(): number;
  18591. /**
  18592. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18593. * @returns the scaled intensity in intensity mode unit
  18594. */
  18595. getScaledIntensity(): number;
  18596. /**
  18597. * Returns a new Light object, named "name", from the current one.
  18598. * @param name The name of the cloned light
  18599. * @param newParent The parent of this light, if it has one
  18600. * @returns the new created light
  18601. */
  18602. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18603. /**
  18604. * Serializes the current light into a Serialization object.
  18605. * @returns the serialized object.
  18606. */
  18607. serialize(): any;
  18608. /**
  18609. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18610. * This new light is named "name" and added to the passed scene.
  18611. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18612. * @param name The friendly name of the light
  18613. * @param scene The scene the new light will belong to
  18614. * @returns the constructor function
  18615. */
  18616. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18617. /**
  18618. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18619. * @param parsedLight The JSON representation of the light
  18620. * @param scene The scene to create the parsed light in
  18621. * @returns the created light after parsing
  18622. */
  18623. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18624. private _hookArrayForExcluded;
  18625. private _hookArrayForIncludedOnly;
  18626. private _resyncMeshes;
  18627. /**
  18628. * Forces the meshes to update their light related information in their rendering used effects
  18629. * @hidden Internal Use Only
  18630. */
  18631. _markMeshesAsLightDirty(): void;
  18632. /**
  18633. * Recomputes the cached photometric scale if needed.
  18634. */
  18635. private _computePhotometricScale;
  18636. /**
  18637. * Returns the Photometric Scale according to the light type and intensity mode.
  18638. */
  18639. private _getPhotometricScale;
  18640. /**
  18641. * Reorder the light in the scene according to their defined priority.
  18642. * @hidden Internal Use Only
  18643. */
  18644. _reorderLightsInScene(): void;
  18645. /**
  18646. * Prepares the list of defines specific to the light type.
  18647. * @param defines the list of defines
  18648. * @param lightIndex defines the index of the light for the effect
  18649. */
  18650. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18651. }
  18652. }
  18653. declare module "babylonjs/Cameras/targetCamera" {
  18654. import { Nullable } from "babylonjs/types";
  18655. import { Camera } from "babylonjs/Cameras/camera";
  18656. import { Scene } from "babylonjs/scene";
  18657. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18658. /**
  18659. * A target camera 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. */
  18663. export class TargetCamera extends Camera {
  18664. private static _RigCamTransformMatrix;
  18665. private static _TargetTransformMatrix;
  18666. private static _TargetFocalPoint;
  18667. /**
  18668. * Define the current direction the camera is moving to
  18669. */
  18670. cameraDirection: Vector3;
  18671. /**
  18672. * Define the current rotation the camera is rotating to
  18673. */
  18674. cameraRotation: Vector2;
  18675. /**
  18676. * When set, the up vector of the camera will be updated by the rotation of the camera
  18677. */
  18678. updateUpVectorFromRotation: boolean;
  18679. private _tmpQuaternion;
  18680. /**
  18681. * Define the current rotation of the camera
  18682. */
  18683. rotation: Vector3;
  18684. /**
  18685. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18686. */
  18687. rotationQuaternion: Quaternion;
  18688. /**
  18689. * Define the current speed of the camera
  18690. */
  18691. speed: number;
  18692. /**
  18693. * Add constraint to the camera to prevent it to move freely in all directions and
  18694. * around all axis.
  18695. */
  18696. noRotationConstraint: boolean;
  18697. /**
  18698. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18699. * panning
  18700. */
  18701. invertRotation: boolean;
  18702. /**
  18703. * Speed multiplier for inverse camera panning
  18704. */
  18705. inverseRotationSpeed: number;
  18706. /**
  18707. * Define the current target of the camera as an object or a position.
  18708. */
  18709. lockedTarget: any;
  18710. /** @hidden */
  18711. _currentTarget: Vector3;
  18712. /** @hidden */
  18713. _initialFocalDistance: number;
  18714. /** @hidden */
  18715. _viewMatrix: Matrix;
  18716. /** @hidden */
  18717. _camMatrix: Matrix;
  18718. /** @hidden */
  18719. _cameraTransformMatrix: Matrix;
  18720. /** @hidden */
  18721. _cameraRotationMatrix: Matrix;
  18722. /** @hidden */
  18723. _referencePoint: Vector3;
  18724. /** @hidden */
  18725. _transformedReferencePoint: Vector3;
  18726. protected _globalCurrentTarget: Vector3;
  18727. protected _globalCurrentUpVector: Vector3;
  18728. /** @hidden */
  18729. _reset: () => void;
  18730. private _defaultUp;
  18731. /**
  18732. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18733. * This is the base of the follow, arc rotate cameras and Free camera
  18734. * @see http://doc.babylonjs.com/features/cameras
  18735. * @param name Defines the name of the camera in the scene
  18736. * @param position Defines the start position of the camera in the scene
  18737. * @param scene Defines the scene the camera belongs to
  18738. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18739. */
  18740. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18741. /**
  18742. * Gets the position in front of the camera at a given distance.
  18743. * @param distance The distance from the camera we want the position to be
  18744. * @returns the position
  18745. */
  18746. getFrontPosition(distance: number): Vector3;
  18747. /** @hidden */
  18748. _getLockedTargetPosition(): Nullable<Vector3>;
  18749. private _storedPosition;
  18750. private _storedRotation;
  18751. private _storedRotationQuaternion;
  18752. /**
  18753. * Store current camera state of the camera (fov, position, rotation, etc..)
  18754. * @returns the camera
  18755. */
  18756. storeState(): Camera;
  18757. /**
  18758. * Restored camera state. You must call storeState() first
  18759. * @returns whether it was successful or not
  18760. * @hidden
  18761. */
  18762. _restoreStateValues(): boolean;
  18763. /** @hidden */
  18764. _initCache(): void;
  18765. /** @hidden */
  18766. _updateCache(ignoreParentClass?: boolean): void;
  18767. /** @hidden */
  18768. _isSynchronizedViewMatrix(): boolean;
  18769. /** @hidden */
  18770. _computeLocalCameraSpeed(): number;
  18771. /**
  18772. * Defines the target the camera should look at.
  18773. * @param target Defines the new target as a Vector or a mesh
  18774. */
  18775. setTarget(target: Vector3): void;
  18776. /**
  18777. * Return the current target position of the camera. This value is expressed in local space.
  18778. * @returns the target position
  18779. */
  18780. getTarget(): Vector3;
  18781. /** @hidden */
  18782. _decideIfNeedsToMove(): boolean;
  18783. /** @hidden */
  18784. _updatePosition(): void;
  18785. /** @hidden */
  18786. _checkInputs(): void;
  18787. protected _updateCameraRotationMatrix(): void;
  18788. /**
  18789. * 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)
  18790. * @returns the current camera
  18791. */
  18792. private _rotateUpVectorWithCameraRotationMatrix;
  18793. private _cachedRotationZ;
  18794. private _cachedQuaternionRotationZ;
  18795. /** @hidden */
  18796. _getViewMatrix(): Matrix;
  18797. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18798. /**
  18799. * @hidden
  18800. */
  18801. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18802. /**
  18803. * @hidden
  18804. */
  18805. _updateRigCameras(): void;
  18806. private _getRigCamPositionAndTarget;
  18807. /**
  18808. * Gets the current object class name.
  18809. * @return the class name
  18810. */
  18811. getClassName(): string;
  18812. }
  18813. }
  18814. declare module "babylonjs/Events/keyboardEvents" {
  18815. /**
  18816. * Gather the list of keyboard event types as constants.
  18817. */
  18818. export class KeyboardEventTypes {
  18819. /**
  18820. * The keydown event is fired when a key becomes active (pressed).
  18821. */
  18822. static readonly KEYDOWN: number;
  18823. /**
  18824. * The keyup event is fired when a key has been released.
  18825. */
  18826. static readonly KEYUP: number;
  18827. }
  18828. /**
  18829. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18830. */
  18831. export class KeyboardInfo {
  18832. /**
  18833. * Defines the type of event (KeyboardEventTypes)
  18834. */
  18835. type: number;
  18836. /**
  18837. * Defines the related dom event
  18838. */
  18839. event: KeyboardEvent;
  18840. /**
  18841. * Instantiates a new keyboard info.
  18842. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18843. * @param type Defines the type of event (KeyboardEventTypes)
  18844. * @param event Defines the related dom event
  18845. */
  18846. constructor(
  18847. /**
  18848. * Defines the type of event (KeyboardEventTypes)
  18849. */
  18850. type: number,
  18851. /**
  18852. * Defines the related dom event
  18853. */
  18854. event: KeyboardEvent);
  18855. }
  18856. /**
  18857. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18858. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18859. */
  18860. export class KeyboardInfoPre extends KeyboardInfo {
  18861. /**
  18862. * Defines the type of event (KeyboardEventTypes)
  18863. */
  18864. type: number;
  18865. /**
  18866. * Defines the related dom event
  18867. */
  18868. event: KeyboardEvent;
  18869. /**
  18870. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18871. */
  18872. skipOnPointerObservable: boolean;
  18873. /**
  18874. * Instantiates a new keyboard pre info.
  18875. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18876. * @param type Defines the type of event (KeyboardEventTypes)
  18877. * @param event Defines the related dom event
  18878. */
  18879. constructor(
  18880. /**
  18881. * Defines the type of event (KeyboardEventTypes)
  18882. */
  18883. type: number,
  18884. /**
  18885. * Defines the related dom event
  18886. */
  18887. event: KeyboardEvent);
  18888. }
  18889. }
  18890. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18891. import { Nullable } from "babylonjs/types";
  18892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18893. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18894. /**
  18895. * Manage the keyboard inputs to control the movement of a free camera.
  18896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18897. */
  18898. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18899. /**
  18900. * Defines the camera the input is attached to.
  18901. */
  18902. camera: FreeCamera;
  18903. /**
  18904. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18905. */
  18906. keysUp: number[];
  18907. /**
  18908. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18909. */
  18910. keysUpward: number[];
  18911. /**
  18912. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18913. */
  18914. keysDown: number[];
  18915. /**
  18916. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18917. */
  18918. keysDownward: number[];
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18921. */
  18922. keysLeft: number[];
  18923. /**
  18924. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18925. */
  18926. keysRight: number[];
  18927. private _keys;
  18928. private _onCanvasBlurObserver;
  18929. private _onKeyboardObserver;
  18930. private _engine;
  18931. private _scene;
  18932. /**
  18933. * Attach the input controls to a specific dom element to get the input from.
  18934. * @param element Defines the element the controls should be listened from
  18935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18936. */
  18937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18938. /**
  18939. * Detach the current controls from the specified dom element.
  18940. * @param element Defines the element to stop listening the inputs from
  18941. */
  18942. detachControl(element: Nullable<HTMLElement>): void;
  18943. /**
  18944. * Update the current camera state depending on the inputs that have been used this frame.
  18945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18946. */
  18947. checkInputs(): void;
  18948. /**
  18949. * Gets the class name of the current intput.
  18950. * @returns the class name
  18951. */
  18952. getClassName(): string;
  18953. /** @hidden */
  18954. _onLostFocus(): void;
  18955. /**
  18956. * Get the friendly name associated with the input class.
  18957. * @returns the input friendly name
  18958. */
  18959. getSimpleName(): string;
  18960. }
  18961. }
  18962. declare module "babylonjs/Events/pointerEvents" {
  18963. import { Nullable } from "babylonjs/types";
  18964. import { Vector2 } from "babylonjs/Maths/math.vector";
  18965. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18966. import { Ray } from "babylonjs/Culling/ray";
  18967. /**
  18968. * Gather the list of pointer event types as constants.
  18969. */
  18970. export class PointerEventTypes {
  18971. /**
  18972. * 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.
  18973. */
  18974. static readonly POINTERDOWN: number;
  18975. /**
  18976. * The pointerup event is fired when a pointer is no longer active.
  18977. */
  18978. static readonly POINTERUP: number;
  18979. /**
  18980. * The pointermove event is fired when a pointer changes coordinates.
  18981. */
  18982. static readonly POINTERMOVE: number;
  18983. /**
  18984. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18985. */
  18986. static readonly POINTERWHEEL: number;
  18987. /**
  18988. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18989. */
  18990. static readonly POINTERPICK: number;
  18991. /**
  18992. * The pointertap event is fired when a the object has been touched and released without drag.
  18993. */
  18994. static readonly POINTERTAP: number;
  18995. /**
  18996. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18997. */
  18998. static readonly POINTERDOUBLETAP: number;
  18999. }
  19000. /**
  19001. * Base class of pointer info types.
  19002. */
  19003. export class PointerInfoBase {
  19004. /**
  19005. * Defines the type of event (PointerEventTypes)
  19006. */
  19007. type: number;
  19008. /**
  19009. * Defines the related dom event
  19010. */
  19011. event: PointerEvent | MouseWheelEvent;
  19012. /**
  19013. * Instantiates the base class of pointers info.
  19014. * @param type Defines the type of event (PointerEventTypes)
  19015. * @param event Defines the related dom event
  19016. */
  19017. constructor(
  19018. /**
  19019. * Defines the type of event (PointerEventTypes)
  19020. */
  19021. type: number,
  19022. /**
  19023. * Defines the related dom event
  19024. */
  19025. event: PointerEvent | MouseWheelEvent);
  19026. }
  19027. /**
  19028. * This class is used to store pointer related info for the onPrePointerObservable event.
  19029. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19030. */
  19031. export class PointerInfoPre extends PointerInfoBase {
  19032. /**
  19033. * Ray from a pointer if availible (eg. 6dof controller)
  19034. */
  19035. ray: Nullable<Ray>;
  19036. /**
  19037. * Defines the local position of the pointer on the canvas.
  19038. */
  19039. localPosition: Vector2;
  19040. /**
  19041. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19042. */
  19043. skipOnPointerObservable: boolean;
  19044. /**
  19045. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19046. * @param type Defines the type of event (PointerEventTypes)
  19047. * @param event Defines the related dom event
  19048. * @param localX Defines the local x coordinates of the pointer when the event occured
  19049. * @param localY Defines the local y coordinates of the pointer when the event occured
  19050. */
  19051. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19052. }
  19053. /**
  19054. * This type contains all the data related to a pointer event in Babylon.js.
  19055. * 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.
  19056. */
  19057. export class PointerInfo extends PointerInfoBase {
  19058. /**
  19059. * Defines the picking info associated to the info (if any)\
  19060. */
  19061. pickInfo: Nullable<PickingInfo>;
  19062. /**
  19063. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19064. * @param type Defines the type of event (PointerEventTypes)
  19065. * @param event Defines the related dom event
  19066. * @param pickInfo Defines the picking info associated to the info (if any)\
  19067. */
  19068. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19069. /**
  19070. * Defines the picking info associated to the info (if any)\
  19071. */
  19072. pickInfo: Nullable<PickingInfo>);
  19073. }
  19074. /**
  19075. * Data relating to a touch event on the screen.
  19076. */
  19077. export interface PointerTouch {
  19078. /**
  19079. * X coordinate of touch.
  19080. */
  19081. x: number;
  19082. /**
  19083. * Y coordinate of touch.
  19084. */
  19085. y: number;
  19086. /**
  19087. * Id of touch. Unique for each finger.
  19088. */
  19089. pointerId: number;
  19090. /**
  19091. * Event type passed from DOM.
  19092. */
  19093. type: any;
  19094. }
  19095. }
  19096. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19097. import { Observable } from "babylonjs/Misc/observable";
  19098. import { Nullable } from "babylonjs/types";
  19099. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19100. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19101. /**
  19102. * Manage the mouse inputs to control the movement of a free camera.
  19103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19104. */
  19105. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19106. /**
  19107. * Define if touch is enabled in the mouse input
  19108. */
  19109. touchEnabled: boolean;
  19110. /**
  19111. * Defines the camera the input is attached to.
  19112. */
  19113. camera: FreeCamera;
  19114. /**
  19115. * Defines the buttons associated with the input to handle camera move.
  19116. */
  19117. buttons: number[];
  19118. /**
  19119. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19120. */
  19121. angularSensibility: number;
  19122. private _pointerInput;
  19123. private _onMouseMove;
  19124. private _observer;
  19125. private previousPosition;
  19126. /**
  19127. * Observable for when a pointer move event occurs containing the move offset
  19128. */
  19129. onPointerMovedObservable: Observable<{
  19130. offsetX: number;
  19131. offsetY: number;
  19132. }>;
  19133. /**
  19134. * @hidden
  19135. * If the camera should be rotated automatically based on pointer movement
  19136. */
  19137. _allowCameraRotation: boolean;
  19138. /**
  19139. * Manage the mouse inputs to control the movement of a free camera.
  19140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19141. * @param touchEnabled Defines if touch is enabled or not
  19142. */
  19143. constructor(
  19144. /**
  19145. * Define if touch is enabled in the mouse input
  19146. */
  19147. touchEnabled?: boolean);
  19148. /**
  19149. * Attach the input controls to a specific dom element to get the input from.
  19150. * @param element Defines the element the controls should be listened from
  19151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19152. */
  19153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19154. /**
  19155. * Called on JS contextmenu event.
  19156. * Override this method to provide functionality.
  19157. */
  19158. protected onContextMenu(evt: PointerEvent): void;
  19159. /**
  19160. * Detach the current controls from the specified dom element.
  19161. * @param element Defines the element to stop listening the inputs from
  19162. */
  19163. detachControl(element: Nullable<HTMLElement>): void;
  19164. /**
  19165. * Gets the class name of the current intput.
  19166. * @returns the class name
  19167. */
  19168. getClassName(): string;
  19169. /**
  19170. * Get the friendly name associated with the input class.
  19171. * @returns the input friendly name
  19172. */
  19173. getSimpleName(): string;
  19174. }
  19175. }
  19176. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19177. import { Nullable } from "babylonjs/types";
  19178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19180. /**
  19181. * Manage the touch inputs to control the movement of a free camera.
  19182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19183. */
  19184. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19185. /**
  19186. * Defines the camera the input is attached to.
  19187. */
  19188. camera: FreeCamera;
  19189. /**
  19190. * Defines the touch sensibility for rotation.
  19191. * The higher the faster.
  19192. */
  19193. touchAngularSensibility: number;
  19194. /**
  19195. * Defines the touch sensibility for move.
  19196. * The higher the faster.
  19197. */
  19198. touchMoveSensibility: number;
  19199. private _offsetX;
  19200. private _offsetY;
  19201. private _pointerPressed;
  19202. private _pointerInput;
  19203. private _observer;
  19204. private _onLostFocus;
  19205. /**
  19206. * Attach the input controls to a specific dom element to get the input from.
  19207. * @param element Defines the element the controls should be listened from
  19208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19209. */
  19210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19211. /**
  19212. * Detach the current controls from the specified dom element.
  19213. * @param element Defines the element to stop listening the inputs from
  19214. */
  19215. detachControl(element: Nullable<HTMLElement>): void;
  19216. /**
  19217. * Update the current camera state depending on the inputs that have been used this frame.
  19218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19219. */
  19220. checkInputs(): void;
  19221. /**
  19222. * Gets the class name of the current intput.
  19223. * @returns the class name
  19224. */
  19225. getClassName(): string;
  19226. /**
  19227. * Get the friendly name associated with the input class.
  19228. * @returns the input friendly name
  19229. */
  19230. getSimpleName(): string;
  19231. }
  19232. }
  19233. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19235. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19236. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19237. import { Nullable } from "babylonjs/types";
  19238. /**
  19239. * Default Inputs manager for the FreeCamera.
  19240. * It groups all the default supported inputs for ease of use.
  19241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19242. */
  19243. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19244. /**
  19245. * @hidden
  19246. */
  19247. _mouseInput: Nullable<FreeCameraMouseInput>;
  19248. /**
  19249. * Instantiates a new FreeCameraInputsManager.
  19250. * @param camera Defines the camera the inputs belong to
  19251. */
  19252. constructor(camera: FreeCamera);
  19253. /**
  19254. * Add keyboard input support to the input manager.
  19255. * @returns the current input manager
  19256. */
  19257. addKeyboard(): FreeCameraInputsManager;
  19258. /**
  19259. * Add mouse input support to the input manager.
  19260. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19261. * @returns the current input manager
  19262. */
  19263. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19264. /**
  19265. * Removes the mouse input support from the manager
  19266. * @returns the current input manager
  19267. */
  19268. removeMouse(): FreeCameraInputsManager;
  19269. /**
  19270. * Add touch input support to the input manager.
  19271. * @returns the current input manager
  19272. */
  19273. addTouch(): FreeCameraInputsManager;
  19274. /**
  19275. * Remove all attached input methods from a camera
  19276. */
  19277. clear(): void;
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/freeCamera" {
  19281. import { Vector3 } from "babylonjs/Maths/math.vector";
  19282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19283. import { Scene } from "babylonjs/scene";
  19284. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19285. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19286. /**
  19287. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19288. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19290. */
  19291. export class FreeCamera extends TargetCamera {
  19292. /**
  19293. * Define the collision ellipsoid of the camera.
  19294. * This is helpful to simulate a camera body like the player body around the camera
  19295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19296. */
  19297. ellipsoid: Vector3;
  19298. /**
  19299. * Define an offset for the position of the ellipsoid around the camera.
  19300. * This can be helpful to determine the center of the body near the gravity center of the body
  19301. * instead of its head.
  19302. */
  19303. ellipsoidOffset: Vector3;
  19304. /**
  19305. * Enable or disable collisions of the camera with the rest of the scene objects.
  19306. */
  19307. checkCollisions: boolean;
  19308. /**
  19309. * Enable or disable gravity on the camera.
  19310. */
  19311. applyGravity: boolean;
  19312. /**
  19313. * Define the input manager associated to the camera.
  19314. */
  19315. inputs: FreeCameraInputsManager;
  19316. /**
  19317. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19318. * Higher values reduce sensitivity.
  19319. */
  19320. get angularSensibility(): number;
  19321. /**
  19322. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19323. * Higher values reduce sensitivity.
  19324. */
  19325. set angularSensibility(value: number);
  19326. /**
  19327. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19328. */
  19329. get keysUp(): number[];
  19330. set keysUp(value: number[]);
  19331. /**
  19332. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19333. */
  19334. get keysUpward(): number[];
  19335. set keysUpward(value: number[]);
  19336. /**
  19337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19338. */
  19339. get keysDown(): number[];
  19340. set keysDown(value: number[]);
  19341. /**
  19342. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19343. */
  19344. get keysDownward(): number[];
  19345. set keysDownward(value: number[]);
  19346. /**
  19347. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19348. */
  19349. get keysLeft(): number[];
  19350. set keysLeft(value: number[]);
  19351. /**
  19352. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19353. */
  19354. get keysRight(): number[];
  19355. set keysRight(value: number[]);
  19356. /**
  19357. * Event raised when the camera collide with a mesh in the scene.
  19358. */
  19359. onCollide: (collidedMesh: AbstractMesh) => void;
  19360. private _collider;
  19361. private _needMoveForGravity;
  19362. private _oldPosition;
  19363. private _diffPosition;
  19364. private _newPosition;
  19365. /** @hidden */
  19366. _localDirection: Vector3;
  19367. /** @hidden */
  19368. _transformedDirection: Vector3;
  19369. /**
  19370. * Instantiates a Free Camera.
  19371. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19372. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19374. * @param name Define the name of the camera in the scene
  19375. * @param position Define the start position of the camera in the scene
  19376. * @param scene Define the scene the camera belongs to
  19377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19378. */
  19379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19380. /**
  19381. * Attached controls to the current camera.
  19382. * @param element Defines the element the controls should be listened from
  19383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19384. */
  19385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19386. /**
  19387. * Detach the current controls from the camera.
  19388. * The camera will stop reacting to inputs.
  19389. * @param element Defines the element to stop listening the inputs from
  19390. */
  19391. detachControl(element: HTMLElement): void;
  19392. private _collisionMask;
  19393. /**
  19394. * Define a collision mask to limit the list of object the camera can collide with
  19395. */
  19396. get collisionMask(): number;
  19397. set collisionMask(mask: number);
  19398. /** @hidden */
  19399. _collideWithWorld(displacement: Vector3): void;
  19400. private _onCollisionPositionChange;
  19401. /** @hidden */
  19402. _checkInputs(): void;
  19403. /** @hidden */
  19404. _decideIfNeedsToMove(): boolean;
  19405. /** @hidden */
  19406. _updatePosition(): void;
  19407. /**
  19408. * Destroy the camera and release the current resources hold by it.
  19409. */
  19410. dispose(): void;
  19411. /**
  19412. * Gets the current object class name.
  19413. * @return the class name
  19414. */
  19415. getClassName(): string;
  19416. }
  19417. }
  19418. declare module "babylonjs/Gamepads/gamepad" {
  19419. import { Observable } from "babylonjs/Misc/observable";
  19420. /**
  19421. * Represents a gamepad control stick position
  19422. */
  19423. export class StickValues {
  19424. /**
  19425. * The x component of the control stick
  19426. */
  19427. x: number;
  19428. /**
  19429. * The y component of the control stick
  19430. */
  19431. y: number;
  19432. /**
  19433. * Initializes the gamepad x and y control stick values
  19434. * @param x The x component of the gamepad control stick value
  19435. * @param y The y component of the gamepad control stick value
  19436. */
  19437. constructor(
  19438. /**
  19439. * The x component of the control stick
  19440. */
  19441. x: number,
  19442. /**
  19443. * The y component of the control stick
  19444. */
  19445. y: number);
  19446. }
  19447. /**
  19448. * An interface which manages callbacks for gamepad button changes
  19449. */
  19450. export interface GamepadButtonChanges {
  19451. /**
  19452. * Called when a gamepad has been changed
  19453. */
  19454. changed: boolean;
  19455. /**
  19456. * Called when a gamepad press event has been triggered
  19457. */
  19458. pressChanged: boolean;
  19459. /**
  19460. * Called when a touch event has been triggered
  19461. */
  19462. touchChanged: boolean;
  19463. /**
  19464. * Called when a value has changed
  19465. */
  19466. valueChanged: boolean;
  19467. }
  19468. /**
  19469. * Represents a gamepad
  19470. */
  19471. export class Gamepad {
  19472. /**
  19473. * The id of the gamepad
  19474. */
  19475. id: string;
  19476. /**
  19477. * The index of the gamepad
  19478. */
  19479. index: number;
  19480. /**
  19481. * The browser gamepad
  19482. */
  19483. browserGamepad: any;
  19484. /**
  19485. * Specifies what type of gamepad this represents
  19486. */
  19487. type: number;
  19488. private _leftStick;
  19489. private _rightStick;
  19490. /** @hidden */
  19491. _isConnected: boolean;
  19492. private _leftStickAxisX;
  19493. private _leftStickAxisY;
  19494. private _rightStickAxisX;
  19495. private _rightStickAxisY;
  19496. /**
  19497. * Triggered when the left control stick has been changed
  19498. */
  19499. private _onleftstickchanged;
  19500. /**
  19501. * Triggered when the right control stick has been changed
  19502. */
  19503. private _onrightstickchanged;
  19504. /**
  19505. * Represents a gamepad controller
  19506. */
  19507. static GAMEPAD: number;
  19508. /**
  19509. * Represents a generic controller
  19510. */
  19511. static GENERIC: number;
  19512. /**
  19513. * Represents an XBox controller
  19514. */
  19515. static XBOX: number;
  19516. /**
  19517. * Represents a pose-enabled controller
  19518. */
  19519. static POSE_ENABLED: number;
  19520. /**
  19521. * Represents an Dual Shock controller
  19522. */
  19523. static DUALSHOCK: number;
  19524. /**
  19525. * Specifies whether the left control stick should be Y-inverted
  19526. */
  19527. protected _invertLeftStickY: boolean;
  19528. /**
  19529. * Specifies if the gamepad has been connected
  19530. */
  19531. get isConnected(): boolean;
  19532. /**
  19533. * Initializes the gamepad
  19534. * @param id The id of the gamepad
  19535. * @param index The index of the gamepad
  19536. * @param browserGamepad The browser gamepad
  19537. * @param leftStickX The x component of the left joystick
  19538. * @param leftStickY The y component of the left joystick
  19539. * @param rightStickX The x component of the right joystick
  19540. * @param rightStickY The y component of the right joystick
  19541. */
  19542. constructor(
  19543. /**
  19544. * The id of the gamepad
  19545. */
  19546. id: string,
  19547. /**
  19548. * The index of the gamepad
  19549. */
  19550. index: number,
  19551. /**
  19552. * The browser gamepad
  19553. */
  19554. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19555. /**
  19556. * Callback triggered when the left joystick has changed
  19557. * @param callback
  19558. */
  19559. onleftstickchanged(callback: (values: StickValues) => void): void;
  19560. /**
  19561. * Callback triggered when the right joystick has changed
  19562. * @param callback
  19563. */
  19564. onrightstickchanged(callback: (values: StickValues) => void): void;
  19565. /**
  19566. * Gets the left joystick
  19567. */
  19568. get leftStick(): StickValues;
  19569. /**
  19570. * Sets the left joystick values
  19571. */
  19572. set leftStick(newValues: StickValues);
  19573. /**
  19574. * Gets the right joystick
  19575. */
  19576. get rightStick(): StickValues;
  19577. /**
  19578. * Sets the right joystick value
  19579. */
  19580. set rightStick(newValues: StickValues);
  19581. /**
  19582. * Updates the gamepad joystick positions
  19583. */
  19584. update(): void;
  19585. /**
  19586. * Disposes the gamepad
  19587. */
  19588. dispose(): void;
  19589. }
  19590. /**
  19591. * Represents a generic gamepad
  19592. */
  19593. export class GenericPad extends Gamepad {
  19594. private _buttons;
  19595. private _onbuttondown;
  19596. private _onbuttonup;
  19597. /**
  19598. * Observable triggered when a button has been pressed
  19599. */
  19600. onButtonDownObservable: Observable<number>;
  19601. /**
  19602. * Observable triggered when a button has been released
  19603. */
  19604. onButtonUpObservable: Observable<number>;
  19605. /**
  19606. * Callback triggered when a button has been pressed
  19607. * @param callback Called when a button has been pressed
  19608. */
  19609. onbuttondown(callback: (buttonPressed: number) => void): void;
  19610. /**
  19611. * Callback triggered when a button has been released
  19612. * @param callback Called when a button has been released
  19613. */
  19614. onbuttonup(callback: (buttonReleased: number) => void): void;
  19615. /**
  19616. * Initializes the generic gamepad
  19617. * @param id The id of the generic gamepad
  19618. * @param index The index of the generic gamepad
  19619. * @param browserGamepad The browser gamepad
  19620. */
  19621. constructor(id: string, index: number, browserGamepad: any);
  19622. private _setButtonValue;
  19623. /**
  19624. * Updates the generic gamepad
  19625. */
  19626. update(): void;
  19627. /**
  19628. * Disposes the generic gamepad
  19629. */
  19630. dispose(): void;
  19631. }
  19632. }
  19633. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19634. import { Observable } from "babylonjs/Misc/observable";
  19635. import { Nullable } from "babylonjs/types";
  19636. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Ray } from "babylonjs/Culling/ray";
  19640. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19641. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19642. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19643. /**
  19644. * Defines the types of pose enabled controllers that are supported
  19645. */
  19646. export enum PoseEnabledControllerType {
  19647. /**
  19648. * HTC Vive
  19649. */
  19650. VIVE = 0,
  19651. /**
  19652. * Oculus Rift
  19653. */
  19654. OCULUS = 1,
  19655. /**
  19656. * Windows mixed reality
  19657. */
  19658. WINDOWS = 2,
  19659. /**
  19660. * Samsung gear VR
  19661. */
  19662. GEAR_VR = 3,
  19663. /**
  19664. * Google Daydream
  19665. */
  19666. DAYDREAM = 4,
  19667. /**
  19668. * Generic
  19669. */
  19670. GENERIC = 5
  19671. }
  19672. /**
  19673. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19674. */
  19675. export interface MutableGamepadButton {
  19676. /**
  19677. * Value of the button/trigger
  19678. */
  19679. value: number;
  19680. /**
  19681. * If the button/trigger is currently touched
  19682. */
  19683. touched: boolean;
  19684. /**
  19685. * If the button/trigger is currently pressed
  19686. */
  19687. pressed: boolean;
  19688. }
  19689. /**
  19690. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19691. * @hidden
  19692. */
  19693. export interface ExtendedGamepadButton extends GamepadButton {
  19694. /**
  19695. * If the button/trigger is currently pressed
  19696. */
  19697. readonly pressed: boolean;
  19698. /**
  19699. * If the button/trigger is currently touched
  19700. */
  19701. readonly touched: boolean;
  19702. /**
  19703. * Value of the button/trigger
  19704. */
  19705. readonly value: number;
  19706. }
  19707. /** @hidden */
  19708. export interface _GamePadFactory {
  19709. /**
  19710. * Returns whether or not the current gamepad can be created for this type of controller.
  19711. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19712. * @returns true if it can be created, otherwise false
  19713. */
  19714. canCreate(gamepadInfo: any): boolean;
  19715. /**
  19716. * Creates a new instance of the Gamepad.
  19717. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19718. * @returns the new gamepad instance
  19719. */
  19720. create(gamepadInfo: any): Gamepad;
  19721. }
  19722. /**
  19723. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19724. */
  19725. export class PoseEnabledControllerHelper {
  19726. /** @hidden */
  19727. static _ControllerFactories: _GamePadFactory[];
  19728. /** @hidden */
  19729. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19730. /**
  19731. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19732. * @param vrGamepad the gamepad to initialized
  19733. * @returns a vr controller of the type the gamepad identified as
  19734. */
  19735. static InitiateController(vrGamepad: any): Gamepad;
  19736. }
  19737. /**
  19738. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19739. */
  19740. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19741. /**
  19742. * If the controller is used in a webXR session
  19743. */
  19744. isXR: boolean;
  19745. private _deviceRoomPosition;
  19746. private _deviceRoomRotationQuaternion;
  19747. /**
  19748. * The device position in babylon space
  19749. */
  19750. devicePosition: Vector3;
  19751. /**
  19752. * The device rotation in babylon space
  19753. */
  19754. deviceRotationQuaternion: Quaternion;
  19755. /**
  19756. * The scale factor of the device in babylon space
  19757. */
  19758. deviceScaleFactor: number;
  19759. /**
  19760. * (Likely devicePosition should be used instead) The device position in its room space
  19761. */
  19762. position: Vector3;
  19763. /**
  19764. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19765. */
  19766. rotationQuaternion: Quaternion;
  19767. /**
  19768. * The type of controller (Eg. Windows mixed reality)
  19769. */
  19770. controllerType: PoseEnabledControllerType;
  19771. protected _calculatedPosition: Vector3;
  19772. private _calculatedRotation;
  19773. /**
  19774. * The raw pose from the device
  19775. */
  19776. rawPose: DevicePose;
  19777. private _trackPosition;
  19778. private _maxRotationDistFromHeadset;
  19779. private _draggedRoomRotation;
  19780. /**
  19781. * @hidden
  19782. */
  19783. _disableTrackPosition(fixedPosition: Vector3): void;
  19784. /**
  19785. * Internal, the mesh attached to the controller
  19786. * @hidden
  19787. */
  19788. _mesh: Nullable<AbstractMesh>;
  19789. private _poseControlledCamera;
  19790. private _leftHandSystemQuaternion;
  19791. /**
  19792. * Internal, matrix used to convert room space to babylon space
  19793. * @hidden
  19794. */
  19795. _deviceToWorld: Matrix;
  19796. /**
  19797. * Node to be used when casting a ray from the controller
  19798. * @hidden
  19799. */
  19800. _pointingPoseNode: Nullable<TransformNode>;
  19801. /**
  19802. * Name of the child mesh that can be used to cast a ray from the controller
  19803. */
  19804. static readonly POINTING_POSE: string;
  19805. /**
  19806. * Creates a new PoseEnabledController from a gamepad
  19807. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19808. */
  19809. constructor(browserGamepad: any);
  19810. private _workingMatrix;
  19811. /**
  19812. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19813. */
  19814. update(): void;
  19815. /**
  19816. * Updates only the pose device and mesh without doing any button event checking
  19817. */
  19818. protected _updatePoseAndMesh(): void;
  19819. /**
  19820. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19821. * @param poseData raw pose fromthe device
  19822. */
  19823. updateFromDevice(poseData: DevicePose): void;
  19824. /**
  19825. * @hidden
  19826. */
  19827. _meshAttachedObservable: Observable<AbstractMesh>;
  19828. /**
  19829. * Attaches a mesh to the controller
  19830. * @param mesh the mesh to be attached
  19831. */
  19832. attachToMesh(mesh: AbstractMesh): void;
  19833. /**
  19834. * Attaches the controllers mesh to a camera
  19835. * @param camera the camera the mesh should be attached to
  19836. */
  19837. attachToPoseControlledCamera(camera: TargetCamera): void;
  19838. /**
  19839. * Disposes of the controller
  19840. */
  19841. dispose(): void;
  19842. /**
  19843. * The mesh that is attached to the controller
  19844. */
  19845. get mesh(): Nullable<AbstractMesh>;
  19846. /**
  19847. * Gets the ray of the controller in the direction the controller is pointing
  19848. * @param length the length the resulting ray should be
  19849. * @returns a ray in the direction the controller is pointing
  19850. */
  19851. getForwardRay(length?: number): Ray;
  19852. }
  19853. }
  19854. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19855. import { Observable } from "babylonjs/Misc/observable";
  19856. import { Scene } from "babylonjs/scene";
  19857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19858. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19859. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19860. import { Nullable } from "babylonjs/types";
  19861. /**
  19862. * Defines the WebVRController object that represents controllers tracked in 3D space
  19863. */
  19864. export abstract class WebVRController extends PoseEnabledController {
  19865. /**
  19866. * Internal, the default controller model for the controller
  19867. */
  19868. protected _defaultModel: Nullable<AbstractMesh>;
  19869. /**
  19870. * Fired when the trigger state has changed
  19871. */
  19872. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19873. /**
  19874. * Fired when the main button state has changed
  19875. */
  19876. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19877. /**
  19878. * Fired when the secondary button state has changed
  19879. */
  19880. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19881. /**
  19882. * Fired when the pad state has changed
  19883. */
  19884. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19885. /**
  19886. * Fired when controllers stick values have changed
  19887. */
  19888. onPadValuesChangedObservable: Observable<StickValues>;
  19889. /**
  19890. * Array of button availible on the controller
  19891. */
  19892. protected _buttons: Array<MutableGamepadButton>;
  19893. private _onButtonStateChange;
  19894. /**
  19895. * Fired when a controller button's state has changed
  19896. * @param callback the callback containing the button that was modified
  19897. */
  19898. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19899. /**
  19900. * X and Y axis corresponding to the controllers joystick
  19901. */
  19902. pad: StickValues;
  19903. /**
  19904. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19905. */
  19906. hand: string;
  19907. /**
  19908. * The default controller model for the controller
  19909. */
  19910. get defaultModel(): Nullable<AbstractMesh>;
  19911. /**
  19912. * Creates a new WebVRController from a gamepad
  19913. * @param vrGamepad the gamepad that the WebVRController should be created from
  19914. */
  19915. constructor(vrGamepad: any);
  19916. /**
  19917. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19918. */
  19919. update(): void;
  19920. /**
  19921. * Function to be called when a button is modified
  19922. */
  19923. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19924. /**
  19925. * Loads a mesh and attaches it to the controller
  19926. * @param scene the scene the mesh should be added to
  19927. * @param meshLoaded callback for when the mesh has been loaded
  19928. */
  19929. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19930. private _setButtonValue;
  19931. private _changes;
  19932. private _checkChanges;
  19933. /**
  19934. * Disposes of th webVRCOntroller
  19935. */
  19936. dispose(): void;
  19937. }
  19938. }
  19939. declare module "babylonjs/Lights/hemisphericLight" {
  19940. import { Nullable } from "babylonjs/types";
  19941. import { Scene } from "babylonjs/scene";
  19942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19943. import { Color3 } from "babylonjs/Maths/math.color";
  19944. import { Effect } from "babylonjs/Materials/effect";
  19945. import { Light } from "babylonjs/Lights/light";
  19946. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19947. /**
  19948. * The HemisphericLight simulates the ambient environment light,
  19949. * so the passed direction is the light reflection direction, not the incoming direction.
  19950. */
  19951. export class HemisphericLight extends Light {
  19952. /**
  19953. * The groundColor is the light in the opposite direction to the one specified during creation.
  19954. * 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.
  19955. */
  19956. groundColor: Color3;
  19957. /**
  19958. * The light reflection direction, not the incoming direction.
  19959. */
  19960. direction: Vector3;
  19961. /**
  19962. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19963. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19964. * The HemisphericLight can't cast shadows.
  19965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19966. * @param name The friendly name of the light
  19967. * @param direction The direction of the light reflection
  19968. * @param scene The scene the light belongs to
  19969. */
  19970. constructor(name: string, direction: Vector3, scene: Scene);
  19971. protected _buildUniformLayout(): void;
  19972. /**
  19973. * Returns the string "HemisphericLight".
  19974. * @return The class name
  19975. */
  19976. getClassName(): string;
  19977. /**
  19978. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19979. * Returns the updated direction.
  19980. * @param target The target the direction should point to
  19981. * @return The computed direction
  19982. */
  19983. setDirectionToTarget(target: Vector3): Vector3;
  19984. /**
  19985. * Returns the shadow generator associated to the light.
  19986. * @returns Always null for hemispheric lights because it does not support shadows.
  19987. */
  19988. getShadowGenerator(): Nullable<IShadowGenerator>;
  19989. /**
  19990. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19991. * @param effect The effect to update
  19992. * @param lightIndex The index of the light in the effect to update
  19993. * @returns The hemispheric light
  19994. */
  19995. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19997. /**
  19998. * Computes the world matrix of the node
  19999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20000. * @param useWasUpdatedFlag defines a reserved property
  20001. * @returns the world matrix
  20002. */
  20003. computeWorldMatrix(): Matrix;
  20004. /**
  20005. * Returns the integer 3.
  20006. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20007. */
  20008. getTypeID(): number;
  20009. /**
  20010. * Prepares the list of defines specific to the light type.
  20011. * @param defines the list of defines
  20012. * @param lightIndex defines the index of the light for the effect
  20013. */
  20014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20015. }
  20016. }
  20017. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20018. /** @hidden */
  20019. export var vrMultiviewToSingleviewPixelShader: {
  20020. name: string;
  20021. shader: string;
  20022. };
  20023. }
  20024. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20026. import { Scene } from "babylonjs/scene";
  20027. /**
  20028. * Renders to multiple views with a single draw call
  20029. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20030. */
  20031. export class MultiviewRenderTarget extends RenderTargetTexture {
  20032. /**
  20033. * Creates a multiview render target
  20034. * @param scene scene used with the render target
  20035. * @param size the size of the render target (used for each view)
  20036. */
  20037. constructor(scene: Scene, size?: number | {
  20038. width: number;
  20039. height: number;
  20040. } | {
  20041. ratio: number;
  20042. });
  20043. /**
  20044. * @hidden
  20045. * @param faceIndex the face index, if its a cube texture
  20046. */
  20047. _bindFrameBuffer(faceIndex?: number): void;
  20048. /**
  20049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20050. * @returns the view count
  20051. */
  20052. getViewCount(): number;
  20053. }
  20054. }
  20055. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20056. import { Camera } from "babylonjs/Cameras/camera";
  20057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20058. import { Nullable } from "babylonjs/types";
  20059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20060. import { Matrix } from "babylonjs/Maths/math.vector";
  20061. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20062. module "babylonjs/Engines/engine" {
  20063. interface Engine {
  20064. /**
  20065. * Creates a new multiview render target
  20066. * @param width defines the width of the texture
  20067. * @param height defines the height of the texture
  20068. * @returns the created multiview texture
  20069. */
  20070. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20071. /**
  20072. * Binds a multiview framebuffer to be drawn to
  20073. * @param multiviewTexture texture to bind
  20074. */
  20075. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20076. }
  20077. }
  20078. module "babylonjs/Cameras/camera" {
  20079. interface Camera {
  20080. /**
  20081. * @hidden
  20082. * 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)
  20083. */
  20084. _useMultiviewToSingleView: boolean;
  20085. /**
  20086. * @hidden
  20087. * 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)
  20088. */
  20089. _multiviewTexture: Nullable<RenderTargetTexture>;
  20090. /**
  20091. * @hidden
  20092. * ensures the multiview texture of the camera exists and has the specified width/height
  20093. * @param width height to set on the multiview texture
  20094. * @param height width to set on the multiview texture
  20095. */
  20096. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20097. }
  20098. }
  20099. module "babylonjs/scene" {
  20100. interface Scene {
  20101. /** @hidden */
  20102. _transformMatrixR: Matrix;
  20103. /** @hidden */
  20104. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20105. /** @hidden */
  20106. _createMultiviewUbo(): void;
  20107. /** @hidden */
  20108. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20109. /** @hidden */
  20110. _renderMultiviewToSingleView(camera: Camera): void;
  20111. }
  20112. }
  20113. }
  20114. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20115. import { Camera } from "babylonjs/Cameras/camera";
  20116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20117. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20118. import "babylonjs/Engines/Extensions/engine.multiview";
  20119. /**
  20120. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20121. * This will not be used for webXR as it supports displaying texture arrays directly
  20122. */
  20123. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20124. /**
  20125. * Initializes a VRMultiviewToSingleview
  20126. * @param name name of the post process
  20127. * @param camera camera to be applied to
  20128. * @param scaleFactor scaling factor to the size of the output texture
  20129. */
  20130. constructor(name: string, camera: Camera, scaleFactor: number);
  20131. }
  20132. }
  20133. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20134. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20135. import { Nullable } from "babylonjs/types";
  20136. import { Size } from "babylonjs/Maths/math.size";
  20137. import { Observable } from "babylonjs/Misc/observable";
  20138. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20139. /**
  20140. * Interface used to define additional presentation attributes
  20141. */
  20142. export interface IVRPresentationAttributes {
  20143. /**
  20144. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20145. */
  20146. highRefreshRate: boolean;
  20147. /**
  20148. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20149. */
  20150. foveationLevel: number;
  20151. }
  20152. module "babylonjs/Engines/engine" {
  20153. interface Engine {
  20154. /** @hidden */
  20155. _vrDisplay: any;
  20156. /** @hidden */
  20157. _vrSupported: boolean;
  20158. /** @hidden */
  20159. _oldSize: Size;
  20160. /** @hidden */
  20161. _oldHardwareScaleFactor: number;
  20162. /** @hidden */
  20163. _vrExclusivePointerMode: boolean;
  20164. /** @hidden */
  20165. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20166. /** @hidden */
  20167. _onVRDisplayPointerRestricted: () => void;
  20168. /** @hidden */
  20169. _onVRDisplayPointerUnrestricted: () => void;
  20170. /** @hidden */
  20171. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20172. /** @hidden */
  20173. _onVrDisplayDisconnect: Nullable<() => void>;
  20174. /** @hidden */
  20175. _onVrDisplayPresentChange: Nullable<() => void>;
  20176. /**
  20177. * Observable signaled when VR display mode changes
  20178. */
  20179. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20180. /**
  20181. * Observable signaled when VR request present is complete
  20182. */
  20183. onVRRequestPresentComplete: Observable<boolean>;
  20184. /**
  20185. * Observable signaled when VR request present starts
  20186. */
  20187. onVRRequestPresentStart: Observable<Engine>;
  20188. /**
  20189. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20190. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20191. */
  20192. isInVRExclusivePointerMode: boolean;
  20193. /**
  20194. * Gets a boolean indicating if a webVR device was detected
  20195. * @returns true if a webVR device was detected
  20196. */
  20197. isVRDevicePresent(): boolean;
  20198. /**
  20199. * Gets the current webVR device
  20200. * @returns the current webVR device (or null)
  20201. */
  20202. getVRDevice(): any;
  20203. /**
  20204. * Initializes a webVR display and starts listening to display change events
  20205. * The onVRDisplayChangedObservable will be notified upon these changes
  20206. * @returns A promise containing a VRDisplay and if vr is supported
  20207. */
  20208. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20209. /** @hidden */
  20210. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20211. /**
  20212. * Gets or sets the presentation attributes used to configure VR rendering
  20213. */
  20214. vrPresentationAttributes?: IVRPresentationAttributes;
  20215. /**
  20216. * Call this function to switch to webVR mode
  20217. * Will do nothing if webVR is not supported or if there is no webVR device
  20218. * @param options the webvr options provided to the camera. mainly used for multiview
  20219. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20220. */
  20221. enableVR(options: WebVROptions): void;
  20222. /** @hidden */
  20223. _onVRFullScreenTriggered(): void;
  20224. }
  20225. }
  20226. }
  20227. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20228. import { Nullable } from "babylonjs/types";
  20229. import { Observable } from "babylonjs/Misc/observable";
  20230. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20231. import { Scene } from "babylonjs/scene";
  20232. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20233. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20234. import { Node } from "babylonjs/node";
  20235. import { Ray } from "babylonjs/Culling/ray";
  20236. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20237. import "babylonjs/Engines/Extensions/engine.webVR";
  20238. /**
  20239. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20240. * IMPORTANT!! The data is right-hand data.
  20241. * @export
  20242. * @interface DevicePose
  20243. */
  20244. export interface DevicePose {
  20245. /**
  20246. * The position of the device, values in array are [x,y,z].
  20247. */
  20248. readonly position: Nullable<Float32Array>;
  20249. /**
  20250. * The linearVelocity of the device, values in array are [x,y,z].
  20251. */
  20252. readonly linearVelocity: Nullable<Float32Array>;
  20253. /**
  20254. * The linearAcceleration of the device, values in array are [x,y,z].
  20255. */
  20256. readonly linearAcceleration: Nullable<Float32Array>;
  20257. /**
  20258. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20259. */
  20260. readonly orientation: Nullable<Float32Array>;
  20261. /**
  20262. * The angularVelocity of the device, values in array are [x,y,z].
  20263. */
  20264. readonly angularVelocity: Nullable<Float32Array>;
  20265. /**
  20266. * The angularAcceleration of the device, values in array are [x,y,z].
  20267. */
  20268. readonly angularAcceleration: Nullable<Float32Array>;
  20269. }
  20270. /**
  20271. * Interface representing a pose controlled object in Babylon.
  20272. * A pose controlled object has both regular pose values as well as pose values
  20273. * from an external device such as a VR head mounted display
  20274. */
  20275. export interface PoseControlled {
  20276. /**
  20277. * The position of the object in babylon space.
  20278. */
  20279. position: Vector3;
  20280. /**
  20281. * The rotation quaternion of the object in babylon space.
  20282. */
  20283. rotationQuaternion: Quaternion;
  20284. /**
  20285. * The position of the device in babylon space.
  20286. */
  20287. devicePosition?: Vector3;
  20288. /**
  20289. * The rotation quaternion of the device in babylon space.
  20290. */
  20291. deviceRotationQuaternion: Quaternion;
  20292. /**
  20293. * The raw pose coming from the device.
  20294. */
  20295. rawPose: Nullable<DevicePose>;
  20296. /**
  20297. * The scale of the device to be used when translating from device space to babylon space.
  20298. */
  20299. deviceScaleFactor: number;
  20300. /**
  20301. * Updates the poseControlled values based on the input device pose.
  20302. * @param poseData the pose data to update the object with
  20303. */
  20304. updateFromDevice(poseData: DevicePose): void;
  20305. }
  20306. /**
  20307. * Set of options to customize the webVRCamera
  20308. */
  20309. export interface WebVROptions {
  20310. /**
  20311. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20312. */
  20313. trackPosition?: boolean;
  20314. /**
  20315. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20316. */
  20317. positionScale?: number;
  20318. /**
  20319. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20320. */
  20321. displayName?: string;
  20322. /**
  20323. * Should the native controller meshes be initialized. (default: true)
  20324. */
  20325. controllerMeshes?: boolean;
  20326. /**
  20327. * Creating a default HemiLight only on controllers. (default: true)
  20328. */
  20329. defaultLightingOnControllers?: boolean;
  20330. /**
  20331. * If you don't want to use the default VR button of the helper. (default: false)
  20332. */
  20333. useCustomVRButton?: boolean;
  20334. /**
  20335. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20336. */
  20337. customVRButton?: HTMLButtonElement;
  20338. /**
  20339. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20340. */
  20341. rayLength?: number;
  20342. /**
  20343. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20344. */
  20345. defaultHeight?: number;
  20346. /**
  20347. * If multiview should be used if availible (default: false)
  20348. */
  20349. useMultiview?: boolean;
  20350. }
  20351. /**
  20352. * This represents a WebVR camera.
  20353. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20354. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20355. */
  20356. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20357. private webVROptions;
  20358. /**
  20359. * @hidden
  20360. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20361. */
  20362. _vrDevice: any;
  20363. /**
  20364. * The rawPose of the vrDevice.
  20365. */
  20366. rawPose: Nullable<DevicePose>;
  20367. private _onVREnabled;
  20368. private _specsVersion;
  20369. private _attached;
  20370. private _frameData;
  20371. protected _descendants: Array<Node>;
  20372. private _deviceRoomPosition;
  20373. /** @hidden */
  20374. _deviceRoomRotationQuaternion: Quaternion;
  20375. private _standingMatrix;
  20376. /**
  20377. * Represents device position in babylon space.
  20378. */
  20379. devicePosition: Vector3;
  20380. /**
  20381. * Represents device rotation in babylon space.
  20382. */
  20383. deviceRotationQuaternion: Quaternion;
  20384. /**
  20385. * The scale of the device to be used when translating from device space to babylon space.
  20386. */
  20387. deviceScaleFactor: number;
  20388. private _deviceToWorld;
  20389. private _worldToDevice;
  20390. /**
  20391. * References to the webVR controllers for the vrDevice.
  20392. */
  20393. controllers: Array<WebVRController>;
  20394. /**
  20395. * Emits an event when a controller is attached.
  20396. */
  20397. onControllersAttachedObservable: Observable<WebVRController[]>;
  20398. /**
  20399. * Emits an event when a controller's mesh has been loaded;
  20400. */
  20401. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20402. /**
  20403. * Emits an event when the HMD's pose has been updated.
  20404. */
  20405. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20406. private _poseSet;
  20407. /**
  20408. * If the rig cameras be used as parent instead of this camera.
  20409. */
  20410. rigParenting: boolean;
  20411. private _lightOnControllers;
  20412. private _defaultHeight?;
  20413. /**
  20414. * Instantiates a WebVRFreeCamera.
  20415. * @param name The name of the WebVRFreeCamera
  20416. * @param position The starting anchor position for the camera
  20417. * @param scene The scene the camera belongs to
  20418. * @param webVROptions a set of customizable options for the webVRCamera
  20419. */
  20420. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20421. /**
  20422. * Gets the device distance from the ground in meters.
  20423. * @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.
  20424. */
  20425. deviceDistanceToRoomGround(): number;
  20426. /**
  20427. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20428. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20429. */
  20430. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20431. /**
  20432. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20433. * @returns A promise with a boolean set to if the standing matrix is supported.
  20434. */
  20435. useStandingMatrixAsync(): Promise<boolean>;
  20436. /**
  20437. * Disposes the camera
  20438. */
  20439. dispose(): void;
  20440. /**
  20441. * Gets a vrController by name.
  20442. * @param name The name of the controller to retreive
  20443. * @returns the controller matching the name specified or null if not found
  20444. */
  20445. getControllerByName(name: string): Nullable<WebVRController>;
  20446. private _leftController;
  20447. /**
  20448. * The controller corresponding to the users left hand.
  20449. */
  20450. get leftController(): Nullable<WebVRController>;
  20451. private _rightController;
  20452. /**
  20453. * The controller corresponding to the users right hand.
  20454. */
  20455. get rightController(): Nullable<WebVRController>;
  20456. /**
  20457. * Casts a ray forward from the vrCamera's gaze.
  20458. * @param length Length of the ray (default: 100)
  20459. * @returns the ray corresponding to the gaze
  20460. */
  20461. getForwardRay(length?: number): Ray;
  20462. /**
  20463. * @hidden
  20464. * Updates the camera based on device's frame data
  20465. */
  20466. _checkInputs(): void;
  20467. /**
  20468. * Updates the poseControlled values based on the input device pose.
  20469. * @param poseData Pose coming from the device
  20470. */
  20471. updateFromDevice(poseData: DevicePose): void;
  20472. private _htmlElementAttached;
  20473. private _detachIfAttached;
  20474. /**
  20475. * WebVR's attach control will start broadcasting frames to the device.
  20476. * Note that in certain browsers (chrome for example) this function must be called
  20477. * within a user-interaction callback. Example:
  20478. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20479. *
  20480. * @param element html element to attach the vrDevice to
  20481. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20482. */
  20483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20484. /**
  20485. * Detaches the camera from the html element and disables VR
  20486. *
  20487. * @param element html element to detach from
  20488. */
  20489. detachControl(element: HTMLElement): void;
  20490. /**
  20491. * @returns the name of this class
  20492. */
  20493. getClassName(): string;
  20494. /**
  20495. * Calls resetPose on the vrDisplay
  20496. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20497. */
  20498. resetToCurrentRotation(): void;
  20499. /**
  20500. * @hidden
  20501. * Updates the rig cameras (left and right eye)
  20502. */
  20503. _updateRigCameras(): void;
  20504. private _workingVector;
  20505. private _oneVector;
  20506. private _workingMatrix;
  20507. private updateCacheCalled;
  20508. private _correctPositionIfNotTrackPosition;
  20509. /**
  20510. * @hidden
  20511. * Updates the cached values of the camera
  20512. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20513. */
  20514. _updateCache(ignoreParentClass?: boolean): void;
  20515. /**
  20516. * @hidden
  20517. * Get current device position in babylon world
  20518. */
  20519. _computeDevicePosition(): void;
  20520. /**
  20521. * Updates the current device position and rotation in the babylon world
  20522. */
  20523. update(): void;
  20524. /**
  20525. * @hidden
  20526. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20527. * @returns an identity matrix
  20528. */
  20529. _getViewMatrix(): Matrix;
  20530. private _tmpMatrix;
  20531. /**
  20532. * This function is called by the two RIG cameras.
  20533. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20534. * @hidden
  20535. */
  20536. _getWebVRViewMatrix(): Matrix;
  20537. /** @hidden */
  20538. _getWebVRProjectionMatrix(): Matrix;
  20539. private _onGamepadConnectedObserver;
  20540. private _onGamepadDisconnectedObserver;
  20541. private _updateCacheWhenTrackingDisabledObserver;
  20542. /**
  20543. * Initializes the controllers and their meshes
  20544. */
  20545. initControllers(): void;
  20546. }
  20547. }
  20548. declare module "babylonjs/Materials/materialHelper" {
  20549. import { Nullable } from "babylonjs/types";
  20550. import { Scene } from "babylonjs/scene";
  20551. import { Engine } from "babylonjs/Engines/engine";
  20552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20553. import { Light } from "babylonjs/Lights/light";
  20554. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20555. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20557. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20558. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20559. /**
  20560. * "Static Class" containing the most commonly used helper while dealing with material for
  20561. * rendering purpose.
  20562. *
  20563. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20564. *
  20565. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20566. */
  20567. export class MaterialHelper {
  20568. /**
  20569. * Bind the current view position to an effect.
  20570. * @param effect The effect to be bound
  20571. * @param scene The scene the eyes position is used from
  20572. * @param variableName name of the shader variable that will hold the eye position
  20573. */
  20574. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20575. /**
  20576. * Helps preparing the defines values about the UVs in used in the effect.
  20577. * UVs are shared as much as we can accross channels in the shaders.
  20578. * @param texture The texture we are preparing the UVs for
  20579. * @param defines The defines to update
  20580. * @param key The channel key "diffuse", "specular"... used in the shader
  20581. */
  20582. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20583. /**
  20584. * Binds a texture matrix value to its corrsponding uniform
  20585. * @param texture The texture to bind the matrix for
  20586. * @param uniformBuffer The uniform buffer receivin the data
  20587. * @param key The channel key "diffuse", "specular"... used in the shader
  20588. */
  20589. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20590. /**
  20591. * Gets the current status of the fog (should it be enabled?)
  20592. * @param mesh defines the mesh to evaluate for fog support
  20593. * @param scene defines the hosting scene
  20594. * @returns true if fog must be enabled
  20595. */
  20596. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20597. /**
  20598. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20599. * @param mesh defines the current mesh
  20600. * @param scene defines the current scene
  20601. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20602. * @param pointsCloud defines if point cloud rendering has to be turned on
  20603. * @param fogEnabled defines if fog has to be turned on
  20604. * @param alphaTest defines if alpha testing has to be turned on
  20605. * @param defines defines the current list of defines
  20606. */
  20607. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20608. /**
  20609. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20610. * @param scene defines the current scene
  20611. * @param engine defines the current engine
  20612. * @param defines specifies the list of active defines
  20613. * @param useInstances defines if instances have to be turned on
  20614. * @param useClipPlane defines if clip plane have to be turned on
  20615. * @param useInstances defines if instances have to be turned on
  20616. * @param useThinInstances defines if thin instances have to be turned on
  20617. */
  20618. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20619. /**
  20620. * Prepares the defines for bones
  20621. * @param mesh The mesh containing the geometry data we will draw
  20622. * @param defines The defines to update
  20623. */
  20624. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20625. /**
  20626. * Prepares the defines for morph targets
  20627. * @param mesh The mesh containing the geometry data we will draw
  20628. * @param defines The defines to update
  20629. */
  20630. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20631. /**
  20632. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20633. * @param mesh The mesh containing the geometry data we will draw
  20634. * @param defines The defines to update
  20635. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20636. * @param useBones Precise whether bones should be used or not (override mesh info)
  20637. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20638. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20639. * @returns false if defines are considered not dirty and have not been checked
  20640. */
  20641. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20642. /**
  20643. * Prepares the defines related to multiview
  20644. * @param scene The scene we are intending to draw
  20645. * @param defines The defines to update
  20646. */
  20647. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20648. /**
  20649. * Prepares the defines related to the light information passed in parameter
  20650. * @param scene The scene we are intending to draw
  20651. * @param mesh The mesh the effect is compiling for
  20652. * @param light The light the effect is compiling for
  20653. * @param lightIndex The index of the light
  20654. * @param defines The defines to update
  20655. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20656. * @param state Defines the current state regarding what is needed (normals, etc...)
  20657. */
  20658. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20659. needNormals: boolean;
  20660. needRebuild: boolean;
  20661. shadowEnabled: boolean;
  20662. specularEnabled: boolean;
  20663. lightmapMode: boolean;
  20664. }): void;
  20665. /**
  20666. * Prepares the defines related to the light information passed in parameter
  20667. * @param scene The scene we are intending to draw
  20668. * @param mesh The mesh the effect is compiling for
  20669. * @param defines The defines to update
  20670. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20671. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20672. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20673. * @returns true if normals will be required for the rest of the effect
  20674. */
  20675. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20676. /**
  20677. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20678. * @param lightIndex defines the light index
  20679. * @param uniformsList The uniform list
  20680. * @param samplersList The sampler list
  20681. * @param projectedLightTexture defines if projected texture must be used
  20682. * @param uniformBuffersList defines an optional list of uniform buffers
  20683. */
  20684. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20685. /**
  20686. * Prepares the uniforms and samplers list to be used in the effect
  20687. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20688. * @param samplersList The sampler list
  20689. * @param defines The defines helping in the list generation
  20690. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20691. */
  20692. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20693. /**
  20694. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20695. * @param defines The defines to update while falling back
  20696. * @param fallbacks The authorized effect fallbacks
  20697. * @param maxSimultaneousLights The maximum number of lights allowed
  20698. * @param rank the current rank of the Effect
  20699. * @returns The newly affected rank
  20700. */
  20701. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20702. private static _TmpMorphInfluencers;
  20703. /**
  20704. * Prepares the list of attributes required for morph targets according to the effect defines.
  20705. * @param attribs The current list of supported attribs
  20706. * @param mesh The mesh to prepare the morph targets attributes for
  20707. * @param influencers The number of influencers
  20708. */
  20709. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20710. /**
  20711. * Prepares the list of attributes required for morph targets according to the effect defines.
  20712. * @param attribs The current list of supported attribs
  20713. * @param mesh The mesh to prepare the morph targets attributes for
  20714. * @param defines The current Defines of the effect
  20715. */
  20716. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20717. /**
  20718. * Prepares the list of attributes required for bones according to the effect defines.
  20719. * @param attribs The current list of supported attribs
  20720. * @param mesh The mesh to prepare the bones attributes for
  20721. * @param defines The current Defines of the effect
  20722. * @param fallbacks The current efffect fallback strategy
  20723. */
  20724. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20725. /**
  20726. * Check and prepare the list of attributes required for instances according to the effect defines.
  20727. * @param attribs The current list of supported attribs
  20728. * @param defines The current MaterialDefines of the effect
  20729. */
  20730. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20731. /**
  20732. * Add the list of attributes required for instances to the attribs array.
  20733. * @param attribs The current list of supported attribs
  20734. */
  20735. static PushAttributesForInstances(attribs: string[]): void;
  20736. /**
  20737. * Binds the light information to the effect.
  20738. * @param light The light containing the generator
  20739. * @param effect The effect we are binding the data to
  20740. * @param lightIndex The light index in the effect used to render
  20741. */
  20742. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20743. /**
  20744. * Binds the lights information from the scene to the effect for the given mesh.
  20745. * @param light Light to bind
  20746. * @param lightIndex Light index
  20747. * @param scene The scene where the light belongs to
  20748. * @param effect The effect we are binding the data to
  20749. * @param useSpecular Defines if specular is supported
  20750. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20751. */
  20752. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20753. /**
  20754. * Binds the lights information from the scene to the effect for the given mesh.
  20755. * @param scene The scene the lights belongs to
  20756. * @param mesh The mesh we are binding the information to render
  20757. * @param effect The effect we are binding the data to
  20758. * @param defines The generated defines for the effect
  20759. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20760. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20761. */
  20762. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20763. private static _tempFogColor;
  20764. /**
  20765. * Binds the fog information from the scene to the effect for the given mesh.
  20766. * @param scene The scene the lights belongs to
  20767. * @param mesh The mesh we are binding the information to render
  20768. * @param effect The effect we are binding the data to
  20769. * @param linearSpace Defines if the fog effect is applied in linear space
  20770. */
  20771. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20772. /**
  20773. * Binds the bones information from the mesh to the effect.
  20774. * @param mesh The mesh we are binding the information to render
  20775. * @param effect The effect we are binding the data to
  20776. */
  20777. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20778. /**
  20779. * Binds the morph targets information from the mesh to the effect.
  20780. * @param abstractMesh The mesh we are binding the information to render
  20781. * @param effect The effect we are binding the data to
  20782. */
  20783. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20784. /**
  20785. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20786. * @param defines The generated defines used in the effect
  20787. * @param effect The effect we are binding the data to
  20788. * @param scene The scene we are willing to render with logarithmic scale for
  20789. */
  20790. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20791. /**
  20792. * Binds the clip plane information from the scene to the effect.
  20793. * @param scene The scene the clip plane information are extracted from
  20794. * @param effect The effect we are binding the data to
  20795. */
  20796. static BindClipPlane(effect: Effect, scene: Scene): void;
  20797. }
  20798. }
  20799. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20801. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20802. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20803. import { Nullable } from "babylonjs/types";
  20804. import { Effect } from "babylonjs/Materials/effect";
  20805. import { Matrix } from "babylonjs/Maths/math.vector";
  20806. import { Scene } from "babylonjs/scene";
  20807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20809. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20810. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20811. import { Observable } from "babylonjs/Misc/observable";
  20812. /**
  20813. * Block used to expose an input value
  20814. */
  20815. export class InputBlock extends NodeMaterialBlock {
  20816. private _mode;
  20817. private _associatedVariableName;
  20818. private _storedValue;
  20819. private _valueCallback;
  20820. private _type;
  20821. private _animationType;
  20822. /** Gets or set a value used to limit the range of float values */
  20823. min: number;
  20824. /** Gets or set a value used to limit the range of float values */
  20825. max: number;
  20826. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20827. isBoolean: boolean;
  20828. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20829. matrixMode: number;
  20830. /** @hidden */
  20831. _systemValue: Nullable<NodeMaterialSystemValues>;
  20832. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20833. visibleInInspector: boolean;
  20834. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20835. isConstant: boolean;
  20836. /** Gets or sets the group to use to display this block in the Inspector */
  20837. groupInInspector: string;
  20838. /** Gets an observable raised when the value is changed */
  20839. onValueChangedObservable: Observable<InputBlock>;
  20840. /**
  20841. * Gets or sets the connection point type (default is float)
  20842. */
  20843. get type(): NodeMaterialBlockConnectionPointTypes;
  20844. /**
  20845. * Creates a new InputBlock
  20846. * @param name defines the block name
  20847. * @param target defines the target of that block (Vertex by default)
  20848. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20849. */
  20850. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20851. /**
  20852. * Gets the output component
  20853. */
  20854. get output(): NodeMaterialConnectionPoint;
  20855. /**
  20856. * Set the source of this connection point to a vertex attribute
  20857. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20858. * @returns the current connection point
  20859. */
  20860. setAsAttribute(attributeName?: string): InputBlock;
  20861. /**
  20862. * Set the source of this connection point to a system value
  20863. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20864. * @returns the current connection point
  20865. */
  20866. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20867. /**
  20868. * Gets or sets the value of that point.
  20869. * Please note that this value will be ignored if valueCallback is defined
  20870. */
  20871. get value(): any;
  20872. set value(value: any);
  20873. /**
  20874. * Gets or sets a callback used to get the value of that point.
  20875. * Please note that setting this value will force the connection point to ignore the value property
  20876. */
  20877. get valueCallback(): () => any;
  20878. set valueCallback(value: () => any);
  20879. /**
  20880. * Gets or sets the associated variable name in the shader
  20881. */
  20882. get associatedVariableName(): string;
  20883. set associatedVariableName(value: string);
  20884. /** Gets or sets the type of animation applied to the input */
  20885. get animationType(): AnimatedInputBlockTypes;
  20886. set animationType(value: AnimatedInputBlockTypes);
  20887. /**
  20888. * Gets a boolean indicating that this connection point not defined yet
  20889. */
  20890. get isUndefined(): boolean;
  20891. /**
  20892. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20893. * In this case the connection point name must be the name of the uniform to use.
  20894. * Can only be set on inputs
  20895. */
  20896. get isUniform(): boolean;
  20897. set isUniform(value: boolean);
  20898. /**
  20899. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20900. * In this case the connection point name must be the name of the attribute to use
  20901. * Can only be set on inputs
  20902. */
  20903. get isAttribute(): boolean;
  20904. set isAttribute(value: boolean);
  20905. /**
  20906. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20907. * Can only be set on exit points
  20908. */
  20909. get isVarying(): boolean;
  20910. set isVarying(value: boolean);
  20911. /**
  20912. * Gets a boolean indicating that the current connection point is a system value
  20913. */
  20914. get isSystemValue(): boolean;
  20915. /**
  20916. * Gets or sets the current well known value or null if not defined as a system value
  20917. */
  20918. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20919. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20920. /**
  20921. * Gets the current class name
  20922. * @returns the class name
  20923. */
  20924. getClassName(): string;
  20925. /**
  20926. * Animate the input if animationType !== None
  20927. * @param scene defines the rendering scene
  20928. */
  20929. animate(scene: Scene): void;
  20930. private _emitDefine;
  20931. initialize(state: NodeMaterialBuildState): void;
  20932. /**
  20933. * Set the input block to its default value (based on its type)
  20934. */
  20935. setDefaultValue(): void;
  20936. private _emitConstant;
  20937. /** @hidden */
  20938. get _noContextSwitch(): boolean;
  20939. private _emit;
  20940. /** @hidden */
  20941. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20942. /** @hidden */
  20943. _transmit(effect: Effect, scene: Scene): void;
  20944. protected _buildBlock(state: NodeMaterialBuildState): void;
  20945. protected _dumpPropertiesCode(): string;
  20946. dispose(): void;
  20947. serialize(): any;
  20948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20949. }
  20950. }
  20951. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20952. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20953. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20954. import { Nullable } from "babylonjs/types";
  20955. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20956. import { Observable } from "babylonjs/Misc/observable";
  20957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20958. /**
  20959. * Enum used to define the compatibility state between two connection points
  20960. */
  20961. export enum NodeMaterialConnectionPointCompatibilityStates {
  20962. /** Points are compatibles */
  20963. Compatible = 0,
  20964. /** Points are incompatible because of their types */
  20965. TypeIncompatible = 1,
  20966. /** Points are incompatible because of their targets (vertex vs fragment) */
  20967. TargetIncompatible = 2
  20968. }
  20969. /**
  20970. * Defines the direction of a connection point
  20971. */
  20972. export enum NodeMaterialConnectionPointDirection {
  20973. /** Input */
  20974. Input = 0,
  20975. /** Output */
  20976. Output = 1
  20977. }
  20978. /**
  20979. * Defines a connection point for a block
  20980. */
  20981. export class NodeMaterialConnectionPoint {
  20982. /** @hidden */
  20983. _ownerBlock: NodeMaterialBlock;
  20984. /** @hidden */
  20985. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20986. private _endpoints;
  20987. private _associatedVariableName;
  20988. private _direction;
  20989. /** @hidden */
  20990. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20991. /** @hidden */
  20992. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20993. private _type;
  20994. /** @hidden */
  20995. _enforceAssociatedVariableName: boolean;
  20996. /** Gets the direction of the point */
  20997. get direction(): NodeMaterialConnectionPointDirection;
  20998. /** Indicates that this connection point needs dual validation before being connected to another point */
  20999. needDualDirectionValidation: boolean;
  21000. /**
  21001. * Gets or sets the additional types supported by this connection point
  21002. */
  21003. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21004. /**
  21005. * Gets or sets the additional types excluded by this connection point
  21006. */
  21007. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21008. /**
  21009. * Observable triggered when this point is connected
  21010. */
  21011. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21012. /**
  21013. * Gets or sets the associated variable name in the shader
  21014. */
  21015. get associatedVariableName(): string;
  21016. set associatedVariableName(value: string);
  21017. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21018. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21019. /**
  21020. * Gets or sets the connection point type (default is float)
  21021. */
  21022. get type(): NodeMaterialBlockConnectionPointTypes;
  21023. set type(value: NodeMaterialBlockConnectionPointTypes);
  21024. /**
  21025. * Gets or sets the connection point name
  21026. */
  21027. name: string;
  21028. /**
  21029. * Gets or sets the connection point name
  21030. */
  21031. displayName: string;
  21032. /**
  21033. * Gets or sets a boolean indicating that this connection point can be omitted
  21034. */
  21035. isOptional: boolean;
  21036. /**
  21037. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21038. */
  21039. define: string;
  21040. /** @hidden */
  21041. _prioritizeVertex: boolean;
  21042. private _target;
  21043. /** Gets or sets the target of that connection point */
  21044. get target(): NodeMaterialBlockTargets;
  21045. set target(value: NodeMaterialBlockTargets);
  21046. /**
  21047. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21048. */
  21049. get isConnected(): boolean;
  21050. /**
  21051. * Gets a boolean indicating that the current point is connected to an input block
  21052. */
  21053. get isConnectedToInputBlock(): boolean;
  21054. /**
  21055. * Gets a the connected input block (if any)
  21056. */
  21057. get connectInputBlock(): Nullable<InputBlock>;
  21058. /** Get the other side of the connection (if any) */
  21059. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21060. /** Get the block that owns this connection point */
  21061. get ownerBlock(): NodeMaterialBlock;
  21062. /** Get the block connected on the other side of this connection (if any) */
  21063. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21064. /** Get the block connected on the endpoints of this connection (if any) */
  21065. get connectedBlocks(): Array<NodeMaterialBlock>;
  21066. /** Gets the list of connected endpoints */
  21067. get endpoints(): NodeMaterialConnectionPoint[];
  21068. /** Gets a boolean indicating if that output point is connected to at least one input */
  21069. get hasEndpoints(): boolean;
  21070. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21071. get isConnectedInVertexShader(): boolean;
  21072. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21073. get isConnectedInFragmentShader(): boolean;
  21074. /**
  21075. * Creates a block suitable to be used as an input for this input point.
  21076. * If null is returned, a block based on the point type will be created.
  21077. * @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
  21078. */
  21079. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21080. /**
  21081. * Creates a new connection point
  21082. * @param name defines the connection point name
  21083. * @param ownerBlock defines the block hosting this connection point
  21084. * @param direction defines the direction of the connection point
  21085. */
  21086. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21087. /**
  21088. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21089. * @returns the class name
  21090. */
  21091. getClassName(): string;
  21092. /**
  21093. * Gets a boolean indicating if the current point can be connected to another point
  21094. * @param connectionPoint defines the other connection point
  21095. * @returns a boolean
  21096. */
  21097. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21098. /**
  21099. * Gets a number indicating if the current point can be connected to another point
  21100. * @param connectionPoint defines the other connection point
  21101. * @returns a number defining the compatibility state
  21102. */
  21103. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21104. /**
  21105. * Connect this point to another connection point
  21106. * @param connectionPoint defines the other connection point
  21107. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21108. * @returns the current connection point
  21109. */
  21110. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21111. /**
  21112. * Disconnect this point from one of his endpoint
  21113. * @param endpoint defines the other connection point
  21114. * @returns the current connection point
  21115. */
  21116. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Serializes this point in a JSON representation
  21119. * @param isInput defines if the connection point is an input (default is true)
  21120. * @returns the serialized point object
  21121. */
  21122. serialize(isInput?: boolean): any;
  21123. /**
  21124. * Release resources
  21125. */
  21126. dispose(): void;
  21127. }
  21128. }
  21129. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21130. /**
  21131. * Enum used to define the material modes
  21132. */
  21133. export enum NodeMaterialModes {
  21134. /** Regular material */
  21135. Material = 0,
  21136. /** For post process */
  21137. PostProcess = 1,
  21138. /** For particle system */
  21139. Particle = 2
  21140. }
  21141. }
  21142. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21145. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21148. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21149. import { Effect } from "babylonjs/Materials/effect";
  21150. import { Mesh } from "babylonjs/Meshes/mesh";
  21151. import { Nullable } from "babylonjs/types";
  21152. import { Texture } from "babylonjs/Materials/Textures/texture";
  21153. import { Scene } from "babylonjs/scene";
  21154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21155. /**
  21156. * Block used to read a texture from a sampler
  21157. */
  21158. export class TextureBlock extends NodeMaterialBlock {
  21159. private _defineName;
  21160. private _linearDefineName;
  21161. private _gammaDefineName;
  21162. private _tempTextureRead;
  21163. private _samplerName;
  21164. private _transformedUVName;
  21165. private _textureTransformName;
  21166. private _textureInfoName;
  21167. private _mainUVName;
  21168. private _mainUVDefineName;
  21169. private _fragmentOnly;
  21170. /**
  21171. * Gets or sets the texture associated with the node
  21172. */
  21173. texture: Nullable<Texture>;
  21174. /**
  21175. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21176. */
  21177. convertToGammaSpace: boolean;
  21178. /**
  21179. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21180. */
  21181. convertToLinearSpace: boolean;
  21182. /**
  21183. * Create a new TextureBlock
  21184. * @param name defines the block name
  21185. */
  21186. constructor(name: string, fragmentOnly?: boolean);
  21187. /**
  21188. * Gets the current class name
  21189. * @returns the class name
  21190. */
  21191. getClassName(): string;
  21192. /**
  21193. * Gets the uv input component
  21194. */
  21195. get uv(): NodeMaterialConnectionPoint;
  21196. /**
  21197. * Gets the rgba output component
  21198. */
  21199. get rgba(): NodeMaterialConnectionPoint;
  21200. /**
  21201. * Gets the rgb output component
  21202. */
  21203. get rgb(): NodeMaterialConnectionPoint;
  21204. /**
  21205. * Gets the r output component
  21206. */
  21207. get r(): NodeMaterialConnectionPoint;
  21208. /**
  21209. * Gets the g output component
  21210. */
  21211. get g(): NodeMaterialConnectionPoint;
  21212. /**
  21213. * Gets the b output component
  21214. */
  21215. get b(): NodeMaterialConnectionPoint;
  21216. /**
  21217. * Gets the a output component
  21218. */
  21219. get a(): NodeMaterialConnectionPoint;
  21220. get target(): NodeMaterialBlockTargets;
  21221. autoConfigure(material: NodeMaterial): void;
  21222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21224. isReady(): boolean;
  21225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21226. private get _isMixed();
  21227. private _injectVertexCode;
  21228. private _writeTextureRead;
  21229. private _writeOutput;
  21230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21231. protected _dumpPropertiesCode(): string;
  21232. serialize(): any;
  21233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21234. }
  21235. }
  21236. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21237. /** @hidden */
  21238. export var reflectionFunction: {
  21239. name: string;
  21240. shader: string;
  21241. };
  21242. }
  21243. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21249. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21250. import { Effect } from "babylonjs/Materials/effect";
  21251. import { Mesh } from "babylonjs/Meshes/mesh";
  21252. import { Nullable } from "babylonjs/types";
  21253. import { Scene } from "babylonjs/scene";
  21254. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21255. /**
  21256. * Base block used to read a reflection texture from a sampler
  21257. */
  21258. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21259. /** @hidden */
  21260. _define3DName: string;
  21261. /** @hidden */
  21262. _defineCubicName: string;
  21263. /** @hidden */
  21264. _defineExplicitName: string;
  21265. /** @hidden */
  21266. _defineProjectionName: string;
  21267. /** @hidden */
  21268. _defineLocalCubicName: string;
  21269. /** @hidden */
  21270. _defineSphericalName: string;
  21271. /** @hidden */
  21272. _definePlanarName: string;
  21273. /** @hidden */
  21274. _defineEquirectangularName: string;
  21275. /** @hidden */
  21276. _defineMirroredEquirectangularFixedName: string;
  21277. /** @hidden */
  21278. _defineEquirectangularFixedName: string;
  21279. /** @hidden */
  21280. _defineSkyboxName: string;
  21281. /** @hidden */
  21282. _defineOppositeZ: string;
  21283. /** @hidden */
  21284. _cubeSamplerName: string;
  21285. /** @hidden */
  21286. _2DSamplerName: string;
  21287. protected _positionUVWName: string;
  21288. protected _directionWName: string;
  21289. protected _reflectionVectorName: string;
  21290. /** @hidden */
  21291. _reflectionCoordsName: string;
  21292. /** @hidden */
  21293. _reflectionMatrixName: string;
  21294. protected _reflectionColorName: string;
  21295. /**
  21296. * Gets or sets the texture associated with the node
  21297. */
  21298. texture: Nullable<BaseTexture>;
  21299. /**
  21300. * Create a new ReflectionTextureBaseBlock
  21301. * @param name defines the block name
  21302. */
  21303. constructor(name: string);
  21304. /**
  21305. * Gets the current class name
  21306. * @returns the class name
  21307. */
  21308. getClassName(): string;
  21309. /**
  21310. * Gets the world position input component
  21311. */
  21312. abstract get position(): NodeMaterialConnectionPoint;
  21313. /**
  21314. * Gets the world position input component
  21315. */
  21316. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21317. /**
  21318. * Gets the world normal input component
  21319. */
  21320. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21321. /**
  21322. * Gets the world input component
  21323. */
  21324. abstract get world(): NodeMaterialConnectionPoint;
  21325. /**
  21326. * Gets the camera (or eye) position component
  21327. */
  21328. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21329. /**
  21330. * Gets the view input component
  21331. */
  21332. abstract get view(): NodeMaterialConnectionPoint;
  21333. protected _getTexture(): Nullable<BaseTexture>;
  21334. autoConfigure(material: NodeMaterial): void;
  21335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21336. isReady(): boolean;
  21337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21338. /**
  21339. * Gets the code to inject in the vertex shader
  21340. * @param state current state of the node material building
  21341. * @returns the shader code
  21342. */
  21343. handleVertexSide(state: NodeMaterialBuildState): string;
  21344. /**
  21345. * Handles the inits for the fragment code path
  21346. * @param state node material build state
  21347. */
  21348. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21349. /**
  21350. * Generates the reflection coords code for the fragment code path
  21351. * @param worldNormalVarName name of the world normal variable
  21352. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21353. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21354. * @returns the shader code
  21355. */
  21356. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21357. /**
  21358. * Generates the reflection color code for the fragment code path
  21359. * @param lodVarName name of the lod variable
  21360. * @param swizzleLookupTexture swizzle to use for the final color variable
  21361. * @returns the shader code
  21362. */
  21363. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21364. /**
  21365. * Generates the code corresponding to the connected output points
  21366. * @param state node material build state
  21367. * @param varName name of the variable to output
  21368. * @returns the shader code
  21369. */
  21370. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21371. protected _buildBlock(state: NodeMaterialBuildState): this;
  21372. protected _dumpPropertiesCode(): string;
  21373. serialize(): any;
  21374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21375. }
  21376. }
  21377. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21379. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21380. import { Nullable } from "babylonjs/types";
  21381. /**
  21382. * Defines a connection point to be used for points with a custom object type
  21383. */
  21384. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21385. private _blockType;
  21386. private _blockName;
  21387. private _nameForCheking?;
  21388. /**
  21389. * Creates a new connection point
  21390. * @param name defines the connection point name
  21391. * @param ownerBlock defines the block hosting this connection point
  21392. * @param direction defines the direction of the connection point
  21393. */
  21394. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21395. /**
  21396. * Gets a number indicating if the current point can be connected to another point
  21397. * @param connectionPoint defines the other connection point
  21398. * @returns a number defining the compatibility state
  21399. */
  21400. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21401. /**
  21402. * Creates a block suitable to be used as an input for this input point.
  21403. * If null is returned, a block based on the point type will be created.
  21404. * @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
  21405. */
  21406. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21407. }
  21408. }
  21409. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21410. /**
  21411. * Enum defining the type of properties that can be edited in the property pages in the NME
  21412. */
  21413. export enum PropertyTypeForEdition {
  21414. /** property is a boolean */
  21415. Boolean = 0,
  21416. /** property is a float */
  21417. Float = 1,
  21418. /** property is a Vector2 */
  21419. Vector2 = 2,
  21420. /** property is a list of values */
  21421. List = 3
  21422. }
  21423. /**
  21424. * Interface that defines an option in a variable of type list
  21425. */
  21426. export interface IEditablePropertyListOption {
  21427. /** label of the option */
  21428. "label": string;
  21429. /** value of the option */
  21430. "value": number;
  21431. }
  21432. /**
  21433. * Interface that defines the options available for an editable property
  21434. */
  21435. export interface IEditablePropertyOption {
  21436. /** min value */
  21437. "min"?: number;
  21438. /** max value */
  21439. "max"?: number;
  21440. /** notifiers: indicates which actions to take when the property is changed */
  21441. "notifiers"?: {
  21442. /** the material should be rebuilt */
  21443. "rebuild"?: boolean;
  21444. /** the preview should be updated */
  21445. "update"?: boolean;
  21446. };
  21447. /** list of the options for a variable of type list */
  21448. "options"?: IEditablePropertyListOption[];
  21449. }
  21450. /**
  21451. * Interface that describes an editable property
  21452. */
  21453. export interface IPropertyDescriptionForEdition {
  21454. /** name of the property */
  21455. "propertyName": string;
  21456. /** display name of the property */
  21457. "displayName": string;
  21458. /** type of the property */
  21459. "type": PropertyTypeForEdition;
  21460. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21461. "groupName": string;
  21462. /** options for the property */
  21463. "options": IEditablePropertyOption;
  21464. }
  21465. /**
  21466. * Decorator that flags a property in a node material block as being editable
  21467. */
  21468. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21469. }
  21470. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21475. import { Nullable } from "babylonjs/types";
  21476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21477. import { Mesh } from "babylonjs/Meshes/mesh";
  21478. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21479. import { Effect } from "babylonjs/Materials/effect";
  21480. import { Scene } from "babylonjs/scene";
  21481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21482. /**
  21483. * Block used to implement the refraction part of the sub surface module of the PBR material
  21484. */
  21485. export class RefractionBlock extends NodeMaterialBlock {
  21486. /** @hidden */
  21487. _define3DName: string;
  21488. /** @hidden */
  21489. _refractionMatrixName: string;
  21490. /** @hidden */
  21491. _defineLODRefractionAlpha: string;
  21492. /** @hidden */
  21493. _defineLinearSpecularRefraction: string;
  21494. /** @hidden */
  21495. _defineOppositeZ: string;
  21496. /** @hidden */
  21497. _cubeSamplerName: string;
  21498. /** @hidden */
  21499. _2DSamplerName: string;
  21500. /** @hidden */
  21501. _vRefractionMicrosurfaceInfosName: string;
  21502. /** @hidden */
  21503. _vRefractionInfosName: string;
  21504. private _scene;
  21505. /**
  21506. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21507. * Materials half opaque for instance using refraction could benefit from this control.
  21508. */
  21509. linkRefractionWithTransparency: boolean;
  21510. /**
  21511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21512. */
  21513. invertRefractionY: boolean;
  21514. /**
  21515. * Gets or sets the texture associated with the node
  21516. */
  21517. texture: Nullable<BaseTexture>;
  21518. /**
  21519. * Create a new RefractionBlock
  21520. * @param name defines the block name
  21521. */
  21522. constructor(name: string);
  21523. /**
  21524. * Gets the current class name
  21525. * @returns the class name
  21526. */
  21527. getClassName(): string;
  21528. /**
  21529. * Gets the intensity input component
  21530. */
  21531. get intensity(): NodeMaterialConnectionPoint;
  21532. /**
  21533. * Gets the index of refraction input component
  21534. */
  21535. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21536. /**
  21537. * Gets the tint at distance input component
  21538. */
  21539. get tintAtDistance(): NodeMaterialConnectionPoint;
  21540. /**
  21541. * Gets the view input component
  21542. */
  21543. get view(): NodeMaterialConnectionPoint;
  21544. /**
  21545. * Gets the refraction object output component
  21546. */
  21547. get refraction(): NodeMaterialConnectionPoint;
  21548. /**
  21549. * Returns true if the block has a texture
  21550. */
  21551. get hasTexture(): boolean;
  21552. protected _getTexture(): Nullable<BaseTexture>;
  21553. autoConfigure(material: NodeMaterial): void;
  21554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21555. isReady(): boolean;
  21556. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21557. /**
  21558. * Gets the main code of the block (fragment side)
  21559. * @param state current state of the node material building
  21560. * @returns the shader code
  21561. */
  21562. getCode(state: NodeMaterialBuildState): string;
  21563. protected _buildBlock(state: NodeMaterialBuildState): this;
  21564. protected _dumpPropertiesCode(): string;
  21565. serialize(): any;
  21566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21567. }
  21568. }
  21569. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21572. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21575. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21577. import { Nullable } from "babylonjs/types";
  21578. import { Scene } from "babylonjs/scene";
  21579. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21580. /**
  21581. * Base block used as input for post process
  21582. */
  21583. export class CurrentScreenBlock extends NodeMaterialBlock {
  21584. private _samplerName;
  21585. private _linearDefineName;
  21586. private _gammaDefineName;
  21587. private _mainUVName;
  21588. private _tempTextureRead;
  21589. /**
  21590. * Gets or sets the texture associated with the node
  21591. */
  21592. texture: Nullable<BaseTexture>;
  21593. /**
  21594. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21595. */
  21596. convertToGammaSpace: boolean;
  21597. /**
  21598. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21599. */
  21600. convertToLinearSpace: boolean;
  21601. /**
  21602. * Create a new CurrentScreenBlock
  21603. * @param name defines the block name
  21604. */
  21605. constructor(name: string);
  21606. /**
  21607. * Gets the current class name
  21608. * @returns the class name
  21609. */
  21610. getClassName(): string;
  21611. /**
  21612. * Gets the uv input component
  21613. */
  21614. get uv(): NodeMaterialConnectionPoint;
  21615. /**
  21616. * Gets the rgba output component
  21617. */
  21618. get rgba(): NodeMaterialConnectionPoint;
  21619. /**
  21620. * Gets the rgb output component
  21621. */
  21622. get rgb(): NodeMaterialConnectionPoint;
  21623. /**
  21624. * Gets the r output component
  21625. */
  21626. get r(): NodeMaterialConnectionPoint;
  21627. /**
  21628. * Gets the g output component
  21629. */
  21630. get g(): NodeMaterialConnectionPoint;
  21631. /**
  21632. * Gets the b output component
  21633. */
  21634. get b(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Gets the a output component
  21637. */
  21638. get a(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Initialize the block and prepare the context for build
  21641. * @param state defines the state that will be used for the build
  21642. */
  21643. initialize(state: NodeMaterialBuildState): void;
  21644. get target(): NodeMaterialBlockTargets;
  21645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21646. isReady(): boolean;
  21647. private _injectVertexCode;
  21648. private _writeTextureRead;
  21649. private _writeOutput;
  21650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21651. serialize(): any;
  21652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21653. }
  21654. }
  21655. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21660. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21662. import { Nullable } from "babylonjs/types";
  21663. import { Scene } from "babylonjs/scene";
  21664. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21665. /**
  21666. * Base block used for the particle texture
  21667. */
  21668. export class ParticleTextureBlock extends NodeMaterialBlock {
  21669. private _samplerName;
  21670. private _linearDefineName;
  21671. private _gammaDefineName;
  21672. private _tempTextureRead;
  21673. /**
  21674. * Gets or sets the texture associated with the node
  21675. */
  21676. texture: Nullable<BaseTexture>;
  21677. /**
  21678. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21679. */
  21680. convertToGammaSpace: boolean;
  21681. /**
  21682. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21683. */
  21684. convertToLinearSpace: boolean;
  21685. /**
  21686. * Create a new ParticleTextureBlock
  21687. * @param name defines the block name
  21688. */
  21689. constructor(name: string);
  21690. /**
  21691. * Gets the current class name
  21692. * @returns the class name
  21693. */
  21694. getClassName(): string;
  21695. /**
  21696. * Gets the uv input component
  21697. */
  21698. get uv(): NodeMaterialConnectionPoint;
  21699. /**
  21700. * Gets the rgba output component
  21701. */
  21702. get rgba(): NodeMaterialConnectionPoint;
  21703. /**
  21704. * Gets the rgb output component
  21705. */
  21706. get rgb(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the r output component
  21709. */
  21710. get r(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the g output component
  21713. */
  21714. get g(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the b output component
  21717. */
  21718. get b(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the a output component
  21721. */
  21722. get a(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Initialize the block and prepare the context for build
  21725. * @param state defines the state that will be used for the build
  21726. */
  21727. initialize(state: NodeMaterialBuildState): void;
  21728. autoConfigure(material: NodeMaterial): void;
  21729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21730. isReady(): boolean;
  21731. private _writeOutput;
  21732. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21733. serialize(): any;
  21734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21735. }
  21736. }
  21737. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21740. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21741. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21742. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21743. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21744. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21745. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21746. import { Scene } from "babylonjs/scene";
  21747. /**
  21748. * Class used to store shared data between 2 NodeMaterialBuildState
  21749. */
  21750. export class NodeMaterialBuildStateSharedData {
  21751. /**
  21752. * Gets the list of emitted varyings
  21753. */
  21754. temps: string[];
  21755. /**
  21756. * Gets the list of emitted varyings
  21757. */
  21758. varyings: string[];
  21759. /**
  21760. * Gets the varying declaration string
  21761. */
  21762. varyingDeclaration: string;
  21763. /**
  21764. * Input blocks
  21765. */
  21766. inputBlocks: InputBlock[];
  21767. /**
  21768. * Input blocks
  21769. */
  21770. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21771. /**
  21772. * Bindable blocks (Blocks that need to set data to the effect)
  21773. */
  21774. bindableBlocks: NodeMaterialBlock[];
  21775. /**
  21776. * List of blocks that can provide a compilation fallback
  21777. */
  21778. blocksWithFallbacks: NodeMaterialBlock[];
  21779. /**
  21780. * List of blocks that can provide a define update
  21781. */
  21782. blocksWithDefines: NodeMaterialBlock[];
  21783. /**
  21784. * List of blocks that can provide a repeatable content
  21785. */
  21786. repeatableContentBlocks: NodeMaterialBlock[];
  21787. /**
  21788. * List of blocks that can provide a dynamic list of uniforms
  21789. */
  21790. dynamicUniformBlocks: NodeMaterialBlock[];
  21791. /**
  21792. * List of blocks that can block the isReady function for the material
  21793. */
  21794. blockingBlocks: NodeMaterialBlock[];
  21795. /**
  21796. * Gets the list of animated inputs
  21797. */
  21798. animatedInputs: InputBlock[];
  21799. /**
  21800. * Build Id used to avoid multiple recompilations
  21801. */
  21802. buildId: number;
  21803. /** List of emitted variables */
  21804. variableNames: {
  21805. [key: string]: number;
  21806. };
  21807. /** List of emitted defines */
  21808. defineNames: {
  21809. [key: string]: number;
  21810. };
  21811. /** Should emit comments? */
  21812. emitComments: boolean;
  21813. /** Emit build activity */
  21814. verbose: boolean;
  21815. /** Gets or sets the hosting scene */
  21816. scene: Scene;
  21817. /**
  21818. * Gets the compilation hints emitted at compilation time
  21819. */
  21820. hints: {
  21821. needWorldViewMatrix: boolean;
  21822. needWorldViewProjectionMatrix: boolean;
  21823. needAlphaBlending: boolean;
  21824. needAlphaTesting: boolean;
  21825. };
  21826. /**
  21827. * List of compilation checks
  21828. */
  21829. checks: {
  21830. emitVertex: boolean;
  21831. emitFragment: boolean;
  21832. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21833. };
  21834. /**
  21835. * Is vertex program allowed to be empty?
  21836. */
  21837. allowEmptyVertexProgram: boolean;
  21838. /** Creates a new shared data */
  21839. constructor();
  21840. /**
  21841. * Emits console errors and exceptions if there is a failing check
  21842. */
  21843. emitErrors(): void;
  21844. }
  21845. }
  21846. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21847. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21848. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21849. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21850. /**
  21851. * Class used to store node based material build state
  21852. */
  21853. export class NodeMaterialBuildState {
  21854. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21855. supportUniformBuffers: boolean;
  21856. /**
  21857. * Gets the list of emitted attributes
  21858. */
  21859. attributes: string[];
  21860. /**
  21861. * Gets the list of emitted uniforms
  21862. */
  21863. uniforms: string[];
  21864. /**
  21865. * Gets the list of emitted constants
  21866. */
  21867. constants: string[];
  21868. /**
  21869. * Gets the list of emitted samplers
  21870. */
  21871. samplers: string[];
  21872. /**
  21873. * Gets the list of emitted functions
  21874. */
  21875. functions: {
  21876. [key: string]: string;
  21877. };
  21878. /**
  21879. * Gets the list of emitted extensions
  21880. */
  21881. extensions: {
  21882. [key: string]: string;
  21883. };
  21884. /**
  21885. * Gets the target of the compilation state
  21886. */
  21887. target: NodeMaterialBlockTargets;
  21888. /**
  21889. * Gets the list of emitted counters
  21890. */
  21891. counters: {
  21892. [key: string]: number;
  21893. };
  21894. /**
  21895. * Shared data between multiple NodeMaterialBuildState instances
  21896. */
  21897. sharedData: NodeMaterialBuildStateSharedData;
  21898. /** @hidden */
  21899. _vertexState: NodeMaterialBuildState;
  21900. /** @hidden */
  21901. _attributeDeclaration: string;
  21902. /** @hidden */
  21903. _uniformDeclaration: string;
  21904. /** @hidden */
  21905. _constantDeclaration: string;
  21906. /** @hidden */
  21907. _samplerDeclaration: string;
  21908. /** @hidden */
  21909. _varyingTransfer: string;
  21910. /** @hidden */
  21911. _injectAtEnd: string;
  21912. private _repeatableContentAnchorIndex;
  21913. /** @hidden */
  21914. _builtCompilationString: string;
  21915. /**
  21916. * Gets the emitted compilation strings
  21917. */
  21918. compilationString: string;
  21919. /**
  21920. * Finalize the compilation strings
  21921. * @param state defines the current compilation state
  21922. */
  21923. finalize(state: NodeMaterialBuildState): void;
  21924. /** @hidden */
  21925. get _repeatableContentAnchor(): string;
  21926. /** @hidden */
  21927. _getFreeVariableName(prefix: string): string;
  21928. /** @hidden */
  21929. _getFreeDefineName(prefix: string): string;
  21930. /** @hidden */
  21931. _excludeVariableName(name: string): void;
  21932. /** @hidden */
  21933. _emit2DSampler(name: string): void;
  21934. /** @hidden */
  21935. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21936. /** @hidden */
  21937. _emitExtension(name: string, extension: string, define?: string): void;
  21938. /** @hidden */
  21939. _emitFunction(name: string, code: string, comments: string): void;
  21940. /** @hidden */
  21941. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21942. replaceStrings?: {
  21943. search: RegExp;
  21944. replace: string;
  21945. }[];
  21946. repeatKey?: string;
  21947. }): string;
  21948. /** @hidden */
  21949. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21950. repeatKey?: string;
  21951. removeAttributes?: boolean;
  21952. removeUniforms?: boolean;
  21953. removeVaryings?: boolean;
  21954. removeIfDef?: boolean;
  21955. replaceStrings?: {
  21956. search: RegExp;
  21957. replace: string;
  21958. }[];
  21959. }, storeKey?: string): void;
  21960. /** @hidden */
  21961. _registerTempVariable(name: string): boolean;
  21962. /** @hidden */
  21963. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21964. /** @hidden */
  21965. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21966. /** @hidden */
  21967. _emitFloat(value: number): string;
  21968. }
  21969. }
  21970. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21971. /**
  21972. * Helper class used to generate session unique ID
  21973. */
  21974. export class UniqueIdGenerator {
  21975. private static _UniqueIdCounter;
  21976. /**
  21977. * Gets an unique (relatively to the current scene) Id
  21978. */
  21979. static get UniqueId(): number;
  21980. }
  21981. }
  21982. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21983. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21985. import { Nullable } from "babylonjs/types";
  21986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21987. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21988. import { Effect } from "babylonjs/Materials/effect";
  21989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21990. import { Mesh } from "babylonjs/Meshes/mesh";
  21991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21992. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21993. import { Scene } from "babylonjs/scene";
  21994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21995. /**
  21996. * Defines a block that can be used inside a node based material
  21997. */
  21998. export class NodeMaterialBlock {
  21999. private _buildId;
  22000. private _buildTarget;
  22001. private _target;
  22002. private _isFinalMerger;
  22003. private _isInput;
  22004. protected _isUnique: boolean;
  22005. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22006. inputsAreExclusive: boolean;
  22007. /** @hidden */
  22008. _codeVariableName: string;
  22009. /** @hidden */
  22010. _inputs: NodeMaterialConnectionPoint[];
  22011. /** @hidden */
  22012. _outputs: NodeMaterialConnectionPoint[];
  22013. /** @hidden */
  22014. _preparationId: number;
  22015. /**
  22016. * Gets or sets the name of the block
  22017. */
  22018. name: string;
  22019. /**
  22020. * Gets or sets the unique id of the node
  22021. */
  22022. uniqueId: number;
  22023. /**
  22024. * Gets or sets the comments associated with this block
  22025. */
  22026. comments: string;
  22027. /**
  22028. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22029. */
  22030. get isUnique(): boolean;
  22031. /**
  22032. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22033. */
  22034. get isFinalMerger(): boolean;
  22035. /**
  22036. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22037. */
  22038. get isInput(): boolean;
  22039. /**
  22040. * Gets or sets the build Id
  22041. */
  22042. get buildId(): number;
  22043. set buildId(value: number);
  22044. /**
  22045. * Gets or sets the target of the block
  22046. */
  22047. get target(): NodeMaterialBlockTargets;
  22048. set target(value: NodeMaterialBlockTargets);
  22049. /**
  22050. * Gets the list of input points
  22051. */
  22052. get inputs(): NodeMaterialConnectionPoint[];
  22053. /** Gets the list of output points */
  22054. get outputs(): NodeMaterialConnectionPoint[];
  22055. /**
  22056. * Find an input by its name
  22057. * @param name defines the name of the input to look for
  22058. * @returns the input or null if not found
  22059. */
  22060. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22061. /**
  22062. * Find an output by its name
  22063. * @param name defines the name of the outputto look for
  22064. * @returns the output or null if not found
  22065. */
  22066. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22067. /**
  22068. * Creates a new NodeMaterialBlock
  22069. * @param name defines the block name
  22070. * @param target defines the target of that block (Vertex by default)
  22071. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22072. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22073. */
  22074. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22075. /**
  22076. * Initialize the block and prepare the context for build
  22077. * @param state defines the state that will be used for the build
  22078. */
  22079. initialize(state: NodeMaterialBuildState): void;
  22080. /**
  22081. * Bind data to effect. Will only be called for blocks with isBindable === true
  22082. * @param effect defines the effect to bind data to
  22083. * @param nodeMaterial defines the hosting NodeMaterial
  22084. * @param mesh defines the mesh that will be rendered
  22085. * @param subMesh defines the submesh that will be rendered
  22086. */
  22087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22088. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22089. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22090. protected _writeFloat(value: number): string;
  22091. /**
  22092. * Gets the current class name e.g. "NodeMaterialBlock"
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Register a new input. Must be called inside a block constructor
  22098. * @param name defines the connection point name
  22099. * @param type defines the connection point type
  22100. * @param isOptional defines a boolean indicating that this input can be omitted
  22101. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22102. * @param point an already created connection point. If not provided, create a new one
  22103. * @returns the current block
  22104. */
  22105. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22106. /**
  22107. * Register a new output. Must be called inside a block constructor
  22108. * @param name defines the connection point name
  22109. * @param type defines the connection point type
  22110. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22111. * @param point an already created connection point. If not provided, create a new one
  22112. * @returns the current block
  22113. */
  22114. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22115. /**
  22116. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22117. * @param forOutput defines an optional connection point to check compatibility with
  22118. * @returns the first available input or null
  22119. */
  22120. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22121. /**
  22122. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22123. * @param forBlock defines an optional block to check compatibility with
  22124. * @returns the first available input or null
  22125. */
  22126. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22127. /**
  22128. * Gets the sibling of the given output
  22129. * @param current defines the current output
  22130. * @returns the next output in the list or null
  22131. */
  22132. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22133. /**
  22134. * Connect current block with another block
  22135. * @param other defines the block to connect with
  22136. * @param options define the various options to help pick the right connections
  22137. * @returns the current block
  22138. */
  22139. connectTo(other: NodeMaterialBlock, options?: {
  22140. input?: string;
  22141. output?: string;
  22142. outputSwizzle?: string;
  22143. }): this | undefined;
  22144. protected _buildBlock(state: NodeMaterialBuildState): void;
  22145. /**
  22146. * Add uniforms, samplers and uniform buffers at compilation time
  22147. * @param state defines the state to update
  22148. * @param nodeMaterial defines the node material requesting the update
  22149. * @param defines defines the material defines to update
  22150. * @param uniformBuffers defines the list of uniform buffer names
  22151. */
  22152. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22153. /**
  22154. * Add potential fallbacks if shader compilation fails
  22155. * @param mesh defines the mesh to be rendered
  22156. * @param fallbacks defines the current prioritized list of fallbacks
  22157. */
  22158. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22159. /**
  22160. * Initialize defines for shader compilation
  22161. * @param mesh defines the mesh to be rendered
  22162. * @param nodeMaterial defines the node material requesting the update
  22163. * @param defines defines the material defines to update
  22164. * @param useInstances specifies that instances should be used
  22165. */
  22166. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22167. /**
  22168. * Update defines for shader compilation
  22169. * @param mesh defines the mesh to be rendered
  22170. * @param nodeMaterial defines the node material requesting the update
  22171. * @param defines defines the material defines to update
  22172. * @param useInstances specifies that instances should be used
  22173. * @param subMesh defines which submesh to render
  22174. */
  22175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22176. /**
  22177. * Lets the block try to connect some inputs automatically
  22178. * @param material defines the hosting NodeMaterial
  22179. */
  22180. autoConfigure(material: NodeMaterial): void;
  22181. /**
  22182. * Function called when a block is declared as repeatable content generator
  22183. * @param vertexShaderState defines the current compilation state for the vertex shader
  22184. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22185. * @param mesh defines the mesh to be rendered
  22186. * @param defines defines the material defines to update
  22187. */
  22188. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22189. /**
  22190. * Checks if the block is ready
  22191. * @param mesh defines the mesh to be rendered
  22192. * @param nodeMaterial defines the node material requesting the update
  22193. * @param defines defines the material defines to update
  22194. * @param useInstances specifies that instances should be used
  22195. * @returns true if the block is ready
  22196. */
  22197. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22198. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22199. private _processBuild;
  22200. /**
  22201. * Compile the current node and generate the shader code
  22202. * @param state defines the current compilation state (uniforms, samplers, current string)
  22203. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22204. * @returns true if already built
  22205. */
  22206. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22207. protected _inputRename(name: string): string;
  22208. protected _outputRename(name: string): string;
  22209. protected _dumpPropertiesCode(): string;
  22210. /** @hidden */
  22211. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22212. /** @hidden */
  22213. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22214. /**
  22215. * Clone the current block to a new identical block
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22218. * @returns a copy of the current block
  22219. */
  22220. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22221. /**
  22222. * Serializes this block in a JSON representation
  22223. * @returns the serialized block object
  22224. */
  22225. serialize(): any;
  22226. /** @hidden */
  22227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22228. private _deserializePortDisplayNames;
  22229. /**
  22230. * Release resources
  22231. */
  22232. dispose(): void;
  22233. }
  22234. }
  22235. declare module "babylonjs/Materials/pushMaterial" {
  22236. import { Nullable } from "babylonjs/types";
  22237. import { Scene } from "babylonjs/scene";
  22238. import { Matrix } from "babylonjs/Maths/math.vector";
  22239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22240. import { Mesh } from "babylonjs/Meshes/mesh";
  22241. import { Material } from "babylonjs/Materials/material";
  22242. import { Effect } from "babylonjs/Materials/effect";
  22243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22244. /**
  22245. * Base class of materials working in push mode in babylon JS
  22246. * @hidden
  22247. */
  22248. export class PushMaterial extends Material {
  22249. protected _activeEffect: Effect;
  22250. protected _normalMatrix: Matrix;
  22251. /**
  22252. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22253. * This means that the material can keep using a previous shader while a new one is being compiled.
  22254. * This is mostly used when shader parallel compilation is supported (true by default)
  22255. */
  22256. allowShaderHotSwapping: boolean;
  22257. constructor(name: string, scene: Scene);
  22258. getEffect(): Effect;
  22259. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22260. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22261. /**
  22262. * Binds the given world matrix to the active effect
  22263. *
  22264. * @param world the matrix to bind
  22265. */
  22266. bindOnlyWorldMatrix(world: Matrix): void;
  22267. /**
  22268. * Binds the given normal matrix to the active effect
  22269. *
  22270. * @param normalMatrix the matrix to bind
  22271. */
  22272. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22273. bind(world: Matrix, mesh?: Mesh): void;
  22274. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22275. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22280. /**
  22281. * Root class for all node material optimizers
  22282. */
  22283. export class NodeMaterialOptimizer {
  22284. /**
  22285. * Function used to optimize a NodeMaterial graph
  22286. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22287. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22288. */
  22289. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. import { Scene } from "babylonjs/scene";
  22297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22298. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22300. /**
  22301. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22302. */
  22303. export class TransformBlock extends NodeMaterialBlock {
  22304. /**
  22305. * Defines the value to use to complement W value to transform it to a Vector4
  22306. */
  22307. complementW: number;
  22308. /**
  22309. * Defines the value to use to complement z value to transform it to a Vector4
  22310. */
  22311. complementZ: number;
  22312. /**
  22313. * Creates a new TransformBlock
  22314. * @param name defines the block name
  22315. */
  22316. constructor(name: string);
  22317. /**
  22318. * Gets the current class name
  22319. * @returns the class name
  22320. */
  22321. getClassName(): string;
  22322. /**
  22323. * Gets the vector input
  22324. */
  22325. get vector(): NodeMaterialConnectionPoint;
  22326. /**
  22327. * Gets the output component
  22328. */
  22329. get output(): NodeMaterialConnectionPoint;
  22330. /**
  22331. * Gets the xyz output component
  22332. */
  22333. get xyz(): NodeMaterialConnectionPoint;
  22334. /**
  22335. * Gets the matrix transform input
  22336. */
  22337. get transform(): NodeMaterialConnectionPoint;
  22338. protected _buildBlock(state: NodeMaterialBuildState): this;
  22339. /**
  22340. * Update defines for shader compilation
  22341. * @param mesh defines the mesh to be rendered
  22342. * @param nodeMaterial defines the node material requesting the update
  22343. * @param defines defines the material defines to update
  22344. * @param useInstances specifies that instances should be used
  22345. * @param subMesh defines which submesh to render
  22346. */
  22347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22348. serialize(): any;
  22349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22350. protected _dumpPropertiesCode(): string;
  22351. }
  22352. }
  22353. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22357. /**
  22358. * Block used to output the vertex position
  22359. */
  22360. export class VertexOutputBlock extends NodeMaterialBlock {
  22361. /**
  22362. * Creates a new VertexOutputBlock
  22363. * @param name defines the block name
  22364. */
  22365. constructor(name: string);
  22366. /**
  22367. * Gets the current class name
  22368. * @returns the class name
  22369. */
  22370. getClassName(): string;
  22371. /**
  22372. * Gets the vector input component
  22373. */
  22374. get vector(): NodeMaterialConnectionPoint;
  22375. protected _buildBlock(state: NodeMaterialBuildState): this;
  22376. }
  22377. }
  22378. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22382. /**
  22383. * Block used to output the final color
  22384. */
  22385. export class FragmentOutputBlock extends NodeMaterialBlock {
  22386. /**
  22387. * Create a new FragmentOutputBlock
  22388. * @param name defines the block name
  22389. */
  22390. constructor(name: string);
  22391. /**
  22392. * Gets the current class name
  22393. * @returns the class name
  22394. */
  22395. getClassName(): string;
  22396. /**
  22397. * Gets the rgba input component
  22398. */
  22399. get rgba(): NodeMaterialConnectionPoint;
  22400. /**
  22401. * Gets the rgb input component
  22402. */
  22403. get rgb(): NodeMaterialConnectionPoint;
  22404. /**
  22405. * Gets the a input component
  22406. */
  22407. get a(): NodeMaterialConnectionPoint;
  22408. protected _buildBlock(state: NodeMaterialBuildState): this;
  22409. }
  22410. }
  22411. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22415. /**
  22416. * Block used for the particle ramp gradient section
  22417. */
  22418. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22419. /**
  22420. * Create a new ParticleRampGradientBlock
  22421. * @param name defines the block name
  22422. */
  22423. constructor(name: string);
  22424. /**
  22425. * Gets the current class name
  22426. * @returns the class name
  22427. */
  22428. getClassName(): string;
  22429. /**
  22430. * Gets the color input component
  22431. */
  22432. get color(): NodeMaterialConnectionPoint;
  22433. /**
  22434. * Gets the rampColor output component
  22435. */
  22436. get rampColor(): NodeMaterialConnectionPoint;
  22437. /**
  22438. * Initialize the block and prepare the context for build
  22439. * @param state defines the state that will be used for the build
  22440. */
  22441. initialize(state: NodeMaterialBuildState): void;
  22442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22443. }
  22444. }
  22445. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22449. /**
  22450. * Block used for the particle blend multiply section
  22451. */
  22452. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22453. /**
  22454. * Create a new ParticleBlendMultiplyBlock
  22455. * @param name defines the block name
  22456. */
  22457. constructor(name: string);
  22458. /**
  22459. * Gets the current class name
  22460. * @returns the class name
  22461. */
  22462. getClassName(): string;
  22463. /**
  22464. * Gets the color input component
  22465. */
  22466. get color(): NodeMaterialConnectionPoint;
  22467. /**
  22468. * Gets the alphaTexture input component
  22469. */
  22470. get alphaTexture(): NodeMaterialConnectionPoint;
  22471. /**
  22472. * Gets the alphaColor input component
  22473. */
  22474. get alphaColor(): NodeMaterialConnectionPoint;
  22475. /**
  22476. * Gets the blendColor output component
  22477. */
  22478. get blendColor(): NodeMaterialConnectionPoint;
  22479. /**
  22480. * Initialize the block and prepare the context for build
  22481. * @param state defines the state that will be used for the build
  22482. */
  22483. initialize(state: NodeMaterialBuildState): void;
  22484. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22485. }
  22486. }
  22487. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22491. /**
  22492. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22493. */
  22494. export class VectorMergerBlock extends NodeMaterialBlock {
  22495. /**
  22496. * Create a new VectorMergerBlock
  22497. * @param name defines the block name
  22498. */
  22499. constructor(name: string);
  22500. /**
  22501. * Gets the current class name
  22502. * @returns the class name
  22503. */
  22504. getClassName(): string;
  22505. /**
  22506. * Gets the xyz component (input)
  22507. */
  22508. get xyzIn(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the xy component (input)
  22511. */
  22512. get xyIn(): NodeMaterialConnectionPoint;
  22513. /**
  22514. * Gets the x component (input)
  22515. */
  22516. get x(): NodeMaterialConnectionPoint;
  22517. /**
  22518. * Gets the y component (input)
  22519. */
  22520. get y(): NodeMaterialConnectionPoint;
  22521. /**
  22522. * Gets the z component (input)
  22523. */
  22524. get z(): NodeMaterialConnectionPoint;
  22525. /**
  22526. * Gets the w component (input)
  22527. */
  22528. get w(): NodeMaterialConnectionPoint;
  22529. /**
  22530. * Gets the xyzw component (output)
  22531. */
  22532. get xyzw(): NodeMaterialConnectionPoint;
  22533. /**
  22534. * Gets the xyz component (output)
  22535. */
  22536. get xyzOut(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the xy component (output)
  22539. */
  22540. get xyOut(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the xy component (output)
  22543. * @deprecated Please use xyOut instead.
  22544. */
  22545. get xy(): NodeMaterialConnectionPoint;
  22546. /**
  22547. * Gets the xyz component (output)
  22548. * @deprecated Please use xyzOut instead.
  22549. */
  22550. get xyz(): NodeMaterialConnectionPoint;
  22551. protected _buildBlock(state: NodeMaterialBuildState): this;
  22552. }
  22553. }
  22554. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22558. import { Vector2 } from "babylonjs/Maths/math.vector";
  22559. import { Scene } from "babylonjs/scene";
  22560. /**
  22561. * Block used to remap a float from a range to a new one
  22562. */
  22563. export class RemapBlock extends NodeMaterialBlock {
  22564. /**
  22565. * Gets or sets the source range
  22566. */
  22567. sourceRange: Vector2;
  22568. /**
  22569. * Gets or sets the target range
  22570. */
  22571. targetRange: Vector2;
  22572. /**
  22573. * Creates a new RemapBlock
  22574. * @param name defines the block name
  22575. */
  22576. constructor(name: string);
  22577. /**
  22578. * Gets the current class name
  22579. * @returns the class name
  22580. */
  22581. getClassName(): string;
  22582. /**
  22583. * Gets the input component
  22584. */
  22585. get input(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the source min input component
  22588. */
  22589. get sourceMin(): NodeMaterialConnectionPoint;
  22590. /**
  22591. * Gets the source max input component
  22592. */
  22593. get sourceMax(): NodeMaterialConnectionPoint;
  22594. /**
  22595. * Gets the target min input component
  22596. */
  22597. get targetMin(): NodeMaterialConnectionPoint;
  22598. /**
  22599. * Gets the target max input component
  22600. */
  22601. get targetMax(): NodeMaterialConnectionPoint;
  22602. /**
  22603. * Gets the output component
  22604. */
  22605. get output(): NodeMaterialConnectionPoint;
  22606. protected _buildBlock(state: NodeMaterialBuildState): this;
  22607. protected _dumpPropertiesCode(): string;
  22608. serialize(): any;
  22609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22610. }
  22611. }
  22612. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22616. /**
  22617. * Block used to multiply 2 values
  22618. */
  22619. export class MultiplyBlock extends NodeMaterialBlock {
  22620. /**
  22621. * Creates a new MultiplyBlock
  22622. * @param name defines the block name
  22623. */
  22624. constructor(name: string);
  22625. /**
  22626. * Gets the current class name
  22627. * @returns the class name
  22628. */
  22629. getClassName(): string;
  22630. /**
  22631. * Gets the left operand input component
  22632. */
  22633. get left(): NodeMaterialConnectionPoint;
  22634. /**
  22635. * Gets the right operand input component
  22636. */
  22637. get right(): NodeMaterialConnectionPoint;
  22638. /**
  22639. * Gets the output component
  22640. */
  22641. get output(): NodeMaterialConnectionPoint;
  22642. protected _buildBlock(state: NodeMaterialBuildState): this;
  22643. }
  22644. }
  22645. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22649. /**
  22650. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22651. */
  22652. export class ColorSplitterBlock extends NodeMaterialBlock {
  22653. /**
  22654. * Create a new ColorSplitterBlock
  22655. * @param name defines the block name
  22656. */
  22657. constructor(name: string);
  22658. /**
  22659. * Gets the current class name
  22660. * @returns the class name
  22661. */
  22662. getClassName(): string;
  22663. /**
  22664. * Gets the rgba component (input)
  22665. */
  22666. get rgba(): NodeMaterialConnectionPoint;
  22667. /**
  22668. * Gets the rgb component (input)
  22669. */
  22670. get rgbIn(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the rgb component (output)
  22673. */
  22674. get rgbOut(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the r component (output)
  22677. */
  22678. get r(): NodeMaterialConnectionPoint;
  22679. /**
  22680. * Gets the g component (output)
  22681. */
  22682. get g(): NodeMaterialConnectionPoint;
  22683. /**
  22684. * Gets the b component (output)
  22685. */
  22686. get b(): NodeMaterialConnectionPoint;
  22687. /**
  22688. * Gets the a component (output)
  22689. */
  22690. get a(): NodeMaterialConnectionPoint;
  22691. protected _inputRename(name: string): string;
  22692. protected _outputRename(name: string): string;
  22693. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22694. }
  22695. }
  22696. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22698. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22699. import { Scene } from "babylonjs/scene";
  22700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22701. import { Matrix } from "babylonjs/Maths/math.vector";
  22702. import { Mesh } from "babylonjs/Meshes/mesh";
  22703. import { Engine } from "babylonjs/Engines/engine";
  22704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22705. import { Observable } from "babylonjs/Misc/observable";
  22706. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22707. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22708. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22709. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22710. import { Nullable } from "babylonjs/types";
  22711. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22712. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22713. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22714. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22715. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22716. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22717. import { Effect } from "babylonjs/Materials/effect";
  22718. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22719. import { Camera } from "babylonjs/Cameras/camera";
  22720. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22721. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22722. /**
  22723. * Interface used to configure the node material editor
  22724. */
  22725. export interface INodeMaterialEditorOptions {
  22726. /** Define the URl to load node editor script */
  22727. editorURL?: string;
  22728. }
  22729. /** @hidden */
  22730. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22731. NORMAL: boolean;
  22732. TANGENT: boolean;
  22733. UV1: boolean;
  22734. /** BONES */
  22735. NUM_BONE_INFLUENCERS: number;
  22736. BonesPerMesh: number;
  22737. BONETEXTURE: boolean;
  22738. /** MORPH TARGETS */
  22739. MORPHTARGETS: boolean;
  22740. MORPHTARGETS_NORMAL: boolean;
  22741. MORPHTARGETS_TANGENT: boolean;
  22742. MORPHTARGETS_UV: boolean;
  22743. NUM_MORPH_INFLUENCERS: number;
  22744. /** IMAGE PROCESSING */
  22745. IMAGEPROCESSING: boolean;
  22746. VIGNETTE: boolean;
  22747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22748. VIGNETTEBLENDMODEOPAQUE: boolean;
  22749. TONEMAPPING: boolean;
  22750. TONEMAPPING_ACES: boolean;
  22751. CONTRAST: boolean;
  22752. EXPOSURE: boolean;
  22753. COLORCURVES: boolean;
  22754. COLORGRADING: boolean;
  22755. COLORGRADING3D: boolean;
  22756. SAMPLER3DGREENDEPTH: boolean;
  22757. SAMPLER3DBGRMAP: boolean;
  22758. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22759. /** MISC. */
  22760. BUMPDIRECTUV: number;
  22761. constructor();
  22762. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22763. }
  22764. /**
  22765. * Class used to configure NodeMaterial
  22766. */
  22767. export interface INodeMaterialOptions {
  22768. /**
  22769. * Defines if blocks should emit comments
  22770. */
  22771. emitComments: boolean;
  22772. }
  22773. /**
  22774. * Class used to create a node based material built by assembling shader blocks
  22775. */
  22776. export class NodeMaterial extends PushMaterial {
  22777. private static _BuildIdGenerator;
  22778. private _options;
  22779. private _vertexCompilationState;
  22780. private _fragmentCompilationState;
  22781. private _sharedData;
  22782. private _buildId;
  22783. private _buildWasSuccessful;
  22784. private _cachedWorldViewMatrix;
  22785. private _cachedWorldViewProjectionMatrix;
  22786. private _optimizers;
  22787. private _animationFrame;
  22788. /** Define the Url to load node editor script */
  22789. static EditorURL: string;
  22790. /** Define the Url to load snippets */
  22791. static SnippetUrl: string;
  22792. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22793. static IgnoreTexturesAtLoadTime: boolean;
  22794. private BJSNODEMATERIALEDITOR;
  22795. /** Get the inspector from bundle or global */
  22796. private _getGlobalNodeMaterialEditor;
  22797. /**
  22798. * Snippet ID if the material was created from the snippet server
  22799. */
  22800. snippetId: string;
  22801. /**
  22802. * Gets or sets data used by visual editor
  22803. * @see https://nme.babylonjs.com
  22804. */
  22805. editorData: any;
  22806. /**
  22807. * 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)
  22808. */
  22809. ignoreAlpha: boolean;
  22810. /**
  22811. * Defines the maximum number of lights that can be used in the material
  22812. */
  22813. maxSimultaneousLights: number;
  22814. /**
  22815. * Observable raised when the material is built
  22816. */
  22817. onBuildObservable: Observable<NodeMaterial>;
  22818. /**
  22819. * Gets or sets the root nodes of the material vertex shader
  22820. */
  22821. _vertexOutputNodes: NodeMaterialBlock[];
  22822. /**
  22823. * Gets or sets the root nodes of the material fragment (pixel) shader
  22824. */
  22825. _fragmentOutputNodes: NodeMaterialBlock[];
  22826. /** Gets or sets options to control the node material overall behavior */
  22827. get options(): INodeMaterialOptions;
  22828. set options(options: INodeMaterialOptions);
  22829. /**
  22830. * Default configuration related to image processing available in the standard Material.
  22831. */
  22832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22833. /**
  22834. * Gets the image processing configuration used either in this material.
  22835. */
  22836. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22837. /**
  22838. * Sets the Default image processing configuration used either in the this material.
  22839. *
  22840. * If sets to null, the scene one is in use.
  22841. */
  22842. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22843. /**
  22844. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22845. */
  22846. attachedBlocks: NodeMaterialBlock[];
  22847. /**
  22848. * Specifies the mode of the node material
  22849. * @hidden
  22850. */
  22851. _mode: NodeMaterialModes;
  22852. /**
  22853. * Gets the mode property
  22854. */
  22855. get mode(): NodeMaterialModes;
  22856. /**
  22857. * Create a new node based material
  22858. * @param name defines the material name
  22859. * @param scene defines the hosting scene
  22860. * @param options defines creation option
  22861. */
  22862. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22863. /**
  22864. * Gets the current class name of the material e.g. "NodeMaterial"
  22865. * @returns the class name
  22866. */
  22867. getClassName(): string;
  22868. /**
  22869. * Keep track of the image processing observer to allow dispose and replace.
  22870. */
  22871. private _imageProcessingObserver;
  22872. /**
  22873. * Attaches a new image processing configuration to the Standard Material.
  22874. * @param configuration
  22875. */
  22876. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22877. /**
  22878. * Get a block by its name
  22879. * @param name defines the name of the block to retrieve
  22880. * @returns the required block or null if not found
  22881. */
  22882. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22883. /**
  22884. * Get a block by its name
  22885. * @param predicate defines the predicate used to find the good candidate
  22886. * @returns the required block or null if not found
  22887. */
  22888. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22889. /**
  22890. * Get an input block by its name
  22891. * @param predicate defines the predicate used to find the good candidate
  22892. * @returns the required input block or null if not found
  22893. */
  22894. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22895. /**
  22896. * Gets the list of input blocks attached to this material
  22897. * @returns an array of InputBlocks
  22898. */
  22899. getInputBlocks(): InputBlock[];
  22900. /**
  22901. * Adds a new optimizer to the list of optimizers
  22902. * @param optimizer defines the optimizers to add
  22903. * @returns the current material
  22904. */
  22905. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22906. /**
  22907. * Remove an optimizer from the list of optimizers
  22908. * @param optimizer defines the optimizers to remove
  22909. * @returns the current material
  22910. */
  22911. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22912. /**
  22913. * Add a new block to the list of output nodes
  22914. * @param node defines the node to add
  22915. * @returns the current material
  22916. */
  22917. addOutputNode(node: NodeMaterialBlock): this;
  22918. /**
  22919. * Remove a block from the list of root nodes
  22920. * @param node defines the node to remove
  22921. * @returns the current material
  22922. */
  22923. removeOutputNode(node: NodeMaterialBlock): this;
  22924. private _addVertexOutputNode;
  22925. private _removeVertexOutputNode;
  22926. private _addFragmentOutputNode;
  22927. private _removeFragmentOutputNode;
  22928. /**
  22929. * Specifies if the material will require alpha blending
  22930. * @returns a boolean specifying if alpha blending is needed
  22931. */
  22932. needAlphaBlending(): boolean;
  22933. /**
  22934. * Specifies if this material should be rendered in alpha test mode
  22935. * @returns a boolean specifying if an alpha test is needed.
  22936. */
  22937. needAlphaTesting(): boolean;
  22938. private _initializeBlock;
  22939. private _resetDualBlocks;
  22940. /**
  22941. * Remove a block from the current node material
  22942. * @param block defines the block to remove
  22943. */
  22944. removeBlock(block: NodeMaterialBlock): void;
  22945. /**
  22946. * Build the material and generates the inner effect
  22947. * @param verbose defines if the build should log activity
  22948. */
  22949. build(verbose?: boolean): void;
  22950. /**
  22951. * Runs an otpimization phase to try to improve the shader code
  22952. */
  22953. optimize(): void;
  22954. private _prepareDefinesForAttributes;
  22955. /**
  22956. * Create a post process from the material
  22957. * @param camera The camera to apply the render pass to.
  22958. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22960. * @param engine The engine which the post process will be applied. (default: current engine)
  22961. * @param reusable If the post process can be reused on the same frame. (default: false)
  22962. * @param textureType Type of textures used when performing the post process. (default: 0)
  22963. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22964. * @returns the post process created
  22965. */
  22966. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22967. /**
  22968. * Create the post process effect from the material
  22969. * @param postProcess The post process to create the effect for
  22970. */
  22971. createEffectForPostProcess(postProcess: PostProcess): void;
  22972. private _createEffectOrPostProcess;
  22973. private _createEffectForParticles;
  22974. /**
  22975. * Create the effect to be used as the custom effect for a particle system
  22976. * @param particleSystem Particle system to create the effect for
  22977. * @param onCompiled defines a function to call when the effect creation is successful
  22978. * @param onError defines a function to call when the effect creation has failed
  22979. */
  22980. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22981. private _processDefines;
  22982. /**
  22983. * Get if the submesh is ready to be used and all its information available.
  22984. * Child classes can use it to update shaders
  22985. * @param mesh defines the mesh to check
  22986. * @param subMesh defines which submesh to check
  22987. * @param useInstances specifies that instances should be used
  22988. * @returns a boolean indicating that the submesh is ready or not
  22989. */
  22990. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22991. /**
  22992. * Get a string representing the shaders built by the current node graph
  22993. */
  22994. get compiledShaders(): string;
  22995. /**
  22996. * Binds the world matrix to the material
  22997. * @param world defines the world transformation matrix
  22998. */
  22999. bindOnlyWorldMatrix(world: Matrix): void;
  23000. /**
  23001. * Binds the submesh to this material by preparing the effect and shader to draw
  23002. * @param world defines the world transformation matrix
  23003. * @param mesh defines the mesh containing the submesh
  23004. * @param subMesh defines the submesh to bind the material to
  23005. */
  23006. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23007. /**
  23008. * Gets the active textures from the material
  23009. * @returns an array of textures
  23010. */
  23011. getActiveTextures(): BaseTexture[];
  23012. /**
  23013. * Gets the list of texture blocks
  23014. * @returns an array of texture blocks
  23015. */
  23016. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23017. /**
  23018. * Specifies if the material uses a texture
  23019. * @param texture defines the texture to check against the material
  23020. * @returns a boolean specifying if the material uses the texture
  23021. */
  23022. hasTexture(texture: BaseTexture): boolean;
  23023. /**
  23024. * Disposes the material
  23025. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23026. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23027. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23028. */
  23029. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23030. /** Creates the node editor window. */
  23031. private _createNodeEditor;
  23032. /**
  23033. * Launch the node material editor
  23034. * @param config Define the configuration of the editor
  23035. * @return a promise fulfilled when the node editor is visible
  23036. */
  23037. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23038. /**
  23039. * Clear the current material
  23040. */
  23041. clear(): void;
  23042. /**
  23043. * Clear the current material and set it to a default state
  23044. */
  23045. setToDefault(): void;
  23046. /**
  23047. * Clear the current material and set it to a default state for post process
  23048. */
  23049. setToDefaultPostProcess(): void;
  23050. /**
  23051. * Clear the current material and set it to a default state for particle
  23052. */
  23053. setToDefaultParticle(): void;
  23054. /**
  23055. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23056. * @param url defines the url to load from
  23057. * @returns a promise that will fullfil when the material is fully loaded
  23058. */
  23059. loadAsync(url: string): Promise<void>;
  23060. private _gatherBlocks;
  23061. /**
  23062. * Generate a string containing the code declaration required to create an equivalent of this material
  23063. * @returns a string
  23064. */
  23065. generateCode(): string;
  23066. /**
  23067. * Serializes this material in a JSON representation
  23068. * @returns the serialized material object
  23069. */
  23070. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23071. private _restoreConnections;
  23072. /**
  23073. * Clear the current graph and load a new one from a serialization object
  23074. * @param source defines the JSON representation of the material
  23075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23076. */
  23077. loadFromSerialization(source: any, rootUrl?: string): void;
  23078. /**
  23079. * Makes a duplicate of the current material.
  23080. * @param name - name to use for the new material.
  23081. */
  23082. clone(name: string): NodeMaterial;
  23083. /**
  23084. * Creates a node material from parsed material data
  23085. * @param source defines the JSON representation of the material
  23086. * @param scene defines the hosting scene
  23087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23088. * @returns a new node material
  23089. */
  23090. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23091. /**
  23092. * Creates a node material from a snippet saved in a remote file
  23093. * @param name defines the name of the material to create
  23094. * @param url defines the url to load from
  23095. * @param scene defines the hosting scene
  23096. * @returns a promise that will resolve to the new node material
  23097. */
  23098. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23099. /**
  23100. * Creates a node material from a snippet saved by the node material editor
  23101. * @param snippetId defines the snippet to load
  23102. * @param scene defines the hosting scene
  23103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23104. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23105. * @returns a promise that will resolve to the new node material
  23106. */
  23107. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23108. /**
  23109. * Creates a new node material set to default basic configuration
  23110. * @param name defines the name of the material
  23111. * @param scene defines the hosting scene
  23112. * @returns a new NodeMaterial
  23113. */
  23114. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23115. }
  23116. }
  23117. declare module "babylonjs/PostProcesses/postProcess" {
  23118. import { Nullable } from "babylonjs/types";
  23119. import { SmartArray } from "babylonjs/Misc/smartArray";
  23120. import { Observable } from "babylonjs/Misc/observable";
  23121. import { Vector2 } from "babylonjs/Maths/math.vector";
  23122. import { Camera } from "babylonjs/Cameras/camera";
  23123. import { Effect } from "babylonjs/Materials/effect";
  23124. import "babylonjs/Shaders/postprocess.vertex";
  23125. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23126. import { Engine } from "babylonjs/Engines/engine";
  23127. import { Color4 } from "babylonjs/Maths/math.color";
  23128. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23129. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23131. /**
  23132. * Size options for a post process
  23133. */
  23134. export type PostProcessOptions = {
  23135. width: number;
  23136. height: number;
  23137. };
  23138. /**
  23139. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23140. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23141. */
  23142. export class PostProcess {
  23143. /** Name of the PostProcess. */
  23144. name: string;
  23145. /**
  23146. * Gets or sets the unique id of the post process
  23147. */
  23148. uniqueId: number;
  23149. /**
  23150. * Width of the texture to apply the post process on
  23151. */
  23152. width: number;
  23153. /**
  23154. * Height of the texture to apply the post process on
  23155. */
  23156. height: number;
  23157. /**
  23158. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23159. */
  23160. nodeMaterialSource: Nullable<NodeMaterial>;
  23161. /**
  23162. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23163. * @hidden
  23164. */
  23165. _outputTexture: Nullable<InternalTexture>;
  23166. /**
  23167. * Sampling mode used by the shader
  23168. * See https://doc.babylonjs.com/classes/3.1/texture
  23169. */
  23170. renderTargetSamplingMode: number;
  23171. /**
  23172. * Clear color to use when screen clearing
  23173. */
  23174. clearColor: Color4;
  23175. /**
  23176. * If the buffer needs to be cleared before applying the post process. (default: true)
  23177. * Should be set to false if shader will overwrite all previous pixels.
  23178. */
  23179. autoClear: boolean;
  23180. /**
  23181. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23182. */
  23183. alphaMode: number;
  23184. /**
  23185. * Sets the setAlphaBlendConstants of the babylon engine
  23186. */
  23187. alphaConstants: Color4;
  23188. /**
  23189. * Animations to be used for the post processing
  23190. */
  23191. animations: import("babylonjs/Animations/animation").Animation[];
  23192. /**
  23193. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23194. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23195. */
  23196. enablePixelPerfectMode: boolean;
  23197. /**
  23198. * Force the postprocess to be applied without taking in account viewport
  23199. */
  23200. forceFullscreenViewport: boolean;
  23201. /**
  23202. * List of inspectable custom properties (used by the Inspector)
  23203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23204. */
  23205. inspectableCustomProperties: IInspectable[];
  23206. /**
  23207. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23208. *
  23209. * | Value | Type | Description |
  23210. * | ----- | ----------------------------------- | ----------- |
  23211. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23212. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23213. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23214. *
  23215. */
  23216. scaleMode: number;
  23217. /**
  23218. * Force textures to be a power of two (default: false)
  23219. */
  23220. alwaysForcePOT: boolean;
  23221. private _samples;
  23222. /**
  23223. * Number of sample textures (default: 1)
  23224. */
  23225. get samples(): number;
  23226. set samples(n: number);
  23227. /**
  23228. * Modify the scale of the post process to be the same as the viewport (default: false)
  23229. */
  23230. adaptScaleToCurrentViewport: boolean;
  23231. private _camera;
  23232. private _scene;
  23233. private _engine;
  23234. private _options;
  23235. private _reusable;
  23236. private _textureType;
  23237. private _textureFormat;
  23238. /**
  23239. * Smart array of input and output textures for the post process.
  23240. * @hidden
  23241. */
  23242. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23243. /**
  23244. * The index in _textures that corresponds to the output texture.
  23245. * @hidden
  23246. */
  23247. _currentRenderTextureInd: number;
  23248. private _effect;
  23249. private _samplers;
  23250. private _fragmentUrl;
  23251. private _vertexUrl;
  23252. private _parameters;
  23253. private _scaleRatio;
  23254. protected _indexParameters: any;
  23255. private _shareOutputWithPostProcess;
  23256. private _texelSize;
  23257. private _forcedOutputTexture;
  23258. /**
  23259. * Returns the fragment url or shader name used in the post process.
  23260. * @returns the fragment url or name in the shader store.
  23261. */
  23262. getEffectName(): string;
  23263. /**
  23264. * An event triggered when the postprocess is activated.
  23265. */
  23266. onActivateObservable: Observable<Camera>;
  23267. private _onActivateObserver;
  23268. /**
  23269. * A function that is added to the onActivateObservable
  23270. */
  23271. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23272. /**
  23273. * An event triggered when the postprocess changes its size.
  23274. */
  23275. onSizeChangedObservable: Observable<PostProcess>;
  23276. private _onSizeChangedObserver;
  23277. /**
  23278. * A function that is added to the onSizeChangedObservable
  23279. */
  23280. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23281. /**
  23282. * An event triggered when the postprocess applies its effect.
  23283. */
  23284. onApplyObservable: Observable<Effect>;
  23285. private _onApplyObserver;
  23286. /**
  23287. * A function that is added to the onApplyObservable
  23288. */
  23289. set onApply(callback: (effect: Effect) => void);
  23290. /**
  23291. * An event triggered before rendering the postprocess
  23292. */
  23293. onBeforeRenderObservable: Observable<Effect>;
  23294. private _onBeforeRenderObserver;
  23295. /**
  23296. * A function that is added to the onBeforeRenderObservable
  23297. */
  23298. set onBeforeRender(callback: (effect: Effect) => void);
  23299. /**
  23300. * An event triggered after rendering the postprocess
  23301. */
  23302. onAfterRenderObservable: Observable<Effect>;
  23303. private _onAfterRenderObserver;
  23304. /**
  23305. * A function that is added to the onAfterRenderObservable
  23306. */
  23307. set onAfterRender(callback: (efect: Effect) => void);
  23308. /**
  23309. * 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
  23310. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23311. */
  23312. get inputTexture(): InternalTexture;
  23313. set inputTexture(value: InternalTexture);
  23314. /**
  23315. * Gets the camera which post process is applied to.
  23316. * @returns The camera the post process is applied to.
  23317. */
  23318. getCamera(): Camera;
  23319. /**
  23320. * Gets the texel size of the postprocess.
  23321. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23322. */
  23323. get texelSize(): Vector2;
  23324. /**
  23325. * Creates a new instance PostProcess
  23326. * @param name The name of the PostProcess.
  23327. * @param fragmentUrl The url of the fragment shader to be used.
  23328. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23329. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23330. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23331. * @param camera The camera to apply the render pass to.
  23332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23333. * @param engine The engine which the post process will be applied. (default: current engine)
  23334. * @param reusable If the post process can be reused on the same frame. (default: false)
  23335. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23336. * @param textureType Type of textures used when performing the post process. (default: 0)
  23337. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23338. * @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
  23339. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23340. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23341. */
  23342. constructor(
  23343. /** Name of the PostProcess. */
  23344. 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);
  23345. /**
  23346. * Gets a string idenfifying the name of the class
  23347. * @returns "PostProcess" string
  23348. */
  23349. getClassName(): string;
  23350. /**
  23351. * Gets the engine which this post process belongs to.
  23352. * @returns The engine the post process was enabled with.
  23353. */
  23354. getEngine(): Engine;
  23355. /**
  23356. * The effect that is created when initializing the post process.
  23357. * @returns The created effect corresponding the the postprocess.
  23358. */
  23359. getEffect(): Effect;
  23360. /**
  23361. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23362. * @param postProcess The post process to share the output with.
  23363. * @returns This post process.
  23364. */
  23365. shareOutputWith(postProcess: PostProcess): PostProcess;
  23366. /**
  23367. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23368. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23369. */
  23370. useOwnOutput(): void;
  23371. /**
  23372. * Updates the effect with the current post process compile time values and recompiles the shader.
  23373. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23374. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23375. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23376. * @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
  23377. * @param onCompiled Called when the shader has been compiled.
  23378. * @param onError Called if there is an error when compiling a shader.
  23379. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23380. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23381. */
  23382. 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;
  23383. /**
  23384. * The post process is reusable if it can be used multiple times within one frame.
  23385. * @returns If the post process is reusable
  23386. */
  23387. isReusable(): boolean;
  23388. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23389. markTextureDirty(): void;
  23390. /**
  23391. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23392. * 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.
  23393. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23394. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23395. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23396. * @returns The target texture that was bound to be written to.
  23397. */
  23398. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23399. /**
  23400. * If the post process is supported.
  23401. */
  23402. get isSupported(): boolean;
  23403. /**
  23404. * The aspect ratio of the output texture.
  23405. */
  23406. get aspectRatio(): number;
  23407. /**
  23408. * Get a value indicating if the post-process is ready to be used
  23409. * @returns true if the post-process is ready (shader is compiled)
  23410. */
  23411. isReady(): boolean;
  23412. /**
  23413. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23414. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23415. */
  23416. apply(): Nullable<Effect>;
  23417. private _disposeTextures;
  23418. /**
  23419. * Disposes the post process.
  23420. * @param camera The camera to dispose the post process on.
  23421. */
  23422. dispose(camera?: Camera): void;
  23423. }
  23424. }
  23425. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23426. /** @hidden */
  23427. export var kernelBlurVaryingDeclaration: {
  23428. name: string;
  23429. shader: string;
  23430. };
  23431. }
  23432. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23433. /** @hidden */
  23434. export var kernelBlurFragment: {
  23435. name: string;
  23436. shader: string;
  23437. };
  23438. }
  23439. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23440. /** @hidden */
  23441. export var kernelBlurFragment2: {
  23442. name: string;
  23443. shader: string;
  23444. };
  23445. }
  23446. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23447. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23448. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23449. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23450. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23451. /** @hidden */
  23452. export var kernelBlurPixelShader: {
  23453. name: string;
  23454. shader: string;
  23455. };
  23456. }
  23457. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23458. /** @hidden */
  23459. export var kernelBlurVertex: {
  23460. name: string;
  23461. shader: string;
  23462. };
  23463. }
  23464. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23465. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23466. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23467. /** @hidden */
  23468. export var kernelBlurVertexShader: {
  23469. name: string;
  23470. shader: string;
  23471. };
  23472. }
  23473. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23474. import { Vector2 } from "babylonjs/Maths/math.vector";
  23475. import { Nullable } from "babylonjs/types";
  23476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23477. import { Camera } from "babylonjs/Cameras/camera";
  23478. import { Effect } from "babylonjs/Materials/effect";
  23479. import { Engine } from "babylonjs/Engines/engine";
  23480. import "babylonjs/Shaders/kernelBlur.fragment";
  23481. import "babylonjs/Shaders/kernelBlur.vertex";
  23482. /**
  23483. * The Blur Post Process which blurs an image based on a kernel and direction.
  23484. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23485. */
  23486. export class BlurPostProcess extends PostProcess {
  23487. /** The direction in which to blur the image. */
  23488. direction: Vector2;
  23489. private blockCompilation;
  23490. protected _kernel: number;
  23491. protected _idealKernel: number;
  23492. protected _packedFloat: boolean;
  23493. private _staticDefines;
  23494. /**
  23495. * Sets the length in pixels of the blur sample region
  23496. */
  23497. set kernel(v: number);
  23498. /**
  23499. * Gets the length in pixels of the blur sample region
  23500. */
  23501. get kernel(): number;
  23502. /**
  23503. * Sets wether or not the blur needs to unpack/repack floats
  23504. */
  23505. set packedFloat(v: boolean);
  23506. /**
  23507. * Gets wether or not the blur is unpacking/repacking floats
  23508. */
  23509. get packedFloat(): boolean;
  23510. /**
  23511. * Creates a new instance BlurPostProcess
  23512. * @param name The name of the effect.
  23513. * @param direction The direction in which to blur the image.
  23514. * @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.
  23515. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23516. * @param camera The camera to apply the render pass to.
  23517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23518. * @param engine The engine which the post process will be applied. (default: current engine)
  23519. * @param reusable If the post process can be reused on the same frame. (default: false)
  23520. * @param textureType Type of textures used when performing the post process. (default: 0)
  23521. * @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)
  23522. */
  23523. constructor(name: string,
  23524. /** The direction in which to blur the image. */
  23525. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23526. /**
  23527. * Updates the effect with the current post process compile time values and recompiles the shader.
  23528. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23529. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23530. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23531. * @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
  23532. * @param onCompiled Called when the shader has been compiled.
  23533. * @param onError Called if there is an error when compiling a shader.
  23534. */
  23535. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23536. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23537. /**
  23538. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23539. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23540. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23541. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23542. * The gaps between physical kernels are compensated for in the weighting of the samples
  23543. * @param idealKernel Ideal blur kernel.
  23544. * @return Nearest best kernel.
  23545. */
  23546. protected _nearestBestKernel(idealKernel: number): number;
  23547. /**
  23548. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23549. * @param x The point on the Gaussian distribution to sample.
  23550. * @return the value of the Gaussian function at x.
  23551. */
  23552. protected _gaussianWeight(x: number): number;
  23553. /**
  23554. * Generates a string that can be used as a floating point number in GLSL.
  23555. * @param x Value to print.
  23556. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23557. * @return GLSL float string.
  23558. */
  23559. protected _glslFloat(x: number, decimalFigures?: number): string;
  23560. }
  23561. }
  23562. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23563. import { Scene } from "babylonjs/scene";
  23564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23565. import { Plane } from "babylonjs/Maths/math.plane";
  23566. /**
  23567. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23568. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23569. * You can then easily use it as a reflectionTexture on a flat surface.
  23570. * In case the surface is not a plane, please consider relying on reflection probes.
  23571. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23572. */
  23573. export class MirrorTexture extends RenderTargetTexture {
  23574. private scene;
  23575. /**
  23576. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23577. * 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.
  23578. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23579. */
  23580. mirrorPlane: Plane;
  23581. /**
  23582. * Define the blur ratio used to blur the reflection if needed.
  23583. */
  23584. set blurRatio(value: number);
  23585. get blurRatio(): number;
  23586. /**
  23587. * Define the adaptive blur kernel used to blur the reflection if needed.
  23588. * This will autocompute the closest best match for the `blurKernel`
  23589. */
  23590. set adaptiveBlurKernel(value: number);
  23591. /**
  23592. * Define the blur kernel used to blur the reflection if needed.
  23593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23594. */
  23595. set blurKernel(value: number);
  23596. /**
  23597. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23598. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23599. */
  23600. set blurKernelX(value: number);
  23601. get blurKernelX(): number;
  23602. /**
  23603. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23604. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23605. */
  23606. set blurKernelY(value: number);
  23607. get blurKernelY(): number;
  23608. private _autoComputeBlurKernel;
  23609. protected _onRatioRescale(): void;
  23610. private _updateGammaSpace;
  23611. private _imageProcessingConfigChangeObserver;
  23612. private _transformMatrix;
  23613. private _mirrorMatrix;
  23614. private _savedViewMatrix;
  23615. private _blurX;
  23616. private _blurY;
  23617. private _adaptiveBlurKernel;
  23618. private _blurKernelX;
  23619. private _blurKernelY;
  23620. private _blurRatio;
  23621. /**
  23622. * Instantiates a Mirror Texture.
  23623. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23624. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23625. * You can then easily use it as a reflectionTexture on a flat surface.
  23626. * In case the surface is not a plane, please consider relying on reflection probes.
  23627. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23628. * @param name
  23629. * @param size
  23630. * @param scene
  23631. * @param generateMipMaps
  23632. * @param type
  23633. * @param samplingMode
  23634. * @param generateDepthBuffer
  23635. */
  23636. constructor(name: string, size: number | {
  23637. width: number;
  23638. height: number;
  23639. } | {
  23640. ratio: number;
  23641. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23642. private _preparePostProcesses;
  23643. /**
  23644. * Clone the mirror texture.
  23645. * @returns the cloned texture
  23646. */
  23647. clone(): MirrorTexture;
  23648. /**
  23649. * Serialize the texture to a JSON representation you could use in Parse later on
  23650. * @returns the serialized JSON representation
  23651. */
  23652. serialize(): any;
  23653. /**
  23654. * Dispose the texture and release its associated resources.
  23655. */
  23656. dispose(): void;
  23657. }
  23658. }
  23659. declare module "babylonjs/Materials/Textures/texture" {
  23660. import { Observable } from "babylonjs/Misc/observable";
  23661. import { Nullable } from "babylonjs/types";
  23662. import { Matrix } from "babylonjs/Maths/math.vector";
  23663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23664. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23665. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23666. import { Scene } from "babylonjs/scene";
  23667. /**
  23668. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23669. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23670. */
  23671. export class Texture extends BaseTexture {
  23672. /**
  23673. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23674. */
  23675. static SerializeBuffers: boolean;
  23676. /** @hidden */
  23677. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23678. /** @hidden */
  23679. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23680. /** @hidden */
  23681. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23682. /** nearest is mag = nearest and min = nearest and mip = linear */
  23683. static readonly NEAREST_SAMPLINGMODE: number;
  23684. /** nearest is mag = nearest and min = nearest and mip = linear */
  23685. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23686. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23687. static readonly BILINEAR_SAMPLINGMODE: number;
  23688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23689. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23690. /** Trilinear is mag = linear and min = linear and mip = linear */
  23691. static readonly TRILINEAR_SAMPLINGMODE: number;
  23692. /** Trilinear is mag = linear and min = linear and mip = linear */
  23693. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23694. /** mag = nearest and min = nearest and mip = nearest */
  23695. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23696. /** mag = nearest and min = linear and mip = nearest */
  23697. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23698. /** mag = nearest and min = linear and mip = linear */
  23699. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23700. /** mag = nearest and min = linear and mip = none */
  23701. static readonly NEAREST_LINEAR: number;
  23702. /** mag = nearest and min = nearest and mip = none */
  23703. static readonly NEAREST_NEAREST: number;
  23704. /** mag = linear and min = nearest and mip = nearest */
  23705. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23706. /** mag = linear and min = nearest and mip = linear */
  23707. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23708. /** mag = linear and min = linear and mip = none */
  23709. static readonly LINEAR_LINEAR: number;
  23710. /** mag = linear and min = nearest and mip = none */
  23711. static readonly LINEAR_NEAREST: number;
  23712. /** Explicit coordinates mode */
  23713. static readonly EXPLICIT_MODE: number;
  23714. /** Spherical coordinates mode */
  23715. static readonly SPHERICAL_MODE: number;
  23716. /** Planar coordinates mode */
  23717. static readonly PLANAR_MODE: number;
  23718. /** Cubic coordinates mode */
  23719. static readonly CUBIC_MODE: number;
  23720. /** Projection coordinates mode */
  23721. static readonly PROJECTION_MODE: number;
  23722. /** Inverse Cubic coordinates mode */
  23723. static readonly SKYBOX_MODE: number;
  23724. /** Inverse Cubic coordinates mode */
  23725. static readonly INVCUBIC_MODE: number;
  23726. /** Equirectangular coordinates mode */
  23727. static readonly EQUIRECTANGULAR_MODE: number;
  23728. /** Equirectangular Fixed coordinates mode */
  23729. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23730. /** Equirectangular Fixed Mirrored coordinates mode */
  23731. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23732. /** Texture is not repeating outside of 0..1 UVs */
  23733. static readonly CLAMP_ADDRESSMODE: number;
  23734. /** Texture is repeating outside of 0..1 UVs */
  23735. static readonly WRAP_ADDRESSMODE: number;
  23736. /** Texture is repeating and mirrored */
  23737. static readonly MIRROR_ADDRESSMODE: number;
  23738. /**
  23739. * 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
  23740. */
  23741. static UseSerializedUrlIfAny: boolean;
  23742. /**
  23743. * Define the url of the texture.
  23744. */
  23745. url: Nullable<string>;
  23746. /**
  23747. * Define an offset on the texture to offset the u coordinates of the UVs
  23748. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23749. */
  23750. uOffset: number;
  23751. /**
  23752. * Define an offset on the texture to offset the v coordinates of the UVs
  23753. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23754. */
  23755. vOffset: number;
  23756. /**
  23757. * Define an offset on the texture to scale the u coordinates of the UVs
  23758. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23759. */
  23760. uScale: number;
  23761. /**
  23762. * Define an offset on the texture to scale the v coordinates of the UVs
  23763. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23764. */
  23765. vScale: number;
  23766. /**
  23767. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23768. * @see http://doc.babylonjs.com/how_to/more_materials
  23769. */
  23770. uAng: number;
  23771. /**
  23772. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23773. * @see http://doc.babylonjs.com/how_to/more_materials
  23774. */
  23775. vAng: number;
  23776. /**
  23777. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23778. * @see http://doc.babylonjs.com/how_to/more_materials
  23779. */
  23780. wAng: number;
  23781. /**
  23782. * Defines the center of rotation (U)
  23783. */
  23784. uRotationCenter: number;
  23785. /**
  23786. * Defines the center of rotation (V)
  23787. */
  23788. vRotationCenter: number;
  23789. /**
  23790. * Defines the center of rotation (W)
  23791. */
  23792. wRotationCenter: number;
  23793. /**
  23794. * Are mip maps generated for this texture or not.
  23795. */
  23796. get noMipmap(): boolean;
  23797. /**
  23798. * List of inspectable custom properties (used by the Inspector)
  23799. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23800. */
  23801. inspectableCustomProperties: Nullable<IInspectable[]>;
  23802. private _noMipmap;
  23803. /** @hidden */
  23804. _invertY: boolean;
  23805. private _rowGenerationMatrix;
  23806. private _cachedTextureMatrix;
  23807. private _projectionModeMatrix;
  23808. private _t0;
  23809. private _t1;
  23810. private _t2;
  23811. private _cachedUOffset;
  23812. private _cachedVOffset;
  23813. private _cachedUScale;
  23814. private _cachedVScale;
  23815. private _cachedUAng;
  23816. private _cachedVAng;
  23817. private _cachedWAng;
  23818. private _cachedProjectionMatrixId;
  23819. private _cachedCoordinatesMode;
  23820. /** @hidden */
  23821. protected _initialSamplingMode: number;
  23822. /** @hidden */
  23823. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23824. private _deleteBuffer;
  23825. protected _format: Nullable<number>;
  23826. private _delayedOnLoad;
  23827. private _delayedOnError;
  23828. private _mimeType?;
  23829. /**
  23830. * Observable triggered once the texture has been loaded.
  23831. */
  23832. onLoadObservable: Observable<Texture>;
  23833. protected _isBlocking: boolean;
  23834. /**
  23835. * Is the texture preventing material to render while loading.
  23836. * If false, a default texture will be used instead of the loading one during the preparation step.
  23837. */
  23838. set isBlocking(value: boolean);
  23839. get isBlocking(): boolean;
  23840. /**
  23841. * Get the current sampling mode associated with the texture.
  23842. */
  23843. get samplingMode(): number;
  23844. /**
  23845. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23846. */
  23847. get invertY(): boolean;
  23848. /**
  23849. * Instantiates a new texture.
  23850. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23851. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23852. * @param url defines the url of the picture to load as a texture
  23853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23854. * @param noMipmap defines if the texture will require mip maps or not
  23855. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23856. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23857. * @param onLoad defines a callback triggered when the texture has been loaded
  23858. * @param onError defines a callback triggered when an error occurred during the loading session
  23859. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23860. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23861. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23862. * @param mimeType defines an optional mime type information
  23863. */
  23864. 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);
  23865. /**
  23866. * Update the url (and optional buffer) of this texture if url was null during construction.
  23867. * @param url the url of the texture
  23868. * @param buffer the buffer of the texture (defaults to null)
  23869. * @param onLoad callback called when the texture is loaded (defaults to null)
  23870. */
  23871. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23872. /**
  23873. * Finish the loading sequence of a texture flagged as delayed load.
  23874. * @hidden
  23875. */
  23876. delayLoad(): void;
  23877. private _prepareRowForTextureGeneration;
  23878. /**
  23879. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23880. * @returns the transform matrix of the texture.
  23881. */
  23882. getTextureMatrix(uBase?: number): Matrix;
  23883. /**
  23884. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23885. * @returns The reflection texture transform
  23886. */
  23887. getReflectionTextureMatrix(): Matrix;
  23888. /**
  23889. * Clones the texture.
  23890. * @returns the cloned texture
  23891. */
  23892. clone(): Texture;
  23893. /**
  23894. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23895. * @returns The JSON representation of the texture
  23896. */
  23897. serialize(): any;
  23898. /**
  23899. * Get the current class name of the texture useful for serialization or dynamic coding.
  23900. * @returns "Texture"
  23901. */
  23902. getClassName(): string;
  23903. /**
  23904. * Dispose the texture and release its associated resources.
  23905. */
  23906. dispose(): void;
  23907. /**
  23908. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23909. * @param parsedTexture Define the JSON representation of the texture
  23910. * @param scene Define the scene the parsed texture should be instantiated in
  23911. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23912. * @returns The parsed texture if successful
  23913. */
  23914. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23915. /**
  23916. * Creates a texture from its base 64 representation.
  23917. * @param data Define the base64 payload without the data: prefix
  23918. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23919. * @param scene Define the scene the texture should belong to
  23920. * @param noMipmap Forces the texture to not create mip map information if true
  23921. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23922. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23923. * @param onLoad define a callback triggered when the texture has been loaded
  23924. * @param onError define a callback triggered when an error occurred during the loading session
  23925. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23926. * @returns the created texture
  23927. */
  23928. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23929. /**
  23930. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23931. * @param data Define the base64 payload without the data: prefix
  23932. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23933. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23934. * @param scene Define the scene the texture should belong to
  23935. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23936. * @param noMipmap Forces the texture to not create mip map information if true
  23937. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23938. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23939. * @param onLoad define a callback triggered when the texture has been loaded
  23940. * @param onError define a callback triggered when an error occurred during the loading session
  23941. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23942. * @returns the created texture
  23943. */
  23944. 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;
  23945. }
  23946. }
  23947. declare module "babylonjs/PostProcesses/postProcessManager" {
  23948. import { Nullable } from "babylonjs/types";
  23949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23950. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23951. import { Scene } from "babylonjs/scene";
  23952. /**
  23953. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23954. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23955. */
  23956. export class PostProcessManager {
  23957. private _scene;
  23958. private _indexBuffer;
  23959. private _vertexBuffers;
  23960. /**
  23961. * Creates a new instance PostProcess
  23962. * @param scene The scene that the post process is associated with.
  23963. */
  23964. constructor(scene: Scene);
  23965. private _prepareBuffers;
  23966. private _buildIndexBuffer;
  23967. /**
  23968. * Rebuilds the vertex buffers of the manager.
  23969. * @hidden
  23970. */
  23971. _rebuild(): void;
  23972. /**
  23973. * Prepares a frame to be run through a post process.
  23974. * @param sourceTexture The input texture to the post procesess. (default: null)
  23975. * @param postProcesses An array of post processes to be run. (default: null)
  23976. * @returns True if the post processes were able to be run.
  23977. * @hidden
  23978. */
  23979. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23980. /**
  23981. * Manually render a set of post processes to a texture.
  23982. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23983. * @param postProcesses An array of post processes to be run.
  23984. * @param targetTexture The target texture to render to.
  23985. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23986. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23987. * @param lodLevel defines which lod of the texture to render to
  23988. */
  23989. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23990. /**
  23991. * Finalize the result of the output of the postprocesses.
  23992. * @param doNotPresent If true the result will not be displayed to the screen.
  23993. * @param targetTexture The target texture to render to.
  23994. * @param faceIndex The index of the face to bind the target texture to.
  23995. * @param postProcesses The array of post processes to render.
  23996. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23997. * @hidden
  23998. */
  23999. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24000. /**
  24001. * Disposes of the post process manager.
  24002. */
  24003. dispose(): void;
  24004. }
  24005. }
  24006. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24007. import { Observable } from "babylonjs/Misc/observable";
  24008. import { SmartArray } from "babylonjs/Misc/smartArray";
  24009. import { Nullable, Immutable } from "babylonjs/types";
  24010. import { Camera } from "babylonjs/Cameras/camera";
  24011. import { Scene } from "babylonjs/scene";
  24012. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24013. import { Color4 } from "babylonjs/Maths/math.color";
  24014. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24016. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24018. import { Texture } from "babylonjs/Materials/Textures/texture";
  24019. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24020. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24021. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24022. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24023. import { Engine } from "babylonjs/Engines/engine";
  24024. /**
  24025. * This Helps creating a texture that will be created from a camera in your scene.
  24026. * It is basically a dynamic texture that could be used to create special effects for instance.
  24027. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24028. */
  24029. export class RenderTargetTexture extends Texture {
  24030. isCube: boolean;
  24031. /**
  24032. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24033. */
  24034. static readonly REFRESHRATE_RENDER_ONCE: number;
  24035. /**
  24036. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24037. */
  24038. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24039. /**
  24040. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24041. * the central point of your effect and can save a lot of performances.
  24042. */
  24043. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24044. /**
  24045. * Use this predicate to dynamically define the list of mesh you want to render.
  24046. * If set, the renderList property will be overwritten.
  24047. */
  24048. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24049. private _renderList;
  24050. /**
  24051. * Use this list to define the list of mesh you want to render.
  24052. */
  24053. get renderList(): Nullable<Array<AbstractMesh>>;
  24054. set renderList(value: Nullable<Array<AbstractMesh>>);
  24055. /**
  24056. * Use this function to overload the renderList array at rendering time.
  24057. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24058. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24059. * the cube (if the RTT is a cube, else layerOrFace=0).
  24060. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24061. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24062. * hold dummy elements!
  24063. */
  24064. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24065. private _hookArray;
  24066. /**
  24067. * Define if particles should be rendered in your texture.
  24068. */
  24069. renderParticles: boolean;
  24070. /**
  24071. * Define if sprites should be rendered in your texture.
  24072. */
  24073. renderSprites: boolean;
  24074. /**
  24075. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24076. */
  24077. coordinatesMode: number;
  24078. /**
  24079. * Define the camera used to render the texture.
  24080. */
  24081. activeCamera: Nullable<Camera>;
  24082. /**
  24083. * Override the mesh isReady function with your own one.
  24084. */
  24085. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24086. /**
  24087. * Override the render function of the texture with your own one.
  24088. */
  24089. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24090. /**
  24091. * Define if camera post processes should be use while rendering the texture.
  24092. */
  24093. useCameraPostProcesses: boolean;
  24094. /**
  24095. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24096. */
  24097. ignoreCameraViewport: boolean;
  24098. private _postProcessManager;
  24099. private _postProcesses;
  24100. private _resizeObserver;
  24101. /**
  24102. * An event triggered when the texture is unbind.
  24103. */
  24104. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24105. /**
  24106. * An event triggered when the texture is unbind.
  24107. */
  24108. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24109. private _onAfterUnbindObserver;
  24110. /**
  24111. * Set a after unbind callback in the texture.
  24112. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24113. */
  24114. set onAfterUnbind(callback: () => void);
  24115. /**
  24116. * An event triggered before rendering the texture
  24117. */
  24118. onBeforeRenderObservable: Observable<number>;
  24119. private _onBeforeRenderObserver;
  24120. /**
  24121. * Set a before render callback in the texture.
  24122. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24123. */
  24124. set onBeforeRender(callback: (faceIndex: number) => void);
  24125. /**
  24126. * An event triggered after rendering the texture
  24127. */
  24128. onAfterRenderObservable: Observable<number>;
  24129. private _onAfterRenderObserver;
  24130. /**
  24131. * Set a after render callback in the texture.
  24132. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24133. */
  24134. set onAfterRender(callback: (faceIndex: number) => void);
  24135. /**
  24136. * An event triggered after the texture clear
  24137. */
  24138. onClearObservable: Observable<Engine>;
  24139. private _onClearObserver;
  24140. /**
  24141. * Set a clear callback in the texture.
  24142. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24143. */
  24144. set onClear(callback: (Engine: Engine) => void);
  24145. /**
  24146. * An event triggered when the texture is resized.
  24147. */
  24148. onResizeObservable: Observable<RenderTargetTexture>;
  24149. /**
  24150. * Define the clear color of the Render Target if it should be different from the scene.
  24151. */
  24152. clearColor: Color4;
  24153. protected _size: number | {
  24154. width: number;
  24155. height: number;
  24156. layers?: number;
  24157. };
  24158. protected _initialSizeParameter: number | {
  24159. width: number;
  24160. height: number;
  24161. } | {
  24162. ratio: number;
  24163. };
  24164. protected _sizeRatio: Nullable<number>;
  24165. /** @hidden */
  24166. _generateMipMaps: boolean;
  24167. protected _renderingManager: RenderingManager;
  24168. /** @hidden */
  24169. _waitingRenderList: string[];
  24170. protected _doNotChangeAspectRatio: boolean;
  24171. protected _currentRefreshId: number;
  24172. protected _refreshRate: number;
  24173. protected _textureMatrix: Matrix;
  24174. protected _samples: number;
  24175. protected _renderTargetOptions: RenderTargetCreationOptions;
  24176. /**
  24177. * Gets render target creation options that were used.
  24178. */
  24179. get renderTargetOptions(): RenderTargetCreationOptions;
  24180. protected _onRatioRescale(): void;
  24181. /**
  24182. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24183. * It must define where the camera used to render the texture is set
  24184. */
  24185. boundingBoxPosition: Vector3;
  24186. private _boundingBoxSize;
  24187. /**
  24188. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24189. * When defined, the cubemap will switch to local mode
  24190. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24191. * @example https://www.babylonjs-playground.com/#RNASML
  24192. */
  24193. set boundingBoxSize(value: Vector3);
  24194. get boundingBoxSize(): Vector3;
  24195. /**
  24196. * In case the RTT has been created with a depth texture, get the associated
  24197. * depth texture.
  24198. * Otherwise, return null.
  24199. */
  24200. get depthStencilTexture(): Nullable<InternalTexture>;
  24201. /**
  24202. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24203. * or used a shadow, depth texture...
  24204. * @param name The friendly name of the texture
  24205. * @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)
  24206. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24207. * @param generateMipMaps True if mip maps need to be generated after render.
  24208. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24209. * @param type The type of the buffer in the RTT (int, half float, float...)
  24210. * @param isCube True if a cube texture needs to be created
  24211. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24212. * @param generateDepthBuffer True to generate a depth buffer
  24213. * @param generateStencilBuffer True to generate a stencil buffer
  24214. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24215. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24216. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24217. */
  24218. constructor(name: string, size: number | {
  24219. width: number;
  24220. height: number;
  24221. layers?: number;
  24222. } | {
  24223. ratio: number;
  24224. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24225. /**
  24226. * Creates a depth stencil texture.
  24227. * This is only available in WebGL 2 or with the depth texture extension available.
  24228. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24229. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24230. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24231. */
  24232. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24233. private _processSizeParameter;
  24234. /**
  24235. * Define the number of samples to use in case of MSAA.
  24236. * It defaults to one meaning no MSAA has been enabled.
  24237. */
  24238. get samples(): number;
  24239. set samples(value: number);
  24240. /**
  24241. * Resets the refresh counter of the texture and start bak from scratch.
  24242. * Could be useful to regenerate the texture if it is setup to render only once.
  24243. */
  24244. resetRefreshCounter(): void;
  24245. /**
  24246. * Define the refresh rate of the texture or the rendering frequency.
  24247. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24248. */
  24249. get refreshRate(): number;
  24250. set refreshRate(value: number);
  24251. /**
  24252. * Adds a post process to the render target rendering passes.
  24253. * @param postProcess define the post process to add
  24254. */
  24255. addPostProcess(postProcess: PostProcess): void;
  24256. /**
  24257. * Clear all the post processes attached to the render target
  24258. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24259. */
  24260. clearPostProcesses(dispose?: boolean): void;
  24261. /**
  24262. * Remove one of the post process from the list of attached post processes to the texture
  24263. * @param postProcess define the post process to remove from the list
  24264. */
  24265. removePostProcess(postProcess: PostProcess): void;
  24266. /** @hidden */
  24267. _shouldRender(): boolean;
  24268. /**
  24269. * Gets the actual render size of the texture.
  24270. * @returns the width of the render size
  24271. */
  24272. getRenderSize(): number;
  24273. /**
  24274. * Gets the actual render width of the texture.
  24275. * @returns the width of the render size
  24276. */
  24277. getRenderWidth(): number;
  24278. /**
  24279. * Gets the actual render height of the texture.
  24280. * @returns the height of the render size
  24281. */
  24282. getRenderHeight(): number;
  24283. /**
  24284. * Gets the actual number of layers of the texture.
  24285. * @returns the number of layers
  24286. */
  24287. getRenderLayers(): number;
  24288. /**
  24289. * Get if the texture can be rescaled or not.
  24290. */
  24291. get canRescale(): boolean;
  24292. /**
  24293. * Resize the texture using a ratio.
  24294. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24295. */
  24296. scale(ratio: number): void;
  24297. /**
  24298. * Get the texture reflection matrix used to rotate/transform the reflection.
  24299. * @returns the reflection matrix
  24300. */
  24301. getReflectionTextureMatrix(): Matrix;
  24302. /**
  24303. * Resize the texture to a new desired size.
  24304. * Be carrefull as it will recreate all the data in the new texture.
  24305. * @param size Define the new size. It can be:
  24306. * - a number for squared texture,
  24307. * - an object containing { width: number, height: number }
  24308. * - or an object containing a ratio { ratio: number }
  24309. */
  24310. resize(size: number | {
  24311. width: number;
  24312. height: number;
  24313. } | {
  24314. ratio: number;
  24315. }): void;
  24316. private _defaultRenderListPrepared;
  24317. /**
  24318. * Renders all the objects from the render list into the texture.
  24319. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24320. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24321. */
  24322. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24323. private _bestReflectionRenderTargetDimension;
  24324. private _prepareRenderingManager;
  24325. /**
  24326. * @hidden
  24327. * @param faceIndex face index to bind to if this is a cubetexture
  24328. * @param layer defines the index of the texture to bind in the array
  24329. */
  24330. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24331. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24332. private renderToTarget;
  24333. /**
  24334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24335. * This allowed control for front to back rendering or reversly depending of the special needs.
  24336. *
  24337. * @param renderingGroupId The rendering group id corresponding to its index
  24338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24341. */
  24342. 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;
  24343. /**
  24344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24345. *
  24346. * @param renderingGroupId The rendering group id corresponding to its index
  24347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24348. */
  24349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24350. /**
  24351. * Clones the texture.
  24352. * @returns the cloned texture
  24353. */
  24354. clone(): RenderTargetTexture;
  24355. /**
  24356. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24357. * @returns The JSON representation of the texture
  24358. */
  24359. serialize(): any;
  24360. /**
  24361. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24362. */
  24363. disposeFramebufferObjects(): void;
  24364. /**
  24365. * Dispose the texture and release its associated resources.
  24366. */
  24367. dispose(): void;
  24368. /** @hidden */
  24369. _rebuild(): void;
  24370. /**
  24371. * Clear the info related to rendering groups preventing retention point in material dispose.
  24372. */
  24373. freeRenderingGroups(): void;
  24374. /**
  24375. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24376. * @returns the view count
  24377. */
  24378. getViewCount(): number;
  24379. }
  24380. }
  24381. declare module "babylonjs/Misc/guid" {
  24382. /**
  24383. * Class used to manipulate GUIDs
  24384. */
  24385. export class GUID {
  24386. /**
  24387. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24388. * Be aware Math.random() could cause collisions, but:
  24389. * "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"
  24390. * @returns a pseudo random id
  24391. */
  24392. static RandomId(): string;
  24393. }
  24394. }
  24395. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24396. import { Nullable } from "babylonjs/types";
  24397. import { Scene } from "babylonjs/scene";
  24398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24399. import { Material } from "babylonjs/Materials/material";
  24400. import { Effect } from "babylonjs/Materials/effect";
  24401. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24402. /**
  24403. * Options to be used when creating a shadow depth material
  24404. */
  24405. export interface IIOptionShadowDepthMaterial {
  24406. /** Variables in the vertex shader code that need to have their names remapped.
  24407. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24408. * "var_name" should be either: worldPos or vNormalW
  24409. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24410. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24411. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24412. */
  24413. remappedVariables?: string[];
  24414. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24415. standalone?: boolean;
  24416. }
  24417. /**
  24418. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24419. */
  24420. export class ShadowDepthWrapper {
  24421. private _scene;
  24422. private _options?;
  24423. private _baseMaterial;
  24424. private _onEffectCreatedObserver;
  24425. private _subMeshToEffect;
  24426. private _subMeshToDepthEffect;
  24427. private _meshes;
  24428. /** @hidden */
  24429. _matriceNames: any;
  24430. /** Gets the standalone status of the wrapper */
  24431. get standalone(): boolean;
  24432. /** Gets the base material the wrapper is built upon */
  24433. get baseMaterial(): Material;
  24434. /**
  24435. * Instantiate a new shadow depth wrapper.
  24436. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24437. * generate the shadow depth map. For more information, please refer to the documentation:
  24438. * https://doc.babylonjs.com/babylon101/shadows
  24439. * @param baseMaterial Material to wrap
  24440. * @param scene Define the scene the material belongs to
  24441. * @param options Options used to create the wrapper
  24442. */
  24443. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24444. /**
  24445. * Gets the effect to use to generate the depth map
  24446. * @param subMesh subMesh to get the effect for
  24447. * @param shadowGenerator shadow generator to get the effect for
  24448. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24449. */
  24450. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24451. /**
  24452. * Specifies that the submesh is ready to be used for depth rendering
  24453. * @param subMesh submesh to check
  24454. * @param defines the list of defines to take into account when checking the effect
  24455. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24456. * @param useInstances specifies that instances should be used
  24457. * @returns a boolean indicating that the submesh is ready or not
  24458. */
  24459. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24460. /**
  24461. * Disposes the resources
  24462. */
  24463. dispose(): void;
  24464. private _makeEffect;
  24465. }
  24466. }
  24467. declare module "babylonjs/Materials/material" {
  24468. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24469. import { SmartArray } from "babylonjs/Misc/smartArray";
  24470. import { Observable } from "babylonjs/Misc/observable";
  24471. import { Nullable } from "babylonjs/types";
  24472. import { Scene } from "babylonjs/scene";
  24473. import { Matrix } from "babylonjs/Maths/math.vector";
  24474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24476. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24477. import { Effect } from "babylonjs/Materials/effect";
  24478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24480. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24481. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24482. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24483. import { Mesh } from "babylonjs/Meshes/mesh";
  24484. import { Animation } from "babylonjs/Animations/animation";
  24485. /**
  24486. * Options for compiling materials.
  24487. */
  24488. export interface IMaterialCompilationOptions {
  24489. /**
  24490. * Defines whether clip planes are enabled.
  24491. */
  24492. clipPlane: boolean;
  24493. /**
  24494. * Defines whether instances are enabled.
  24495. */
  24496. useInstances: boolean;
  24497. }
  24498. /**
  24499. * Options passed when calling customShaderNameResolve
  24500. */
  24501. export interface ICustomShaderNameResolveOptions {
  24502. /**
  24503. * 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
  24504. */
  24505. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24506. }
  24507. /**
  24508. * Base class for the main features of a material in Babylon.js
  24509. */
  24510. export class Material implements IAnimatable {
  24511. /**
  24512. * Returns the triangle fill mode
  24513. */
  24514. static readonly TriangleFillMode: number;
  24515. /**
  24516. * Returns the wireframe mode
  24517. */
  24518. static readonly WireFrameFillMode: number;
  24519. /**
  24520. * Returns the point fill mode
  24521. */
  24522. static readonly PointFillMode: number;
  24523. /**
  24524. * Returns the point list draw mode
  24525. */
  24526. static readonly PointListDrawMode: number;
  24527. /**
  24528. * Returns the line list draw mode
  24529. */
  24530. static readonly LineListDrawMode: number;
  24531. /**
  24532. * Returns the line loop draw mode
  24533. */
  24534. static readonly LineLoopDrawMode: number;
  24535. /**
  24536. * Returns the line strip draw mode
  24537. */
  24538. static readonly LineStripDrawMode: number;
  24539. /**
  24540. * Returns the triangle strip draw mode
  24541. */
  24542. static readonly TriangleStripDrawMode: number;
  24543. /**
  24544. * Returns the triangle fan draw mode
  24545. */
  24546. static readonly TriangleFanDrawMode: number;
  24547. /**
  24548. * Stores the clock-wise side orientation
  24549. */
  24550. static readonly ClockWiseSideOrientation: number;
  24551. /**
  24552. * Stores the counter clock-wise side orientation
  24553. */
  24554. static readonly CounterClockWiseSideOrientation: number;
  24555. /**
  24556. * The dirty texture flag value
  24557. */
  24558. static readonly TextureDirtyFlag: number;
  24559. /**
  24560. * The dirty light flag value
  24561. */
  24562. static readonly LightDirtyFlag: number;
  24563. /**
  24564. * The dirty fresnel flag value
  24565. */
  24566. static readonly FresnelDirtyFlag: number;
  24567. /**
  24568. * The dirty attribute flag value
  24569. */
  24570. static readonly AttributesDirtyFlag: number;
  24571. /**
  24572. * The dirty misc flag value
  24573. */
  24574. static readonly MiscDirtyFlag: number;
  24575. /**
  24576. * The all dirty flag value
  24577. */
  24578. static readonly AllDirtyFlag: number;
  24579. /**
  24580. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24581. */
  24582. static readonly MATERIAL_OPAQUE: number;
  24583. /**
  24584. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24585. */
  24586. static readonly MATERIAL_ALPHATEST: number;
  24587. /**
  24588. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24589. */
  24590. static readonly MATERIAL_ALPHABLEND: number;
  24591. /**
  24592. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24593. * They are also discarded below the alpha cutoff threshold to improve performances.
  24594. */
  24595. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24596. /**
  24597. * Custom callback helping to override the default shader used in the material.
  24598. */
  24599. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24600. /**
  24601. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24602. */
  24603. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24604. /**
  24605. * The ID of the material
  24606. */
  24607. id: string;
  24608. /**
  24609. * Gets or sets the unique id of the material
  24610. */
  24611. uniqueId: number;
  24612. /**
  24613. * The name of the material
  24614. */
  24615. name: string;
  24616. /**
  24617. * Gets or sets user defined metadata
  24618. */
  24619. metadata: any;
  24620. /**
  24621. * For internal use only. Please do not use.
  24622. */
  24623. reservedDataStore: any;
  24624. /**
  24625. * Specifies if the ready state should be checked on each call
  24626. */
  24627. checkReadyOnEveryCall: boolean;
  24628. /**
  24629. * Specifies if the ready state should be checked once
  24630. */
  24631. checkReadyOnlyOnce: boolean;
  24632. /**
  24633. * The state of the material
  24634. */
  24635. state: string;
  24636. /**
  24637. * The alpha value of the material
  24638. */
  24639. protected _alpha: number;
  24640. /**
  24641. * List of inspectable custom properties (used by the Inspector)
  24642. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24643. */
  24644. inspectableCustomProperties: IInspectable[];
  24645. /**
  24646. * Sets the alpha value of the material
  24647. */
  24648. set alpha(value: number);
  24649. /**
  24650. * Gets the alpha value of the material
  24651. */
  24652. get alpha(): number;
  24653. /**
  24654. * Specifies if back face culling is enabled
  24655. */
  24656. protected _backFaceCulling: boolean;
  24657. /**
  24658. * Sets the back-face culling state
  24659. */
  24660. set backFaceCulling(value: boolean);
  24661. /**
  24662. * Gets the back-face culling state
  24663. */
  24664. get backFaceCulling(): boolean;
  24665. /**
  24666. * Stores the value for side orientation
  24667. */
  24668. sideOrientation: number;
  24669. /**
  24670. * Callback triggered when the material is compiled
  24671. */
  24672. onCompiled: Nullable<(effect: Effect) => void>;
  24673. /**
  24674. * Callback triggered when an error occurs
  24675. */
  24676. onError: Nullable<(effect: Effect, errors: string) => void>;
  24677. /**
  24678. * Callback triggered to get the render target textures
  24679. */
  24680. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24681. /**
  24682. * Gets a boolean indicating that current material needs to register RTT
  24683. */
  24684. get hasRenderTargetTextures(): boolean;
  24685. /**
  24686. * Specifies if the material should be serialized
  24687. */
  24688. doNotSerialize: boolean;
  24689. /**
  24690. * @hidden
  24691. */
  24692. _storeEffectOnSubMeshes: boolean;
  24693. /**
  24694. * Stores the animations for the material
  24695. */
  24696. animations: Nullable<Array<Animation>>;
  24697. /**
  24698. * An event triggered when the material is disposed
  24699. */
  24700. onDisposeObservable: Observable<Material>;
  24701. /**
  24702. * An observer which watches for dispose events
  24703. */
  24704. private _onDisposeObserver;
  24705. private _onUnBindObservable;
  24706. /**
  24707. * Called during a dispose event
  24708. */
  24709. set onDispose(callback: () => void);
  24710. private _onBindObservable;
  24711. /**
  24712. * An event triggered when the material is bound
  24713. */
  24714. get onBindObservable(): Observable<AbstractMesh>;
  24715. /**
  24716. * An observer which watches for bind events
  24717. */
  24718. private _onBindObserver;
  24719. /**
  24720. * Called during a bind event
  24721. */
  24722. set onBind(callback: (Mesh: AbstractMesh) => void);
  24723. /**
  24724. * An event triggered when the material is unbound
  24725. */
  24726. get onUnBindObservable(): Observable<Material>;
  24727. protected _onEffectCreatedObservable: Nullable<Observable<{
  24728. effect: Effect;
  24729. subMesh: Nullable<SubMesh>;
  24730. }>>;
  24731. /**
  24732. * An event triggered when the effect is (re)created
  24733. */
  24734. get onEffectCreatedObservable(): Observable<{
  24735. effect: Effect;
  24736. subMesh: Nullable<SubMesh>;
  24737. }>;
  24738. /**
  24739. * Stores the value of the alpha mode
  24740. */
  24741. private _alphaMode;
  24742. /**
  24743. * Sets the value of the alpha mode.
  24744. *
  24745. * | Value | Type | Description |
  24746. * | --- | --- | --- |
  24747. * | 0 | ALPHA_DISABLE | |
  24748. * | 1 | ALPHA_ADD | |
  24749. * | 2 | ALPHA_COMBINE | |
  24750. * | 3 | ALPHA_SUBTRACT | |
  24751. * | 4 | ALPHA_MULTIPLY | |
  24752. * | 5 | ALPHA_MAXIMIZED | |
  24753. * | 6 | ALPHA_ONEONE | |
  24754. * | 7 | ALPHA_PREMULTIPLIED | |
  24755. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24756. * | 9 | ALPHA_INTERPOLATE | |
  24757. * | 10 | ALPHA_SCREENMODE | |
  24758. *
  24759. */
  24760. set alphaMode(value: number);
  24761. /**
  24762. * Gets the value of the alpha mode
  24763. */
  24764. get alphaMode(): number;
  24765. /**
  24766. * Stores the state of the need depth pre-pass value
  24767. */
  24768. private _needDepthPrePass;
  24769. /**
  24770. * Sets the need depth pre-pass value
  24771. */
  24772. set needDepthPrePass(value: boolean);
  24773. /**
  24774. * Gets the depth pre-pass value
  24775. */
  24776. get needDepthPrePass(): boolean;
  24777. /**
  24778. * Specifies if depth writing should be disabled
  24779. */
  24780. disableDepthWrite: boolean;
  24781. /**
  24782. * Specifies if color writing should be disabled
  24783. */
  24784. disableColorWrite: boolean;
  24785. /**
  24786. * Specifies if depth writing should be forced
  24787. */
  24788. forceDepthWrite: boolean;
  24789. /**
  24790. * Specifies the depth function that should be used. 0 means the default engine function
  24791. */
  24792. depthFunction: number;
  24793. /**
  24794. * Specifies if there should be a separate pass for culling
  24795. */
  24796. separateCullingPass: boolean;
  24797. /**
  24798. * Stores the state specifing if fog should be enabled
  24799. */
  24800. private _fogEnabled;
  24801. /**
  24802. * Sets the state for enabling fog
  24803. */
  24804. set fogEnabled(value: boolean);
  24805. /**
  24806. * Gets the value of the fog enabled state
  24807. */
  24808. get fogEnabled(): boolean;
  24809. /**
  24810. * Stores the size of points
  24811. */
  24812. pointSize: number;
  24813. /**
  24814. * Stores the z offset value
  24815. */
  24816. zOffset: number;
  24817. get wireframe(): boolean;
  24818. /**
  24819. * Sets the state of wireframe mode
  24820. */
  24821. set wireframe(value: boolean);
  24822. /**
  24823. * Gets the value specifying if point clouds are enabled
  24824. */
  24825. get pointsCloud(): boolean;
  24826. /**
  24827. * Sets the state of point cloud mode
  24828. */
  24829. set pointsCloud(value: boolean);
  24830. /**
  24831. * Gets the material fill mode
  24832. */
  24833. get fillMode(): number;
  24834. /**
  24835. * Sets the material fill mode
  24836. */
  24837. set fillMode(value: number);
  24838. /**
  24839. * @hidden
  24840. * Stores the effects for the material
  24841. */
  24842. _effect: Nullable<Effect>;
  24843. /**
  24844. * Specifies if uniform buffers should be used
  24845. */
  24846. private _useUBO;
  24847. /**
  24848. * Stores a reference to the scene
  24849. */
  24850. private _scene;
  24851. /**
  24852. * Stores the fill mode state
  24853. */
  24854. private _fillMode;
  24855. /**
  24856. * Specifies if the depth write state should be cached
  24857. */
  24858. private _cachedDepthWriteState;
  24859. /**
  24860. * Specifies if the color write state should be cached
  24861. */
  24862. private _cachedColorWriteState;
  24863. /**
  24864. * Specifies if the depth function state should be cached
  24865. */
  24866. private _cachedDepthFunctionState;
  24867. /**
  24868. * Stores the uniform buffer
  24869. */
  24870. protected _uniformBuffer: UniformBuffer;
  24871. /** @hidden */
  24872. _indexInSceneMaterialArray: number;
  24873. /** @hidden */
  24874. meshMap: Nullable<{
  24875. [id: string]: AbstractMesh | undefined;
  24876. }>;
  24877. /**
  24878. * Creates a material instance
  24879. * @param name defines the name of the material
  24880. * @param scene defines the scene to reference
  24881. * @param doNotAdd specifies if the material should be added to the scene
  24882. */
  24883. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24884. /**
  24885. * Returns a string representation of the current material
  24886. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24887. * @returns a string with material information
  24888. */
  24889. toString(fullDetails?: boolean): string;
  24890. /**
  24891. * Gets the class name of the material
  24892. * @returns a string with the class name of the material
  24893. */
  24894. getClassName(): string;
  24895. /**
  24896. * Specifies if updates for the material been locked
  24897. */
  24898. get isFrozen(): boolean;
  24899. /**
  24900. * Locks updates for the material
  24901. */
  24902. freeze(): void;
  24903. /**
  24904. * Unlocks updates for the material
  24905. */
  24906. unfreeze(): void;
  24907. /**
  24908. * Specifies if the material is ready to be used
  24909. * @param mesh defines the mesh to check
  24910. * @param useInstances specifies if instances should be used
  24911. * @returns a boolean indicating if the material is ready to be used
  24912. */
  24913. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24914. /**
  24915. * Specifies that the submesh is ready to be used
  24916. * @param mesh defines the mesh to check
  24917. * @param subMesh defines which submesh to check
  24918. * @param useInstances specifies that instances should be used
  24919. * @returns a boolean indicating that the submesh is ready or not
  24920. */
  24921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24922. /**
  24923. * Returns the material effect
  24924. * @returns the effect associated with the material
  24925. */
  24926. getEffect(): Nullable<Effect>;
  24927. /**
  24928. * Returns the current scene
  24929. * @returns a Scene
  24930. */
  24931. getScene(): Scene;
  24932. /**
  24933. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24934. */
  24935. protected _forceAlphaTest: boolean;
  24936. /**
  24937. * The transparency mode of the material.
  24938. */
  24939. protected _transparencyMode: Nullable<number>;
  24940. /**
  24941. * Gets the current transparency mode.
  24942. */
  24943. get transparencyMode(): Nullable<number>;
  24944. /**
  24945. * Sets the transparency mode of the material.
  24946. *
  24947. * | Value | Type | Description |
  24948. * | ----- | ----------------------------------- | ----------- |
  24949. * | 0 | OPAQUE | |
  24950. * | 1 | ALPHATEST | |
  24951. * | 2 | ALPHABLEND | |
  24952. * | 3 | ALPHATESTANDBLEND | |
  24953. *
  24954. */
  24955. set transparencyMode(value: Nullable<number>);
  24956. /**
  24957. * Returns true if alpha blending should be disabled.
  24958. */
  24959. protected get _disableAlphaBlending(): boolean;
  24960. /**
  24961. * Specifies whether or not this material should be rendered in alpha blend mode.
  24962. * @returns a boolean specifying if alpha blending is needed
  24963. */
  24964. needAlphaBlending(): boolean;
  24965. /**
  24966. * Specifies if the mesh will require alpha blending
  24967. * @param mesh defines the mesh to check
  24968. * @returns a boolean specifying if alpha blending is needed for the mesh
  24969. */
  24970. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24971. /**
  24972. * Specifies whether or not this material should be rendered in alpha test mode.
  24973. * @returns a boolean specifying if an alpha test is needed.
  24974. */
  24975. needAlphaTesting(): boolean;
  24976. /**
  24977. * Specifies if material alpha testing should be turned on for the mesh
  24978. * @param mesh defines the mesh to check
  24979. */
  24980. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24981. /**
  24982. * Gets the texture used for the alpha test
  24983. * @returns the texture to use for alpha testing
  24984. */
  24985. getAlphaTestTexture(): Nullable<BaseTexture>;
  24986. /**
  24987. * Marks the material to indicate that it needs to be re-calculated
  24988. */
  24989. markDirty(): void;
  24990. /** @hidden */
  24991. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24992. /**
  24993. * Binds the material to the mesh
  24994. * @param world defines the world transformation matrix
  24995. * @param mesh defines the mesh to bind the material to
  24996. */
  24997. bind(world: Matrix, mesh?: Mesh): void;
  24998. /**
  24999. * Binds the submesh to the material
  25000. * @param world defines the world transformation matrix
  25001. * @param mesh defines the mesh containing the submesh
  25002. * @param subMesh defines the submesh to bind the material to
  25003. */
  25004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25005. /**
  25006. * Binds the world matrix to the material
  25007. * @param world defines the world transformation matrix
  25008. */
  25009. bindOnlyWorldMatrix(world: Matrix): void;
  25010. /**
  25011. * Binds the scene's uniform buffer to the effect.
  25012. * @param effect defines the effect to bind to the scene uniform buffer
  25013. * @param sceneUbo defines the uniform buffer storing scene data
  25014. */
  25015. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25016. /**
  25017. * Binds the view matrix to the effect
  25018. * @param effect defines the effect to bind the view matrix to
  25019. */
  25020. bindView(effect: Effect): void;
  25021. /**
  25022. * Binds the view projection matrix to the effect
  25023. * @param effect defines the effect to bind the view projection matrix to
  25024. */
  25025. bindViewProjection(effect: Effect): void;
  25026. /**
  25027. * Processes to execute after binding the material to a mesh
  25028. * @param mesh defines the rendered mesh
  25029. */
  25030. protected _afterBind(mesh?: Mesh): void;
  25031. /**
  25032. * Unbinds the material from the mesh
  25033. */
  25034. unbind(): void;
  25035. /**
  25036. * Gets the active textures from the material
  25037. * @returns an array of textures
  25038. */
  25039. getActiveTextures(): BaseTexture[];
  25040. /**
  25041. * Specifies if the material uses a texture
  25042. * @param texture defines the texture to check against the material
  25043. * @returns a boolean specifying if the material uses the texture
  25044. */
  25045. hasTexture(texture: BaseTexture): boolean;
  25046. /**
  25047. * Makes a duplicate of the material, and gives it a new name
  25048. * @param name defines the new name for the duplicated material
  25049. * @returns the cloned material
  25050. */
  25051. clone(name: string): Nullable<Material>;
  25052. /**
  25053. * Gets the meshes bound to the material
  25054. * @returns an array of meshes bound to the material
  25055. */
  25056. getBindedMeshes(): AbstractMesh[];
  25057. /**
  25058. * Force shader compilation
  25059. * @param mesh defines the mesh associated with this material
  25060. * @param onCompiled defines a function to execute once the material is compiled
  25061. * @param options defines the options to configure the compilation
  25062. * @param onError defines a function to execute if the material fails compiling
  25063. */
  25064. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25065. /**
  25066. * Force shader compilation
  25067. * @param mesh defines the mesh that will use this material
  25068. * @param options defines additional options for compiling the shaders
  25069. * @returns a promise that resolves when the compilation completes
  25070. */
  25071. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25072. private static readonly _AllDirtyCallBack;
  25073. private static readonly _ImageProcessingDirtyCallBack;
  25074. private static readonly _TextureDirtyCallBack;
  25075. private static readonly _FresnelDirtyCallBack;
  25076. private static readonly _MiscDirtyCallBack;
  25077. private static readonly _LightsDirtyCallBack;
  25078. private static readonly _AttributeDirtyCallBack;
  25079. private static _FresnelAndMiscDirtyCallBack;
  25080. private static _TextureAndMiscDirtyCallBack;
  25081. private static readonly _DirtyCallbackArray;
  25082. private static readonly _RunDirtyCallBacks;
  25083. /**
  25084. * Marks a define in the material to indicate that it needs to be re-computed
  25085. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25086. */
  25087. markAsDirty(flag: number): void;
  25088. /**
  25089. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25090. * @param func defines a function which checks material defines against the submeshes
  25091. */
  25092. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25093. /**
  25094. * Indicates that we need to re-calculated for all submeshes
  25095. */
  25096. protected _markAllSubMeshesAsAllDirty(): void;
  25097. /**
  25098. * Indicates that image processing needs to be re-calculated for all submeshes
  25099. */
  25100. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25101. /**
  25102. * Indicates that textures need to be re-calculated for all submeshes
  25103. */
  25104. protected _markAllSubMeshesAsTexturesDirty(): void;
  25105. /**
  25106. * Indicates that fresnel needs to be re-calculated for all submeshes
  25107. */
  25108. protected _markAllSubMeshesAsFresnelDirty(): void;
  25109. /**
  25110. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25111. */
  25112. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25113. /**
  25114. * Indicates that lights need to be re-calculated for all submeshes
  25115. */
  25116. protected _markAllSubMeshesAsLightsDirty(): void;
  25117. /**
  25118. * Indicates that attributes need to be re-calculated for all submeshes
  25119. */
  25120. protected _markAllSubMeshesAsAttributesDirty(): void;
  25121. /**
  25122. * Indicates that misc needs to be re-calculated for all submeshes
  25123. */
  25124. protected _markAllSubMeshesAsMiscDirty(): void;
  25125. /**
  25126. * Indicates that textures and misc need to be re-calculated for all submeshes
  25127. */
  25128. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25129. /**
  25130. * Disposes the material
  25131. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25132. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25133. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25134. */
  25135. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25136. /** @hidden */
  25137. private releaseVertexArrayObject;
  25138. /**
  25139. * Serializes this material
  25140. * @returns the serialized material object
  25141. */
  25142. serialize(): any;
  25143. /**
  25144. * Creates a material from parsed material data
  25145. * @param parsedMaterial defines parsed material data
  25146. * @param scene defines the hosting scene
  25147. * @param rootUrl defines the root URL to use to load textures
  25148. * @returns a new material
  25149. */
  25150. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25151. }
  25152. }
  25153. declare module "babylonjs/Materials/multiMaterial" {
  25154. import { Nullable } from "babylonjs/types";
  25155. import { Scene } from "babylonjs/scene";
  25156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25159. import { Material } from "babylonjs/Materials/material";
  25160. /**
  25161. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25162. * separate meshes. This can be use to improve performances.
  25163. * @see http://doc.babylonjs.com/how_to/multi_materials
  25164. */
  25165. export class MultiMaterial extends Material {
  25166. private _subMaterials;
  25167. /**
  25168. * Gets or Sets the list of Materials used within the multi material.
  25169. * They need to be ordered according to the submeshes order in the associated mesh
  25170. */
  25171. get subMaterials(): Nullable<Material>[];
  25172. set subMaterials(value: Nullable<Material>[]);
  25173. /**
  25174. * Function used to align with Node.getChildren()
  25175. * @returns the list of Materials used within the multi material
  25176. */
  25177. getChildren(): Nullable<Material>[];
  25178. /**
  25179. * Instantiates a new Multi Material
  25180. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25181. * separate meshes. This can be use to improve performances.
  25182. * @see http://doc.babylonjs.com/how_to/multi_materials
  25183. * @param name Define the name in the scene
  25184. * @param scene Define the scene the material belongs to
  25185. */
  25186. constructor(name: string, scene: Scene);
  25187. private _hookArray;
  25188. /**
  25189. * Get one of the submaterial by its index in the submaterials array
  25190. * @param index The index to look the sub material at
  25191. * @returns The Material if the index has been defined
  25192. */
  25193. getSubMaterial(index: number): Nullable<Material>;
  25194. /**
  25195. * Get the list of active textures for the whole sub materials list.
  25196. * @returns All the textures that will be used during the rendering
  25197. */
  25198. getActiveTextures(): BaseTexture[];
  25199. /**
  25200. * Gets the current class name of the material e.g. "MultiMaterial"
  25201. * Mainly use in serialization.
  25202. * @returns the class name
  25203. */
  25204. getClassName(): string;
  25205. /**
  25206. * Checks if the material is ready to render the requested sub mesh
  25207. * @param mesh Define the mesh the submesh belongs to
  25208. * @param subMesh Define the sub mesh to look readyness for
  25209. * @param useInstances Define whether or not the material is used with instances
  25210. * @returns true if ready, otherwise false
  25211. */
  25212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25213. /**
  25214. * Clones the current material and its related sub materials
  25215. * @param name Define the name of the newly cloned material
  25216. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25217. * @returns the cloned material
  25218. */
  25219. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25220. /**
  25221. * Serializes the materials into a JSON representation.
  25222. * @returns the JSON representation
  25223. */
  25224. serialize(): any;
  25225. /**
  25226. * Dispose the material and release its associated resources
  25227. * @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)
  25228. * @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)
  25229. * @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)
  25230. */
  25231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25232. /**
  25233. * Creates a MultiMaterial from parsed MultiMaterial data.
  25234. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25235. * @param scene defines the hosting scene
  25236. * @returns a new MultiMaterial
  25237. */
  25238. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25239. }
  25240. }
  25241. declare module "babylonjs/Meshes/subMesh" {
  25242. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25243. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25244. import { Engine } from "babylonjs/Engines/engine";
  25245. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25246. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25247. import { Effect } from "babylonjs/Materials/effect";
  25248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25249. import { Plane } from "babylonjs/Maths/math.plane";
  25250. import { Collider } from "babylonjs/Collisions/collider";
  25251. import { Material } from "babylonjs/Materials/material";
  25252. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25254. import { Mesh } from "babylonjs/Meshes/mesh";
  25255. import { Ray } from "babylonjs/Culling/ray";
  25256. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25257. /**
  25258. * Defines a subdivision inside a mesh
  25259. */
  25260. export class SubMesh implements ICullable {
  25261. /** the material index to use */
  25262. materialIndex: number;
  25263. /** vertex index start */
  25264. verticesStart: number;
  25265. /** vertices count */
  25266. verticesCount: number;
  25267. /** index start */
  25268. indexStart: number;
  25269. /** indices count */
  25270. indexCount: number;
  25271. /** @hidden */
  25272. _materialDefines: Nullable<MaterialDefines>;
  25273. /** @hidden */
  25274. _materialEffect: Nullable<Effect>;
  25275. /** @hidden */
  25276. _effectOverride: Nullable<Effect>;
  25277. /**
  25278. * Gets material defines used by the effect associated to the sub mesh
  25279. */
  25280. get materialDefines(): Nullable<MaterialDefines>;
  25281. /**
  25282. * Sets material defines used by the effect associated to the sub mesh
  25283. */
  25284. set materialDefines(defines: Nullable<MaterialDefines>);
  25285. /**
  25286. * Gets associated effect
  25287. */
  25288. get effect(): Nullable<Effect>;
  25289. /**
  25290. * Sets associated effect (effect used to render this submesh)
  25291. * @param effect defines the effect to associate with
  25292. * @param defines defines the set of defines used to compile this effect
  25293. */
  25294. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25295. /** @hidden */
  25296. _linesIndexCount: number;
  25297. private _mesh;
  25298. private _renderingMesh;
  25299. private _boundingInfo;
  25300. private _linesIndexBuffer;
  25301. /** @hidden */
  25302. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25303. /** @hidden */
  25304. _trianglePlanes: Plane[];
  25305. /** @hidden */
  25306. _lastColliderTransformMatrix: Nullable<Matrix>;
  25307. /** @hidden */
  25308. _renderId: number;
  25309. /** @hidden */
  25310. _alphaIndex: number;
  25311. /** @hidden */
  25312. _distanceToCamera: number;
  25313. /** @hidden */
  25314. _id: number;
  25315. private _currentMaterial;
  25316. /**
  25317. * Add a new submesh to a mesh
  25318. * @param materialIndex defines the material index to use
  25319. * @param verticesStart defines vertex index start
  25320. * @param verticesCount defines vertices count
  25321. * @param indexStart defines index start
  25322. * @param indexCount defines indices count
  25323. * @param mesh defines the parent mesh
  25324. * @param renderingMesh defines an optional rendering mesh
  25325. * @param createBoundingBox defines if bounding box should be created for this submesh
  25326. * @returns the new submesh
  25327. */
  25328. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25329. /**
  25330. * Creates a new submesh
  25331. * @param materialIndex defines the material index to use
  25332. * @param verticesStart defines vertex index start
  25333. * @param verticesCount defines vertices count
  25334. * @param indexStart defines index start
  25335. * @param indexCount defines indices count
  25336. * @param mesh defines the parent mesh
  25337. * @param renderingMesh defines an optional rendering mesh
  25338. * @param createBoundingBox defines if bounding box should be created for this submesh
  25339. */
  25340. constructor(
  25341. /** the material index to use */
  25342. materialIndex: number,
  25343. /** vertex index start */
  25344. verticesStart: number,
  25345. /** vertices count */
  25346. verticesCount: number,
  25347. /** index start */
  25348. indexStart: number,
  25349. /** indices count */
  25350. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  25351. /**
  25352. * Returns true if this submesh covers the entire parent mesh
  25353. * @ignorenaming
  25354. */
  25355. get IsGlobal(): boolean;
  25356. /**
  25357. * Returns the submesh BoudingInfo object
  25358. * @returns current bounding info (or mesh's one if the submesh is global)
  25359. */
  25360. getBoundingInfo(): BoundingInfo;
  25361. /**
  25362. * Sets the submesh BoundingInfo
  25363. * @param boundingInfo defines the new bounding info to use
  25364. * @returns the SubMesh
  25365. */
  25366. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25367. /**
  25368. * Returns the mesh of the current submesh
  25369. * @return the parent mesh
  25370. */
  25371. getMesh(): AbstractMesh;
  25372. /**
  25373. * Returns the rendering mesh of the submesh
  25374. * @returns the rendering mesh (could be different from parent mesh)
  25375. */
  25376. getRenderingMesh(): Mesh;
  25377. /**
  25378. * Returns the replacement mesh of the submesh
  25379. * @returns the replacement mesh (could be different from parent mesh)
  25380. */
  25381. getReplacementMesh(): Nullable<AbstractMesh>;
  25382. /**
  25383. * Returns the effective mesh of the submesh
  25384. * @returns the effective mesh (could be different from parent mesh)
  25385. */
  25386. getEffectiveMesh(): AbstractMesh;
  25387. /**
  25388. * Returns the submesh material
  25389. * @returns null or the current material
  25390. */
  25391. getMaterial(): Nullable<Material>;
  25392. /**
  25393. * Sets a new updated BoundingInfo object to the submesh
  25394. * @param data defines an optional position array to use to determine the bounding info
  25395. * @returns the SubMesh
  25396. */
  25397. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25398. /** @hidden */
  25399. _checkCollision(collider: Collider): boolean;
  25400. /**
  25401. * Updates the submesh BoundingInfo
  25402. * @param world defines the world matrix to use to update the bounding info
  25403. * @returns the submesh
  25404. */
  25405. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25406. /**
  25407. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25408. * @param frustumPlanes defines the frustum planes
  25409. * @returns true if the submesh is intersecting with the frustum
  25410. */
  25411. isInFrustum(frustumPlanes: Plane[]): boolean;
  25412. /**
  25413. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25414. * @param frustumPlanes defines the frustum planes
  25415. * @returns true if the submesh is inside the frustum
  25416. */
  25417. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25418. /**
  25419. * Renders the submesh
  25420. * @param enableAlphaMode defines if alpha needs to be used
  25421. * @returns the submesh
  25422. */
  25423. render(enableAlphaMode: boolean): SubMesh;
  25424. /**
  25425. * @hidden
  25426. */
  25427. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25428. /**
  25429. * Checks if the submesh intersects with a ray
  25430. * @param ray defines the ray to test
  25431. * @returns true is the passed ray intersects the submesh bounding box
  25432. */
  25433. canIntersects(ray: Ray): boolean;
  25434. /**
  25435. * Intersects current submesh with a ray
  25436. * @param ray defines the ray to test
  25437. * @param positions defines mesh's positions array
  25438. * @param indices defines mesh's indices array
  25439. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25440. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25441. * @returns intersection info or null if no intersection
  25442. */
  25443. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25444. /** @hidden */
  25445. private _intersectLines;
  25446. /** @hidden */
  25447. private _intersectUnIndexedLines;
  25448. /** @hidden */
  25449. private _intersectTriangles;
  25450. /** @hidden */
  25451. private _intersectUnIndexedTriangles;
  25452. /** @hidden */
  25453. _rebuild(): void;
  25454. /**
  25455. * Creates a new submesh from the passed mesh
  25456. * @param newMesh defines the new hosting mesh
  25457. * @param newRenderingMesh defines an optional rendering mesh
  25458. * @returns the new submesh
  25459. */
  25460. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25461. /**
  25462. * Release associated resources
  25463. */
  25464. dispose(): void;
  25465. /**
  25466. * Gets the class name
  25467. * @returns the string "SubMesh".
  25468. */
  25469. getClassName(): string;
  25470. /**
  25471. * Creates a new submesh from indices data
  25472. * @param materialIndex the index of the main mesh material
  25473. * @param startIndex the index where to start the copy in the mesh indices array
  25474. * @param indexCount the number of indices to copy then from the startIndex
  25475. * @param mesh the main mesh to create the submesh from
  25476. * @param renderingMesh the optional rendering mesh
  25477. * @returns a new submesh
  25478. */
  25479. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25480. }
  25481. }
  25482. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25483. /**
  25484. * Class used to represent data loading progression
  25485. */
  25486. export class SceneLoaderFlags {
  25487. private static _ForceFullSceneLoadingForIncremental;
  25488. private static _ShowLoadingScreen;
  25489. private static _CleanBoneMatrixWeights;
  25490. private static _loggingLevel;
  25491. /**
  25492. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25493. */
  25494. static get ForceFullSceneLoadingForIncremental(): boolean;
  25495. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25496. /**
  25497. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25498. */
  25499. static get ShowLoadingScreen(): boolean;
  25500. static set ShowLoadingScreen(value: boolean);
  25501. /**
  25502. * Defines the current logging level (while loading the scene)
  25503. * @ignorenaming
  25504. */
  25505. static get loggingLevel(): number;
  25506. static set loggingLevel(value: number);
  25507. /**
  25508. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25509. */
  25510. static get CleanBoneMatrixWeights(): boolean;
  25511. static set CleanBoneMatrixWeights(value: boolean);
  25512. }
  25513. }
  25514. declare module "babylonjs/Meshes/geometry" {
  25515. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25516. import { Scene } from "babylonjs/scene";
  25517. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25518. import { Engine } from "babylonjs/Engines/engine";
  25519. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25520. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25521. import { Effect } from "babylonjs/Materials/effect";
  25522. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25523. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25524. import { Mesh } from "babylonjs/Meshes/mesh";
  25525. /**
  25526. * Class used to store geometry data (vertex buffers + index buffer)
  25527. */
  25528. export class Geometry implements IGetSetVerticesData {
  25529. /**
  25530. * Gets or sets the ID of the geometry
  25531. */
  25532. id: string;
  25533. /**
  25534. * Gets or sets the unique ID of the geometry
  25535. */
  25536. uniqueId: number;
  25537. /**
  25538. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25539. */
  25540. delayLoadState: number;
  25541. /**
  25542. * Gets the file containing the data to load when running in delay load state
  25543. */
  25544. delayLoadingFile: Nullable<string>;
  25545. /**
  25546. * Callback called when the geometry is updated
  25547. */
  25548. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25549. private _scene;
  25550. private _engine;
  25551. private _meshes;
  25552. private _totalVertices;
  25553. /** @hidden */
  25554. _indices: IndicesArray;
  25555. /** @hidden */
  25556. _vertexBuffers: {
  25557. [key: string]: VertexBuffer;
  25558. };
  25559. private _isDisposed;
  25560. private _extend;
  25561. private _boundingBias;
  25562. /** @hidden */
  25563. _delayInfo: Array<string>;
  25564. private _indexBuffer;
  25565. private _indexBufferIsUpdatable;
  25566. /** @hidden */
  25567. _boundingInfo: Nullable<BoundingInfo>;
  25568. /** @hidden */
  25569. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25570. /** @hidden */
  25571. _softwareSkinningFrameId: number;
  25572. private _vertexArrayObjects;
  25573. private _updatable;
  25574. /** @hidden */
  25575. _positions: Nullable<Vector3[]>;
  25576. /**
  25577. * 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
  25578. */
  25579. get boundingBias(): Vector2;
  25580. /**
  25581. * 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
  25582. */
  25583. set boundingBias(value: Vector2);
  25584. /**
  25585. * Static function used to attach a new empty geometry to a mesh
  25586. * @param mesh defines the mesh to attach the geometry to
  25587. * @returns the new Geometry
  25588. */
  25589. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25590. /** Get the list of meshes using this geometry */
  25591. get meshes(): Mesh[];
  25592. /**
  25593. * Creates a new geometry
  25594. * @param id defines the unique ID
  25595. * @param scene defines the hosting scene
  25596. * @param vertexData defines the VertexData used to get geometry data
  25597. * @param updatable defines if geometry must be updatable (false by default)
  25598. * @param mesh defines the mesh that will be associated with the geometry
  25599. */
  25600. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25601. /**
  25602. * Gets the current extend of the geometry
  25603. */
  25604. get extend(): {
  25605. minimum: Vector3;
  25606. maximum: Vector3;
  25607. };
  25608. /**
  25609. * Gets the hosting scene
  25610. * @returns the hosting Scene
  25611. */
  25612. getScene(): Scene;
  25613. /**
  25614. * Gets the hosting engine
  25615. * @returns the hosting Engine
  25616. */
  25617. getEngine(): Engine;
  25618. /**
  25619. * Defines if the geometry is ready to use
  25620. * @returns true if the geometry is ready to be used
  25621. */
  25622. isReady(): boolean;
  25623. /**
  25624. * Gets a value indicating that the geometry should not be serialized
  25625. */
  25626. get doNotSerialize(): boolean;
  25627. /** @hidden */
  25628. _rebuild(): void;
  25629. /**
  25630. * Affects all geometry data in one call
  25631. * @param vertexData defines the geometry data
  25632. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25633. */
  25634. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25635. /**
  25636. * Set specific vertex data
  25637. * @param kind defines the data kind (Position, normal, etc...)
  25638. * @param data defines the vertex data to use
  25639. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25640. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25641. */
  25642. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25643. /**
  25644. * Removes a specific vertex data
  25645. * @param kind defines the data kind (Position, normal, etc...)
  25646. */
  25647. removeVerticesData(kind: string): void;
  25648. /**
  25649. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25650. * @param buffer defines the vertex buffer to use
  25651. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25652. */
  25653. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25654. /**
  25655. * Update a specific vertex buffer
  25656. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25657. * It will do nothing if the buffer is not updatable
  25658. * @param kind defines the data kind (Position, normal, etc...)
  25659. * @param data defines the data to use
  25660. * @param offset defines the offset in the target buffer where to store the data
  25661. * @param useBytes set to true if the offset is in bytes
  25662. */
  25663. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25664. /**
  25665. * Update a specific vertex buffer
  25666. * This function will create a new buffer if the current one is not updatable
  25667. * @param kind defines the data kind (Position, normal, etc...)
  25668. * @param data defines the data to use
  25669. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25670. */
  25671. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25672. private _updateBoundingInfo;
  25673. /** @hidden */
  25674. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25675. /**
  25676. * Gets total number of vertices
  25677. * @returns the total number of vertices
  25678. */
  25679. getTotalVertices(): number;
  25680. /**
  25681. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25682. * @param kind defines the data kind (Position, normal, etc...)
  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 a float array containing vertex data
  25686. */
  25687. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25688. /**
  25689. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25690. * @param kind defines the data kind (Position, normal, etc...)
  25691. * @returns true if the vertex buffer with the specified kind is updatable
  25692. */
  25693. isVertexBufferUpdatable(kind: string): boolean;
  25694. /**
  25695. * Gets a specific vertex buffer
  25696. * @param kind defines the data kind (Position, normal, etc...)
  25697. * @returns a VertexBuffer
  25698. */
  25699. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25700. /**
  25701. * Returns all vertex buffers
  25702. * @return an object holding all vertex buffers indexed by kind
  25703. */
  25704. getVertexBuffers(): Nullable<{
  25705. [key: string]: VertexBuffer;
  25706. }>;
  25707. /**
  25708. * Gets a boolean indicating if specific vertex buffer is present
  25709. * @param kind defines the data kind (Position, normal, etc...)
  25710. * @returns true if data is present
  25711. */
  25712. isVerticesDataPresent(kind: string): boolean;
  25713. /**
  25714. * Gets a list of all attached data kinds (Position, normal, etc...)
  25715. * @returns a list of string containing all kinds
  25716. */
  25717. getVerticesDataKinds(): string[];
  25718. /**
  25719. * Update index buffer
  25720. * @param indices defines the indices to store in the index buffer
  25721. * @param offset defines the offset in the target buffer where to store the data
  25722. * @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)
  25723. */
  25724. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25725. /**
  25726. * Creates a new index buffer
  25727. * @param indices defines the indices to store in the index buffer
  25728. * @param totalVertices defines the total number of vertices (could be null)
  25729. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25730. */
  25731. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25732. /**
  25733. * Return the total number of indices
  25734. * @returns the total number of indices
  25735. */
  25736. getTotalIndices(): number;
  25737. /**
  25738. * Gets the index buffer array
  25739. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25740. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25741. * @returns the index buffer array
  25742. */
  25743. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25744. /**
  25745. * Gets the index buffer
  25746. * @return the index buffer
  25747. */
  25748. getIndexBuffer(): Nullable<DataBuffer>;
  25749. /** @hidden */
  25750. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25751. /**
  25752. * Release the associated resources for a specific mesh
  25753. * @param mesh defines the source mesh
  25754. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25755. */
  25756. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25757. /**
  25758. * Apply current geometry to a given mesh
  25759. * @param mesh defines the mesh to apply geometry to
  25760. */
  25761. applyToMesh(mesh: Mesh): void;
  25762. private _updateExtend;
  25763. private _applyToMesh;
  25764. private notifyUpdate;
  25765. /**
  25766. * Load the geometry if it was flagged as delay loaded
  25767. * @param scene defines the hosting scene
  25768. * @param onLoaded defines a callback called when the geometry is loaded
  25769. */
  25770. load(scene: Scene, onLoaded?: () => void): void;
  25771. private _queueLoad;
  25772. /**
  25773. * Invert the geometry to move from a right handed system to a left handed one.
  25774. */
  25775. toLeftHanded(): void;
  25776. /** @hidden */
  25777. _resetPointsArrayCache(): void;
  25778. /** @hidden */
  25779. _generatePointsArray(): boolean;
  25780. /**
  25781. * Gets a value indicating if the geometry is disposed
  25782. * @returns true if the geometry was disposed
  25783. */
  25784. isDisposed(): boolean;
  25785. private _disposeVertexArrayObjects;
  25786. /**
  25787. * Free all associated resources
  25788. */
  25789. dispose(): void;
  25790. /**
  25791. * Clone the current geometry into a new geometry
  25792. * @param id defines the unique ID of the new geometry
  25793. * @returns a new geometry object
  25794. */
  25795. copy(id: string): Geometry;
  25796. /**
  25797. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25798. * @return a JSON representation of the current geometry data (without the vertices data)
  25799. */
  25800. serialize(): any;
  25801. private toNumberArray;
  25802. /**
  25803. * Serialize all vertices data into a JSON oject
  25804. * @returns a JSON representation of the current geometry data
  25805. */
  25806. serializeVerticeData(): any;
  25807. /**
  25808. * Extracts a clone of a mesh geometry
  25809. * @param mesh defines the source mesh
  25810. * @param id defines the unique ID of the new geometry object
  25811. * @returns the new geometry object
  25812. */
  25813. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25814. /**
  25815. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25816. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25817. * Be aware Math.random() could cause collisions, but:
  25818. * "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"
  25819. * @returns a string containing a new GUID
  25820. */
  25821. static RandomId(): string;
  25822. /** @hidden */
  25823. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25824. private static _CleanMatricesWeights;
  25825. /**
  25826. * Create a new geometry from persisted data (Using .babylon file format)
  25827. * @param parsedVertexData defines the persisted data
  25828. * @param scene defines the hosting scene
  25829. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25830. * @returns the new geometry object
  25831. */
  25832. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25833. }
  25834. }
  25835. declare module "babylonjs/Meshes/mesh.vertexData" {
  25836. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25837. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25838. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25839. import { Geometry } from "babylonjs/Meshes/geometry";
  25840. import { Mesh } from "babylonjs/Meshes/mesh";
  25841. /**
  25842. * Define an interface for all classes that will get and set the data on vertices
  25843. */
  25844. export interface IGetSetVerticesData {
  25845. /**
  25846. * Gets a boolean indicating if specific vertex data is present
  25847. * @param kind defines the vertex data kind to use
  25848. * @returns true is data kind is present
  25849. */
  25850. isVerticesDataPresent(kind: string): boolean;
  25851. /**
  25852. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25853. * @param kind defines the data kind (Position, normal, etc...)
  25854. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25855. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25856. * @returns a float array containing vertex data
  25857. */
  25858. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25859. /**
  25860. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25861. * @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.
  25862. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25863. * @returns the indices array or an empty array if the mesh has no geometry
  25864. */
  25865. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25866. /**
  25867. * Set specific vertex data
  25868. * @param kind defines the data kind (Position, normal, etc...)
  25869. * @param data defines the vertex data to use
  25870. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25871. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25872. */
  25873. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25874. /**
  25875. * Update a specific associated vertex buffer
  25876. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25877. * - VertexBuffer.PositionKind
  25878. * - VertexBuffer.UVKind
  25879. * - VertexBuffer.UV2Kind
  25880. * - VertexBuffer.UV3Kind
  25881. * - VertexBuffer.UV4Kind
  25882. * - VertexBuffer.UV5Kind
  25883. * - VertexBuffer.UV6Kind
  25884. * - VertexBuffer.ColorKind
  25885. * - VertexBuffer.MatricesIndicesKind
  25886. * - VertexBuffer.MatricesIndicesExtraKind
  25887. * - VertexBuffer.MatricesWeightsKind
  25888. * - VertexBuffer.MatricesWeightsExtraKind
  25889. * @param data defines the data source
  25890. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25891. * @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)
  25892. */
  25893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25894. /**
  25895. * Creates a new index buffer
  25896. * @param indices defines the indices to store in the index buffer
  25897. * @param totalVertices defines the total number of vertices (could be null)
  25898. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25899. */
  25900. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25901. }
  25902. /**
  25903. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25904. */
  25905. export class VertexData {
  25906. /**
  25907. * Mesh side orientation : usually the external or front surface
  25908. */
  25909. static readonly FRONTSIDE: number;
  25910. /**
  25911. * Mesh side orientation : usually the internal or back surface
  25912. */
  25913. static readonly BACKSIDE: number;
  25914. /**
  25915. * Mesh side orientation : both internal and external or front and back surfaces
  25916. */
  25917. static readonly DOUBLESIDE: number;
  25918. /**
  25919. * Mesh side orientation : by default, `FRONTSIDE`
  25920. */
  25921. static readonly DEFAULTSIDE: number;
  25922. /**
  25923. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25924. */
  25925. positions: Nullable<FloatArray>;
  25926. /**
  25927. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25928. */
  25929. normals: Nullable<FloatArray>;
  25930. /**
  25931. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25932. */
  25933. tangents: Nullable<FloatArray>;
  25934. /**
  25935. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25936. */
  25937. uvs: Nullable<FloatArray>;
  25938. /**
  25939. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25940. */
  25941. uvs2: Nullable<FloatArray>;
  25942. /**
  25943. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25944. */
  25945. uvs3: Nullable<FloatArray>;
  25946. /**
  25947. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25948. */
  25949. uvs4: Nullable<FloatArray>;
  25950. /**
  25951. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25952. */
  25953. uvs5: Nullable<FloatArray>;
  25954. /**
  25955. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25956. */
  25957. uvs6: Nullable<FloatArray>;
  25958. /**
  25959. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25960. */
  25961. colors: Nullable<FloatArray>;
  25962. /**
  25963. * 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).
  25964. */
  25965. matricesIndices: Nullable<FloatArray>;
  25966. /**
  25967. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25968. */
  25969. matricesWeights: Nullable<FloatArray>;
  25970. /**
  25971. * An array extending the number of possible indices
  25972. */
  25973. matricesIndicesExtra: Nullable<FloatArray>;
  25974. /**
  25975. * An array extending the number of possible weights when the number of indices is extended
  25976. */
  25977. matricesWeightsExtra: Nullable<FloatArray>;
  25978. /**
  25979. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25980. */
  25981. indices: Nullable<IndicesArray>;
  25982. /**
  25983. * Uses the passed data array to set the set the values for the specified kind of data
  25984. * @param data a linear array of floating numbers
  25985. * @param kind the type of data that is being set, eg positions, colors etc
  25986. */
  25987. set(data: FloatArray, kind: string): void;
  25988. /**
  25989. * Associates the vertexData to the passed Mesh.
  25990. * Sets it as updatable or not (default `false`)
  25991. * @param mesh the mesh the vertexData is applied to
  25992. * @param updatable when used and having the value true allows new data to update the vertexData
  25993. * @returns the VertexData
  25994. */
  25995. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25996. /**
  25997. * Associates the vertexData to the passed Geometry.
  25998. * Sets it as updatable or not (default `false`)
  25999. * @param geometry the geometry the vertexData is applied to
  26000. * @param updatable when used and having the value true allows new data to update the vertexData
  26001. * @returns VertexData
  26002. */
  26003. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26004. /**
  26005. * Updates the associated mesh
  26006. * @param mesh the mesh to be updated
  26007. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26008. * @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
  26009. * @returns VertexData
  26010. */
  26011. updateMesh(mesh: Mesh): VertexData;
  26012. /**
  26013. * Updates the associated geometry
  26014. * @param geometry the geometry to be updated
  26015. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26016. * @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
  26017. * @returns VertexData.
  26018. */
  26019. updateGeometry(geometry: Geometry): VertexData;
  26020. private _applyTo;
  26021. private _update;
  26022. /**
  26023. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26024. * @param matrix the transforming matrix
  26025. * @returns the VertexData
  26026. */
  26027. transform(matrix: Matrix): VertexData;
  26028. /**
  26029. * Merges the passed VertexData into the current one
  26030. * @param other the VertexData to be merged into the current one
  26031. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26032. * @returns the modified VertexData
  26033. */
  26034. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26035. private _mergeElement;
  26036. private _validate;
  26037. /**
  26038. * Serializes the VertexData
  26039. * @returns a serialized object
  26040. */
  26041. serialize(): any;
  26042. /**
  26043. * Extracts the vertexData from a mesh
  26044. * @param mesh the mesh from which to extract the VertexData
  26045. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26046. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26047. * @returns the object VertexData associated to the passed mesh
  26048. */
  26049. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26050. /**
  26051. * Extracts the vertexData from the geometry
  26052. * @param geometry the geometry from which to extract the VertexData
  26053. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26054. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26055. * @returns the object VertexData associated to the passed mesh
  26056. */
  26057. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26058. private static _ExtractFrom;
  26059. /**
  26060. * Creates the VertexData for a Ribbon
  26061. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26062. * * pathArray array of paths, each of which an array of successive Vector3
  26063. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26064. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26065. * * 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
  26066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26067. * * 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)
  26068. * * 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)
  26069. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26070. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26071. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26072. * @returns the VertexData of the ribbon
  26073. */
  26074. static CreateRibbon(options: {
  26075. pathArray: Vector3[][];
  26076. closeArray?: boolean;
  26077. closePath?: boolean;
  26078. offset?: number;
  26079. sideOrientation?: number;
  26080. frontUVs?: Vector4;
  26081. backUVs?: Vector4;
  26082. invertUV?: boolean;
  26083. uvs?: Vector2[];
  26084. colors?: Color4[];
  26085. }): VertexData;
  26086. /**
  26087. * Creates the VertexData for a box
  26088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26089. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26090. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26091. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26092. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26093. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26094. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26096. * * 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)
  26097. * * 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)
  26098. * @returns the VertexData of the box
  26099. */
  26100. static CreateBox(options: {
  26101. size?: number;
  26102. width?: number;
  26103. height?: number;
  26104. depth?: number;
  26105. faceUV?: Vector4[];
  26106. faceColors?: Color4[];
  26107. sideOrientation?: number;
  26108. frontUVs?: Vector4;
  26109. backUVs?: Vector4;
  26110. }): VertexData;
  26111. /**
  26112. * Creates the VertexData for a tiled box
  26113. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26114. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26115. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26116. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26118. * @returns the VertexData of the box
  26119. */
  26120. static CreateTiledBox(options: {
  26121. pattern?: number;
  26122. width?: number;
  26123. height?: number;
  26124. depth?: number;
  26125. tileSize?: number;
  26126. tileWidth?: number;
  26127. tileHeight?: number;
  26128. alignHorizontal?: number;
  26129. alignVertical?: number;
  26130. faceUV?: Vector4[];
  26131. faceColors?: Color4[];
  26132. sideOrientation?: number;
  26133. }): VertexData;
  26134. /**
  26135. * Creates the VertexData for a tiled plane
  26136. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26137. * * pattern a limited pattern arrangement depending on the number
  26138. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26139. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26140. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26142. * * 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)
  26143. * * 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)
  26144. * @returns the VertexData of the tiled plane
  26145. */
  26146. static CreateTiledPlane(options: {
  26147. pattern?: number;
  26148. tileSize?: number;
  26149. tileWidth?: number;
  26150. tileHeight?: number;
  26151. size?: number;
  26152. width?: number;
  26153. height?: number;
  26154. alignHorizontal?: number;
  26155. alignVertical?: number;
  26156. sideOrientation?: number;
  26157. frontUVs?: Vector4;
  26158. backUVs?: Vector4;
  26159. }): VertexData;
  26160. /**
  26161. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26162. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26163. * * segments sets the number of horizontal strips optional, default 32
  26164. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26165. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26166. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26167. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26168. * * 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
  26169. * * 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
  26170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26171. * * 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)
  26172. * * 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)
  26173. * @returns the VertexData of the ellipsoid
  26174. */
  26175. static CreateSphere(options: {
  26176. segments?: number;
  26177. diameter?: number;
  26178. diameterX?: number;
  26179. diameterY?: number;
  26180. diameterZ?: number;
  26181. arc?: number;
  26182. slice?: number;
  26183. sideOrientation?: number;
  26184. frontUVs?: Vector4;
  26185. backUVs?: Vector4;
  26186. }): VertexData;
  26187. /**
  26188. * Creates the VertexData for a cylinder, cone or prism
  26189. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26190. * * height sets the height (y direction) of the cylinder, optional, default 2
  26191. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26192. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26193. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26194. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26195. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26196. * * 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
  26197. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26198. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26199. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26200. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26202. * * 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)
  26203. * * 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)
  26204. * @returns the VertexData of the cylinder, cone or prism
  26205. */
  26206. static CreateCylinder(options: {
  26207. height?: number;
  26208. diameterTop?: number;
  26209. diameterBottom?: number;
  26210. diameter?: number;
  26211. tessellation?: number;
  26212. subdivisions?: number;
  26213. arc?: number;
  26214. faceColors?: Color4[];
  26215. faceUV?: Vector4[];
  26216. hasRings?: boolean;
  26217. enclose?: boolean;
  26218. sideOrientation?: number;
  26219. frontUVs?: Vector4;
  26220. backUVs?: Vector4;
  26221. }): VertexData;
  26222. /**
  26223. * Creates the VertexData for a torus
  26224. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26225. * * diameter the diameter of the torus, optional default 1
  26226. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26227. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26229. * * 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)
  26230. * * 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)
  26231. * @returns the VertexData of the torus
  26232. */
  26233. static CreateTorus(options: {
  26234. diameter?: number;
  26235. thickness?: number;
  26236. tessellation?: number;
  26237. sideOrientation?: number;
  26238. frontUVs?: Vector4;
  26239. backUVs?: Vector4;
  26240. }): VertexData;
  26241. /**
  26242. * Creates the VertexData of the LineSystem
  26243. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26244. * - lines an array of lines, each line being an array of successive Vector3
  26245. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26246. * @returns the VertexData of the LineSystem
  26247. */
  26248. static CreateLineSystem(options: {
  26249. lines: Vector3[][];
  26250. colors?: Nullable<Color4[][]>;
  26251. }): VertexData;
  26252. /**
  26253. * Create the VertexData for a DashedLines
  26254. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26255. * - points an array successive Vector3
  26256. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26257. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26258. * - dashNb the intended total number of dashes, optional, default 200
  26259. * @returns the VertexData for the DashedLines
  26260. */
  26261. static CreateDashedLines(options: {
  26262. points: Vector3[];
  26263. dashSize?: number;
  26264. gapSize?: number;
  26265. dashNb?: number;
  26266. }): VertexData;
  26267. /**
  26268. * Creates the VertexData for a Ground
  26269. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26270. * - width the width (x direction) of the ground, optional, default 1
  26271. * - height the height (z direction) of the ground, optional, default 1
  26272. * - subdivisions the number of subdivisions per side, optional, default 1
  26273. * @returns the VertexData of the Ground
  26274. */
  26275. static CreateGround(options: {
  26276. width?: number;
  26277. height?: number;
  26278. subdivisions?: number;
  26279. subdivisionsX?: number;
  26280. subdivisionsY?: number;
  26281. }): VertexData;
  26282. /**
  26283. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26284. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26285. * * xmin the ground minimum X coordinate, optional, default -1
  26286. * * zmin the ground minimum Z coordinate, optional, default -1
  26287. * * xmax the ground maximum X coordinate, optional, default 1
  26288. * * zmax the ground maximum Z coordinate, optional, default 1
  26289. * * 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}
  26290. * * 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}
  26291. * @returns the VertexData of the TiledGround
  26292. */
  26293. static CreateTiledGround(options: {
  26294. xmin: number;
  26295. zmin: number;
  26296. xmax: number;
  26297. zmax: number;
  26298. subdivisions?: {
  26299. w: number;
  26300. h: number;
  26301. };
  26302. precision?: {
  26303. w: number;
  26304. h: number;
  26305. };
  26306. }): VertexData;
  26307. /**
  26308. * Creates the VertexData of the Ground designed from a heightmap
  26309. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26310. * * width the width (x direction) of the ground
  26311. * * height the height (z direction) of the ground
  26312. * * subdivisions the number of subdivisions per side
  26313. * * minHeight the minimum altitude on the ground, optional, default 0
  26314. * * maxHeight the maximum altitude on the ground, optional default 1
  26315. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26316. * * buffer the array holding the image color data
  26317. * * bufferWidth the width of image
  26318. * * bufferHeight the height of image
  26319. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26320. * @returns the VertexData of the Ground designed from a heightmap
  26321. */
  26322. static CreateGroundFromHeightMap(options: {
  26323. width: number;
  26324. height: number;
  26325. subdivisions: number;
  26326. minHeight: number;
  26327. maxHeight: number;
  26328. colorFilter: Color3;
  26329. buffer: Uint8Array;
  26330. bufferWidth: number;
  26331. bufferHeight: number;
  26332. alphaFilter: number;
  26333. }): VertexData;
  26334. /**
  26335. * Creates the VertexData for a Plane
  26336. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26337. * * size sets the width and height of the plane to the value of size, optional default 1
  26338. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26339. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26341. * * 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)
  26342. * * 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)
  26343. * @returns the VertexData of the box
  26344. */
  26345. static CreatePlane(options: {
  26346. size?: number;
  26347. width?: number;
  26348. height?: number;
  26349. sideOrientation?: number;
  26350. frontUVs?: Vector4;
  26351. backUVs?: Vector4;
  26352. }): VertexData;
  26353. /**
  26354. * Creates the VertexData of the Disc or regular Polygon
  26355. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26356. * * radius the radius of the disc, optional default 0.5
  26357. * * tessellation the number of polygon sides, optional, default 64
  26358. * * 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
  26359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26360. * * 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)
  26361. * * 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)
  26362. * @returns the VertexData of the box
  26363. */
  26364. static CreateDisc(options: {
  26365. radius?: number;
  26366. tessellation?: number;
  26367. arc?: number;
  26368. sideOrientation?: number;
  26369. frontUVs?: Vector4;
  26370. backUVs?: Vector4;
  26371. }): VertexData;
  26372. /**
  26373. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26374. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26375. * @param polygon a mesh built from polygonTriangulation.build()
  26376. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26377. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26378. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26379. * @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)
  26380. * @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)
  26381. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26382. * @returns the VertexData of the Polygon
  26383. */
  26384. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26385. /**
  26386. * Creates the VertexData of the IcoSphere
  26387. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26388. * * radius the radius of the IcoSphere, optional default 1
  26389. * * radiusX allows stretching in the x direction, optional, default radius
  26390. * * radiusY allows stretching in the y direction, optional, default radius
  26391. * * radiusZ allows stretching in the z direction, optional, default radius
  26392. * * flat when true creates a flat shaded mesh, optional, default true
  26393. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26395. * * 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)
  26396. * * 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)
  26397. * @returns the VertexData of the IcoSphere
  26398. */
  26399. static CreateIcoSphere(options: {
  26400. radius?: number;
  26401. radiusX?: number;
  26402. radiusY?: number;
  26403. radiusZ?: number;
  26404. flat?: boolean;
  26405. subdivisions?: number;
  26406. sideOrientation?: number;
  26407. frontUVs?: Vector4;
  26408. backUVs?: Vector4;
  26409. }): VertexData;
  26410. /**
  26411. * Creates the VertexData for a Polyhedron
  26412. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26413. * * type provided types are:
  26414. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26415. * * 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)
  26416. * * size the size of the IcoSphere, optional default 1
  26417. * * sizeX allows stretching in the x direction, optional, default size
  26418. * * sizeY allows stretching in the y direction, optional, default size
  26419. * * sizeZ allows stretching in the z direction, optional, default size
  26420. * * 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
  26421. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26422. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26423. * * flat when true creates a flat shaded mesh, optional, default true
  26424. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26426. * * 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)
  26427. * * 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)
  26428. * @returns the VertexData of the Polyhedron
  26429. */
  26430. static CreatePolyhedron(options: {
  26431. type?: number;
  26432. size?: number;
  26433. sizeX?: number;
  26434. sizeY?: number;
  26435. sizeZ?: number;
  26436. custom?: any;
  26437. faceUV?: Vector4[];
  26438. faceColors?: Color4[];
  26439. flat?: boolean;
  26440. sideOrientation?: number;
  26441. frontUVs?: Vector4;
  26442. backUVs?: Vector4;
  26443. }): VertexData;
  26444. /**
  26445. * Creates the VertexData for a TorusKnot
  26446. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26447. * * radius the radius of the torus knot, optional, default 2
  26448. * * tube the thickness of the tube, optional, default 0.5
  26449. * * radialSegments the number of sides on each tube segments, optional, default 32
  26450. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26451. * * p the number of windings around the z axis, optional, default 2
  26452. * * q the number of windings around the x axis, optional, default 3
  26453. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26454. * * 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)
  26455. * * 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)
  26456. * @returns the VertexData of the Torus Knot
  26457. */
  26458. static CreateTorusKnot(options: {
  26459. radius?: number;
  26460. tube?: number;
  26461. radialSegments?: number;
  26462. tubularSegments?: number;
  26463. p?: number;
  26464. q?: number;
  26465. sideOrientation?: number;
  26466. frontUVs?: Vector4;
  26467. backUVs?: Vector4;
  26468. }): VertexData;
  26469. /**
  26470. * Compute normals for given positions and indices
  26471. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26472. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26473. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26474. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26475. * * facetNormals : optional array of facet normals (vector3)
  26476. * * facetPositions : optional array of facet positions (vector3)
  26477. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26478. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26479. * * bInfo : optional bounding info, required for facetPartitioning computation
  26480. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26481. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26482. * * useRightHandedSystem: optional boolean to for right handed system computation
  26483. * * depthSort : optional boolean to enable the facet depth sort computation
  26484. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26485. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26486. */
  26487. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26488. facetNormals?: any;
  26489. facetPositions?: any;
  26490. facetPartitioning?: any;
  26491. ratio?: number;
  26492. bInfo?: any;
  26493. bbSize?: Vector3;
  26494. subDiv?: any;
  26495. useRightHandedSystem?: boolean;
  26496. depthSort?: boolean;
  26497. distanceTo?: Vector3;
  26498. depthSortedFacets?: any;
  26499. }): void;
  26500. /** @hidden */
  26501. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26502. /**
  26503. * Applies VertexData created from the imported parameters to the geometry
  26504. * @param parsedVertexData the parsed data from an imported file
  26505. * @param geometry the geometry to apply the VertexData to
  26506. */
  26507. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26508. }
  26509. }
  26510. declare module "babylonjs/Morph/morphTarget" {
  26511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26512. import { Observable } from "babylonjs/Misc/observable";
  26513. import { Nullable, FloatArray } from "babylonjs/types";
  26514. import { Scene } from "babylonjs/scene";
  26515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26516. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26517. /**
  26518. * Defines a target to use with MorphTargetManager
  26519. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26520. */
  26521. export class MorphTarget implements IAnimatable {
  26522. /** defines the name of the target */
  26523. name: string;
  26524. /**
  26525. * Gets or sets the list of animations
  26526. */
  26527. animations: import("babylonjs/Animations/animation").Animation[];
  26528. private _scene;
  26529. private _positions;
  26530. private _normals;
  26531. private _tangents;
  26532. private _uvs;
  26533. private _influence;
  26534. private _uniqueId;
  26535. /**
  26536. * Observable raised when the influence changes
  26537. */
  26538. onInfluenceChanged: Observable<boolean>;
  26539. /** @hidden */
  26540. _onDataLayoutChanged: Observable<void>;
  26541. /**
  26542. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26543. */
  26544. get influence(): number;
  26545. set influence(influence: number);
  26546. /**
  26547. * Gets or sets the id of the morph Target
  26548. */
  26549. id: string;
  26550. private _animationPropertiesOverride;
  26551. /**
  26552. * Gets or sets the animation properties override
  26553. */
  26554. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26555. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26556. /**
  26557. * Creates a new MorphTarget
  26558. * @param name defines the name of the target
  26559. * @param influence defines the influence to use
  26560. * @param scene defines the scene the morphtarget belongs to
  26561. */
  26562. constructor(
  26563. /** defines the name of the target */
  26564. name: string, influence?: number, scene?: Nullable<Scene>);
  26565. /**
  26566. * Gets the unique ID of this manager
  26567. */
  26568. get uniqueId(): number;
  26569. /**
  26570. * Gets a boolean defining if the target contains position data
  26571. */
  26572. get hasPositions(): boolean;
  26573. /**
  26574. * Gets a boolean defining if the target contains normal data
  26575. */
  26576. get hasNormals(): boolean;
  26577. /**
  26578. * Gets a boolean defining if the target contains tangent data
  26579. */
  26580. get hasTangents(): boolean;
  26581. /**
  26582. * Gets a boolean defining if the target contains texture coordinates data
  26583. */
  26584. get hasUVs(): boolean;
  26585. /**
  26586. * Affects position data to this target
  26587. * @param data defines the position data to use
  26588. */
  26589. setPositions(data: Nullable<FloatArray>): void;
  26590. /**
  26591. * Gets the position data stored in this target
  26592. * @returns a FloatArray containing the position data (or null if not present)
  26593. */
  26594. getPositions(): Nullable<FloatArray>;
  26595. /**
  26596. * Affects normal data to this target
  26597. * @param data defines the normal data to use
  26598. */
  26599. setNormals(data: Nullable<FloatArray>): void;
  26600. /**
  26601. * Gets the normal data stored in this target
  26602. * @returns a FloatArray containing the normal data (or null if not present)
  26603. */
  26604. getNormals(): Nullable<FloatArray>;
  26605. /**
  26606. * Affects tangent data to this target
  26607. * @param data defines the tangent data to use
  26608. */
  26609. setTangents(data: Nullable<FloatArray>): void;
  26610. /**
  26611. * Gets the tangent data stored in this target
  26612. * @returns a FloatArray containing the tangent data (or null if not present)
  26613. */
  26614. getTangents(): Nullable<FloatArray>;
  26615. /**
  26616. * Affects texture coordinates data to this target
  26617. * @param data defines the texture coordinates data to use
  26618. */
  26619. setUVs(data: Nullable<FloatArray>): void;
  26620. /**
  26621. * Gets the texture coordinates data stored in this target
  26622. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26623. */
  26624. getUVs(): Nullable<FloatArray>;
  26625. /**
  26626. * Clone the current target
  26627. * @returns a new MorphTarget
  26628. */
  26629. clone(): MorphTarget;
  26630. /**
  26631. * Serializes the current target into a Serialization object
  26632. * @returns the serialized object
  26633. */
  26634. serialize(): any;
  26635. /**
  26636. * Returns the string "MorphTarget"
  26637. * @returns "MorphTarget"
  26638. */
  26639. getClassName(): string;
  26640. /**
  26641. * Creates a new target from serialized data
  26642. * @param serializationObject defines the serialized data to use
  26643. * @returns a new MorphTarget
  26644. */
  26645. static Parse(serializationObject: any): MorphTarget;
  26646. /**
  26647. * Creates a MorphTarget from mesh data
  26648. * @param mesh defines the source mesh
  26649. * @param name defines the name to use for the new target
  26650. * @param influence defines the influence to attach to the target
  26651. * @returns a new MorphTarget
  26652. */
  26653. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26654. }
  26655. }
  26656. declare module "babylonjs/Morph/morphTargetManager" {
  26657. import { Nullable } from "babylonjs/types";
  26658. import { Scene } from "babylonjs/scene";
  26659. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26660. /**
  26661. * This class is used to deform meshes using morphing between different targets
  26662. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26663. */
  26664. export class MorphTargetManager {
  26665. private _targets;
  26666. private _targetInfluenceChangedObservers;
  26667. private _targetDataLayoutChangedObservers;
  26668. private _activeTargets;
  26669. private _scene;
  26670. private _influences;
  26671. private _supportsNormals;
  26672. private _supportsTangents;
  26673. private _supportsUVs;
  26674. private _vertexCount;
  26675. private _uniqueId;
  26676. private _tempInfluences;
  26677. /**
  26678. * Gets or sets a boolean indicating if normals must be morphed
  26679. */
  26680. enableNormalMorphing: boolean;
  26681. /**
  26682. * Gets or sets a boolean indicating if tangents must be morphed
  26683. */
  26684. enableTangentMorphing: boolean;
  26685. /**
  26686. * Gets or sets a boolean indicating if UV must be morphed
  26687. */
  26688. enableUVMorphing: boolean;
  26689. /**
  26690. * Creates a new MorphTargetManager
  26691. * @param scene defines the current scene
  26692. */
  26693. constructor(scene?: Nullable<Scene>);
  26694. /**
  26695. * Gets the unique ID of this manager
  26696. */
  26697. get uniqueId(): number;
  26698. /**
  26699. * Gets the number of vertices handled by this manager
  26700. */
  26701. get vertexCount(): number;
  26702. /**
  26703. * Gets a boolean indicating if this manager supports morphing of normals
  26704. */
  26705. get supportsNormals(): boolean;
  26706. /**
  26707. * Gets a boolean indicating if this manager supports morphing of tangents
  26708. */
  26709. get supportsTangents(): boolean;
  26710. /**
  26711. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26712. */
  26713. get supportsUVs(): boolean;
  26714. /**
  26715. * Gets the number of targets stored in this manager
  26716. */
  26717. get numTargets(): number;
  26718. /**
  26719. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26720. */
  26721. get numInfluencers(): number;
  26722. /**
  26723. * Gets the list of influences (one per target)
  26724. */
  26725. get influences(): Float32Array;
  26726. /**
  26727. * Gets the active target at specified index. An active target is a target with an influence > 0
  26728. * @param index defines the index to check
  26729. * @returns the requested target
  26730. */
  26731. getActiveTarget(index: number): MorphTarget;
  26732. /**
  26733. * Gets the target at specified index
  26734. * @param index defines the index to check
  26735. * @returns the requested target
  26736. */
  26737. getTarget(index: number): MorphTarget;
  26738. /**
  26739. * Add a new target to this manager
  26740. * @param target defines the target to add
  26741. */
  26742. addTarget(target: MorphTarget): void;
  26743. /**
  26744. * Removes a target from the manager
  26745. * @param target defines the target to remove
  26746. */
  26747. removeTarget(target: MorphTarget): void;
  26748. /**
  26749. * Clone the current manager
  26750. * @returns a new MorphTargetManager
  26751. */
  26752. clone(): MorphTargetManager;
  26753. /**
  26754. * Serializes the current manager into a Serialization object
  26755. * @returns the serialized object
  26756. */
  26757. serialize(): any;
  26758. private _syncActiveTargets;
  26759. /**
  26760. * Syncrhonize the targets with all the meshes using this morph target manager
  26761. */
  26762. synchronize(): void;
  26763. /**
  26764. * Creates a new MorphTargetManager from serialized data
  26765. * @param serializationObject defines the serialized data
  26766. * @param scene defines the hosting scene
  26767. * @returns the new MorphTargetManager
  26768. */
  26769. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26770. }
  26771. }
  26772. declare module "babylonjs/Meshes/meshLODLevel" {
  26773. import { Mesh } from "babylonjs/Meshes/mesh";
  26774. import { Nullable } from "babylonjs/types";
  26775. /**
  26776. * Class used to represent a specific level of detail of a mesh
  26777. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26778. */
  26779. export class MeshLODLevel {
  26780. /** Defines the distance where this level should start being displayed */
  26781. distance: number;
  26782. /** Defines the mesh to use to render this level */
  26783. mesh: Nullable<Mesh>;
  26784. /**
  26785. * Creates a new LOD level
  26786. * @param distance defines the distance where this level should star being displayed
  26787. * @param mesh defines the mesh to use to render this level
  26788. */
  26789. constructor(
  26790. /** Defines the distance where this level should start being displayed */
  26791. distance: number,
  26792. /** Defines the mesh to use to render this level */
  26793. mesh: Nullable<Mesh>);
  26794. }
  26795. }
  26796. declare module "babylonjs/Meshes/groundMesh" {
  26797. import { Scene } from "babylonjs/scene";
  26798. import { Vector3 } from "babylonjs/Maths/math.vector";
  26799. import { Mesh } from "babylonjs/Meshes/mesh";
  26800. /**
  26801. * Mesh representing the gorund
  26802. */
  26803. export class GroundMesh extends Mesh {
  26804. /** If octree should be generated */
  26805. generateOctree: boolean;
  26806. private _heightQuads;
  26807. /** @hidden */
  26808. _subdivisionsX: number;
  26809. /** @hidden */
  26810. _subdivisionsY: number;
  26811. /** @hidden */
  26812. _width: number;
  26813. /** @hidden */
  26814. _height: number;
  26815. /** @hidden */
  26816. _minX: number;
  26817. /** @hidden */
  26818. _maxX: number;
  26819. /** @hidden */
  26820. _minZ: number;
  26821. /** @hidden */
  26822. _maxZ: number;
  26823. constructor(name: string, scene: Scene);
  26824. /**
  26825. * "GroundMesh"
  26826. * @returns "GroundMesh"
  26827. */
  26828. getClassName(): string;
  26829. /**
  26830. * The minimum of x and y subdivisions
  26831. */
  26832. get subdivisions(): number;
  26833. /**
  26834. * X subdivisions
  26835. */
  26836. get subdivisionsX(): number;
  26837. /**
  26838. * Y subdivisions
  26839. */
  26840. get subdivisionsY(): number;
  26841. /**
  26842. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26843. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26844. * @param chunksCount the number of subdivisions for x and y
  26845. * @param octreeBlocksSize (Default: 32)
  26846. */
  26847. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26848. /**
  26849. * Returns a height (y) value in the Worl system :
  26850. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26851. * @param x x coordinate
  26852. * @param z z coordinate
  26853. * @returns the ground y position if (x, z) are outside the ground surface.
  26854. */
  26855. getHeightAtCoordinates(x: number, z: number): number;
  26856. /**
  26857. * Returns a normalized vector (Vector3) orthogonal to the ground
  26858. * at the ground coordinates (x, z) expressed in the World system.
  26859. * @param x x coordinate
  26860. * @param z z coordinate
  26861. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26862. */
  26863. getNormalAtCoordinates(x: number, z: number): Vector3;
  26864. /**
  26865. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26866. * at the ground coordinates (x, z) expressed in the World system.
  26867. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26868. * @param x x coordinate
  26869. * @param z z coordinate
  26870. * @param ref vector to store the result
  26871. * @returns the GroundMesh.
  26872. */
  26873. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26874. /**
  26875. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26876. * if the ground has been updated.
  26877. * This can be used in the render loop.
  26878. * @returns the GroundMesh.
  26879. */
  26880. updateCoordinateHeights(): GroundMesh;
  26881. private _getFacetAt;
  26882. private _initHeightQuads;
  26883. private _computeHeightQuads;
  26884. /**
  26885. * Serializes this ground mesh
  26886. * @param serializationObject object to write serialization to
  26887. */
  26888. serialize(serializationObject: any): void;
  26889. /**
  26890. * Parses a serialized ground mesh
  26891. * @param parsedMesh the serialized mesh
  26892. * @param scene the scene to create the ground mesh in
  26893. * @returns the created ground mesh
  26894. */
  26895. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26896. }
  26897. }
  26898. declare module "babylonjs/Physics/physicsJoint" {
  26899. import { Vector3 } from "babylonjs/Maths/math.vector";
  26900. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26901. /**
  26902. * Interface for Physics-Joint data
  26903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26904. */
  26905. export interface PhysicsJointData {
  26906. /**
  26907. * The main pivot of the joint
  26908. */
  26909. mainPivot?: Vector3;
  26910. /**
  26911. * The connected pivot of the joint
  26912. */
  26913. connectedPivot?: Vector3;
  26914. /**
  26915. * The main axis of the joint
  26916. */
  26917. mainAxis?: Vector3;
  26918. /**
  26919. * The connected axis of the joint
  26920. */
  26921. connectedAxis?: Vector3;
  26922. /**
  26923. * The collision of the joint
  26924. */
  26925. collision?: boolean;
  26926. /**
  26927. * Native Oimo/Cannon/Energy data
  26928. */
  26929. nativeParams?: any;
  26930. }
  26931. /**
  26932. * This is a holder class for the physics joint created by the physics plugin
  26933. * It holds a set of functions to control the underlying joint
  26934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26935. */
  26936. export class PhysicsJoint {
  26937. /**
  26938. * The type of the physics joint
  26939. */
  26940. type: number;
  26941. /**
  26942. * The data for the physics joint
  26943. */
  26944. jointData: PhysicsJointData;
  26945. private _physicsJoint;
  26946. protected _physicsPlugin: IPhysicsEnginePlugin;
  26947. /**
  26948. * Initializes the physics joint
  26949. * @param type The type of the physics joint
  26950. * @param jointData The data for the physics joint
  26951. */
  26952. constructor(
  26953. /**
  26954. * The type of the physics joint
  26955. */
  26956. type: number,
  26957. /**
  26958. * The data for the physics joint
  26959. */
  26960. jointData: PhysicsJointData);
  26961. /**
  26962. * Gets the physics joint
  26963. */
  26964. get physicsJoint(): any;
  26965. /**
  26966. * Sets the physics joint
  26967. */
  26968. set physicsJoint(newJoint: any);
  26969. /**
  26970. * Sets the physics plugin
  26971. */
  26972. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26973. /**
  26974. * Execute a function that is physics-plugin specific.
  26975. * @param {Function} func the function that will be executed.
  26976. * It accepts two parameters: the physics world and the physics joint
  26977. */
  26978. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26979. /**
  26980. * Distance-Joint type
  26981. */
  26982. static DistanceJoint: number;
  26983. /**
  26984. * Hinge-Joint type
  26985. */
  26986. static HingeJoint: number;
  26987. /**
  26988. * Ball-and-Socket joint type
  26989. */
  26990. static BallAndSocketJoint: number;
  26991. /**
  26992. * Wheel-Joint type
  26993. */
  26994. static WheelJoint: number;
  26995. /**
  26996. * Slider-Joint type
  26997. */
  26998. static SliderJoint: number;
  26999. /**
  27000. * Prismatic-Joint type
  27001. */
  27002. static PrismaticJoint: number;
  27003. /**
  27004. * Universal-Joint type
  27005. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27006. */
  27007. static UniversalJoint: number;
  27008. /**
  27009. * Hinge-Joint 2 type
  27010. */
  27011. static Hinge2Joint: number;
  27012. /**
  27013. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27014. */
  27015. static PointToPointJoint: number;
  27016. /**
  27017. * Spring-Joint type
  27018. */
  27019. static SpringJoint: number;
  27020. /**
  27021. * Lock-Joint type
  27022. */
  27023. static LockJoint: number;
  27024. }
  27025. /**
  27026. * A class representing a physics distance joint
  27027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27028. */
  27029. export class DistanceJoint extends PhysicsJoint {
  27030. /**
  27031. *
  27032. * @param jointData The data for the Distance-Joint
  27033. */
  27034. constructor(jointData: DistanceJointData);
  27035. /**
  27036. * Update the predefined distance.
  27037. * @param maxDistance The maximum preferred distance
  27038. * @param minDistance The minimum preferred distance
  27039. */
  27040. updateDistance(maxDistance: number, minDistance?: number): void;
  27041. }
  27042. /**
  27043. * Represents a Motor-Enabled Joint
  27044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27045. */
  27046. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27047. /**
  27048. * Initializes the Motor-Enabled Joint
  27049. * @param type The type of the joint
  27050. * @param jointData The physica joint data for the joint
  27051. */
  27052. constructor(type: number, jointData: PhysicsJointData);
  27053. /**
  27054. * Set the motor values.
  27055. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27056. * @param force the force to apply
  27057. * @param maxForce max force for this motor.
  27058. */
  27059. setMotor(force?: number, maxForce?: number): void;
  27060. /**
  27061. * Set the motor's limits.
  27062. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27063. * @param upperLimit The upper limit of the motor
  27064. * @param lowerLimit The lower limit of the motor
  27065. */
  27066. setLimit(upperLimit: number, lowerLimit?: number): void;
  27067. }
  27068. /**
  27069. * This class represents a single physics Hinge-Joint
  27070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27071. */
  27072. export class HingeJoint extends MotorEnabledJoint {
  27073. /**
  27074. * Initializes the Hinge-Joint
  27075. * @param jointData The joint data for the Hinge-Joint
  27076. */
  27077. constructor(jointData: PhysicsJointData);
  27078. /**
  27079. * Set the motor values.
  27080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27081. * @param {number} force the force to apply
  27082. * @param {number} maxForce max force for this motor.
  27083. */
  27084. setMotor(force?: number, maxForce?: number): void;
  27085. /**
  27086. * Set the motor's limits.
  27087. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27088. * @param upperLimit The upper limit of the motor
  27089. * @param lowerLimit The lower limit of the motor
  27090. */
  27091. setLimit(upperLimit: number, lowerLimit?: number): void;
  27092. }
  27093. /**
  27094. * This class represents a dual hinge physics joint (same as wheel joint)
  27095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27096. */
  27097. export class Hinge2Joint extends MotorEnabledJoint {
  27098. /**
  27099. * Initializes the Hinge2-Joint
  27100. * @param jointData The joint data for the Hinge2-Joint
  27101. */
  27102. constructor(jointData: PhysicsJointData);
  27103. /**
  27104. * Set the motor values.
  27105. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27106. * @param {number} targetSpeed the speed the motor is to reach
  27107. * @param {number} maxForce max force for this motor.
  27108. * @param {motorIndex} the motor's index, 0 or 1.
  27109. */
  27110. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27111. /**
  27112. * Set the motor limits.
  27113. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27114. * @param {number} upperLimit the upper limit
  27115. * @param {number} lowerLimit lower limit
  27116. * @param {motorIndex} the motor's index, 0 or 1.
  27117. */
  27118. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27119. }
  27120. /**
  27121. * Interface for a motor enabled joint
  27122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27123. */
  27124. export interface IMotorEnabledJoint {
  27125. /**
  27126. * Physics joint
  27127. */
  27128. physicsJoint: any;
  27129. /**
  27130. * Sets the motor of the motor-enabled joint
  27131. * @param force The force of the motor
  27132. * @param maxForce The maximum force of the motor
  27133. * @param motorIndex The index of the motor
  27134. */
  27135. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27136. /**
  27137. * Sets the limit of the motor
  27138. * @param upperLimit The upper limit of the motor
  27139. * @param lowerLimit The lower limit of the motor
  27140. * @param motorIndex The index of the motor
  27141. */
  27142. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27143. }
  27144. /**
  27145. * Joint data for a Distance-Joint
  27146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27147. */
  27148. export interface DistanceJointData extends PhysicsJointData {
  27149. /**
  27150. * Max distance the 2 joint objects can be apart
  27151. */
  27152. maxDistance: number;
  27153. }
  27154. /**
  27155. * Joint data from a spring joint
  27156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27157. */
  27158. export interface SpringJointData extends PhysicsJointData {
  27159. /**
  27160. * Length of the spring
  27161. */
  27162. length: number;
  27163. /**
  27164. * Stiffness of the spring
  27165. */
  27166. stiffness: number;
  27167. /**
  27168. * Damping of the spring
  27169. */
  27170. damping: number;
  27171. /** this callback will be called when applying the force to the impostors. */
  27172. forceApplicationCallback: () => void;
  27173. }
  27174. }
  27175. declare module "babylonjs/Physics/physicsRaycastResult" {
  27176. import { Vector3 } from "babylonjs/Maths/math.vector";
  27177. /**
  27178. * Holds the data for the raycast result
  27179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27180. */
  27181. export class PhysicsRaycastResult {
  27182. private _hasHit;
  27183. private _hitDistance;
  27184. private _hitNormalWorld;
  27185. private _hitPointWorld;
  27186. private _rayFromWorld;
  27187. private _rayToWorld;
  27188. /**
  27189. * Gets if there was a hit
  27190. */
  27191. get hasHit(): boolean;
  27192. /**
  27193. * Gets the distance from the hit
  27194. */
  27195. get hitDistance(): number;
  27196. /**
  27197. * Gets the hit normal/direction in the world
  27198. */
  27199. get hitNormalWorld(): Vector3;
  27200. /**
  27201. * Gets the hit point in the world
  27202. */
  27203. get hitPointWorld(): Vector3;
  27204. /**
  27205. * Gets the ray "start point" of the ray in the world
  27206. */
  27207. get rayFromWorld(): Vector3;
  27208. /**
  27209. * Gets the ray "end point" of the ray in the world
  27210. */
  27211. get rayToWorld(): Vector3;
  27212. /**
  27213. * Sets the hit data (normal & point in world space)
  27214. * @param hitNormalWorld defines the normal in world space
  27215. * @param hitPointWorld defines the point in world space
  27216. */
  27217. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27218. /**
  27219. * Sets the distance from the start point to the hit point
  27220. * @param distance
  27221. */
  27222. setHitDistance(distance: number): void;
  27223. /**
  27224. * Calculates the distance manually
  27225. */
  27226. calculateHitDistance(): void;
  27227. /**
  27228. * Resets all the values to default
  27229. * @param from The from point on world space
  27230. * @param to The to point on world space
  27231. */
  27232. reset(from?: Vector3, to?: Vector3): void;
  27233. }
  27234. /**
  27235. * Interface for the size containing width and height
  27236. */
  27237. interface IXYZ {
  27238. /**
  27239. * X
  27240. */
  27241. x: number;
  27242. /**
  27243. * Y
  27244. */
  27245. y: number;
  27246. /**
  27247. * Z
  27248. */
  27249. z: number;
  27250. }
  27251. }
  27252. declare module "babylonjs/Physics/IPhysicsEngine" {
  27253. import { Nullable } from "babylonjs/types";
  27254. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27256. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27257. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27258. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27259. /**
  27260. * Interface used to describe a physics joint
  27261. */
  27262. export interface PhysicsImpostorJoint {
  27263. /** Defines the main impostor to which the joint is linked */
  27264. mainImpostor: PhysicsImpostor;
  27265. /** Defines the impostor that is connected to the main impostor using this joint */
  27266. connectedImpostor: PhysicsImpostor;
  27267. /** Defines the joint itself */
  27268. joint: PhysicsJoint;
  27269. }
  27270. /** @hidden */
  27271. export interface IPhysicsEnginePlugin {
  27272. world: any;
  27273. name: string;
  27274. setGravity(gravity: Vector3): void;
  27275. setTimeStep(timeStep: number): void;
  27276. getTimeStep(): number;
  27277. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27278. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27279. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27280. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27281. removePhysicsBody(impostor: PhysicsImpostor): void;
  27282. generateJoint(joint: PhysicsImpostorJoint): void;
  27283. removeJoint(joint: PhysicsImpostorJoint): void;
  27284. isSupported(): boolean;
  27285. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27286. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27287. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27288. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27289. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27291. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27292. getBodyMass(impostor: PhysicsImpostor): number;
  27293. getBodyFriction(impostor: PhysicsImpostor): number;
  27294. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27295. getBodyRestitution(impostor: PhysicsImpostor): number;
  27296. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27297. getBodyPressure?(impostor: PhysicsImpostor): number;
  27298. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27299. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27300. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27301. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27302. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27303. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27304. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27305. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27306. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27307. sleepBody(impostor: PhysicsImpostor): void;
  27308. wakeUpBody(impostor: PhysicsImpostor): void;
  27309. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27310. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27311. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27312. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27313. getRadius(impostor: PhysicsImpostor): number;
  27314. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27315. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27316. dispose(): void;
  27317. }
  27318. /**
  27319. * Interface used to define a physics engine
  27320. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27321. */
  27322. export interface IPhysicsEngine {
  27323. /**
  27324. * Gets the gravity vector used by the simulation
  27325. */
  27326. gravity: Vector3;
  27327. /**
  27328. * Sets the gravity vector used by the simulation
  27329. * @param gravity defines the gravity vector to use
  27330. */
  27331. setGravity(gravity: Vector3): void;
  27332. /**
  27333. * Set the time step of the physics engine.
  27334. * Default is 1/60.
  27335. * To slow it down, enter 1/600 for example.
  27336. * To speed it up, 1/30
  27337. * @param newTimeStep the new timestep to apply to this world.
  27338. */
  27339. setTimeStep(newTimeStep: number): void;
  27340. /**
  27341. * Get the time step of the physics engine.
  27342. * @returns the current time step
  27343. */
  27344. getTimeStep(): number;
  27345. /**
  27346. * Set the sub time step of the physics engine.
  27347. * Default is 0 meaning there is no sub steps
  27348. * To increase physics resolution precision, set a small value (like 1 ms)
  27349. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27350. */
  27351. setSubTimeStep(subTimeStep: number): void;
  27352. /**
  27353. * Get the sub time step of the physics engine.
  27354. * @returns the current sub time step
  27355. */
  27356. getSubTimeStep(): number;
  27357. /**
  27358. * Release all resources
  27359. */
  27360. dispose(): void;
  27361. /**
  27362. * Gets the name of the current physics plugin
  27363. * @returns the name of the plugin
  27364. */
  27365. getPhysicsPluginName(): string;
  27366. /**
  27367. * Adding a new impostor for the impostor tracking.
  27368. * This will be done by the impostor itself.
  27369. * @param impostor the impostor to add
  27370. */
  27371. addImpostor(impostor: PhysicsImpostor): void;
  27372. /**
  27373. * Remove an impostor from the engine.
  27374. * This impostor and its mesh will not longer be updated by the physics engine.
  27375. * @param impostor the impostor to remove
  27376. */
  27377. removeImpostor(impostor: PhysicsImpostor): void;
  27378. /**
  27379. * Add a joint to the physics engine
  27380. * @param mainImpostor defines the main impostor to which the joint is added.
  27381. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27382. * @param joint defines the joint that will connect both impostors.
  27383. */
  27384. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27385. /**
  27386. * Removes a joint from the simulation
  27387. * @param mainImpostor defines the impostor used with the joint
  27388. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27389. * @param joint defines the joint to remove
  27390. */
  27391. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27392. /**
  27393. * Gets the current plugin used to run the simulation
  27394. * @returns current plugin
  27395. */
  27396. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27397. /**
  27398. * Gets the list of physic impostors
  27399. * @returns an array of PhysicsImpostor
  27400. */
  27401. getImpostors(): Array<PhysicsImpostor>;
  27402. /**
  27403. * Gets the impostor for a physics enabled object
  27404. * @param object defines the object impersonated by the impostor
  27405. * @returns the PhysicsImpostor or null if not found
  27406. */
  27407. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27408. /**
  27409. * Gets the impostor for a physics body object
  27410. * @param body defines physics body used by the impostor
  27411. * @returns the PhysicsImpostor or null if not found
  27412. */
  27413. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27414. /**
  27415. * Does a raycast in the physics world
  27416. * @param from when should the ray start?
  27417. * @param to when should the ray end?
  27418. * @returns PhysicsRaycastResult
  27419. */
  27420. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27421. /**
  27422. * Called by the scene. No need to call it.
  27423. * @param delta defines the timespam between frames
  27424. */
  27425. _step(delta: number): void;
  27426. }
  27427. }
  27428. declare module "babylonjs/Physics/physicsImpostor" {
  27429. import { Nullable, IndicesArray } from "babylonjs/types";
  27430. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27433. import { Scene } from "babylonjs/scene";
  27434. import { Bone } from "babylonjs/Bones/bone";
  27435. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27436. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27437. import { Space } from "babylonjs/Maths/math.axis";
  27438. /**
  27439. * The interface for the physics imposter parameters
  27440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27441. */
  27442. export interface PhysicsImpostorParameters {
  27443. /**
  27444. * The mass of the physics imposter
  27445. */
  27446. mass: number;
  27447. /**
  27448. * The friction of the physics imposter
  27449. */
  27450. friction?: number;
  27451. /**
  27452. * The coefficient of restitution of the physics imposter
  27453. */
  27454. restitution?: number;
  27455. /**
  27456. * The native options of the physics imposter
  27457. */
  27458. nativeOptions?: any;
  27459. /**
  27460. * Specifies if the parent should be ignored
  27461. */
  27462. ignoreParent?: boolean;
  27463. /**
  27464. * Specifies if bi-directional transformations should be disabled
  27465. */
  27466. disableBidirectionalTransformation?: boolean;
  27467. /**
  27468. * The pressure inside the physics imposter, soft object only
  27469. */
  27470. pressure?: number;
  27471. /**
  27472. * The stiffness the physics imposter, soft object only
  27473. */
  27474. stiffness?: number;
  27475. /**
  27476. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27477. */
  27478. velocityIterations?: number;
  27479. /**
  27480. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27481. */
  27482. positionIterations?: number;
  27483. /**
  27484. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27485. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27486. * Add to fix multiple points
  27487. */
  27488. fixedPoints?: number;
  27489. /**
  27490. * The collision margin around a soft object
  27491. */
  27492. margin?: number;
  27493. /**
  27494. * The collision margin around a soft object
  27495. */
  27496. damping?: number;
  27497. /**
  27498. * The path for a rope based on an extrusion
  27499. */
  27500. path?: any;
  27501. /**
  27502. * The shape of an extrusion used for a rope based on an extrusion
  27503. */
  27504. shape?: any;
  27505. }
  27506. /**
  27507. * Interface for a physics-enabled object
  27508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27509. */
  27510. export interface IPhysicsEnabledObject {
  27511. /**
  27512. * The position of the physics-enabled object
  27513. */
  27514. position: Vector3;
  27515. /**
  27516. * The rotation of the physics-enabled object
  27517. */
  27518. rotationQuaternion: Nullable<Quaternion>;
  27519. /**
  27520. * The scale of the physics-enabled object
  27521. */
  27522. scaling: Vector3;
  27523. /**
  27524. * The rotation of the physics-enabled object
  27525. */
  27526. rotation?: Vector3;
  27527. /**
  27528. * The parent of the physics-enabled object
  27529. */
  27530. parent?: any;
  27531. /**
  27532. * The bounding info of the physics-enabled object
  27533. * @returns The bounding info of the physics-enabled object
  27534. */
  27535. getBoundingInfo(): BoundingInfo;
  27536. /**
  27537. * Computes the world matrix
  27538. * @param force Specifies if the world matrix should be computed by force
  27539. * @returns A world matrix
  27540. */
  27541. computeWorldMatrix(force: boolean): Matrix;
  27542. /**
  27543. * Gets the world matrix
  27544. * @returns A world matrix
  27545. */
  27546. getWorldMatrix?(): Matrix;
  27547. /**
  27548. * Gets the child meshes
  27549. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27550. * @returns An array of abstract meshes
  27551. */
  27552. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27553. /**
  27554. * Gets the vertex data
  27555. * @param kind The type of vertex data
  27556. * @returns A nullable array of numbers, or a float32 array
  27557. */
  27558. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27559. /**
  27560. * Gets the indices from the mesh
  27561. * @returns A nullable array of index arrays
  27562. */
  27563. getIndices?(): Nullable<IndicesArray>;
  27564. /**
  27565. * Gets the scene from the mesh
  27566. * @returns the indices array or null
  27567. */
  27568. getScene?(): Scene;
  27569. /**
  27570. * Gets the absolute position from the mesh
  27571. * @returns the absolute position
  27572. */
  27573. getAbsolutePosition(): Vector3;
  27574. /**
  27575. * Gets the absolute pivot point from the mesh
  27576. * @returns the absolute pivot point
  27577. */
  27578. getAbsolutePivotPoint(): Vector3;
  27579. /**
  27580. * Rotates the mesh
  27581. * @param axis The axis of rotation
  27582. * @param amount The amount of rotation
  27583. * @param space The space of the rotation
  27584. * @returns The rotation transform node
  27585. */
  27586. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27587. /**
  27588. * Translates the mesh
  27589. * @param axis The axis of translation
  27590. * @param distance The distance of translation
  27591. * @param space The space of the translation
  27592. * @returns The transform node
  27593. */
  27594. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27595. /**
  27596. * Sets the absolute position of the mesh
  27597. * @param absolutePosition The absolute position of the mesh
  27598. * @returns The transform node
  27599. */
  27600. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27601. /**
  27602. * Gets the class name of the mesh
  27603. * @returns The class name
  27604. */
  27605. getClassName(): string;
  27606. }
  27607. /**
  27608. * Represents a physics imposter
  27609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27610. */
  27611. export class PhysicsImpostor {
  27612. /**
  27613. * The physics-enabled object used as the physics imposter
  27614. */
  27615. object: IPhysicsEnabledObject;
  27616. /**
  27617. * The type of the physics imposter
  27618. */
  27619. type: number;
  27620. private _options;
  27621. private _scene?;
  27622. /**
  27623. * The default object size of the imposter
  27624. */
  27625. static DEFAULT_OBJECT_SIZE: Vector3;
  27626. /**
  27627. * The identity quaternion of the imposter
  27628. */
  27629. static IDENTITY_QUATERNION: Quaternion;
  27630. /** @hidden */
  27631. _pluginData: any;
  27632. private _physicsEngine;
  27633. private _physicsBody;
  27634. private _bodyUpdateRequired;
  27635. private _onBeforePhysicsStepCallbacks;
  27636. private _onAfterPhysicsStepCallbacks;
  27637. /** @hidden */
  27638. _onPhysicsCollideCallbacks: Array<{
  27639. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27640. otherImpostors: Array<PhysicsImpostor>;
  27641. }>;
  27642. private _deltaPosition;
  27643. private _deltaRotation;
  27644. private _deltaRotationConjugated;
  27645. /** @hidden */
  27646. _isFromLine: boolean;
  27647. private _parent;
  27648. private _isDisposed;
  27649. private static _tmpVecs;
  27650. private static _tmpQuat;
  27651. /**
  27652. * Specifies if the physics imposter is disposed
  27653. */
  27654. get isDisposed(): boolean;
  27655. /**
  27656. * Gets the mass of the physics imposter
  27657. */
  27658. get mass(): number;
  27659. set mass(value: number);
  27660. /**
  27661. * Gets the coefficient of friction
  27662. */
  27663. get friction(): number;
  27664. /**
  27665. * Sets the coefficient of friction
  27666. */
  27667. set friction(value: number);
  27668. /**
  27669. * Gets the coefficient of restitution
  27670. */
  27671. get restitution(): number;
  27672. /**
  27673. * Sets the coefficient of restitution
  27674. */
  27675. set restitution(value: number);
  27676. /**
  27677. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27678. */
  27679. get pressure(): number;
  27680. /**
  27681. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27682. */
  27683. set pressure(value: number);
  27684. /**
  27685. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27686. */
  27687. get stiffness(): number;
  27688. /**
  27689. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27690. */
  27691. set stiffness(value: number);
  27692. /**
  27693. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27694. */
  27695. get velocityIterations(): number;
  27696. /**
  27697. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27698. */
  27699. set velocityIterations(value: number);
  27700. /**
  27701. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27702. */
  27703. get positionIterations(): number;
  27704. /**
  27705. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27706. */
  27707. set positionIterations(value: number);
  27708. /**
  27709. * The unique id of the physics imposter
  27710. * set by the physics engine when adding this impostor to the array
  27711. */
  27712. uniqueId: number;
  27713. /**
  27714. * @hidden
  27715. */
  27716. soft: boolean;
  27717. /**
  27718. * @hidden
  27719. */
  27720. segments: number;
  27721. private _joints;
  27722. /**
  27723. * Initializes the physics imposter
  27724. * @param object The physics-enabled object used as the physics imposter
  27725. * @param type The type of the physics imposter
  27726. * @param _options The options for the physics imposter
  27727. * @param _scene The Babylon scene
  27728. */
  27729. constructor(
  27730. /**
  27731. * The physics-enabled object used as the physics imposter
  27732. */
  27733. object: IPhysicsEnabledObject,
  27734. /**
  27735. * The type of the physics imposter
  27736. */
  27737. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27738. /**
  27739. * This function will completly initialize this impostor.
  27740. * It will create a new body - but only if this mesh has no parent.
  27741. * If it has, this impostor will not be used other than to define the impostor
  27742. * of the child mesh.
  27743. * @hidden
  27744. */
  27745. _init(): void;
  27746. private _getPhysicsParent;
  27747. /**
  27748. * Should a new body be generated.
  27749. * @returns boolean specifying if body initialization is required
  27750. */
  27751. isBodyInitRequired(): boolean;
  27752. /**
  27753. * Sets the updated scaling
  27754. * @param updated Specifies if the scaling is updated
  27755. */
  27756. setScalingUpdated(): void;
  27757. /**
  27758. * Force a regeneration of this or the parent's impostor's body.
  27759. * Use under cautious - This will remove all joints already implemented.
  27760. */
  27761. forceUpdate(): void;
  27762. /**
  27763. * Gets the body that holds this impostor. Either its own, or its parent.
  27764. */
  27765. get physicsBody(): any;
  27766. /**
  27767. * Get the parent of the physics imposter
  27768. * @returns Physics imposter or null
  27769. */
  27770. get parent(): Nullable<PhysicsImpostor>;
  27771. /**
  27772. * Sets the parent of the physics imposter
  27773. */
  27774. set parent(value: Nullable<PhysicsImpostor>);
  27775. /**
  27776. * Set the physics body. Used mainly by the physics engine/plugin
  27777. */
  27778. set physicsBody(physicsBody: any);
  27779. /**
  27780. * Resets the update flags
  27781. */
  27782. resetUpdateFlags(): void;
  27783. /**
  27784. * Gets the object extend size
  27785. * @returns the object extend size
  27786. */
  27787. getObjectExtendSize(): Vector3;
  27788. /**
  27789. * Gets the object center
  27790. * @returns The object center
  27791. */
  27792. getObjectCenter(): Vector3;
  27793. /**
  27794. * Get a specific parameter from the options parameters
  27795. * @param paramName The object parameter name
  27796. * @returns The object parameter
  27797. */
  27798. getParam(paramName: string): any;
  27799. /**
  27800. * Sets a specific parameter in the options given to the physics plugin
  27801. * @param paramName The parameter name
  27802. * @param value The value of the parameter
  27803. */
  27804. setParam(paramName: string, value: number): void;
  27805. /**
  27806. * Specifically change the body's mass option. Won't recreate the physics body object
  27807. * @param mass The mass of the physics imposter
  27808. */
  27809. setMass(mass: number): void;
  27810. /**
  27811. * Gets the linear velocity
  27812. * @returns linear velocity or null
  27813. */
  27814. getLinearVelocity(): Nullable<Vector3>;
  27815. /**
  27816. * Sets the linear velocity
  27817. * @param velocity linear velocity or null
  27818. */
  27819. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27820. /**
  27821. * Gets the angular velocity
  27822. * @returns angular velocity or null
  27823. */
  27824. getAngularVelocity(): Nullable<Vector3>;
  27825. /**
  27826. * Sets the angular velocity
  27827. * @param velocity The velocity or null
  27828. */
  27829. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27830. /**
  27831. * Execute a function with the physics plugin native code
  27832. * Provide a function the will have two variables - the world object and the physics body object
  27833. * @param func The function to execute with the physics plugin native code
  27834. */
  27835. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27836. /**
  27837. * Register a function that will be executed before the physics world is stepping forward
  27838. * @param func The function to execute before the physics world is stepped forward
  27839. */
  27840. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Unregister a function that will be executed before the physics world is stepping forward
  27843. * @param func The function to execute before the physics world is stepped forward
  27844. */
  27845. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * Register a function that will be executed after the physics step
  27848. * @param func The function to execute after physics step
  27849. */
  27850. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27851. /**
  27852. * Unregisters a function that will be executed after the physics step
  27853. * @param func The function to execute after physics step
  27854. */
  27855. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27856. /**
  27857. * register a function that will be executed when this impostor collides against a different body
  27858. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27859. * @param func Callback that is executed on collision
  27860. */
  27861. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27862. /**
  27863. * Unregisters the physics imposter on contact
  27864. * @param collideAgainst The physics object to collide against
  27865. * @param func Callback to execute on collision
  27866. */
  27867. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27868. private _tmpQuat;
  27869. private _tmpQuat2;
  27870. /**
  27871. * Get the parent rotation
  27872. * @returns The parent rotation
  27873. */
  27874. getParentsRotation(): Quaternion;
  27875. /**
  27876. * this function is executed by the physics engine.
  27877. */
  27878. beforeStep: () => void;
  27879. /**
  27880. * this function is executed by the physics engine
  27881. */
  27882. afterStep: () => void;
  27883. /**
  27884. * Legacy collision detection event support
  27885. */
  27886. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27887. /**
  27888. * event and body object due to cannon's event-based architecture.
  27889. */
  27890. onCollide: (e: {
  27891. body: any;
  27892. }) => void;
  27893. /**
  27894. * Apply a force
  27895. * @param force The force to apply
  27896. * @param contactPoint The contact point for the force
  27897. * @returns The physics imposter
  27898. */
  27899. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27900. /**
  27901. * Apply an impulse
  27902. * @param force The impulse force
  27903. * @param contactPoint The contact point for the impulse force
  27904. * @returns The physics imposter
  27905. */
  27906. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27907. /**
  27908. * A help function to create a joint
  27909. * @param otherImpostor A physics imposter used to create a joint
  27910. * @param jointType The type of joint
  27911. * @param jointData The data for the joint
  27912. * @returns The physics imposter
  27913. */
  27914. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27915. /**
  27916. * Add a joint to this impostor with a different impostor
  27917. * @param otherImpostor A physics imposter used to add a joint
  27918. * @param joint The joint to add
  27919. * @returns The physics imposter
  27920. */
  27921. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27922. /**
  27923. * Add an anchor to a cloth impostor
  27924. * @param otherImpostor rigid impostor to anchor to
  27925. * @param width ratio across width from 0 to 1
  27926. * @param height ratio up height from 0 to 1
  27927. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27928. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27929. * @returns impostor the soft imposter
  27930. */
  27931. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27932. /**
  27933. * Add a hook to a rope impostor
  27934. * @param otherImpostor rigid impostor to anchor to
  27935. * @param length ratio across rope from 0 to 1
  27936. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27937. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27938. * @returns impostor the rope imposter
  27939. */
  27940. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27941. /**
  27942. * Will keep this body still, in a sleep mode.
  27943. * @returns the physics imposter
  27944. */
  27945. sleep(): PhysicsImpostor;
  27946. /**
  27947. * Wake the body up.
  27948. * @returns The physics imposter
  27949. */
  27950. wakeUp(): PhysicsImpostor;
  27951. /**
  27952. * Clones the physics imposter
  27953. * @param newObject The physics imposter clones to this physics-enabled object
  27954. * @returns A nullable physics imposter
  27955. */
  27956. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27957. /**
  27958. * Disposes the physics imposter
  27959. */
  27960. dispose(): void;
  27961. /**
  27962. * Sets the delta position
  27963. * @param position The delta position amount
  27964. */
  27965. setDeltaPosition(position: Vector3): void;
  27966. /**
  27967. * Sets the delta rotation
  27968. * @param rotation The delta rotation amount
  27969. */
  27970. setDeltaRotation(rotation: Quaternion): void;
  27971. /**
  27972. * Gets the box size of the physics imposter and stores the result in the input parameter
  27973. * @param result Stores the box size
  27974. * @returns The physics imposter
  27975. */
  27976. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27977. /**
  27978. * Gets the radius of the physics imposter
  27979. * @returns Radius of the physics imposter
  27980. */
  27981. getRadius(): number;
  27982. /**
  27983. * Sync a bone with this impostor
  27984. * @param bone The bone to sync to the impostor.
  27985. * @param boneMesh The mesh that the bone is influencing.
  27986. * @param jointPivot The pivot of the joint / bone in local space.
  27987. * @param distToJoint Optional distance from the impostor to the joint.
  27988. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27989. */
  27990. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27991. /**
  27992. * Sync impostor to a bone
  27993. * @param bone The bone that the impostor will be synced to.
  27994. * @param boneMesh The mesh that the bone is influencing.
  27995. * @param jointPivot The pivot of the joint / bone in local space.
  27996. * @param distToJoint Optional distance from the impostor to the joint.
  27997. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27998. * @param boneAxis Optional vector3 axis the bone is aligned with
  27999. */
  28000. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28001. /**
  28002. * No-Imposter type
  28003. */
  28004. static NoImpostor: number;
  28005. /**
  28006. * Sphere-Imposter type
  28007. */
  28008. static SphereImpostor: number;
  28009. /**
  28010. * Box-Imposter type
  28011. */
  28012. static BoxImpostor: number;
  28013. /**
  28014. * Plane-Imposter type
  28015. */
  28016. static PlaneImpostor: number;
  28017. /**
  28018. * Mesh-imposter type
  28019. */
  28020. static MeshImpostor: number;
  28021. /**
  28022. * Capsule-Impostor type (Ammo.js plugin only)
  28023. */
  28024. static CapsuleImpostor: number;
  28025. /**
  28026. * Cylinder-Imposter type
  28027. */
  28028. static CylinderImpostor: number;
  28029. /**
  28030. * Particle-Imposter type
  28031. */
  28032. static ParticleImpostor: number;
  28033. /**
  28034. * Heightmap-Imposter type
  28035. */
  28036. static HeightmapImpostor: number;
  28037. /**
  28038. * ConvexHull-Impostor type (Ammo.js plugin only)
  28039. */
  28040. static ConvexHullImpostor: number;
  28041. /**
  28042. * Custom-Imposter type (Ammo.js plugin only)
  28043. */
  28044. static CustomImpostor: number;
  28045. /**
  28046. * Rope-Imposter type
  28047. */
  28048. static RopeImpostor: number;
  28049. /**
  28050. * Cloth-Imposter type
  28051. */
  28052. static ClothImpostor: number;
  28053. /**
  28054. * Softbody-Imposter type
  28055. */
  28056. static SoftbodyImpostor: number;
  28057. }
  28058. }
  28059. declare module "babylonjs/Meshes/mesh" {
  28060. import { Observable } from "babylonjs/Misc/observable";
  28061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28062. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28063. import { Camera } from "babylonjs/Cameras/camera";
  28064. import { Scene } from "babylonjs/scene";
  28065. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28066. import { Color4 } from "babylonjs/Maths/math.color";
  28067. import { Engine } from "babylonjs/Engines/engine";
  28068. import { Node } from "babylonjs/node";
  28069. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28070. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28071. import { Buffer } from "babylonjs/Meshes/buffer";
  28072. import { Geometry } from "babylonjs/Meshes/geometry";
  28073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28075. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28076. import { Effect } from "babylonjs/Materials/effect";
  28077. import { Material } from "babylonjs/Materials/material";
  28078. import { Skeleton } from "babylonjs/Bones/skeleton";
  28079. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28080. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28081. import { Path3D } from "babylonjs/Maths/math.path";
  28082. import { Plane } from "babylonjs/Maths/math.plane";
  28083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28084. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28086. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28087. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28088. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28089. /**
  28090. * @hidden
  28091. **/
  28092. export class _CreationDataStorage {
  28093. closePath?: boolean;
  28094. closeArray?: boolean;
  28095. idx: number[];
  28096. dashSize: number;
  28097. gapSize: number;
  28098. path3D: Path3D;
  28099. pathArray: Vector3[][];
  28100. arc: number;
  28101. radius: number;
  28102. cap: number;
  28103. tessellation: number;
  28104. }
  28105. /**
  28106. * @hidden
  28107. **/
  28108. class _InstanceDataStorage {
  28109. visibleInstances: any;
  28110. batchCache: _InstancesBatch;
  28111. instancesBufferSize: number;
  28112. instancesBuffer: Nullable<Buffer>;
  28113. instancesData: Float32Array;
  28114. overridenInstanceCount: number;
  28115. isFrozen: boolean;
  28116. previousBatch: Nullable<_InstancesBatch>;
  28117. hardwareInstancedRendering: boolean;
  28118. sideOrientation: number;
  28119. manualUpdate: boolean;
  28120. }
  28121. /**
  28122. * @hidden
  28123. **/
  28124. export class _InstancesBatch {
  28125. mustReturn: boolean;
  28126. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28127. renderSelf: boolean[];
  28128. hardwareInstancedRendering: boolean[];
  28129. }
  28130. /**
  28131. * @hidden
  28132. **/
  28133. class _ThinInstanceDataStorage {
  28134. instancesCount: number;
  28135. matrixBuffer: Nullable<Buffer>;
  28136. matrixBufferSize: number;
  28137. matrixData: Nullable<Float32Array>;
  28138. boundingVectors: Array<Vector3>;
  28139. }
  28140. /**
  28141. * Class used to represent renderable models
  28142. */
  28143. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28144. /**
  28145. * Mesh side orientation : usually the external or front surface
  28146. */
  28147. static readonly FRONTSIDE: number;
  28148. /**
  28149. * Mesh side orientation : usually the internal or back surface
  28150. */
  28151. static readonly BACKSIDE: number;
  28152. /**
  28153. * Mesh side orientation : both internal and external or front and back surfaces
  28154. */
  28155. static readonly DOUBLESIDE: number;
  28156. /**
  28157. * Mesh side orientation : by default, `FRONTSIDE`
  28158. */
  28159. static readonly DEFAULTSIDE: number;
  28160. /**
  28161. * Mesh cap setting : no cap
  28162. */
  28163. static readonly NO_CAP: number;
  28164. /**
  28165. * Mesh cap setting : one cap at the beginning of the mesh
  28166. */
  28167. static readonly CAP_START: number;
  28168. /**
  28169. * Mesh cap setting : one cap at the end of the mesh
  28170. */
  28171. static readonly CAP_END: number;
  28172. /**
  28173. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28174. */
  28175. static readonly CAP_ALL: number;
  28176. /**
  28177. * Mesh pattern setting : no flip or rotate
  28178. */
  28179. static readonly NO_FLIP: number;
  28180. /**
  28181. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28182. */
  28183. static readonly FLIP_TILE: number;
  28184. /**
  28185. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28186. */
  28187. static readonly ROTATE_TILE: number;
  28188. /**
  28189. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28190. */
  28191. static readonly FLIP_ROW: number;
  28192. /**
  28193. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28194. */
  28195. static readonly ROTATE_ROW: number;
  28196. /**
  28197. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28198. */
  28199. static readonly FLIP_N_ROTATE_TILE: number;
  28200. /**
  28201. * Mesh pattern setting : rotate pattern and rotate
  28202. */
  28203. static readonly FLIP_N_ROTATE_ROW: number;
  28204. /**
  28205. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28206. */
  28207. static readonly CENTER: number;
  28208. /**
  28209. * Mesh tile positioning : part tiles on left
  28210. */
  28211. static readonly LEFT: number;
  28212. /**
  28213. * Mesh tile positioning : part tiles on right
  28214. */
  28215. static readonly RIGHT: number;
  28216. /**
  28217. * Mesh tile positioning : part tiles on top
  28218. */
  28219. static readonly TOP: number;
  28220. /**
  28221. * Mesh tile positioning : part tiles on bottom
  28222. */
  28223. static readonly BOTTOM: number;
  28224. /**
  28225. * Gets the default side orientation.
  28226. * @param orientation the orientation to value to attempt to get
  28227. * @returns the default orientation
  28228. * @hidden
  28229. */
  28230. static _GetDefaultSideOrientation(orientation?: number): number;
  28231. private _internalMeshDataInfo;
  28232. /**
  28233. * An event triggered before rendering the mesh
  28234. */
  28235. get onBeforeRenderObservable(): Observable<Mesh>;
  28236. /**
  28237. * An event triggered before binding the mesh
  28238. */
  28239. get onBeforeBindObservable(): Observable<Mesh>;
  28240. /**
  28241. * An event triggered after rendering the mesh
  28242. */
  28243. get onAfterRenderObservable(): Observable<Mesh>;
  28244. /**
  28245. * An event triggered before drawing the mesh
  28246. */
  28247. get onBeforeDrawObservable(): Observable<Mesh>;
  28248. private _onBeforeDrawObserver;
  28249. /**
  28250. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28251. */
  28252. set onBeforeDraw(callback: () => void);
  28253. get hasInstances(): boolean;
  28254. get hasThinInstances(): boolean;
  28255. /**
  28256. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28257. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28258. */
  28259. delayLoadState: number;
  28260. /**
  28261. * Gets the list of instances created from this mesh
  28262. * it is not supposed to be modified manually.
  28263. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28264. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28265. */
  28266. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28267. /**
  28268. * Gets the file containing delay loading data for this mesh
  28269. */
  28270. delayLoadingFile: string;
  28271. /** @hidden */
  28272. _binaryInfo: any;
  28273. /**
  28274. * User defined function used to change how LOD level selection is done
  28275. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28276. */
  28277. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28278. /**
  28279. * Gets or sets the morph target manager
  28280. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28281. */
  28282. get morphTargetManager(): Nullable<MorphTargetManager>;
  28283. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28284. /** @hidden */
  28285. _creationDataStorage: Nullable<_CreationDataStorage>;
  28286. /** @hidden */
  28287. _geometry: Nullable<Geometry>;
  28288. /** @hidden */
  28289. _delayInfo: Array<string>;
  28290. /** @hidden */
  28291. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28292. /** @hidden */
  28293. _instanceDataStorage: _InstanceDataStorage;
  28294. /** @hidden */
  28295. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28296. private _effectiveMaterial;
  28297. /** @hidden */
  28298. _shouldGenerateFlatShading: boolean;
  28299. /** @hidden */
  28300. _originalBuilderSideOrientation: number;
  28301. /**
  28302. * Use this property to change the original side orientation defined at construction time
  28303. */
  28304. overrideMaterialSideOrientation: Nullable<number>;
  28305. /**
  28306. * Gets the source mesh (the one used to clone this one from)
  28307. */
  28308. get source(): Nullable<Mesh>;
  28309. /**
  28310. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28311. */
  28312. get isUnIndexed(): boolean;
  28313. set isUnIndexed(value: boolean);
  28314. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28315. get worldMatrixInstancedBuffer(): Float32Array;
  28316. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28317. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28318. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28319. /**
  28320. * @constructor
  28321. * @param name The value used by scene.getMeshByName() to do a lookup.
  28322. * @param scene The scene to add this mesh to.
  28323. * @param parent The parent of this mesh, if it has one
  28324. * @param source An optional Mesh from which geometry is shared, cloned.
  28325. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28326. * When false, achieved by calling a clone(), also passing False.
  28327. * This will make creation of children, recursive.
  28328. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28329. */
  28330. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28331. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28332. doNotInstantiate: boolean;
  28333. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28334. /**
  28335. * Gets the class name
  28336. * @returns the string "Mesh".
  28337. */
  28338. getClassName(): string;
  28339. /** @hidden */
  28340. get _isMesh(): boolean;
  28341. /**
  28342. * Returns a description of this mesh
  28343. * @param fullDetails define if full details about this mesh must be used
  28344. * @returns a descriptive string representing this mesh
  28345. */
  28346. toString(fullDetails?: boolean): string;
  28347. /** @hidden */
  28348. _unBindEffect(): void;
  28349. /**
  28350. * Gets a boolean indicating if this mesh has LOD
  28351. */
  28352. get hasLODLevels(): boolean;
  28353. /**
  28354. * Gets the list of MeshLODLevel associated with the current mesh
  28355. * @returns an array of MeshLODLevel
  28356. */
  28357. getLODLevels(): MeshLODLevel[];
  28358. private _sortLODLevels;
  28359. /**
  28360. * Add a mesh as LOD level triggered at the given distance.
  28361. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28362. * @param distance The distance from the center of the object to show this level
  28363. * @param mesh The mesh to be added as LOD level (can be null)
  28364. * @return This mesh (for chaining)
  28365. */
  28366. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28367. /**
  28368. * Returns the LOD level mesh at the passed distance or null if not found.
  28369. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28370. * @param distance The distance from the center of the object to show this level
  28371. * @returns a Mesh or `null`
  28372. */
  28373. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28374. /**
  28375. * Remove a mesh from the LOD array
  28376. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28377. * @param mesh defines the mesh to be removed
  28378. * @return This mesh (for chaining)
  28379. */
  28380. removeLODLevel(mesh: Mesh): Mesh;
  28381. /**
  28382. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28383. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28384. * @param camera defines the camera to use to compute distance
  28385. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28386. * @return This mesh (for chaining)
  28387. */
  28388. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28389. /**
  28390. * Gets the mesh internal Geometry object
  28391. */
  28392. get geometry(): Nullable<Geometry>;
  28393. /**
  28394. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28395. * @returns the total number of vertices
  28396. */
  28397. getTotalVertices(): number;
  28398. /**
  28399. * Returns the content of an associated vertex buffer
  28400. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28401. * - VertexBuffer.PositionKind
  28402. * - VertexBuffer.UVKind
  28403. * - VertexBuffer.UV2Kind
  28404. * - VertexBuffer.UV3Kind
  28405. * - VertexBuffer.UV4Kind
  28406. * - VertexBuffer.UV5Kind
  28407. * - VertexBuffer.UV6Kind
  28408. * - VertexBuffer.ColorKind
  28409. * - VertexBuffer.MatricesIndicesKind
  28410. * - VertexBuffer.MatricesIndicesExtraKind
  28411. * - VertexBuffer.MatricesWeightsKind
  28412. * - VertexBuffer.MatricesWeightsExtraKind
  28413. * @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
  28414. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28415. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28416. */
  28417. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28418. /**
  28419. * Returns the mesh VertexBuffer object from the requested `kind`
  28420. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28421. * - VertexBuffer.PositionKind
  28422. * - VertexBuffer.NormalKind
  28423. * - VertexBuffer.UVKind
  28424. * - VertexBuffer.UV2Kind
  28425. * - VertexBuffer.UV3Kind
  28426. * - VertexBuffer.UV4Kind
  28427. * - VertexBuffer.UV5Kind
  28428. * - VertexBuffer.UV6Kind
  28429. * - VertexBuffer.ColorKind
  28430. * - VertexBuffer.MatricesIndicesKind
  28431. * - VertexBuffer.MatricesIndicesExtraKind
  28432. * - VertexBuffer.MatricesWeightsKind
  28433. * - VertexBuffer.MatricesWeightsExtraKind
  28434. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28435. */
  28436. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28437. /**
  28438. * Tests if a specific vertex buffer is associated with this mesh
  28439. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28440. * - VertexBuffer.PositionKind
  28441. * - VertexBuffer.NormalKind
  28442. * - VertexBuffer.UVKind
  28443. * - VertexBuffer.UV2Kind
  28444. * - VertexBuffer.UV3Kind
  28445. * - VertexBuffer.UV4Kind
  28446. * - VertexBuffer.UV5Kind
  28447. * - VertexBuffer.UV6Kind
  28448. * - VertexBuffer.ColorKind
  28449. * - VertexBuffer.MatricesIndicesKind
  28450. * - VertexBuffer.MatricesIndicesExtraKind
  28451. * - VertexBuffer.MatricesWeightsKind
  28452. * - VertexBuffer.MatricesWeightsExtraKind
  28453. * @returns a boolean
  28454. */
  28455. isVerticesDataPresent(kind: string): boolean;
  28456. /**
  28457. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28458. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28459. * - VertexBuffer.PositionKind
  28460. * - VertexBuffer.UVKind
  28461. * - VertexBuffer.UV2Kind
  28462. * - VertexBuffer.UV3Kind
  28463. * - VertexBuffer.UV4Kind
  28464. * - VertexBuffer.UV5Kind
  28465. * - VertexBuffer.UV6Kind
  28466. * - VertexBuffer.ColorKind
  28467. * - VertexBuffer.MatricesIndicesKind
  28468. * - VertexBuffer.MatricesIndicesExtraKind
  28469. * - VertexBuffer.MatricesWeightsKind
  28470. * - VertexBuffer.MatricesWeightsExtraKind
  28471. * @returns a boolean
  28472. */
  28473. isVertexBufferUpdatable(kind: string): boolean;
  28474. /**
  28475. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28477. * - VertexBuffer.PositionKind
  28478. * - VertexBuffer.NormalKind
  28479. * - VertexBuffer.UVKind
  28480. * - VertexBuffer.UV2Kind
  28481. * - VertexBuffer.UV3Kind
  28482. * - VertexBuffer.UV4Kind
  28483. * - VertexBuffer.UV5Kind
  28484. * - VertexBuffer.UV6Kind
  28485. * - VertexBuffer.ColorKind
  28486. * - VertexBuffer.MatricesIndicesKind
  28487. * - VertexBuffer.MatricesIndicesExtraKind
  28488. * - VertexBuffer.MatricesWeightsKind
  28489. * - VertexBuffer.MatricesWeightsExtraKind
  28490. * @returns an array of strings
  28491. */
  28492. getVerticesDataKinds(): string[];
  28493. /**
  28494. * Returns a positive integer : the total number of indices in this mesh geometry.
  28495. * @returns the numner of indices or zero if the mesh has no geometry.
  28496. */
  28497. getTotalIndices(): number;
  28498. /**
  28499. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28500. * @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.
  28501. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28502. * @returns the indices array or an empty array if the mesh has no geometry
  28503. */
  28504. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28505. get isBlocked(): boolean;
  28506. /**
  28507. * Determine if the current mesh is ready to be rendered
  28508. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28509. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28510. * @returns true if all associated assets are ready (material, textures, shaders)
  28511. */
  28512. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28513. /**
  28514. * 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.
  28515. */
  28516. get areNormalsFrozen(): boolean;
  28517. /**
  28518. * 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.
  28519. * @returns the current mesh
  28520. */
  28521. freezeNormals(): Mesh;
  28522. /**
  28523. * 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
  28524. * @returns the current mesh
  28525. */
  28526. unfreezeNormals(): Mesh;
  28527. /**
  28528. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28529. */
  28530. set overridenInstanceCount(count: number);
  28531. /** @hidden */
  28532. _preActivate(): Mesh;
  28533. /** @hidden */
  28534. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28535. /** @hidden */
  28536. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28537. protected _afterComputeWorldMatrix(): void;
  28538. /**
  28539. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28540. * This means the mesh underlying bounding box and sphere are recomputed.
  28541. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28542. * @returns the current mesh
  28543. */
  28544. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28545. /** @hidden */
  28546. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28547. /**
  28548. * This function will subdivide the mesh into multiple submeshes
  28549. * @param count defines the expected number of submeshes
  28550. */
  28551. subdivide(count: number): void;
  28552. /**
  28553. * Copy a FloatArray into a specific associated vertex buffer
  28554. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28555. * - VertexBuffer.PositionKind
  28556. * - VertexBuffer.UVKind
  28557. * - VertexBuffer.UV2Kind
  28558. * - VertexBuffer.UV3Kind
  28559. * - VertexBuffer.UV4Kind
  28560. * - VertexBuffer.UV5Kind
  28561. * - VertexBuffer.UV6Kind
  28562. * - VertexBuffer.ColorKind
  28563. * - VertexBuffer.MatricesIndicesKind
  28564. * - VertexBuffer.MatricesIndicesExtraKind
  28565. * - VertexBuffer.MatricesWeightsKind
  28566. * - VertexBuffer.MatricesWeightsExtraKind
  28567. * @param data defines the data source
  28568. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28569. * @param stride defines the data stride size (can be null)
  28570. * @returns the current mesh
  28571. */
  28572. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28573. /**
  28574. * Delete a vertex buffer associated with this mesh
  28575. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28576. * - VertexBuffer.PositionKind
  28577. * - VertexBuffer.UVKind
  28578. * - VertexBuffer.UV2Kind
  28579. * - VertexBuffer.UV3Kind
  28580. * - VertexBuffer.UV4Kind
  28581. * - VertexBuffer.UV5Kind
  28582. * - VertexBuffer.UV6Kind
  28583. * - VertexBuffer.ColorKind
  28584. * - VertexBuffer.MatricesIndicesKind
  28585. * - VertexBuffer.MatricesIndicesExtraKind
  28586. * - VertexBuffer.MatricesWeightsKind
  28587. * - VertexBuffer.MatricesWeightsExtraKind
  28588. */
  28589. removeVerticesData(kind: string): void;
  28590. /**
  28591. * Flags an associated vertex buffer as updatable
  28592. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28593. * - VertexBuffer.PositionKind
  28594. * - VertexBuffer.UVKind
  28595. * - VertexBuffer.UV2Kind
  28596. * - VertexBuffer.UV3Kind
  28597. * - VertexBuffer.UV4Kind
  28598. * - VertexBuffer.UV5Kind
  28599. * - VertexBuffer.UV6Kind
  28600. * - VertexBuffer.ColorKind
  28601. * - VertexBuffer.MatricesIndicesKind
  28602. * - VertexBuffer.MatricesIndicesExtraKind
  28603. * - VertexBuffer.MatricesWeightsKind
  28604. * - VertexBuffer.MatricesWeightsExtraKind
  28605. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28606. */
  28607. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28608. /**
  28609. * Sets the mesh global Vertex Buffer
  28610. * @param buffer defines the buffer to use
  28611. * @returns the current mesh
  28612. */
  28613. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28614. /**
  28615. * Update a specific associated vertex buffer
  28616. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28617. * - VertexBuffer.PositionKind
  28618. * - VertexBuffer.UVKind
  28619. * - VertexBuffer.UV2Kind
  28620. * - VertexBuffer.UV3Kind
  28621. * - VertexBuffer.UV4Kind
  28622. * - VertexBuffer.UV5Kind
  28623. * - VertexBuffer.UV6Kind
  28624. * - VertexBuffer.ColorKind
  28625. * - VertexBuffer.MatricesIndicesKind
  28626. * - VertexBuffer.MatricesIndicesExtraKind
  28627. * - VertexBuffer.MatricesWeightsKind
  28628. * - VertexBuffer.MatricesWeightsExtraKind
  28629. * @param data defines the data source
  28630. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28631. * @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)
  28632. * @returns the current mesh
  28633. */
  28634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28635. /**
  28636. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28637. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28638. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28639. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28640. * @returns the current mesh
  28641. */
  28642. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28643. /**
  28644. * Creates a un-shared specific occurence of the geometry for the mesh.
  28645. * @returns the current mesh
  28646. */
  28647. makeGeometryUnique(): Mesh;
  28648. /**
  28649. * Set the index buffer of this mesh
  28650. * @param indices defines the source data
  28651. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28652. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28653. * @returns the current mesh
  28654. */
  28655. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28656. /**
  28657. * Update the current index buffer
  28658. * @param indices defines the source data
  28659. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28660. * @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)
  28661. * @returns the current mesh
  28662. */
  28663. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28664. /**
  28665. * Invert the geometry to move from a right handed system to a left handed one.
  28666. * @returns the current mesh
  28667. */
  28668. toLeftHanded(): Mesh;
  28669. /** @hidden */
  28670. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28671. /** @hidden */
  28672. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28673. /**
  28674. * Registers for this mesh a javascript function called just before the rendering process
  28675. * @param func defines the function to call before rendering this mesh
  28676. * @returns the current mesh
  28677. */
  28678. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28679. /**
  28680. * Disposes a previously registered javascript function called before the rendering
  28681. * @param func defines the function to remove
  28682. * @returns the current mesh
  28683. */
  28684. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28685. /**
  28686. * Registers for this mesh a javascript function called just after the rendering is complete
  28687. * @param func defines the function to call after rendering this mesh
  28688. * @returns the current mesh
  28689. */
  28690. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28691. /**
  28692. * Disposes a previously registered javascript function called after the rendering.
  28693. * @param func defines the function to remove
  28694. * @returns the current mesh
  28695. */
  28696. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28697. /** @hidden */
  28698. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28699. /** @hidden */
  28700. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28701. /** @hidden */
  28702. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28703. /** @hidden */
  28704. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28705. /** @hidden */
  28706. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28707. /** @hidden */
  28708. _rebuild(): void;
  28709. /** @hidden */
  28710. _freeze(): void;
  28711. /** @hidden */
  28712. _unFreeze(): void;
  28713. /**
  28714. * 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
  28715. * @param subMesh defines the subMesh to render
  28716. * @param enableAlphaMode defines if alpha mode can be changed
  28717. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28718. * @returns the current mesh
  28719. */
  28720. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28721. private _onBeforeDraw;
  28722. /**
  28723. * Renormalize the mesh and patch it up if there are no weights
  28724. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28725. * However in the case of zero weights then we set just a single influence to 1.
  28726. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28727. */
  28728. cleanMatrixWeights(): void;
  28729. private normalizeSkinFourWeights;
  28730. private normalizeSkinWeightsAndExtra;
  28731. /**
  28732. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28733. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28734. * the user know there was an issue with importing the mesh
  28735. * @returns a validation object with skinned, valid and report string
  28736. */
  28737. validateSkinning(): {
  28738. skinned: boolean;
  28739. valid: boolean;
  28740. report: string;
  28741. };
  28742. /** @hidden */
  28743. _checkDelayState(): Mesh;
  28744. private _queueLoad;
  28745. /**
  28746. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28747. * A mesh is in the frustum if its bounding box intersects the frustum
  28748. * @param frustumPlanes defines the frustum to test
  28749. * @returns true if the mesh is in the frustum planes
  28750. */
  28751. isInFrustum(frustumPlanes: Plane[]): boolean;
  28752. /**
  28753. * Sets the mesh material by the material or multiMaterial `id` property
  28754. * @param id is a string identifying the material or the multiMaterial
  28755. * @returns the current mesh
  28756. */
  28757. setMaterialByID(id: string): Mesh;
  28758. /**
  28759. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28760. * @returns an array of IAnimatable
  28761. */
  28762. getAnimatables(): IAnimatable[];
  28763. /**
  28764. * Modifies the mesh geometry according to the passed transformation matrix.
  28765. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28766. * The mesh normals are modified using the same transformation.
  28767. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28768. * @param transform defines the transform matrix to use
  28769. * @see http://doc.babylonjs.com/resources/baking_transformations
  28770. * @returns the current mesh
  28771. */
  28772. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28773. /**
  28774. * Modifies the mesh geometry according to its own current World Matrix.
  28775. * The mesh World Matrix is then reset.
  28776. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28777. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28778. * @see http://doc.babylonjs.com/resources/baking_transformations
  28779. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28780. * @returns the current mesh
  28781. */
  28782. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28783. /** @hidden */
  28784. get _positions(): Nullable<Vector3[]>;
  28785. /** @hidden */
  28786. _resetPointsArrayCache(): Mesh;
  28787. /** @hidden */
  28788. _generatePointsArray(): boolean;
  28789. /**
  28790. * Returns a new Mesh object generated from the current mesh properties.
  28791. * This method must not get confused with createInstance()
  28792. * @param name is a string, the name given to the new mesh
  28793. * @param newParent can be any Node object (default `null`)
  28794. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28795. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28796. * @returns a new mesh
  28797. */
  28798. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28799. /**
  28800. * Releases resources associated with this mesh.
  28801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28803. */
  28804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28805. /** @hidden */
  28806. _disposeInstanceSpecificData(): void;
  28807. /** @hidden */
  28808. _disposeThinInstanceSpecificData(): void;
  28809. /**
  28810. * Modifies the mesh geometry according to a displacement map.
  28811. * 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.
  28812. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28813. * @param url is a string, the URL from the image file is to be downloaded.
  28814. * @param minHeight is the lower limit of the displacement.
  28815. * @param maxHeight is the upper limit of the displacement.
  28816. * @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.
  28817. * @param uvOffset is an optional vector2 used to offset UV.
  28818. * @param uvScale is an optional vector2 used to scale UV.
  28819. * @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.
  28820. * @returns the Mesh.
  28821. */
  28822. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28823. /**
  28824. * Modifies the mesh geometry according to a displacementMap buffer.
  28825. * 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.
  28826. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28827. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28828. * @param heightMapWidth is the width of the buffer image.
  28829. * @param heightMapHeight is the height of the buffer image.
  28830. * @param minHeight is the lower limit of the displacement.
  28831. * @param maxHeight is the upper limit of the displacement.
  28832. * @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.
  28833. * @param uvOffset is an optional vector2 used to offset UV.
  28834. * @param uvScale is an optional vector2 used to scale UV.
  28835. * @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.
  28836. * @returns the Mesh.
  28837. */
  28838. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28839. /**
  28840. * Modify the mesh to get a flat shading rendering.
  28841. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28842. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28843. * @returns current mesh
  28844. */
  28845. convertToFlatShadedMesh(): Mesh;
  28846. /**
  28847. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28848. * In other words, more vertices, no more indices and a single bigger VBO.
  28849. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28850. * @returns current mesh
  28851. */
  28852. convertToUnIndexedMesh(): Mesh;
  28853. /**
  28854. * Inverses facet orientations.
  28855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28856. * @param flipNormals will also inverts the normals
  28857. * @returns current mesh
  28858. */
  28859. flipFaces(flipNormals?: boolean): Mesh;
  28860. /**
  28861. * Increase the number of facets and hence vertices in a mesh
  28862. * Vertex normals are interpolated from existing vertex normals
  28863. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28864. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28865. */
  28866. increaseVertices(numberPerEdge: number): void;
  28867. /**
  28868. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28869. * This will undo any application of covertToFlatShadedMesh
  28870. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28871. */
  28872. forceSharedVertices(): void;
  28873. /** @hidden */
  28874. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28875. /** @hidden */
  28876. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28877. /**
  28878. * Creates a new InstancedMesh object from the mesh model.
  28879. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28880. * @param name defines the name of the new instance
  28881. * @returns a new InstancedMesh
  28882. */
  28883. createInstance(name: string): InstancedMesh;
  28884. /**
  28885. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28886. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28887. * @returns the current mesh
  28888. */
  28889. synchronizeInstances(): Mesh;
  28890. /**
  28891. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28892. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28893. * This should be used together with the simplification to avoid disappearing triangles.
  28894. * @param successCallback an optional success callback to be called after the optimization finished.
  28895. * @returns the current mesh
  28896. */
  28897. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28898. /**
  28899. * Serialize current mesh
  28900. * @param serializationObject defines the object which will receive the serialization data
  28901. */
  28902. serialize(serializationObject: any): void;
  28903. /** @hidden */
  28904. _syncGeometryWithMorphTargetManager(): void;
  28905. /** @hidden */
  28906. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28907. /**
  28908. * Returns a new Mesh object parsed from the source provided.
  28909. * @param parsedMesh is the source
  28910. * @param scene defines the hosting scene
  28911. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28912. * @returns a new Mesh
  28913. */
  28914. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28915. /**
  28916. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28917. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28918. * @param name defines the name of the mesh to create
  28919. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28920. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28921. * @param closePath creates a seam between the first and the last points of each path of the path array
  28922. * @param offset is taken in account only if the `pathArray` is containing a single path
  28923. * @param scene defines the hosting scene
  28924. * @param updatable defines if the mesh must be flagged as updatable
  28925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28926. * @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)
  28927. * @returns a new Mesh
  28928. */
  28929. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28930. /**
  28931. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28932. * @param name defines the name of the mesh to create
  28933. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28934. * @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
  28935. * @param scene defines the hosting scene
  28936. * @param updatable defines if the mesh must be flagged as updatable
  28937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28938. * @returns a new Mesh
  28939. */
  28940. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28941. /**
  28942. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28943. * @param name defines the name of the mesh to create
  28944. * @param size sets the size (float) of each box side (default 1)
  28945. * @param scene defines the hosting scene
  28946. * @param updatable defines if the mesh must be flagged as updatable
  28947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28948. * @returns a new Mesh
  28949. */
  28950. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28951. /**
  28952. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28953. * @param name defines the name of the mesh to create
  28954. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28955. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28956. * @param scene defines the hosting scene
  28957. * @param updatable defines if the mesh must be flagged as updatable
  28958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28959. * @returns a new Mesh
  28960. */
  28961. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28962. /**
  28963. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28964. * @param name defines the name of the mesh to create
  28965. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28966. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28967. * @param scene defines the hosting scene
  28968. * @returns a new Mesh
  28969. */
  28970. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28971. /**
  28972. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28973. * @param name defines the name of the mesh to create
  28974. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28975. * @param diameterTop set the top cap diameter (floats, default 1)
  28976. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28977. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28978. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28979. * @param scene defines the hosting scene
  28980. * @param updatable defines if the mesh must be flagged as updatable
  28981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28982. * @returns a new Mesh
  28983. */
  28984. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28985. /**
  28986. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28987. * @param name defines the name of the mesh to create
  28988. * @param diameter sets the diameter size (float) of the torus (default 1)
  28989. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28990. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28991. * @param scene defines the hosting scene
  28992. * @param updatable defines if the mesh must be flagged as updatable
  28993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28994. * @returns a new Mesh
  28995. */
  28996. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28997. /**
  28998. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28999. * @param name defines the name of the mesh to create
  29000. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29001. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29002. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29003. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29004. * @param p the number of windings on X axis (positive integers, default 2)
  29005. * @param q the number of windings on Y axis (positive integers, default 3)
  29006. * @param scene defines the hosting scene
  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. * @returns a new Mesh
  29010. */
  29011. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29012. /**
  29013. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29014. * @param name defines the name of the mesh to create
  29015. * @param points is an array successive Vector3
  29016. * @param scene defines the hosting scene
  29017. * @param updatable defines if the mesh must be flagged as updatable
  29018. * @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).
  29019. * @returns a new Mesh
  29020. */
  29021. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29022. /**
  29023. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29024. * @param name defines the name of the mesh to create
  29025. * @param points is an array successive Vector3
  29026. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29027. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29028. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29029. * @param scene defines the hosting scene
  29030. * @param updatable defines if the mesh must be flagged as updatable
  29031. * @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)
  29032. * @returns a new Mesh
  29033. */
  29034. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29035. /**
  29036. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29037. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29038. * 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.
  29039. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29040. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29041. * Remember you can only change the shape positions, not their number when updating a polygon.
  29042. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29043. * @param name defines the name of the mesh to create
  29044. * @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
  29045. * @param scene defines the hosting scene
  29046. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29047. * @param updatable defines if the mesh must be flagged as updatable
  29048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29049. * @param earcutInjection can be used to inject your own earcut reference
  29050. * @returns a new Mesh
  29051. */
  29052. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29053. /**
  29054. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29055. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29056. * @param name defines the name of the mesh to create
  29057. * @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
  29058. * @param depth defines the height of extrusion
  29059. * @param scene defines the hosting scene
  29060. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29061. * @param updatable defines if the mesh must be flagged as updatable
  29062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29063. * @param earcutInjection can be used to inject your own earcut reference
  29064. * @returns a new Mesh
  29065. */
  29066. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29067. /**
  29068. * Creates an extruded shape mesh.
  29069. * 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
  29070. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29072. * @param name defines the name of the mesh to create
  29073. * @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
  29074. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29075. * @param scale is the value to scale the shape
  29076. * @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
  29077. * @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
  29078. * @param scene defines the hosting scene
  29079. * @param updatable defines if the mesh must be flagged as updatable
  29080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29081. * @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)
  29082. * @returns a new Mesh
  29083. */
  29084. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29085. /**
  29086. * Creates an custom extruded shape mesh.
  29087. * The custom extrusion is a parametric shape.
  29088. * It has no predefined shape. Its final shape will depend on the input parameters.
  29089. * Please consider using the same method from the MeshBuilder class instead
  29090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29091. * @param name defines the name of the mesh to create
  29092. * @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
  29093. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29094. * @param scaleFunction is a custom Javascript function called on each path point
  29095. * @param rotationFunction is a custom Javascript function called on each path point
  29096. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29097. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29098. * @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
  29099. * @param scene defines the hosting scene
  29100. * @param updatable defines if the mesh must be flagged as updatable
  29101. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29102. * @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)
  29103. * @returns a new Mesh
  29104. */
  29105. 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;
  29106. /**
  29107. * Creates lathe mesh.
  29108. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29109. * Please consider using the same method from the MeshBuilder class instead
  29110. * @param name defines the name of the mesh to create
  29111. * @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
  29112. * @param radius is the radius value of the lathe
  29113. * @param tessellation is the side number of the lathe.
  29114. * @param scene defines the hosting scene
  29115. * @param updatable defines if the mesh must be flagged as updatable
  29116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29117. * @returns a new Mesh
  29118. */
  29119. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29120. /**
  29121. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29122. * @param name defines the name of the mesh to create
  29123. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29124. * @param scene defines the hosting scene
  29125. * @param updatable defines if the mesh must be flagged as updatable
  29126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29127. * @returns a new Mesh
  29128. */
  29129. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29130. /**
  29131. * Creates a ground mesh.
  29132. * Please consider using the same method from the MeshBuilder class instead
  29133. * @param name defines the name of the mesh to create
  29134. * @param width set the width of the ground
  29135. * @param height set the height of the ground
  29136. * @param subdivisions sets the number of subdivisions per side
  29137. * @param scene defines the hosting scene
  29138. * @param updatable defines if the mesh must be flagged as updatable
  29139. * @returns a new Mesh
  29140. */
  29141. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29142. /**
  29143. * Creates a tiled ground mesh.
  29144. * Please consider using the same method from the MeshBuilder class instead
  29145. * @param name defines the name of the mesh to create
  29146. * @param xmin set the ground minimum X coordinate
  29147. * @param zmin set the ground minimum Y coordinate
  29148. * @param xmax set the ground maximum X coordinate
  29149. * @param zmax set the ground maximum Z coordinate
  29150. * @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
  29151. * @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
  29152. * @param scene defines the hosting scene
  29153. * @param updatable defines if the mesh must be flagged as updatable
  29154. * @returns a new Mesh
  29155. */
  29156. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29157. w: number;
  29158. h: number;
  29159. }, precision: {
  29160. w: number;
  29161. h: number;
  29162. }, scene: Scene, updatable?: boolean): Mesh;
  29163. /**
  29164. * Creates a ground mesh from a height map.
  29165. * Please consider using the same method from the MeshBuilder class instead
  29166. * @see http://doc.babylonjs.com/babylon101/height_map
  29167. * @param name defines the name of the mesh to create
  29168. * @param url sets the URL of the height map image resource
  29169. * @param width set the ground width size
  29170. * @param height set the ground height size
  29171. * @param subdivisions sets the number of subdivision per side
  29172. * @param minHeight is the minimum altitude on the ground
  29173. * @param maxHeight is the maximum altitude on the ground
  29174. * @param scene defines the hosting scene
  29175. * @param updatable defines if the mesh must be flagged as updatable
  29176. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29177. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29178. * @returns a new Mesh
  29179. */
  29180. 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;
  29181. /**
  29182. * Creates a tube mesh.
  29183. * The tube is a parametric shape.
  29184. * It has no predefined shape. Its final shape will depend on the input parameters.
  29185. * Please consider using the same method from the MeshBuilder class instead
  29186. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29187. * @param name defines the name of the mesh to create
  29188. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29189. * @param radius sets the tube radius size
  29190. * @param tessellation is the number of sides on the tubular surface
  29191. * @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
  29192. * @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
  29193. * @param scene defines the hosting scene
  29194. * @param updatable defines if the mesh must be flagged as updatable
  29195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29196. * @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)
  29197. * @returns a new Mesh
  29198. */
  29199. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29200. (i: number, distance: number): number;
  29201. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29202. /**
  29203. * Creates a polyhedron mesh.
  29204. * Please consider using the same method from the MeshBuilder class instead.
  29205. * * 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
  29206. * * The parameter `size` (positive float, default 1) sets the polygon size
  29207. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29208. * * 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`
  29209. * * 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
  29210. * * 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)`)
  29211. * * 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
  29212. * * 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
  29213. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29214. * * If you create a double-sided mesh, you can choose what parts of 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
  29215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29216. * @param name defines the name of the mesh to create
  29217. * @param options defines the options used to create the mesh
  29218. * @param scene defines the hosting scene
  29219. * @returns a new Mesh
  29220. */
  29221. static CreatePolyhedron(name: string, options: {
  29222. type?: number;
  29223. size?: number;
  29224. sizeX?: number;
  29225. sizeY?: number;
  29226. sizeZ?: number;
  29227. custom?: any;
  29228. faceUV?: Vector4[];
  29229. faceColors?: Color4[];
  29230. updatable?: boolean;
  29231. sideOrientation?: number;
  29232. }, scene: Scene): Mesh;
  29233. /**
  29234. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29235. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29236. * * 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`)
  29237. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29238. * * 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
  29239. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29240. * * If you create a double-sided mesh, you can choose what parts of 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
  29241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29242. * @param name defines the name of the mesh
  29243. * @param options defines the options used to create the mesh
  29244. * @param scene defines the hosting scene
  29245. * @returns a new Mesh
  29246. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29247. */
  29248. static CreateIcoSphere(name: string, options: {
  29249. radius?: number;
  29250. flat?: boolean;
  29251. subdivisions?: number;
  29252. sideOrientation?: number;
  29253. updatable?: boolean;
  29254. }, scene: Scene): Mesh;
  29255. /**
  29256. * Creates a decal mesh.
  29257. * Please consider using the same method from the MeshBuilder class instead.
  29258. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29259. * @param name defines the name of the mesh
  29260. * @param sourceMesh defines the mesh receiving the decal
  29261. * @param position sets the position of the decal in world coordinates
  29262. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29263. * @param size sets the decal scaling
  29264. * @param angle sets the angle to rotate the decal
  29265. * @returns a new Mesh
  29266. */
  29267. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29268. /**
  29269. * Prepare internal position array for software CPU skinning
  29270. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29271. */
  29272. setPositionsForCPUSkinning(): Float32Array;
  29273. /**
  29274. * Prepare internal normal array for software CPU skinning
  29275. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29276. */
  29277. setNormalsForCPUSkinning(): Float32Array;
  29278. /**
  29279. * Updates the vertex buffer by applying transformation from the bones
  29280. * @param skeleton defines the skeleton to apply to current mesh
  29281. * @returns the current mesh
  29282. */
  29283. applySkeleton(skeleton: Skeleton): Mesh;
  29284. /**
  29285. * 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
  29286. * @param meshes defines the list of meshes to scan
  29287. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29288. */
  29289. static MinMax(meshes: AbstractMesh[]): {
  29290. min: Vector3;
  29291. max: Vector3;
  29292. };
  29293. /**
  29294. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29295. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29296. * @returns a vector3
  29297. */
  29298. static Center(meshesOrMinMaxVector: {
  29299. min: Vector3;
  29300. max: Vector3;
  29301. } | AbstractMesh[]): Vector3;
  29302. /**
  29303. * Merge the array of meshes into a single mesh for performance reasons.
  29304. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29305. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29306. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29307. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29308. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29309. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29310. * @returns a new mesh
  29311. */
  29312. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29313. /** @hidden */
  29314. addInstance(instance: InstancedMesh): void;
  29315. /** @hidden */
  29316. removeInstance(instance: InstancedMesh): void;
  29317. }
  29318. }
  29319. declare module "babylonjs/Cameras/camera" {
  29320. import { SmartArray } from "babylonjs/Misc/smartArray";
  29321. import { Observable } from "babylonjs/Misc/observable";
  29322. import { Nullable } from "babylonjs/types";
  29323. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29324. import { Scene } from "babylonjs/scene";
  29325. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29326. import { Node } from "babylonjs/node";
  29327. import { Mesh } from "babylonjs/Meshes/mesh";
  29328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29329. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29330. import { Viewport } from "babylonjs/Maths/math.viewport";
  29331. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29332. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29333. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29334. import { Ray } from "babylonjs/Culling/ray";
  29335. /**
  29336. * This is the base class of all the camera used in the application.
  29337. * @see http://doc.babylonjs.com/features/cameras
  29338. */
  29339. export class Camera extends Node {
  29340. /** @hidden */
  29341. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29342. /**
  29343. * This is the default projection mode used by the cameras.
  29344. * It helps recreating a feeling of perspective and better appreciate depth.
  29345. * This is the best way to simulate real life cameras.
  29346. */
  29347. static readonly PERSPECTIVE_CAMERA: number;
  29348. /**
  29349. * This helps creating camera with an orthographic mode.
  29350. * 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.
  29351. */
  29352. static readonly ORTHOGRAPHIC_CAMERA: number;
  29353. /**
  29354. * This is the default FOV mode for perspective cameras.
  29355. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29356. */
  29357. static readonly FOVMODE_VERTICAL_FIXED: number;
  29358. /**
  29359. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29360. */
  29361. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29362. /**
  29363. * This specifies ther is no need for a camera rig.
  29364. * Basically only one eye is rendered corresponding to the camera.
  29365. */
  29366. static readonly RIG_MODE_NONE: number;
  29367. /**
  29368. * Simulates a camera Rig with one blue eye and one red eye.
  29369. * This can be use with 3d blue and red glasses.
  29370. */
  29371. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29372. /**
  29373. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29374. */
  29375. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29376. /**
  29377. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29378. */
  29379. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29380. /**
  29381. * Defines that both eyes of the camera will be rendered over under each other.
  29382. */
  29383. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29384. /**
  29385. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29386. */
  29387. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29388. /**
  29389. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29390. */
  29391. static readonly RIG_MODE_VR: number;
  29392. /**
  29393. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29394. */
  29395. static readonly RIG_MODE_WEBVR: number;
  29396. /**
  29397. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29398. */
  29399. static readonly RIG_MODE_CUSTOM: number;
  29400. /**
  29401. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29402. */
  29403. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29404. /**
  29405. * Define the input manager associated with the camera.
  29406. */
  29407. inputs: CameraInputsManager<Camera>;
  29408. /** @hidden */
  29409. _position: Vector3;
  29410. /**
  29411. * Define the current local position of the camera in the scene
  29412. */
  29413. get position(): Vector3;
  29414. set position(newPosition: Vector3);
  29415. /**
  29416. * The vector the camera should consider as up.
  29417. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29418. */
  29419. upVector: Vector3;
  29420. /**
  29421. * Define the current limit on the left side for an orthographic camera
  29422. * In scene unit
  29423. */
  29424. orthoLeft: Nullable<number>;
  29425. /**
  29426. * Define the current limit on the right side for an orthographic camera
  29427. * In scene unit
  29428. */
  29429. orthoRight: Nullable<number>;
  29430. /**
  29431. * Define the current limit on the bottom side for an orthographic camera
  29432. * In scene unit
  29433. */
  29434. orthoBottom: Nullable<number>;
  29435. /**
  29436. * Define the current limit on the top side for an orthographic camera
  29437. * In scene unit
  29438. */
  29439. orthoTop: Nullable<number>;
  29440. /**
  29441. * Field Of View is set in Radians. (default is 0.8)
  29442. */
  29443. fov: number;
  29444. /**
  29445. * Define the minimum distance the camera can see from.
  29446. * This is important to note that the depth buffer are not infinite and the closer it starts
  29447. * the more your scene might encounter depth fighting issue.
  29448. */
  29449. minZ: number;
  29450. /**
  29451. * Define the maximum distance the camera can see to.
  29452. * This is important to note that the depth buffer are not infinite and the further it end
  29453. * the more your scene might encounter depth fighting issue.
  29454. */
  29455. maxZ: number;
  29456. /**
  29457. * Define the default inertia of the camera.
  29458. * This helps giving a smooth feeling to the camera movement.
  29459. */
  29460. inertia: number;
  29461. /**
  29462. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29463. */
  29464. mode: number;
  29465. /**
  29466. * Define whether the camera is intermediate.
  29467. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29468. */
  29469. isIntermediate: boolean;
  29470. /**
  29471. * Define the viewport of the camera.
  29472. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29473. */
  29474. viewport: Viewport;
  29475. /**
  29476. * Restricts the camera to viewing objects with the same layerMask.
  29477. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29478. */
  29479. layerMask: number;
  29480. /**
  29481. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29482. */
  29483. fovMode: number;
  29484. /**
  29485. * Rig mode of the camera.
  29486. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29487. * This is normally controlled byt the camera themselves as internal use.
  29488. */
  29489. cameraRigMode: number;
  29490. /**
  29491. * Defines the distance between both "eyes" in case of a RIG
  29492. */
  29493. interaxialDistance: number;
  29494. /**
  29495. * Defines if stereoscopic rendering is done side by side or over under.
  29496. */
  29497. isStereoscopicSideBySide: boolean;
  29498. /**
  29499. * 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
  29500. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29501. * else in the scene. (Eg. security camera)
  29502. *
  29503. * 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)
  29504. */
  29505. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29506. /**
  29507. * When set, the camera will render to this render target instead of the default canvas
  29508. *
  29509. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29510. */
  29511. outputRenderTarget: Nullable<RenderTargetTexture>;
  29512. /**
  29513. * Observable triggered when the camera view matrix has changed.
  29514. */
  29515. onViewMatrixChangedObservable: Observable<Camera>;
  29516. /**
  29517. * Observable triggered when the camera Projection matrix has changed.
  29518. */
  29519. onProjectionMatrixChangedObservable: Observable<Camera>;
  29520. /**
  29521. * Observable triggered when the inputs have been processed.
  29522. */
  29523. onAfterCheckInputsObservable: Observable<Camera>;
  29524. /**
  29525. * Observable triggered when reset has been called and applied to the camera.
  29526. */
  29527. onRestoreStateObservable: Observable<Camera>;
  29528. /**
  29529. * Is this camera a part of a rig system?
  29530. */
  29531. isRigCamera: boolean;
  29532. /**
  29533. * If isRigCamera set to true this will be set with the parent camera.
  29534. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29535. */
  29536. rigParent?: Camera;
  29537. /** @hidden */
  29538. _cameraRigParams: any;
  29539. /** @hidden */
  29540. _rigCameras: Camera[];
  29541. /** @hidden */
  29542. _rigPostProcess: Nullable<PostProcess>;
  29543. protected _webvrViewMatrix: Matrix;
  29544. /** @hidden */
  29545. _skipRendering: boolean;
  29546. /** @hidden */
  29547. _projectionMatrix: Matrix;
  29548. /** @hidden */
  29549. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29550. /** @hidden */
  29551. _activeMeshes: SmartArray<AbstractMesh>;
  29552. protected _globalPosition: Vector3;
  29553. /** @hidden */
  29554. _computedViewMatrix: Matrix;
  29555. private _doNotComputeProjectionMatrix;
  29556. private _transformMatrix;
  29557. private _frustumPlanes;
  29558. private _refreshFrustumPlanes;
  29559. private _storedFov;
  29560. private _stateStored;
  29561. /**
  29562. * Instantiates a new camera object.
  29563. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29564. * @see http://doc.babylonjs.com/features/cameras
  29565. * @param name Defines the name of the camera in the scene
  29566. * @param position Defines the position of the camera
  29567. * @param scene Defines the scene the camera belongs too
  29568. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29569. */
  29570. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29571. /**
  29572. * Store current camera state (fov, position, etc..)
  29573. * @returns the camera
  29574. */
  29575. storeState(): Camera;
  29576. /**
  29577. * Restores the camera state values if it has been stored. You must call storeState() first
  29578. */
  29579. protected _restoreStateValues(): boolean;
  29580. /**
  29581. * Restored camera state. You must call storeState() first.
  29582. * @returns true if restored and false otherwise
  29583. */
  29584. restoreState(): boolean;
  29585. /**
  29586. * Gets the class name of the camera.
  29587. * @returns the class name
  29588. */
  29589. getClassName(): string;
  29590. /** @hidden */
  29591. readonly _isCamera: boolean;
  29592. /**
  29593. * Gets a string representation of the camera useful for debug purpose.
  29594. * @param fullDetails Defines that a more verboe level of logging is required
  29595. * @returns the string representation
  29596. */
  29597. toString(fullDetails?: boolean): string;
  29598. /**
  29599. * Gets the current world space position of the camera.
  29600. */
  29601. get globalPosition(): Vector3;
  29602. /**
  29603. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29604. * @returns the active meshe list
  29605. */
  29606. getActiveMeshes(): SmartArray<AbstractMesh>;
  29607. /**
  29608. * Check whether a mesh is part of the current active mesh list of the camera
  29609. * @param mesh Defines the mesh to check
  29610. * @returns true if active, false otherwise
  29611. */
  29612. isActiveMesh(mesh: Mesh): boolean;
  29613. /**
  29614. * Is this camera ready to be used/rendered
  29615. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29616. * @return true if the camera is ready
  29617. */
  29618. isReady(completeCheck?: boolean): boolean;
  29619. /** @hidden */
  29620. _initCache(): void;
  29621. /** @hidden */
  29622. _updateCache(ignoreParentClass?: boolean): void;
  29623. /** @hidden */
  29624. _isSynchronized(): boolean;
  29625. /** @hidden */
  29626. _isSynchronizedViewMatrix(): boolean;
  29627. /** @hidden */
  29628. _isSynchronizedProjectionMatrix(): boolean;
  29629. /**
  29630. * Attach the input controls to a specific dom element to get the input from.
  29631. * @param element Defines the element the controls should be listened from
  29632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29633. */
  29634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29635. /**
  29636. * Detach the current controls from the specified dom element.
  29637. * @param element Defines the element to stop listening the inputs from
  29638. */
  29639. detachControl(element: HTMLElement): void;
  29640. /**
  29641. * Update the camera state according to the different inputs gathered during the frame.
  29642. */
  29643. update(): void;
  29644. /** @hidden */
  29645. _checkInputs(): void;
  29646. /** @hidden */
  29647. get rigCameras(): Camera[];
  29648. /**
  29649. * Gets the post process used by the rig cameras
  29650. */
  29651. get rigPostProcess(): Nullable<PostProcess>;
  29652. /**
  29653. * Internal, gets the first post proces.
  29654. * @returns the first post process to be run on this camera.
  29655. */
  29656. _getFirstPostProcess(): Nullable<PostProcess>;
  29657. private _cascadePostProcessesToRigCams;
  29658. /**
  29659. * Attach a post process to the camera.
  29660. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29661. * @param postProcess The post process to attach to the camera
  29662. * @param insertAt The position of the post process in case several of them are in use in the scene
  29663. * @returns the position the post process has been inserted at
  29664. */
  29665. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29666. /**
  29667. * Detach a post process to the camera.
  29668. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29669. * @param postProcess The post process to detach from the camera
  29670. */
  29671. detachPostProcess(postProcess: PostProcess): void;
  29672. /**
  29673. * Gets the current world matrix of the camera
  29674. */
  29675. getWorldMatrix(): Matrix;
  29676. /** @hidden */
  29677. _getViewMatrix(): Matrix;
  29678. /**
  29679. * Gets the current view matrix of the camera.
  29680. * @param force forces the camera to recompute the matrix without looking at the cached state
  29681. * @returns the view matrix
  29682. */
  29683. getViewMatrix(force?: boolean): Matrix;
  29684. /**
  29685. * Freeze the projection matrix.
  29686. * It will prevent the cache check of the camera projection compute and can speed up perf
  29687. * if no parameter of the camera are meant to change
  29688. * @param projection Defines manually a projection if necessary
  29689. */
  29690. freezeProjectionMatrix(projection?: Matrix): void;
  29691. /**
  29692. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29693. */
  29694. unfreezeProjectionMatrix(): void;
  29695. /**
  29696. * Gets the current projection matrix of the camera.
  29697. * @param force forces the camera to recompute the matrix without looking at the cached state
  29698. * @returns the projection matrix
  29699. */
  29700. getProjectionMatrix(force?: boolean): Matrix;
  29701. /**
  29702. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29703. * @returns a Matrix
  29704. */
  29705. getTransformationMatrix(): Matrix;
  29706. private _updateFrustumPlanes;
  29707. /**
  29708. * Checks if a cullable object (mesh...) is in the camera frustum
  29709. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29710. * @param target The object to check
  29711. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29712. * @returns true if the object is in frustum otherwise false
  29713. */
  29714. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29715. /**
  29716. * Checks if a cullable object (mesh...) is in the camera frustum
  29717. * Unlike isInFrustum this cheks the full bounding box
  29718. * @param target The object to check
  29719. * @returns true if the object is in frustum otherwise false
  29720. */
  29721. isCompletelyInFrustum(target: ICullable): boolean;
  29722. /**
  29723. * Gets a ray in the forward direction from the camera.
  29724. * @param length Defines the length of the ray to create
  29725. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29726. * @param origin Defines the start point of the ray which defaults to the camera position
  29727. * @returns the forward ray
  29728. */
  29729. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29730. /**
  29731. * Releases resources associated with this node.
  29732. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29733. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29734. */
  29735. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29736. /** @hidden */
  29737. _isLeftCamera: boolean;
  29738. /**
  29739. * Gets the left camera of a rig setup in case of Rigged Camera
  29740. */
  29741. get isLeftCamera(): boolean;
  29742. /** @hidden */
  29743. _isRightCamera: boolean;
  29744. /**
  29745. * Gets the right camera of a rig setup in case of Rigged Camera
  29746. */
  29747. get isRightCamera(): boolean;
  29748. /**
  29749. * Gets the left camera of a rig setup in case of Rigged Camera
  29750. */
  29751. get leftCamera(): Nullable<FreeCamera>;
  29752. /**
  29753. * Gets the right camera of a rig setup in case of Rigged Camera
  29754. */
  29755. get rightCamera(): Nullable<FreeCamera>;
  29756. /**
  29757. * Gets the left camera target of a rig setup in case of Rigged Camera
  29758. * @returns the target position
  29759. */
  29760. getLeftTarget(): Nullable<Vector3>;
  29761. /**
  29762. * Gets the right camera target of a rig setup in case of Rigged Camera
  29763. * @returns the target position
  29764. */
  29765. getRightTarget(): Nullable<Vector3>;
  29766. /**
  29767. * @hidden
  29768. */
  29769. setCameraRigMode(mode: number, rigParams: any): void;
  29770. /** @hidden */
  29771. static _setStereoscopicRigMode(camera: Camera): void;
  29772. /** @hidden */
  29773. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29774. /** @hidden */
  29775. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29776. /** @hidden */
  29777. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29778. /** @hidden */
  29779. _getVRProjectionMatrix(): Matrix;
  29780. protected _updateCameraRotationMatrix(): void;
  29781. protected _updateWebVRCameraRotationMatrix(): void;
  29782. /**
  29783. * This function MUST be overwritten by the different WebVR cameras available.
  29784. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29785. * @hidden
  29786. */
  29787. _getWebVRProjectionMatrix(): Matrix;
  29788. /**
  29789. * This function MUST be overwritten by the different WebVR cameras available.
  29790. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29791. * @hidden
  29792. */
  29793. _getWebVRViewMatrix(): Matrix;
  29794. /** @hidden */
  29795. setCameraRigParameter(name: string, value: any): void;
  29796. /**
  29797. * needs to be overridden by children so sub has required properties to be copied
  29798. * @hidden
  29799. */
  29800. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29801. /**
  29802. * May need to be overridden by children
  29803. * @hidden
  29804. */
  29805. _updateRigCameras(): void;
  29806. /** @hidden */
  29807. _setupInputs(): void;
  29808. /**
  29809. * Serialiaze the camera setup to a json represention
  29810. * @returns the JSON representation
  29811. */
  29812. serialize(): any;
  29813. /**
  29814. * Clones the current camera.
  29815. * @param name The cloned camera name
  29816. * @returns the cloned camera
  29817. */
  29818. clone(name: string): Camera;
  29819. /**
  29820. * Gets the direction of the camera relative to a given local axis.
  29821. * @param localAxis Defines the reference axis to provide a relative direction.
  29822. * @return the direction
  29823. */
  29824. getDirection(localAxis: Vector3): Vector3;
  29825. /**
  29826. * Returns the current camera absolute rotation
  29827. */
  29828. get absoluteRotation(): Quaternion;
  29829. /**
  29830. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29831. * @param localAxis Defines the reference axis to provide a relative direction.
  29832. * @param result Defines the vector to store the result in
  29833. */
  29834. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29835. /**
  29836. * Gets a camera constructor for a given camera type
  29837. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29838. * @param name The name of the camera the result will be able to instantiate
  29839. * @param scene The scene the result will construct the camera in
  29840. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29841. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29842. * @returns a factory method to construc the camera
  29843. */
  29844. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29845. /**
  29846. * Compute the world matrix of the camera.
  29847. * @returns the camera world matrix
  29848. */
  29849. computeWorldMatrix(): Matrix;
  29850. /**
  29851. * Parse a JSON and creates the camera from the parsed information
  29852. * @param parsedCamera The JSON to parse
  29853. * @param scene The scene to instantiate the camera in
  29854. * @returns the newly constructed camera
  29855. */
  29856. static Parse(parsedCamera: any, scene: Scene): Camera;
  29857. }
  29858. }
  29859. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29860. import { Nullable } from "babylonjs/types";
  29861. import { Scene } from "babylonjs/scene";
  29862. import { Vector4 } from "babylonjs/Maths/math.vector";
  29863. import { Mesh } from "babylonjs/Meshes/mesh";
  29864. /**
  29865. * Class containing static functions to help procedurally build meshes
  29866. */
  29867. export class DiscBuilder {
  29868. /**
  29869. * Creates a plane polygonal mesh. By default, this is a disc
  29870. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29871. * * 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
  29872. * * 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
  29873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29876. * @param name defines the name of the mesh
  29877. * @param options defines the options used to create the mesh
  29878. * @param scene defines the hosting scene
  29879. * @returns the plane polygonal mesh
  29880. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29881. */
  29882. static CreateDisc(name: string, options: {
  29883. radius?: number;
  29884. tessellation?: number;
  29885. arc?: number;
  29886. updatable?: boolean;
  29887. sideOrientation?: number;
  29888. frontUVs?: Vector4;
  29889. backUVs?: Vector4;
  29890. }, scene?: Nullable<Scene>): Mesh;
  29891. }
  29892. }
  29893. declare module "babylonjs/Materials/fresnelParameters" {
  29894. import { DeepImmutable } from "babylonjs/types";
  29895. import { Color3 } from "babylonjs/Maths/math.color";
  29896. /**
  29897. * Options to be used when creating a FresnelParameters.
  29898. */
  29899. export type IFresnelParametersCreationOptions = {
  29900. /**
  29901. * Define the color used on edges (grazing angle)
  29902. */
  29903. leftColor?: Color3;
  29904. /**
  29905. * Define the color used on center
  29906. */
  29907. rightColor?: Color3;
  29908. /**
  29909. * Define bias applied to computed fresnel term
  29910. */
  29911. bias?: number;
  29912. /**
  29913. * Defined the power exponent applied to fresnel term
  29914. */
  29915. power?: number;
  29916. /**
  29917. * Define if the fresnel effect is enable or not.
  29918. */
  29919. isEnabled?: boolean;
  29920. };
  29921. /**
  29922. * Serialized format for FresnelParameters.
  29923. */
  29924. export type IFresnelParametersSerialized = {
  29925. /**
  29926. * Define the color used on edges (grazing angle) [as an array]
  29927. */
  29928. leftColor: number[];
  29929. /**
  29930. * Define the color used on center [as an array]
  29931. */
  29932. rightColor: number[];
  29933. /**
  29934. * Define bias applied to computed fresnel term
  29935. */
  29936. bias: number;
  29937. /**
  29938. * Defined the power exponent applied to fresnel term
  29939. */
  29940. power?: number;
  29941. /**
  29942. * Define if the fresnel effect is enable or not.
  29943. */
  29944. isEnabled: boolean;
  29945. };
  29946. /**
  29947. * This represents all the required information to add a fresnel effect on a material:
  29948. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29949. */
  29950. export class FresnelParameters {
  29951. private _isEnabled;
  29952. /**
  29953. * Define if the fresnel effect is enable or not.
  29954. */
  29955. get isEnabled(): boolean;
  29956. set isEnabled(value: boolean);
  29957. /**
  29958. * Define the color used on edges (grazing angle)
  29959. */
  29960. leftColor: Color3;
  29961. /**
  29962. * Define the color used on center
  29963. */
  29964. rightColor: Color3;
  29965. /**
  29966. * Define bias applied to computed fresnel term
  29967. */
  29968. bias: number;
  29969. /**
  29970. * Defined the power exponent applied to fresnel term
  29971. */
  29972. power: number;
  29973. /**
  29974. * Creates a new FresnelParameters object.
  29975. *
  29976. * @param options provide your own settings to optionally to override defaults
  29977. */
  29978. constructor(options?: IFresnelParametersCreationOptions);
  29979. /**
  29980. * Clones the current fresnel and its valuues
  29981. * @returns a clone fresnel configuration
  29982. */
  29983. clone(): FresnelParameters;
  29984. /**
  29985. * Determines equality between FresnelParameters objects
  29986. * @param otherFresnelParameters defines the second operand
  29987. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29988. */
  29989. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29990. /**
  29991. * Serializes the current fresnel parameters to a JSON representation.
  29992. * @return the JSON serialization
  29993. */
  29994. serialize(): IFresnelParametersSerialized;
  29995. /**
  29996. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29997. * @param parsedFresnelParameters Define the JSON representation
  29998. * @returns the parsed parameters
  29999. */
  30000. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30001. }
  30002. }
  30003. declare module "babylonjs/Materials/materialFlags" {
  30004. /**
  30005. * This groups all the flags used to control the materials channel.
  30006. */
  30007. export class MaterialFlags {
  30008. private static _DiffuseTextureEnabled;
  30009. /**
  30010. * Are diffuse textures enabled in the application.
  30011. */
  30012. static get DiffuseTextureEnabled(): boolean;
  30013. static set DiffuseTextureEnabled(value: boolean);
  30014. private static _AmbientTextureEnabled;
  30015. /**
  30016. * Are ambient textures enabled in the application.
  30017. */
  30018. static get AmbientTextureEnabled(): boolean;
  30019. static set AmbientTextureEnabled(value: boolean);
  30020. private static _OpacityTextureEnabled;
  30021. /**
  30022. * Are opacity textures enabled in the application.
  30023. */
  30024. static get OpacityTextureEnabled(): boolean;
  30025. static set OpacityTextureEnabled(value: boolean);
  30026. private static _ReflectionTextureEnabled;
  30027. /**
  30028. * Are reflection textures enabled in the application.
  30029. */
  30030. static get ReflectionTextureEnabled(): boolean;
  30031. static set ReflectionTextureEnabled(value: boolean);
  30032. private static _EmissiveTextureEnabled;
  30033. /**
  30034. * Are emissive textures enabled in the application.
  30035. */
  30036. static get EmissiveTextureEnabled(): boolean;
  30037. static set EmissiveTextureEnabled(value: boolean);
  30038. private static _SpecularTextureEnabled;
  30039. /**
  30040. * Are specular textures enabled in the application.
  30041. */
  30042. static get SpecularTextureEnabled(): boolean;
  30043. static set SpecularTextureEnabled(value: boolean);
  30044. private static _BumpTextureEnabled;
  30045. /**
  30046. * Are bump textures enabled in the application.
  30047. */
  30048. static get BumpTextureEnabled(): boolean;
  30049. static set BumpTextureEnabled(value: boolean);
  30050. private static _LightmapTextureEnabled;
  30051. /**
  30052. * Are lightmap textures enabled in the application.
  30053. */
  30054. static get LightmapTextureEnabled(): boolean;
  30055. static set LightmapTextureEnabled(value: boolean);
  30056. private static _RefractionTextureEnabled;
  30057. /**
  30058. * Are refraction textures enabled in the application.
  30059. */
  30060. static get RefractionTextureEnabled(): boolean;
  30061. static set RefractionTextureEnabled(value: boolean);
  30062. private static _ColorGradingTextureEnabled;
  30063. /**
  30064. * Are color grading textures enabled in the application.
  30065. */
  30066. static get ColorGradingTextureEnabled(): boolean;
  30067. static set ColorGradingTextureEnabled(value: boolean);
  30068. private static _FresnelEnabled;
  30069. /**
  30070. * Are fresnels enabled in the application.
  30071. */
  30072. static get FresnelEnabled(): boolean;
  30073. static set FresnelEnabled(value: boolean);
  30074. private static _ClearCoatTextureEnabled;
  30075. /**
  30076. * Are clear coat textures enabled in the application.
  30077. */
  30078. static get ClearCoatTextureEnabled(): boolean;
  30079. static set ClearCoatTextureEnabled(value: boolean);
  30080. private static _ClearCoatBumpTextureEnabled;
  30081. /**
  30082. * Are clear coat bump textures enabled in the application.
  30083. */
  30084. static get ClearCoatBumpTextureEnabled(): boolean;
  30085. static set ClearCoatBumpTextureEnabled(value: boolean);
  30086. private static _ClearCoatTintTextureEnabled;
  30087. /**
  30088. * Are clear coat tint textures enabled in the application.
  30089. */
  30090. static get ClearCoatTintTextureEnabled(): boolean;
  30091. static set ClearCoatTintTextureEnabled(value: boolean);
  30092. private static _SheenTextureEnabled;
  30093. /**
  30094. * Are sheen textures enabled in the application.
  30095. */
  30096. static get SheenTextureEnabled(): boolean;
  30097. static set SheenTextureEnabled(value: boolean);
  30098. private static _AnisotropicTextureEnabled;
  30099. /**
  30100. * Are anisotropic textures enabled in the application.
  30101. */
  30102. static get AnisotropicTextureEnabled(): boolean;
  30103. static set AnisotropicTextureEnabled(value: boolean);
  30104. private static _ThicknessTextureEnabled;
  30105. /**
  30106. * Are thickness textures enabled in the application.
  30107. */
  30108. static get ThicknessTextureEnabled(): boolean;
  30109. static set ThicknessTextureEnabled(value: boolean);
  30110. }
  30111. }
  30112. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30113. /** @hidden */
  30114. export var defaultFragmentDeclaration: {
  30115. name: string;
  30116. shader: string;
  30117. };
  30118. }
  30119. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30120. /** @hidden */
  30121. export var defaultUboDeclaration: {
  30122. name: string;
  30123. shader: string;
  30124. };
  30125. }
  30126. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30127. /** @hidden */
  30128. export var lightFragmentDeclaration: {
  30129. name: string;
  30130. shader: string;
  30131. };
  30132. }
  30133. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30134. /** @hidden */
  30135. export var lightUboDeclaration: {
  30136. name: string;
  30137. shader: string;
  30138. };
  30139. }
  30140. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30141. /** @hidden */
  30142. export var lightsFragmentFunctions: {
  30143. name: string;
  30144. shader: string;
  30145. };
  30146. }
  30147. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30148. /** @hidden */
  30149. export var shadowsFragmentFunctions: {
  30150. name: string;
  30151. shader: string;
  30152. };
  30153. }
  30154. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30155. /** @hidden */
  30156. export var fresnelFunction: {
  30157. name: string;
  30158. shader: string;
  30159. };
  30160. }
  30161. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30162. /** @hidden */
  30163. export var bumpFragmentMainFunctions: {
  30164. name: string;
  30165. shader: string;
  30166. };
  30167. }
  30168. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30169. /** @hidden */
  30170. export var bumpFragmentFunctions: {
  30171. name: string;
  30172. shader: string;
  30173. };
  30174. }
  30175. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30176. /** @hidden */
  30177. export var logDepthDeclaration: {
  30178. name: string;
  30179. shader: string;
  30180. };
  30181. }
  30182. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30183. /** @hidden */
  30184. export var bumpFragment: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30190. /** @hidden */
  30191. export var depthPrePass: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30197. /** @hidden */
  30198. export var lightFragment: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30204. /** @hidden */
  30205. export var logDepthFragment: {
  30206. name: string;
  30207. shader: string;
  30208. };
  30209. }
  30210. declare module "babylonjs/Shaders/default.fragment" {
  30211. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30212. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30213. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30214. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30215. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30216. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30217. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30218. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30219. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30220. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30221. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30222. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30223. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30224. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30225. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30226. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30227. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30228. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30229. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30230. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30231. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30232. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30233. /** @hidden */
  30234. export var defaultPixelShader: {
  30235. name: string;
  30236. shader: string;
  30237. };
  30238. }
  30239. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30240. /** @hidden */
  30241. export var defaultVertexDeclaration: {
  30242. name: string;
  30243. shader: string;
  30244. };
  30245. }
  30246. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30247. /** @hidden */
  30248. export var bumpVertexDeclaration: {
  30249. name: string;
  30250. shader: string;
  30251. };
  30252. }
  30253. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30254. /** @hidden */
  30255. export var bumpVertex: {
  30256. name: string;
  30257. shader: string;
  30258. };
  30259. }
  30260. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30261. /** @hidden */
  30262. export var fogVertex: {
  30263. name: string;
  30264. shader: string;
  30265. };
  30266. }
  30267. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30268. /** @hidden */
  30269. export var shadowsVertex: {
  30270. name: string;
  30271. shader: string;
  30272. };
  30273. }
  30274. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30275. /** @hidden */
  30276. export var pointCloudVertex: {
  30277. name: string;
  30278. shader: string;
  30279. };
  30280. }
  30281. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30282. /** @hidden */
  30283. export var logDepthVertex: {
  30284. name: string;
  30285. shader: string;
  30286. };
  30287. }
  30288. declare module "babylonjs/Shaders/default.vertex" {
  30289. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30292. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30297. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30298. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30299. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30301. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30302. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30303. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30304. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30305. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30306. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30307. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30308. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30309. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30310. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30311. /** @hidden */
  30312. export var defaultVertexShader: {
  30313. name: string;
  30314. shader: string;
  30315. };
  30316. }
  30317. declare module "babylonjs/Materials/standardMaterial" {
  30318. import { SmartArray } from "babylonjs/Misc/smartArray";
  30319. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30320. import { Nullable } from "babylonjs/types";
  30321. import { Scene } from "babylonjs/scene";
  30322. import { Matrix } from "babylonjs/Maths/math.vector";
  30323. import { Color3 } from "babylonjs/Maths/math.color";
  30324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30326. import { Mesh } from "babylonjs/Meshes/mesh";
  30327. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30328. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30329. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30330. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30331. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30333. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30334. import "babylonjs/Shaders/default.fragment";
  30335. import "babylonjs/Shaders/default.vertex";
  30336. /** @hidden */
  30337. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30338. MAINUV1: boolean;
  30339. MAINUV2: boolean;
  30340. DIFFUSE: boolean;
  30341. DIFFUSEDIRECTUV: number;
  30342. AMBIENT: boolean;
  30343. AMBIENTDIRECTUV: number;
  30344. OPACITY: boolean;
  30345. OPACITYDIRECTUV: number;
  30346. OPACITYRGB: boolean;
  30347. REFLECTION: boolean;
  30348. EMISSIVE: boolean;
  30349. EMISSIVEDIRECTUV: number;
  30350. SPECULAR: boolean;
  30351. SPECULARDIRECTUV: number;
  30352. BUMP: boolean;
  30353. BUMPDIRECTUV: number;
  30354. PARALLAX: boolean;
  30355. PARALLAXOCCLUSION: boolean;
  30356. SPECULAROVERALPHA: boolean;
  30357. CLIPPLANE: boolean;
  30358. CLIPPLANE2: boolean;
  30359. CLIPPLANE3: boolean;
  30360. CLIPPLANE4: boolean;
  30361. CLIPPLANE5: boolean;
  30362. CLIPPLANE6: boolean;
  30363. ALPHATEST: boolean;
  30364. DEPTHPREPASS: boolean;
  30365. ALPHAFROMDIFFUSE: boolean;
  30366. POINTSIZE: boolean;
  30367. FOG: boolean;
  30368. SPECULARTERM: boolean;
  30369. DIFFUSEFRESNEL: boolean;
  30370. OPACITYFRESNEL: boolean;
  30371. REFLECTIONFRESNEL: boolean;
  30372. REFRACTIONFRESNEL: boolean;
  30373. EMISSIVEFRESNEL: boolean;
  30374. FRESNEL: boolean;
  30375. NORMAL: boolean;
  30376. UV1: boolean;
  30377. UV2: boolean;
  30378. VERTEXCOLOR: boolean;
  30379. VERTEXALPHA: boolean;
  30380. NUM_BONE_INFLUENCERS: number;
  30381. BonesPerMesh: number;
  30382. BONETEXTURE: boolean;
  30383. INSTANCES: boolean;
  30384. THIN_INSTANCES: boolean;
  30385. GLOSSINESS: boolean;
  30386. ROUGHNESS: boolean;
  30387. EMISSIVEASILLUMINATION: boolean;
  30388. LINKEMISSIVEWITHDIFFUSE: boolean;
  30389. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30390. LIGHTMAP: boolean;
  30391. LIGHTMAPDIRECTUV: number;
  30392. OBJECTSPACE_NORMALMAP: boolean;
  30393. USELIGHTMAPASSHADOWMAP: boolean;
  30394. REFLECTIONMAP_3D: boolean;
  30395. REFLECTIONMAP_SPHERICAL: boolean;
  30396. REFLECTIONMAP_PLANAR: boolean;
  30397. REFLECTIONMAP_CUBIC: boolean;
  30398. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30399. REFLECTIONMAP_PROJECTION: boolean;
  30400. REFLECTIONMAP_SKYBOX: boolean;
  30401. REFLECTIONMAP_EXPLICIT: boolean;
  30402. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30403. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30404. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30405. INVERTCUBICMAP: boolean;
  30406. LOGARITHMICDEPTH: boolean;
  30407. REFRACTION: boolean;
  30408. REFRACTIONMAP_3D: boolean;
  30409. REFLECTIONOVERALPHA: boolean;
  30410. TWOSIDEDLIGHTING: boolean;
  30411. SHADOWFLOAT: boolean;
  30412. MORPHTARGETS: boolean;
  30413. MORPHTARGETS_NORMAL: boolean;
  30414. MORPHTARGETS_TANGENT: boolean;
  30415. MORPHTARGETS_UV: boolean;
  30416. NUM_MORPH_INFLUENCERS: number;
  30417. NONUNIFORMSCALING: boolean;
  30418. PREMULTIPLYALPHA: boolean;
  30419. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30420. ALPHABLEND: boolean;
  30421. RGBDLIGHTMAP: boolean;
  30422. RGBDREFLECTION: boolean;
  30423. RGBDREFRACTION: boolean;
  30424. IMAGEPROCESSING: boolean;
  30425. VIGNETTE: boolean;
  30426. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30427. VIGNETTEBLENDMODEOPAQUE: boolean;
  30428. TONEMAPPING: boolean;
  30429. TONEMAPPING_ACES: boolean;
  30430. CONTRAST: boolean;
  30431. COLORCURVES: boolean;
  30432. COLORGRADING: boolean;
  30433. COLORGRADING3D: boolean;
  30434. SAMPLER3DGREENDEPTH: boolean;
  30435. SAMPLER3DBGRMAP: boolean;
  30436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30437. MULTIVIEW: boolean;
  30438. /**
  30439. * If the reflection texture on this material is in linear color space
  30440. * @hidden
  30441. */
  30442. IS_REFLECTION_LINEAR: boolean;
  30443. /**
  30444. * If the refraction texture on this material is in linear color space
  30445. * @hidden
  30446. */
  30447. IS_REFRACTION_LINEAR: boolean;
  30448. EXPOSURE: boolean;
  30449. constructor();
  30450. setReflectionMode(modeToEnable: string): void;
  30451. }
  30452. /**
  30453. * This is the default material used in Babylon. It is the best trade off between quality
  30454. * and performances.
  30455. * @see http://doc.babylonjs.com/babylon101/materials
  30456. */
  30457. export class StandardMaterial extends PushMaterial {
  30458. private _diffuseTexture;
  30459. /**
  30460. * The basic texture of the material as viewed under a light.
  30461. */
  30462. diffuseTexture: Nullable<BaseTexture>;
  30463. private _ambientTexture;
  30464. /**
  30465. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30466. */
  30467. ambientTexture: Nullable<BaseTexture>;
  30468. private _opacityTexture;
  30469. /**
  30470. * Define the transparency of the material from a texture.
  30471. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30472. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30473. */
  30474. opacityTexture: Nullable<BaseTexture>;
  30475. private _reflectionTexture;
  30476. /**
  30477. * Define the texture used to display the reflection.
  30478. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30479. */
  30480. reflectionTexture: Nullable<BaseTexture>;
  30481. private _emissiveTexture;
  30482. /**
  30483. * Define texture of the material as if self lit.
  30484. * This will be mixed in the final result even in the absence of light.
  30485. */
  30486. emissiveTexture: Nullable<BaseTexture>;
  30487. private _specularTexture;
  30488. /**
  30489. * Define how the color and intensity of the highlight given by the light in the material.
  30490. */
  30491. specularTexture: Nullable<BaseTexture>;
  30492. private _bumpTexture;
  30493. /**
  30494. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30495. * 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.
  30496. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30497. */
  30498. bumpTexture: Nullable<BaseTexture>;
  30499. private _lightmapTexture;
  30500. /**
  30501. * Complex lighting can be computationally expensive to compute at runtime.
  30502. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30503. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30504. */
  30505. lightmapTexture: Nullable<BaseTexture>;
  30506. private _refractionTexture;
  30507. /**
  30508. * Define the texture used to display the refraction.
  30509. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30510. */
  30511. refractionTexture: Nullable<BaseTexture>;
  30512. /**
  30513. * The color of the material lit by the environmental background lighting.
  30514. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30515. */
  30516. ambientColor: Color3;
  30517. /**
  30518. * The basic color of the material as viewed under a light.
  30519. */
  30520. diffuseColor: Color3;
  30521. /**
  30522. * Define how the color and intensity of the highlight given by the light in the material.
  30523. */
  30524. specularColor: Color3;
  30525. /**
  30526. * Define the color of the material as if self lit.
  30527. * This will be mixed in the final result even in the absence of light.
  30528. */
  30529. emissiveColor: Color3;
  30530. /**
  30531. * Defines how sharp are the highlights in the material.
  30532. * The bigger the value the sharper giving a more glossy feeling to the result.
  30533. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30534. */
  30535. specularPower: number;
  30536. private _useAlphaFromDiffuseTexture;
  30537. /**
  30538. * Does the transparency come from the diffuse texture alpha channel.
  30539. */
  30540. useAlphaFromDiffuseTexture: boolean;
  30541. private _useEmissiveAsIllumination;
  30542. /**
  30543. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30544. */
  30545. useEmissiveAsIllumination: boolean;
  30546. private _linkEmissiveWithDiffuse;
  30547. /**
  30548. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30549. * the emissive level when the final color is close to one.
  30550. */
  30551. linkEmissiveWithDiffuse: boolean;
  30552. private _useSpecularOverAlpha;
  30553. /**
  30554. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30555. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30556. */
  30557. useSpecularOverAlpha: boolean;
  30558. private _useReflectionOverAlpha;
  30559. /**
  30560. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30561. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30562. */
  30563. useReflectionOverAlpha: boolean;
  30564. private _disableLighting;
  30565. /**
  30566. * Does lights from the scene impacts this material.
  30567. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30568. */
  30569. disableLighting: boolean;
  30570. private _useObjectSpaceNormalMap;
  30571. /**
  30572. * Allows using an object space normal map (instead of tangent space).
  30573. */
  30574. useObjectSpaceNormalMap: boolean;
  30575. private _useParallax;
  30576. /**
  30577. * Is parallax enabled or not.
  30578. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30579. */
  30580. useParallax: boolean;
  30581. private _useParallaxOcclusion;
  30582. /**
  30583. * Is parallax occlusion enabled or not.
  30584. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30585. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30586. */
  30587. useParallaxOcclusion: boolean;
  30588. /**
  30589. * 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.
  30590. */
  30591. parallaxScaleBias: number;
  30592. private _roughness;
  30593. /**
  30594. * Helps to define how blurry the reflections should appears in the material.
  30595. */
  30596. roughness: number;
  30597. /**
  30598. * In case of refraction, define the value of the index of refraction.
  30599. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30600. */
  30601. indexOfRefraction: number;
  30602. /**
  30603. * Invert the refraction texture alongside the y axis.
  30604. * It can be useful with procedural textures or probe for instance.
  30605. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30606. */
  30607. invertRefractionY: boolean;
  30608. /**
  30609. * Defines the alpha limits in alpha test mode.
  30610. */
  30611. alphaCutOff: number;
  30612. private _useLightmapAsShadowmap;
  30613. /**
  30614. * In case of light mapping, define whether the map contains light or shadow informations.
  30615. */
  30616. useLightmapAsShadowmap: boolean;
  30617. private _diffuseFresnelParameters;
  30618. /**
  30619. * Define the diffuse fresnel parameters of the material.
  30620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30621. */
  30622. diffuseFresnelParameters: FresnelParameters;
  30623. private _opacityFresnelParameters;
  30624. /**
  30625. * Define the opacity fresnel parameters of the material.
  30626. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30627. */
  30628. opacityFresnelParameters: FresnelParameters;
  30629. private _reflectionFresnelParameters;
  30630. /**
  30631. * Define the reflection fresnel parameters of the material.
  30632. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30633. */
  30634. reflectionFresnelParameters: FresnelParameters;
  30635. private _refractionFresnelParameters;
  30636. /**
  30637. * Define the refraction fresnel parameters of the material.
  30638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30639. */
  30640. refractionFresnelParameters: FresnelParameters;
  30641. private _emissiveFresnelParameters;
  30642. /**
  30643. * Define the emissive fresnel parameters of the material.
  30644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30645. */
  30646. emissiveFresnelParameters: FresnelParameters;
  30647. private _useReflectionFresnelFromSpecular;
  30648. /**
  30649. * If true automatically deducts the fresnels values from the material specularity.
  30650. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30651. */
  30652. useReflectionFresnelFromSpecular: boolean;
  30653. private _useGlossinessFromSpecularMapAlpha;
  30654. /**
  30655. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30656. */
  30657. useGlossinessFromSpecularMapAlpha: boolean;
  30658. private _maxSimultaneousLights;
  30659. /**
  30660. * Defines the maximum number of lights that can be used in the material
  30661. */
  30662. maxSimultaneousLights: number;
  30663. private _invertNormalMapX;
  30664. /**
  30665. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30666. */
  30667. invertNormalMapX: boolean;
  30668. private _invertNormalMapY;
  30669. /**
  30670. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30671. */
  30672. invertNormalMapY: boolean;
  30673. private _twoSidedLighting;
  30674. /**
  30675. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30676. */
  30677. twoSidedLighting: boolean;
  30678. /**
  30679. * Default configuration related to image processing available in the standard Material.
  30680. */
  30681. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30682. /**
  30683. * Gets the image processing configuration used either in this material.
  30684. */
  30685. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30686. /**
  30687. * Sets the Default image processing configuration used either in the this material.
  30688. *
  30689. * If sets to null, the scene one is in use.
  30690. */
  30691. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30692. /**
  30693. * Keep track of the image processing observer to allow dispose and replace.
  30694. */
  30695. private _imageProcessingObserver;
  30696. /**
  30697. * Attaches a new image processing configuration to the Standard Material.
  30698. * @param configuration
  30699. */
  30700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30701. /**
  30702. * Gets wether the color curves effect is enabled.
  30703. */
  30704. get cameraColorCurvesEnabled(): boolean;
  30705. /**
  30706. * Sets wether the color curves effect is enabled.
  30707. */
  30708. set cameraColorCurvesEnabled(value: boolean);
  30709. /**
  30710. * Gets wether the color grading effect is enabled.
  30711. */
  30712. get cameraColorGradingEnabled(): boolean;
  30713. /**
  30714. * Gets wether the color grading effect is enabled.
  30715. */
  30716. set cameraColorGradingEnabled(value: boolean);
  30717. /**
  30718. * Gets wether tonemapping is enabled or not.
  30719. */
  30720. get cameraToneMappingEnabled(): boolean;
  30721. /**
  30722. * Sets wether tonemapping is enabled or not
  30723. */
  30724. set cameraToneMappingEnabled(value: boolean);
  30725. /**
  30726. * The camera exposure used on this material.
  30727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30728. * This corresponds to a photographic exposure.
  30729. */
  30730. get cameraExposure(): number;
  30731. /**
  30732. * The camera exposure used on this material.
  30733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30734. * This corresponds to a photographic exposure.
  30735. */
  30736. set cameraExposure(value: number);
  30737. /**
  30738. * Gets The camera contrast used on this material.
  30739. */
  30740. get cameraContrast(): number;
  30741. /**
  30742. * Sets The camera contrast used on this material.
  30743. */
  30744. set cameraContrast(value: number);
  30745. /**
  30746. * Gets the Color Grading 2D Lookup Texture.
  30747. */
  30748. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30749. /**
  30750. * Sets the Color Grading 2D Lookup Texture.
  30751. */
  30752. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30753. /**
  30754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30756. * 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;
  30757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30758. */
  30759. get cameraColorCurves(): Nullable<ColorCurves>;
  30760. /**
  30761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30763. * 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;
  30764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30765. */
  30766. set cameraColorCurves(value: Nullable<ColorCurves>);
  30767. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30768. protected _worldViewProjectionMatrix: Matrix;
  30769. protected _globalAmbientColor: Color3;
  30770. protected _useLogarithmicDepth: boolean;
  30771. protected _rebuildInParallel: boolean;
  30772. /**
  30773. * Instantiates a new standard material.
  30774. * This is the default material used in Babylon. It is the best trade off between quality
  30775. * and performances.
  30776. * @see http://doc.babylonjs.com/babylon101/materials
  30777. * @param name Define the name of the material in the scene
  30778. * @param scene Define the scene the material belong to
  30779. */
  30780. constructor(name: string, scene: Scene);
  30781. /**
  30782. * Gets a boolean indicating that current material needs to register RTT
  30783. */
  30784. get hasRenderTargetTextures(): boolean;
  30785. /**
  30786. * Gets the current class name of the material e.g. "StandardMaterial"
  30787. * Mainly use in serialization.
  30788. * @returns the class name
  30789. */
  30790. getClassName(): string;
  30791. /**
  30792. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30793. * You can try switching to logarithmic depth.
  30794. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30795. */
  30796. get useLogarithmicDepth(): boolean;
  30797. set useLogarithmicDepth(value: boolean);
  30798. /**
  30799. * Specifies if the material will require alpha blending
  30800. * @returns a boolean specifying if alpha blending is needed
  30801. */
  30802. needAlphaBlending(): boolean;
  30803. /**
  30804. * Specifies if this material should be rendered in alpha test mode
  30805. * @returns a boolean specifying if an alpha test is needed.
  30806. */
  30807. needAlphaTesting(): boolean;
  30808. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30809. /**
  30810. * Get the texture used for alpha test purpose.
  30811. * @returns the diffuse texture in case of the standard material.
  30812. */
  30813. getAlphaTestTexture(): Nullable<BaseTexture>;
  30814. /**
  30815. * Get if the submesh is ready to be used and all its information available.
  30816. * Child classes can use it to update shaders
  30817. * @param mesh defines the mesh to check
  30818. * @param subMesh defines which submesh to check
  30819. * @param useInstances specifies that instances should be used
  30820. * @returns a boolean indicating that the submesh is ready or not
  30821. */
  30822. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30823. /**
  30824. * Builds the material UBO layouts.
  30825. * Used internally during the effect preparation.
  30826. */
  30827. buildUniformLayout(): void;
  30828. /**
  30829. * Unbinds the material from the mesh
  30830. */
  30831. unbind(): void;
  30832. /**
  30833. * Binds the submesh to this material by preparing the effect and shader to draw
  30834. * @param world defines the world transformation matrix
  30835. * @param mesh defines the mesh containing the submesh
  30836. * @param subMesh defines the submesh to bind the material to
  30837. */
  30838. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30839. /**
  30840. * Get the list of animatables in the material.
  30841. * @returns the list of animatables object used in the material
  30842. */
  30843. getAnimatables(): IAnimatable[];
  30844. /**
  30845. * Gets the active textures from the material
  30846. * @returns an array of textures
  30847. */
  30848. getActiveTextures(): BaseTexture[];
  30849. /**
  30850. * Specifies if the material uses a texture
  30851. * @param texture defines the texture to check against the material
  30852. * @returns a boolean specifying if the material uses the texture
  30853. */
  30854. hasTexture(texture: BaseTexture): boolean;
  30855. /**
  30856. * Disposes the material
  30857. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30858. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30859. */
  30860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30861. /**
  30862. * Makes a duplicate of the material, and gives it a new name
  30863. * @param name defines the new name for the duplicated material
  30864. * @returns the cloned material
  30865. */
  30866. clone(name: string): StandardMaterial;
  30867. /**
  30868. * Serializes this material in a JSON representation
  30869. * @returns the serialized material object
  30870. */
  30871. serialize(): any;
  30872. /**
  30873. * Creates a standard material from parsed material data
  30874. * @param source defines the JSON representation of the material
  30875. * @param scene defines the hosting scene
  30876. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30877. * @returns a new standard material
  30878. */
  30879. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30880. /**
  30881. * Are diffuse textures enabled in the application.
  30882. */
  30883. static get DiffuseTextureEnabled(): boolean;
  30884. static set DiffuseTextureEnabled(value: boolean);
  30885. /**
  30886. * Are ambient textures enabled in the application.
  30887. */
  30888. static get AmbientTextureEnabled(): boolean;
  30889. static set AmbientTextureEnabled(value: boolean);
  30890. /**
  30891. * Are opacity textures enabled in the application.
  30892. */
  30893. static get OpacityTextureEnabled(): boolean;
  30894. static set OpacityTextureEnabled(value: boolean);
  30895. /**
  30896. * Are reflection textures enabled in the application.
  30897. */
  30898. static get ReflectionTextureEnabled(): boolean;
  30899. static set ReflectionTextureEnabled(value: boolean);
  30900. /**
  30901. * Are emissive textures enabled in the application.
  30902. */
  30903. static get EmissiveTextureEnabled(): boolean;
  30904. static set EmissiveTextureEnabled(value: boolean);
  30905. /**
  30906. * Are specular textures enabled in the application.
  30907. */
  30908. static get SpecularTextureEnabled(): boolean;
  30909. static set SpecularTextureEnabled(value: boolean);
  30910. /**
  30911. * Are bump textures enabled in the application.
  30912. */
  30913. static get BumpTextureEnabled(): boolean;
  30914. static set BumpTextureEnabled(value: boolean);
  30915. /**
  30916. * Are lightmap textures enabled in the application.
  30917. */
  30918. static get LightmapTextureEnabled(): boolean;
  30919. static set LightmapTextureEnabled(value: boolean);
  30920. /**
  30921. * Are refraction textures enabled in the application.
  30922. */
  30923. static get RefractionTextureEnabled(): boolean;
  30924. static set RefractionTextureEnabled(value: boolean);
  30925. /**
  30926. * Are color grading textures enabled in the application.
  30927. */
  30928. static get ColorGradingTextureEnabled(): boolean;
  30929. static set ColorGradingTextureEnabled(value: boolean);
  30930. /**
  30931. * Are fresnels enabled in the application.
  30932. */
  30933. static get FresnelEnabled(): boolean;
  30934. static set FresnelEnabled(value: boolean);
  30935. }
  30936. }
  30937. declare module "babylonjs/Particles/solidParticleSystem" {
  30938. import { Nullable } from "babylonjs/types";
  30939. import { Mesh } from "babylonjs/Meshes/mesh";
  30940. import { Scene, IDisposable } from "babylonjs/scene";
  30941. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  30942. import { Material } from "babylonjs/Materials/material";
  30943. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  30944. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  30945. /**
  30946. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30947. *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.
  30948. * The SPS is also a particle system. It provides some methods to manage the particles.
  30949. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30950. *
  30951. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30952. */
  30953. export class SolidParticleSystem implements IDisposable {
  30954. /**
  30955. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30956. * Example : var p = SPS.particles[i];
  30957. */
  30958. particles: SolidParticle[];
  30959. /**
  30960. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30961. */
  30962. nbParticles: number;
  30963. /**
  30964. * If the particles must ever face the camera (default false). Useful for planar particles.
  30965. */
  30966. billboard: boolean;
  30967. /**
  30968. * Recompute normals when adding a shape
  30969. */
  30970. recomputeNormals: boolean;
  30971. /**
  30972. * This a counter ofr your own usage. It's not set by any SPS functions.
  30973. */
  30974. counter: number;
  30975. /**
  30976. * The SPS name. This name is also given to the underlying mesh.
  30977. */
  30978. name: string;
  30979. /**
  30980. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30981. */
  30982. mesh: Mesh;
  30983. /**
  30984. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30985. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30986. */
  30987. vars: any;
  30988. /**
  30989. * This array is populated when the SPS is set as 'pickable'.
  30990. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30991. * Each element of this array is an object `{idx: int, faceId: int}`.
  30992. * `idx` is the picked particle index in the `SPS.particles` array
  30993. * `faceId` is the picked face index counted within this particle.
  30994. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30995. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30996. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30997. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30998. */
  30999. pickedParticles: {
  31000. idx: number;
  31001. faceId: number;
  31002. }[];
  31003. /**
  31004. * This array is populated when the SPS is set as 'pickable'
  31005. * Each key of this array is a submesh index.
  31006. * Each element of this array is a second array defined like this :
  31007. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31008. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31009. * `idx` is the picked particle index in the `SPS.particles` array
  31010. * `faceId` is the picked face index counted within this particle.
  31011. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31012. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31013. */
  31014. pickedBySubMesh: {
  31015. idx: number;
  31016. faceId: number;
  31017. }[][];
  31018. /**
  31019. * This array is populated when `enableDepthSort` is set to true.
  31020. * Each element of this array is an instance of the class DepthSortedParticle.
  31021. */
  31022. depthSortedParticles: DepthSortedParticle[];
  31023. /**
  31024. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31025. * @hidden
  31026. */
  31027. _bSphereOnly: boolean;
  31028. /**
  31029. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31030. * @hidden
  31031. */
  31032. _bSphereRadiusFactor: number;
  31033. private _scene;
  31034. private _positions;
  31035. private _indices;
  31036. private _normals;
  31037. private _colors;
  31038. private _uvs;
  31039. private _indices32;
  31040. private _positions32;
  31041. private _normals32;
  31042. private _fixedNormal32;
  31043. private _colors32;
  31044. private _uvs32;
  31045. private _index;
  31046. private _updatable;
  31047. private _pickable;
  31048. private _isVisibilityBoxLocked;
  31049. private _alwaysVisible;
  31050. private _depthSort;
  31051. private _expandable;
  31052. private _shapeCounter;
  31053. private _copy;
  31054. private _color;
  31055. private _computeParticleColor;
  31056. private _computeParticleTexture;
  31057. private _computeParticleRotation;
  31058. private _computeParticleVertex;
  31059. private _computeBoundingBox;
  31060. private _depthSortParticles;
  31061. private _camera;
  31062. private _mustUnrotateFixedNormals;
  31063. private _particlesIntersect;
  31064. private _needs32Bits;
  31065. private _isNotBuilt;
  31066. private _lastParticleId;
  31067. private _idxOfId;
  31068. private _multimaterialEnabled;
  31069. private _useModelMaterial;
  31070. private _indicesByMaterial;
  31071. private _materialIndexes;
  31072. private _depthSortFunction;
  31073. private _materialSortFunction;
  31074. private _materials;
  31075. private _multimaterial;
  31076. private _materialIndexesById;
  31077. private _defaultMaterial;
  31078. private _autoUpdateSubMeshes;
  31079. private _tmpVertex;
  31080. /**
  31081. * Creates a SPS (Solid Particle System) object.
  31082. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31083. * @param scene (Scene) is the scene in which the SPS is added.
  31084. * @param options defines the options of the sps e.g.
  31085. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31086. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31087. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31088. * * 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.
  31089. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31090. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31091. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31092. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31093. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31094. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31095. */
  31096. constructor(name: string, scene: Scene, options?: {
  31097. updatable?: boolean;
  31098. isPickable?: boolean;
  31099. enableDepthSort?: boolean;
  31100. particleIntersection?: boolean;
  31101. boundingSphereOnly?: boolean;
  31102. bSphereRadiusFactor?: number;
  31103. expandable?: boolean;
  31104. useModelMaterial?: boolean;
  31105. enableMultiMaterial?: boolean;
  31106. });
  31107. /**
  31108. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31109. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31110. * @returns the created mesh
  31111. */
  31112. buildMesh(): Mesh;
  31113. /**
  31114. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31115. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31116. * Thus the particles generated from `digest()` have their property `position` set yet.
  31117. * @param mesh ( Mesh ) is the mesh to be digested
  31118. * @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
  31119. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31120. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31121. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31122. * @returns the current SPS
  31123. */
  31124. digest(mesh: Mesh, options?: {
  31125. facetNb?: number;
  31126. number?: number;
  31127. delta?: number;
  31128. storage?: [];
  31129. }): SolidParticleSystem;
  31130. /**
  31131. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31132. * @hidden
  31133. */
  31134. private _unrotateFixedNormals;
  31135. /**
  31136. * Resets the temporary working copy particle
  31137. * @hidden
  31138. */
  31139. private _resetCopy;
  31140. /**
  31141. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31142. * @param p the current index in the positions array to be updated
  31143. * @param ind the current index in the indices array
  31144. * @param shape a Vector3 array, the shape geometry
  31145. * @param positions the positions array to be updated
  31146. * @param meshInd the shape indices array
  31147. * @param indices the indices array to be updated
  31148. * @param meshUV the shape uv array
  31149. * @param uvs the uv array to be updated
  31150. * @param meshCol the shape color array
  31151. * @param colors the color array to be updated
  31152. * @param meshNor the shape normals array
  31153. * @param normals the normals array to be updated
  31154. * @param idx the particle index
  31155. * @param idxInShape the particle index in its shape
  31156. * @param options the addShape() method passed options
  31157. * @model the particle model
  31158. * @hidden
  31159. */
  31160. private _meshBuilder;
  31161. /**
  31162. * Returns a shape Vector3 array from positions float array
  31163. * @param positions float array
  31164. * @returns a vector3 array
  31165. * @hidden
  31166. */
  31167. private _posToShape;
  31168. /**
  31169. * Returns a shapeUV array from a float uvs (array deep copy)
  31170. * @param uvs as a float array
  31171. * @returns a shapeUV array
  31172. * @hidden
  31173. */
  31174. private _uvsToShapeUV;
  31175. /**
  31176. * Adds a new particle object in the particles array
  31177. * @param idx particle index in particles array
  31178. * @param id particle id
  31179. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31180. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31181. * @param model particle ModelShape object
  31182. * @param shapeId model shape identifier
  31183. * @param idxInShape index of the particle in the current model
  31184. * @param bInfo model bounding info object
  31185. * @param storage target storage array, if any
  31186. * @hidden
  31187. */
  31188. private _addParticle;
  31189. /**
  31190. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31191. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31192. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31193. * @param nb (positive integer) the number of particles to be created from this model
  31194. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31195. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31196. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31197. * @returns the number of shapes in the system
  31198. */
  31199. addShape(mesh: Mesh, nb: number, options?: {
  31200. positionFunction?: any;
  31201. vertexFunction?: any;
  31202. storage?: [];
  31203. }): number;
  31204. /**
  31205. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31206. * @hidden
  31207. */
  31208. private _rebuildParticle;
  31209. /**
  31210. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31211. * @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.
  31212. * @returns the SPS.
  31213. */
  31214. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31215. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31216. * Returns an array with the removed particles.
  31217. * 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.
  31218. * The SPS can't be empty so at least one particle needs to remain in place.
  31219. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31220. * @param start index of the first particle to remove
  31221. * @param end index of the last particle to remove (included)
  31222. * @returns an array populated with the removed particles
  31223. */
  31224. removeParticles(start: number, end: number): SolidParticle[];
  31225. /**
  31226. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31227. * @param solidParticleArray an array populated with Solid Particles objects
  31228. * @returns the SPS
  31229. */
  31230. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31231. /**
  31232. * Creates a new particle and modifies the SPS mesh geometry :
  31233. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31234. * - calls _addParticle() to populate the particle array
  31235. * factorized code from addShape() and insertParticlesFromArray()
  31236. * @param idx particle index in the particles array
  31237. * @param i particle index in its shape
  31238. * @param modelShape particle ModelShape object
  31239. * @param shape shape vertex array
  31240. * @param meshInd shape indices array
  31241. * @param meshUV shape uv array
  31242. * @param meshCol shape color array
  31243. * @param meshNor shape normals array
  31244. * @param bbInfo shape bounding info
  31245. * @param storage target particle storage
  31246. * @options addShape() passed options
  31247. * @hidden
  31248. */
  31249. private _insertNewParticle;
  31250. /**
  31251. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31252. * This method calls `updateParticle()` for each particle of the SPS.
  31253. * For an animated SPS, it is usually called within the render loop.
  31254. * 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.
  31255. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31256. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31257. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31258. * @returns the SPS.
  31259. */
  31260. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31261. /**
  31262. * Disposes the SPS.
  31263. */
  31264. dispose(): void;
  31265. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31266. * idx is the particle index in the SPS
  31267. * faceId is the picked face index counted within this particle.
  31268. * Returns null if the pickInfo can't identify a picked particle.
  31269. * @param pickingInfo (PickingInfo object)
  31270. * @returns {idx: number, faceId: number} or null
  31271. */
  31272. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31273. idx: number;
  31274. faceId: number;
  31275. }>;
  31276. /**
  31277. * Returns a SolidParticle object from its identifier : particle.id
  31278. * @param id (integer) the particle Id
  31279. * @returns the searched particle or null if not found in the SPS.
  31280. */
  31281. getParticleById(id: number): Nullable<SolidParticle>;
  31282. /**
  31283. * Returns a new array populated with the particles having the passed shapeId.
  31284. * @param shapeId (integer) the shape identifier
  31285. * @returns a new solid particle array
  31286. */
  31287. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31288. /**
  31289. * Populates the passed array "ref" with the particles having the passed shapeId.
  31290. * @param shapeId the shape identifier
  31291. * @returns the SPS
  31292. * @param ref
  31293. */
  31294. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31295. /**
  31296. * Computes the required SubMeshes according the materials assigned to the particles.
  31297. * @returns the solid particle system.
  31298. * Does nothing if called before the SPS mesh is built.
  31299. */
  31300. computeSubMeshes(): SolidParticleSystem;
  31301. /**
  31302. * Sorts the solid particles by material when MultiMaterial is enabled.
  31303. * Updates the indices32 array.
  31304. * Updates the indicesByMaterial array.
  31305. * Updates the mesh indices array.
  31306. * @returns the SPS
  31307. * @hidden
  31308. */
  31309. private _sortParticlesByMaterial;
  31310. /**
  31311. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31312. * @hidden
  31313. */
  31314. private _setMaterialIndexesById;
  31315. /**
  31316. * Returns an array with unique values of Materials from the passed array
  31317. * @param array the material array to be checked and filtered
  31318. * @hidden
  31319. */
  31320. private _filterUniqueMaterialId;
  31321. /**
  31322. * Sets a new Standard Material as _defaultMaterial if not already set.
  31323. * @hidden
  31324. */
  31325. private _setDefaultMaterial;
  31326. /**
  31327. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31328. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31329. * @returns the SPS.
  31330. */
  31331. refreshVisibleSize(): SolidParticleSystem;
  31332. /**
  31333. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31334. * @param size the size (float) of the visibility box
  31335. * note : this doesn't lock the SPS mesh bounding box.
  31336. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31337. */
  31338. setVisibilityBox(size: number): void;
  31339. /**
  31340. * Gets whether the SPS as always visible or not
  31341. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31342. */
  31343. get isAlwaysVisible(): boolean;
  31344. /**
  31345. * Sets the SPS as always visible or not
  31346. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31347. */
  31348. set isAlwaysVisible(val: boolean);
  31349. /**
  31350. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31351. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31352. */
  31353. set isVisibilityBoxLocked(val: boolean);
  31354. /**
  31355. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31356. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31357. */
  31358. get isVisibilityBoxLocked(): boolean;
  31359. /**
  31360. * Tells to `setParticles()` to compute the particle rotations or not.
  31361. * Default value : true. The SPS is faster when it's set to false.
  31362. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31363. */
  31364. set computeParticleRotation(val: boolean);
  31365. /**
  31366. * Tells to `setParticles()` to compute the particle colors or not.
  31367. * Default value : true. The SPS is faster when it's set to false.
  31368. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31369. */
  31370. set computeParticleColor(val: boolean);
  31371. set computeParticleTexture(val: boolean);
  31372. /**
  31373. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31374. * Default value : false. The SPS is faster when it's set to false.
  31375. * Note : the particle custom vertex positions aren't stored values.
  31376. */
  31377. set computeParticleVertex(val: boolean);
  31378. /**
  31379. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31380. */
  31381. set computeBoundingBox(val: boolean);
  31382. /**
  31383. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31384. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31385. * Default : `true`
  31386. */
  31387. set depthSortParticles(val: boolean);
  31388. /**
  31389. * Gets if `setParticles()` computes the particle rotations or not.
  31390. * Default value : true. The SPS is faster when it's set to false.
  31391. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31392. */
  31393. get computeParticleRotation(): boolean;
  31394. /**
  31395. * Gets if `setParticles()` computes the particle colors or not.
  31396. * Default value : true. The SPS is faster when it's set to false.
  31397. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31398. */
  31399. get computeParticleColor(): boolean;
  31400. /**
  31401. * Gets if `setParticles()` computes the particle textures or not.
  31402. * Default value : true. The SPS is faster when it's set to false.
  31403. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31404. */
  31405. get computeParticleTexture(): boolean;
  31406. /**
  31407. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31408. * Default value : false. The SPS is faster when it's set to false.
  31409. * Note : the particle custom vertex positions aren't stored values.
  31410. */
  31411. get computeParticleVertex(): boolean;
  31412. /**
  31413. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31414. */
  31415. get computeBoundingBox(): boolean;
  31416. /**
  31417. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31418. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31419. * Default : `true`
  31420. */
  31421. get depthSortParticles(): boolean;
  31422. /**
  31423. * Gets if the SPS is created as expandable at construction time.
  31424. * Default : `false`
  31425. */
  31426. get expandable(): boolean;
  31427. /**
  31428. * Gets if the SPS supports the Multi Materials
  31429. */
  31430. get multimaterialEnabled(): boolean;
  31431. /**
  31432. * Gets if the SPS uses the model materials for its own multimaterial.
  31433. */
  31434. get useModelMaterial(): boolean;
  31435. /**
  31436. * The SPS used material array.
  31437. */
  31438. get materials(): Material[];
  31439. /**
  31440. * Sets the SPS MultiMaterial from the passed materials.
  31441. * Note : the passed array is internally copied and not used then by reference.
  31442. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31443. */
  31444. setMultiMaterial(materials: Material[]): void;
  31445. /**
  31446. * The SPS computed multimaterial object
  31447. */
  31448. get multimaterial(): MultiMaterial;
  31449. set multimaterial(mm: MultiMaterial);
  31450. /**
  31451. * If the subMeshes must be updated on the next call to setParticles()
  31452. */
  31453. get autoUpdateSubMeshes(): boolean;
  31454. set autoUpdateSubMeshes(val: boolean);
  31455. /**
  31456. * This function does nothing. It may be overwritten to set all the particle first values.
  31457. * The SPS doesn't call this function, you may have to call it by your own.
  31458. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31459. */
  31460. initParticles(): void;
  31461. /**
  31462. * This function does nothing. It may be overwritten to recycle a particle.
  31463. * The SPS doesn't call this function, you may have to call it by your own.
  31464. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31465. * @param particle The particle to recycle
  31466. * @returns the recycled particle
  31467. */
  31468. recycleParticle(particle: SolidParticle): SolidParticle;
  31469. /**
  31470. * Updates a particle : this function should be overwritten by the user.
  31471. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31472. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31473. * @example : just set a particle position or velocity and recycle conditions
  31474. * @param particle The particle to update
  31475. * @returns the updated particle
  31476. */
  31477. updateParticle(particle: SolidParticle): SolidParticle;
  31478. /**
  31479. * Updates a vertex of a particle : it can be overwritten by the user.
  31480. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31481. * @param particle the current particle
  31482. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31483. * @param pt the index of the current vertex in the particle shape
  31484. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31485. * @example : just set a vertex particle position or color
  31486. * @returns the sps
  31487. */
  31488. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31489. /**
  31490. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31491. * This does nothing and may be overwritten by the user.
  31492. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31493. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31494. * @param update the boolean update value actually passed to setParticles()
  31495. */
  31496. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31497. /**
  31498. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31499. * This will be passed three parameters.
  31500. * This does nothing and may be overwritten by the user.
  31501. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31502. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31503. * @param update the boolean update value actually passed to setParticles()
  31504. */
  31505. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31506. }
  31507. }
  31508. declare module "babylonjs/Particles/solidParticle" {
  31509. import { Nullable } from "babylonjs/types";
  31510. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31511. import { Color4 } from "babylonjs/Maths/math.color";
  31512. import { Mesh } from "babylonjs/Meshes/mesh";
  31513. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31514. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31515. import { Plane } from "babylonjs/Maths/math.plane";
  31516. import { Material } from "babylonjs/Materials/material";
  31517. /**
  31518. * Represents one particle of a solid particle system.
  31519. */
  31520. export class SolidParticle {
  31521. /**
  31522. * particle global index
  31523. */
  31524. idx: number;
  31525. /**
  31526. * particle identifier
  31527. */
  31528. id: number;
  31529. /**
  31530. * The color of the particle
  31531. */
  31532. color: Nullable<Color4>;
  31533. /**
  31534. * The world space position of the particle.
  31535. */
  31536. position: Vector3;
  31537. /**
  31538. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31539. */
  31540. rotation: Vector3;
  31541. /**
  31542. * The world space rotation quaternion of the particle.
  31543. */
  31544. rotationQuaternion: Nullable<Quaternion>;
  31545. /**
  31546. * The scaling of the particle.
  31547. */
  31548. scaling: Vector3;
  31549. /**
  31550. * The uvs of the particle.
  31551. */
  31552. uvs: Vector4;
  31553. /**
  31554. * The current speed of the particle.
  31555. */
  31556. velocity: Vector3;
  31557. /**
  31558. * The pivot point in the particle local space.
  31559. */
  31560. pivot: Vector3;
  31561. /**
  31562. * Must the particle be translated from its pivot point in its local space ?
  31563. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31564. * Default : false
  31565. */
  31566. translateFromPivot: boolean;
  31567. /**
  31568. * Is the particle active or not ?
  31569. */
  31570. alive: boolean;
  31571. /**
  31572. * Is the particle visible or not ?
  31573. */
  31574. isVisible: boolean;
  31575. /**
  31576. * Index of this particle in the global "positions" array (Internal use)
  31577. * @hidden
  31578. */
  31579. _pos: number;
  31580. /**
  31581. * @hidden Index of this particle in the global "indices" array (Internal use)
  31582. */
  31583. _ind: number;
  31584. /**
  31585. * @hidden ModelShape of this particle (Internal use)
  31586. */
  31587. _model: ModelShape;
  31588. /**
  31589. * ModelShape id of this particle
  31590. */
  31591. shapeId: number;
  31592. /**
  31593. * Index of the particle in its shape id
  31594. */
  31595. idxInShape: number;
  31596. /**
  31597. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31598. */
  31599. _modelBoundingInfo: BoundingInfo;
  31600. /**
  31601. * @hidden Particle BoundingInfo object (Internal use)
  31602. */
  31603. _boundingInfo: BoundingInfo;
  31604. /**
  31605. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31606. */
  31607. _sps: SolidParticleSystem;
  31608. /**
  31609. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31610. */
  31611. _stillInvisible: boolean;
  31612. /**
  31613. * @hidden Last computed particle rotation matrix
  31614. */
  31615. _rotationMatrix: number[];
  31616. /**
  31617. * Parent particle Id, if any.
  31618. * Default null.
  31619. */
  31620. parentId: Nullable<number>;
  31621. /**
  31622. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31623. */
  31624. materialIndex: Nullable<number>;
  31625. /**
  31626. * Custom object or properties.
  31627. */
  31628. props: Nullable<any>;
  31629. /**
  31630. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31631. * The possible values are :
  31632. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31633. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31634. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31635. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31636. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31637. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31638. * */
  31639. cullingStrategy: number;
  31640. /**
  31641. * @hidden Internal global position in the SPS.
  31642. */
  31643. _globalPosition: Vector3;
  31644. /**
  31645. * Creates a Solid Particle object.
  31646. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31647. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31648. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31649. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31650. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31651. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31652. * @param shapeId (integer) is the model shape identifier in the SPS.
  31653. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31654. * @param sps defines the sps it is associated to
  31655. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31656. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31657. */
  31658. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31659. /**
  31660. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31661. * @param target the particle target
  31662. * @returns the current particle
  31663. */
  31664. copyToRef(target: SolidParticle): SolidParticle;
  31665. /**
  31666. * Legacy support, changed scale to scaling
  31667. */
  31668. get scale(): Vector3;
  31669. /**
  31670. * Legacy support, changed scale to scaling
  31671. */
  31672. set scale(scale: Vector3);
  31673. /**
  31674. * Legacy support, changed quaternion to rotationQuaternion
  31675. */
  31676. get quaternion(): Nullable<Quaternion>;
  31677. /**
  31678. * Legacy support, changed quaternion to rotationQuaternion
  31679. */
  31680. set quaternion(q: Nullable<Quaternion>);
  31681. /**
  31682. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31683. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31684. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31685. * @returns true if it intersects
  31686. */
  31687. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31688. /**
  31689. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31690. * A particle is in the frustum if its bounding box intersects the frustum
  31691. * @param frustumPlanes defines the frustum to test
  31692. * @returns true if the particle is in the frustum planes
  31693. */
  31694. isInFrustum(frustumPlanes: Plane[]): boolean;
  31695. /**
  31696. * get the rotation matrix of the particle
  31697. * @hidden
  31698. */
  31699. getRotationMatrix(m: Matrix): void;
  31700. }
  31701. /**
  31702. * Represents the shape of the model used by one particle of a solid particle system.
  31703. * SPS internal tool, don't use it manually.
  31704. */
  31705. export class ModelShape {
  31706. /**
  31707. * The shape id
  31708. * @hidden
  31709. */
  31710. shapeID: number;
  31711. /**
  31712. * flat array of model positions (internal use)
  31713. * @hidden
  31714. */
  31715. _shape: Vector3[];
  31716. /**
  31717. * flat array of model UVs (internal use)
  31718. * @hidden
  31719. */
  31720. _shapeUV: number[];
  31721. /**
  31722. * color array of the model
  31723. * @hidden
  31724. */
  31725. _shapeColors: number[];
  31726. /**
  31727. * indices array of the model
  31728. * @hidden
  31729. */
  31730. _indices: number[];
  31731. /**
  31732. * normals array of the model
  31733. * @hidden
  31734. */
  31735. _normals: number[];
  31736. /**
  31737. * length of the shape in the model indices array (internal use)
  31738. * @hidden
  31739. */
  31740. _indicesLength: number;
  31741. /**
  31742. * Custom position function (internal use)
  31743. * @hidden
  31744. */
  31745. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31746. /**
  31747. * Custom vertex function (internal use)
  31748. * @hidden
  31749. */
  31750. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31751. /**
  31752. * Model material (internal use)
  31753. * @hidden
  31754. */
  31755. _material: Nullable<Material>;
  31756. /**
  31757. * 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.
  31758. * SPS internal tool, don't use it manually.
  31759. * @hidden
  31760. */
  31761. 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>);
  31762. }
  31763. /**
  31764. * Represents a Depth Sorted Particle in the solid particle system.
  31765. * @hidden
  31766. */
  31767. export class DepthSortedParticle {
  31768. /**
  31769. * Particle index
  31770. */
  31771. idx: number;
  31772. /**
  31773. * Index of the particle in the "indices" array
  31774. */
  31775. ind: number;
  31776. /**
  31777. * Length of the particle shape in the "indices" array
  31778. */
  31779. indicesLength: number;
  31780. /**
  31781. * Squared distance from the particle to the camera
  31782. */
  31783. sqDistance: number;
  31784. /**
  31785. * Material index when used with MultiMaterials
  31786. */
  31787. materialIndex: number;
  31788. /**
  31789. * Creates a new sorted particle
  31790. * @param materialIndex
  31791. */
  31792. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31793. }
  31794. /**
  31795. * Represents a solid particle vertex
  31796. */
  31797. export class SolidParticleVertex {
  31798. /**
  31799. * Vertex position
  31800. */
  31801. position: Vector3;
  31802. /**
  31803. * Vertex color
  31804. */
  31805. color: Color4;
  31806. /**
  31807. * Vertex UV
  31808. */
  31809. uv: Vector2;
  31810. /**
  31811. * Creates a new solid particle vertex
  31812. */
  31813. constructor();
  31814. /** Vertex x coordinate */
  31815. get x(): number;
  31816. set x(val: number);
  31817. /** Vertex y coordinate */
  31818. get y(): number;
  31819. set y(val: number);
  31820. /** Vertex z coordinate */
  31821. get z(): number;
  31822. set z(val: number);
  31823. }
  31824. }
  31825. declare module "babylonjs/Collisions/meshCollisionData" {
  31826. import { Collider } from "babylonjs/Collisions/collider";
  31827. import { Vector3 } from "babylonjs/Maths/math.vector";
  31828. import { Nullable } from "babylonjs/types";
  31829. import { Observer } from "babylonjs/Misc/observable";
  31830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31831. /**
  31832. * @hidden
  31833. */
  31834. export class _MeshCollisionData {
  31835. _checkCollisions: boolean;
  31836. _collisionMask: number;
  31837. _collisionGroup: number;
  31838. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31839. _collider: Nullable<Collider>;
  31840. _oldPositionForCollisions: Vector3;
  31841. _diffPositionForCollisions: Vector3;
  31842. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31843. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31844. }
  31845. }
  31846. declare module "babylonjs/Meshes/abstractMesh" {
  31847. import { Observable } from "babylonjs/Misc/observable";
  31848. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31849. import { Camera } from "babylonjs/Cameras/camera";
  31850. import { Scene, IDisposable } from "babylonjs/scene";
  31851. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31852. import { Node } from "babylonjs/node";
  31853. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31854. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31856. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31857. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31858. import { Material } from "babylonjs/Materials/material";
  31859. import { Light } from "babylonjs/Lights/light";
  31860. import { Skeleton } from "babylonjs/Bones/skeleton";
  31861. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31862. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31863. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31864. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31865. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31866. import { Plane } from "babylonjs/Maths/math.plane";
  31867. import { Ray } from "babylonjs/Culling/ray";
  31868. import { Collider } from "babylonjs/Collisions/collider";
  31869. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31870. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31871. /** @hidden */
  31872. class _FacetDataStorage {
  31873. facetPositions: Vector3[];
  31874. facetNormals: Vector3[];
  31875. facetPartitioning: number[][];
  31876. facetNb: number;
  31877. partitioningSubdivisions: number;
  31878. partitioningBBoxRatio: number;
  31879. facetDataEnabled: boolean;
  31880. facetParameters: any;
  31881. bbSize: Vector3;
  31882. subDiv: {
  31883. max: number;
  31884. X: number;
  31885. Y: number;
  31886. Z: number;
  31887. };
  31888. facetDepthSort: boolean;
  31889. facetDepthSortEnabled: boolean;
  31890. depthSortedIndices: IndicesArray;
  31891. depthSortedFacets: {
  31892. ind: number;
  31893. sqDistance: number;
  31894. }[];
  31895. facetDepthSortFunction: (f1: {
  31896. ind: number;
  31897. sqDistance: number;
  31898. }, f2: {
  31899. ind: number;
  31900. sqDistance: number;
  31901. }) => number;
  31902. facetDepthSortFrom: Vector3;
  31903. facetDepthSortOrigin: Vector3;
  31904. invertedMatrix: Matrix;
  31905. }
  31906. /**
  31907. * @hidden
  31908. **/
  31909. class _InternalAbstractMeshDataInfo {
  31910. _hasVertexAlpha: boolean;
  31911. _useVertexColors: boolean;
  31912. _numBoneInfluencers: number;
  31913. _applyFog: boolean;
  31914. _receiveShadows: boolean;
  31915. _facetData: _FacetDataStorage;
  31916. _visibility: number;
  31917. _skeleton: Nullable<Skeleton>;
  31918. _layerMask: number;
  31919. _computeBonesUsingShaders: boolean;
  31920. _isActive: boolean;
  31921. _onlyForInstances: boolean;
  31922. _isActiveIntermediate: boolean;
  31923. _onlyForInstancesIntermediate: boolean;
  31924. _actAsRegularMesh: boolean;
  31925. }
  31926. /**
  31927. * Class used to store all common mesh properties
  31928. */
  31929. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31930. /** No occlusion */
  31931. static OCCLUSION_TYPE_NONE: number;
  31932. /** Occlusion set to optimisitic */
  31933. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31934. /** Occlusion set to strict */
  31935. static OCCLUSION_TYPE_STRICT: number;
  31936. /** Use an accurante occlusion algorithm */
  31937. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31938. /** Use a conservative occlusion algorithm */
  31939. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31940. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31941. * Test order :
  31942. * Is the bounding sphere outside the frustum ?
  31943. * If not, are the bounding box vertices outside the frustum ?
  31944. * It not, then the cullable object is in the frustum.
  31945. */
  31946. static readonly CULLINGSTRATEGY_STANDARD: number;
  31947. /** Culling strategy : Bounding Sphere Only.
  31948. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31949. * It's also less accurate than the standard because some not visible objects can still be selected.
  31950. * Test : is the bounding sphere outside the frustum ?
  31951. * If not, then the cullable object is in the frustum.
  31952. */
  31953. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31954. /** Culling strategy : Optimistic Inclusion.
  31955. * This in an inclusion test first, then the standard exclusion test.
  31956. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31957. * 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.
  31958. * Anyway, it's as accurate as the standard strategy.
  31959. * Test :
  31960. * Is the cullable object bounding sphere center in the frustum ?
  31961. * If not, apply the default culling strategy.
  31962. */
  31963. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31964. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31965. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31966. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31967. * 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.
  31968. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31969. * Test :
  31970. * Is the cullable object bounding sphere center in the frustum ?
  31971. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31972. */
  31973. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31974. /**
  31975. * No billboard
  31976. */
  31977. static get BILLBOARDMODE_NONE(): number;
  31978. /** Billboard on X axis */
  31979. static get BILLBOARDMODE_X(): number;
  31980. /** Billboard on Y axis */
  31981. static get BILLBOARDMODE_Y(): number;
  31982. /** Billboard on Z axis */
  31983. static get BILLBOARDMODE_Z(): number;
  31984. /** Billboard on all axes */
  31985. static get BILLBOARDMODE_ALL(): number;
  31986. /** Billboard on using position instead of orientation */
  31987. static get BILLBOARDMODE_USE_POSITION(): number;
  31988. /** @hidden */
  31989. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31990. /**
  31991. * The culling strategy to use to check whether the mesh must be rendered or not.
  31992. * This value can be changed at any time and will be used on the next render mesh selection.
  31993. * The possible values are :
  31994. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31995. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31996. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31997. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31998. * Please read each static variable documentation to get details about the culling process.
  31999. * */
  32000. cullingStrategy: number;
  32001. /**
  32002. * Gets the number of facets in the mesh
  32003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32004. */
  32005. get facetNb(): number;
  32006. /**
  32007. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32009. */
  32010. get partitioningSubdivisions(): number;
  32011. set partitioningSubdivisions(nb: number);
  32012. /**
  32013. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32014. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32016. */
  32017. get partitioningBBoxRatio(): number;
  32018. set partitioningBBoxRatio(ratio: number);
  32019. /**
  32020. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32021. * Works only for updatable meshes.
  32022. * Doesn't work with multi-materials
  32023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32024. */
  32025. get mustDepthSortFacets(): boolean;
  32026. set mustDepthSortFacets(sort: boolean);
  32027. /**
  32028. * The location (Vector3) where the facet depth sort must be computed from.
  32029. * By default, the active camera position.
  32030. * Used only when facet depth sort is enabled
  32031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32032. */
  32033. get facetDepthSortFrom(): Vector3;
  32034. set facetDepthSortFrom(location: Vector3);
  32035. /**
  32036. * gets a boolean indicating if facetData is enabled
  32037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32038. */
  32039. get isFacetDataEnabled(): boolean;
  32040. /** @hidden */
  32041. _updateNonUniformScalingState(value: boolean): boolean;
  32042. /**
  32043. * An event triggered when this mesh collides with another one
  32044. */
  32045. onCollideObservable: Observable<AbstractMesh>;
  32046. /** Set a function to call when this mesh collides with another one */
  32047. set onCollide(callback: () => void);
  32048. /**
  32049. * An event triggered when the collision's position changes
  32050. */
  32051. onCollisionPositionChangeObservable: Observable<Vector3>;
  32052. /** Set a function to call when the collision's position changes */
  32053. set onCollisionPositionChange(callback: () => void);
  32054. /**
  32055. * An event triggered when material is changed
  32056. */
  32057. onMaterialChangedObservable: Observable<AbstractMesh>;
  32058. /**
  32059. * Gets or sets the orientation for POV movement & rotation
  32060. */
  32061. definedFacingForward: boolean;
  32062. /** @hidden */
  32063. _occlusionQuery: Nullable<WebGLQuery>;
  32064. /** @hidden */
  32065. _renderingGroup: Nullable<RenderingGroup>;
  32066. /**
  32067. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32068. */
  32069. get visibility(): number;
  32070. /**
  32071. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32072. */
  32073. set visibility(value: number);
  32074. /** Gets or sets the alpha index used to sort transparent meshes
  32075. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32076. */
  32077. alphaIndex: number;
  32078. /**
  32079. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32080. */
  32081. isVisible: boolean;
  32082. /**
  32083. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32084. */
  32085. isPickable: boolean;
  32086. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32087. showSubMeshesBoundingBox: boolean;
  32088. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32090. */
  32091. isBlocker: boolean;
  32092. /**
  32093. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32094. */
  32095. enablePointerMoveEvents: boolean;
  32096. /**
  32097. * Specifies the rendering group id for this mesh (0 by default)
  32098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32099. */
  32100. renderingGroupId: number;
  32101. private _material;
  32102. /** Gets or sets current material */
  32103. get material(): Nullable<Material>;
  32104. set material(value: Nullable<Material>);
  32105. /**
  32106. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32107. * @see http://doc.babylonjs.com/babylon101/shadows
  32108. */
  32109. get receiveShadows(): boolean;
  32110. set receiveShadows(value: boolean);
  32111. /** Defines color to use when rendering outline */
  32112. outlineColor: Color3;
  32113. /** Define width to use when rendering outline */
  32114. outlineWidth: number;
  32115. /** Defines color to use when rendering overlay */
  32116. overlayColor: Color3;
  32117. /** Defines alpha to use when rendering overlay */
  32118. overlayAlpha: number;
  32119. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32120. get hasVertexAlpha(): boolean;
  32121. set hasVertexAlpha(value: boolean);
  32122. /** 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) */
  32123. get useVertexColors(): boolean;
  32124. set useVertexColors(value: boolean);
  32125. /**
  32126. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32127. */
  32128. get computeBonesUsingShaders(): boolean;
  32129. set computeBonesUsingShaders(value: boolean);
  32130. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32131. get numBoneInfluencers(): number;
  32132. set numBoneInfluencers(value: number);
  32133. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32134. get applyFog(): boolean;
  32135. set applyFog(value: boolean);
  32136. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32137. useOctreeForRenderingSelection: boolean;
  32138. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32139. useOctreeForPicking: boolean;
  32140. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32141. useOctreeForCollisions: boolean;
  32142. /**
  32143. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32144. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32145. */
  32146. get layerMask(): number;
  32147. set layerMask(value: number);
  32148. /**
  32149. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32150. */
  32151. alwaysSelectAsActiveMesh: boolean;
  32152. /**
  32153. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32154. */
  32155. doNotSyncBoundingInfo: boolean;
  32156. /**
  32157. * Gets or sets the current action manager
  32158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32159. */
  32160. actionManager: Nullable<AbstractActionManager>;
  32161. private _meshCollisionData;
  32162. /**
  32163. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32165. */
  32166. ellipsoid: Vector3;
  32167. /**
  32168. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32169. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32170. */
  32171. ellipsoidOffset: Vector3;
  32172. /**
  32173. * Gets or sets a collision mask used to mask collisions (default is -1).
  32174. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32175. */
  32176. get collisionMask(): number;
  32177. set collisionMask(mask: number);
  32178. /**
  32179. * Gets or sets the current collision group mask (-1 by default).
  32180. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32181. */
  32182. get collisionGroup(): number;
  32183. set collisionGroup(mask: number);
  32184. /**
  32185. * Gets or sets current surrounding meshes (null by default).
  32186. *
  32187. * By default collision detection is tested against every mesh in the scene.
  32188. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32189. * meshes will be tested for the collision.
  32190. *
  32191. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32192. */
  32193. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32194. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32195. /**
  32196. * Defines edge width used when edgesRenderer is enabled
  32197. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32198. */
  32199. edgesWidth: number;
  32200. /**
  32201. * Defines edge color used when edgesRenderer is enabled
  32202. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32203. */
  32204. edgesColor: Color4;
  32205. /** @hidden */
  32206. _edgesRenderer: Nullable<IEdgesRenderer>;
  32207. /** @hidden */
  32208. _masterMesh: Nullable<AbstractMesh>;
  32209. /** @hidden */
  32210. _boundingInfo: Nullable<BoundingInfo>;
  32211. /** @hidden */
  32212. _renderId: number;
  32213. /**
  32214. * Gets or sets the list of subMeshes
  32215. * @see http://doc.babylonjs.com/how_to/multi_materials
  32216. */
  32217. subMeshes: SubMesh[];
  32218. /** @hidden */
  32219. _intersectionsInProgress: AbstractMesh[];
  32220. /** @hidden */
  32221. _unIndexed: boolean;
  32222. /** @hidden */
  32223. _lightSources: Light[];
  32224. /** Gets the list of lights affecting that mesh */
  32225. get lightSources(): Light[];
  32226. /** @hidden */
  32227. get _positions(): Nullable<Vector3[]>;
  32228. /** @hidden */
  32229. _waitingData: {
  32230. lods: Nullable<any>;
  32231. actions: Nullable<any>;
  32232. freezeWorldMatrix: Nullable<boolean>;
  32233. };
  32234. /** @hidden */
  32235. _bonesTransformMatrices: Nullable<Float32Array>;
  32236. /** @hidden */
  32237. _transformMatrixTexture: Nullable<RawTexture>;
  32238. /**
  32239. * Gets or sets a skeleton to apply skining transformations
  32240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32241. */
  32242. set skeleton(value: Nullable<Skeleton>);
  32243. get skeleton(): Nullable<Skeleton>;
  32244. /**
  32245. * An event triggered when the mesh is rebuilt.
  32246. */
  32247. onRebuildObservable: Observable<AbstractMesh>;
  32248. /**
  32249. * Creates a new AbstractMesh
  32250. * @param name defines the name of the mesh
  32251. * @param scene defines the hosting scene
  32252. */
  32253. constructor(name: string, scene?: Nullable<Scene>);
  32254. /**
  32255. * Returns the string "AbstractMesh"
  32256. * @returns "AbstractMesh"
  32257. */
  32258. getClassName(): string;
  32259. /**
  32260. * Gets a string representation of the current mesh
  32261. * @param fullDetails defines a boolean indicating if full details must be included
  32262. * @returns a string representation of the current mesh
  32263. */
  32264. toString(fullDetails?: boolean): string;
  32265. /**
  32266. * @hidden
  32267. */
  32268. protected _getEffectiveParent(): Nullable<Node>;
  32269. /** @hidden */
  32270. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32271. /** @hidden */
  32272. _rebuild(): void;
  32273. /** @hidden */
  32274. _resyncLightSources(): void;
  32275. /** @hidden */
  32276. _resyncLightSource(light: Light): void;
  32277. /** @hidden */
  32278. _unBindEffect(): void;
  32279. /** @hidden */
  32280. _removeLightSource(light: Light, dispose: boolean): void;
  32281. private _markSubMeshesAsDirty;
  32282. /** @hidden */
  32283. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32284. /** @hidden */
  32285. _markSubMeshesAsAttributesDirty(): void;
  32286. /** @hidden */
  32287. _markSubMeshesAsMiscDirty(): void;
  32288. /**
  32289. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32290. */
  32291. get scaling(): Vector3;
  32292. set scaling(newScaling: Vector3);
  32293. /**
  32294. * Returns true if the mesh is blocked. Implemented by child classes
  32295. */
  32296. get isBlocked(): boolean;
  32297. /**
  32298. * Returns the mesh itself by default. Implemented by child classes
  32299. * @param camera defines the camera to use to pick the right LOD level
  32300. * @returns the currentAbstractMesh
  32301. */
  32302. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32303. /**
  32304. * Returns 0 by default. Implemented by child classes
  32305. * @returns an integer
  32306. */
  32307. getTotalVertices(): number;
  32308. /**
  32309. * Returns a positive integer : the total number of indices in this mesh geometry.
  32310. * @returns the numner of indices or zero if the mesh has no geometry.
  32311. */
  32312. getTotalIndices(): number;
  32313. /**
  32314. * Returns null by default. Implemented by child classes
  32315. * @returns null
  32316. */
  32317. getIndices(): Nullable<IndicesArray>;
  32318. /**
  32319. * Returns the array of the requested vertex data kind. Implemented by child classes
  32320. * @param kind defines the vertex data kind to use
  32321. * @returns null
  32322. */
  32323. getVerticesData(kind: string): Nullable<FloatArray>;
  32324. /**
  32325. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32326. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32327. * Note that a new underlying VertexBuffer object is created each call.
  32328. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32329. * @param kind defines vertex data kind:
  32330. * * VertexBuffer.PositionKind
  32331. * * VertexBuffer.UVKind
  32332. * * VertexBuffer.UV2Kind
  32333. * * VertexBuffer.UV3Kind
  32334. * * VertexBuffer.UV4Kind
  32335. * * VertexBuffer.UV5Kind
  32336. * * VertexBuffer.UV6Kind
  32337. * * VertexBuffer.ColorKind
  32338. * * VertexBuffer.MatricesIndicesKind
  32339. * * VertexBuffer.MatricesIndicesExtraKind
  32340. * * VertexBuffer.MatricesWeightsKind
  32341. * * VertexBuffer.MatricesWeightsExtraKind
  32342. * @param data defines the data source
  32343. * @param updatable defines if the data must be flagged as updatable (or static)
  32344. * @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
  32345. * @returns the current mesh
  32346. */
  32347. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32348. /**
  32349. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32350. * If the mesh has no geometry, it is simply returned as it is.
  32351. * @param kind defines vertex data kind:
  32352. * * VertexBuffer.PositionKind
  32353. * * VertexBuffer.UVKind
  32354. * * VertexBuffer.UV2Kind
  32355. * * VertexBuffer.UV3Kind
  32356. * * VertexBuffer.UV4Kind
  32357. * * VertexBuffer.UV5Kind
  32358. * * VertexBuffer.UV6Kind
  32359. * * VertexBuffer.ColorKind
  32360. * * VertexBuffer.MatricesIndicesKind
  32361. * * VertexBuffer.MatricesIndicesExtraKind
  32362. * * VertexBuffer.MatricesWeightsKind
  32363. * * VertexBuffer.MatricesWeightsExtraKind
  32364. * @param data defines the data source
  32365. * @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
  32366. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32367. * @returns the current mesh
  32368. */
  32369. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32370. /**
  32371. * Sets the mesh indices,
  32372. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32373. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32374. * @param totalVertices Defines the total number of vertices
  32375. * @returns the current mesh
  32376. */
  32377. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32378. /**
  32379. * Gets a boolean indicating if specific vertex data is present
  32380. * @param kind defines the vertex data kind to use
  32381. * @returns true is data kind is present
  32382. */
  32383. isVerticesDataPresent(kind: string): boolean;
  32384. /**
  32385. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32386. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32387. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32388. * @returns a BoundingInfo
  32389. */
  32390. getBoundingInfo(): BoundingInfo;
  32391. /**
  32392. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32393. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32394. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32395. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32396. * @returns the current mesh
  32397. */
  32398. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32399. /**
  32400. * Overwrite the current bounding info
  32401. * @param boundingInfo defines the new bounding info
  32402. * @returns the current mesh
  32403. */
  32404. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32405. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32406. get useBones(): boolean;
  32407. /** @hidden */
  32408. _preActivate(): void;
  32409. /** @hidden */
  32410. _preActivateForIntermediateRendering(renderId: number): void;
  32411. /** @hidden */
  32412. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32413. /** @hidden */
  32414. _postActivate(): void;
  32415. /** @hidden */
  32416. _freeze(): void;
  32417. /** @hidden */
  32418. _unFreeze(): void;
  32419. /**
  32420. * Gets the current world matrix
  32421. * @returns a Matrix
  32422. */
  32423. getWorldMatrix(): Matrix;
  32424. /** @hidden */
  32425. _getWorldMatrixDeterminant(): number;
  32426. /**
  32427. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32428. */
  32429. get isAnInstance(): boolean;
  32430. /**
  32431. * Gets a boolean indicating if this mesh has instances
  32432. */
  32433. get hasInstances(): boolean;
  32434. /**
  32435. * Gets a boolean indicating if this mesh has thin instances
  32436. */
  32437. get hasThinInstances(): boolean;
  32438. /**
  32439. * Perform relative position change from the point of view of behind the front of the mesh.
  32440. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32441. * Supports definition of mesh facing forward or backward
  32442. * @param amountRight defines the distance on the right axis
  32443. * @param amountUp defines the distance on the up axis
  32444. * @param amountForward defines the distance on the forward axis
  32445. * @returns the current mesh
  32446. */
  32447. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32448. /**
  32449. * Calculate relative position change from the point of view of behind the front of the mesh.
  32450. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32451. * Supports definition of mesh facing forward or backward
  32452. * @param amountRight defines the distance on the right axis
  32453. * @param amountUp defines the distance on the up axis
  32454. * @param amountForward defines the distance on the forward axis
  32455. * @returns the new displacement vector
  32456. */
  32457. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32458. /**
  32459. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32460. * Supports definition of mesh facing forward or backward
  32461. * @param flipBack defines the flip
  32462. * @param twirlClockwise defines the twirl
  32463. * @param tiltRight defines the tilt
  32464. * @returns the current mesh
  32465. */
  32466. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32467. /**
  32468. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32469. * Supports definition of mesh facing forward or backward.
  32470. * @param flipBack defines the flip
  32471. * @param twirlClockwise defines the twirl
  32472. * @param tiltRight defines the tilt
  32473. * @returns the new rotation vector
  32474. */
  32475. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32476. /**
  32477. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32478. * This means the mesh underlying bounding box and sphere are recomputed.
  32479. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32480. * @returns the current mesh
  32481. */
  32482. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32483. /** @hidden */
  32484. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32485. /** @hidden */
  32486. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32487. /** @hidden */
  32488. _updateBoundingInfo(): AbstractMesh;
  32489. /** @hidden */
  32490. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32491. /** @hidden */
  32492. protected _afterComputeWorldMatrix(): void;
  32493. /** @hidden */
  32494. get _effectiveMesh(): AbstractMesh;
  32495. /**
  32496. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32497. * A mesh is in the frustum if its bounding box intersects the frustum
  32498. * @param frustumPlanes defines the frustum to test
  32499. * @returns true if the mesh is in the frustum planes
  32500. */
  32501. isInFrustum(frustumPlanes: Plane[]): boolean;
  32502. /**
  32503. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32504. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32505. * @param frustumPlanes defines the frustum to test
  32506. * @returns true if the mesh is completely in the frustum planes
  32507. */
  32508. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32509. /**
  32510. * True if the mesh intersects another mesh or a SolidParticle object
  32511. * @param mesh defines a target mesh or SolidParticle to test
  32512. * @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)
  32513. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32514. * @returns true if there is an intersection
  32515. */
  32516. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32517. /**
  32518. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32519. * @param point defines the point to test
  32520. * @returns true if there is an intersection
  32521. */
  32522. intersectsPoint(point: Vector3): boolean;
  32523. /**
  32524. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32526. */
  32527. get checkCollisions(): boolean;
  32528. set checkCollisions(collisionEnabled: boolean);
  32529. /**
  32530. * Gets Collider object used to compute collisions (not physics)
  32531. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32532. */
  32533. get collider(): Nullable<Collider>;
  32534. /**
  32535. * Move the mesh using collision engine
  32536. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32537. * @param displacement defines the requested displacement vector
  32538. * @returns the current mesh
  32539. */
  32540. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32541. private _onCollisionPositionChange;
  32542. /** @hidden */
  32543. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32544. /** @hidden */
  32545. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32546. /** @hidden */
  32547. _checkCollision(collider: Collider): AbstractMesh;
  32548. /** @hidden */
  32549. _generatePointsArray(): boolean;
  32550. /**
  32551. * Checks if the passed Ray intersects with the mesh
  32552. * @param ray defines the ray to use
  32553. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32554. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32555. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32556. * @returns the picking info
  32557. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32558. */
  32559. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32560. /**
  32561. * Clones the current mesh
  32562. * @param name defines the mesh name
  32563. * @param newParent defines the new mesh parent
  32564. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32565. * @returns the new mesh
  32566. */
  32567. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32568. /**
  32569. * Disposes all the submeshes of the current meshnp
  32570. * @returns the current mesh
  32571. */
  32572. releaseSubMeshes(): AbstractMesh;
  32573. /**
  32574. * Releases resources associated with this abstract mesh.
  32575. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32576. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32577. */
  32578. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32579. /**
  32580. * Adds the passed mesh as a child to the current mesh
  32581. * @param mesh defines the child mesh
  32582. * @returns the current mesh
  32583. */
  32584. addChild(mesh: AbstractMesh): AbstractMesh;
  32585. /**
  32586. * Removes the passed mesh from the current mesh children list
  32587. * @param mesh defines the child mesh
  32588. * @returns the current mesh
  32589. */
  32590. removeChild(mesh: AbstractMesh): AbstractMesh;
  32591. /** @hidden */
  32592. private _initFacetData;
  32593. /**
  32594. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32595. * This method can be called within the render loop.
  32596. * 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
  32597. * @returns the current mesh
  32598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32599. */
  32600. updateFacetData(): AbstractMesh;
  32601. /**
  32602. * Returns the facetLocalNormals array.
  32603. * The normals are expressed in the mesh local spac
  32604. * @returns an array of Vector3
  32605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32606. */
  32607. getFacetLocalNormals(): Vector3[];
  32608. /**
  32609. * Returns the facetLocalPositions array.
  32610. * The facet positions are expressed in the mesh local space
  32611. * @returns an array of Vector3
  32612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32613. */
  32614. getFacetLocalPositions(): Vector3[];
  32615. /**
  32616. * Returns the facetLocalPartioning array
  32617. * @returns an array of array of numbers
  32618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32619. */
  32620. getFacetLocalPartitioning(): number[][];
  32621. /**
  32622. * Returns the i-th facet position in the world system.
  32623. * This method allocates a new Vector3 per call
  32624. * @param i defines the facet index
  32625. * @returns a new Vector3
  32626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32627. */
  32628. getFacetPosition(i: number): Vector3;
  32629. /**
  32630. * Sets the reference Vector3 with the i-th facet position in the world system
  32631. * @param i defines the facet index
  32632. * @param ref defines the target vector
  32633. * @returns the current mesh
  32634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32635. */
  32636. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32637. /**
  32638. * Returns the i-th facet normal in the world system.
  32639. * This method allocates a new Vector3 per call
  32640. * @param i defines the facet index
  32641. * @returns a new Vector3
  32642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32643. */
  32644. getFacetNormal(i: number): Vector3;
  32645. /**
  32646. * Sets the reference Vector3 with the i-th facet normal in the world system
  32647. * @param i defines the facet index
  32648. * @param ref defines the target vector
  32649. * @returns the current mesh
  32650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32651. */
  32652. getFacetNormalToRef(i: number, ref: Vector3): this;
  32653. /**
  32654. * 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)
  32655. * @param x defines x coordinate
  32656. * @param y defines y coordinate
  32657. * @param z defines z coordinate
  32658. * @returns the array of facet indexes
  32659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32660. */
  32661. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32662. /**
  32663. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32664. * @param projected sets as the (x,y,z) world projection on the facet
  32665. * @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
  32666. * @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
  32667. * @param x defines x coordinate
  32668. * @param y defines y coordinate
  32669. * @param z defines z coordinate
  32670. * @returns the face index if found (or null instead)
  32671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32672. */
  32673. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32674. /**
  32675. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32676. * @param projected sets as the (x,y,z) local projection on the facet
  32677. * @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
  32678. * @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
  32679. * @param x defines x coordinate
  32680. * @param y defines y coordinate
  32681. * @param z defines z coordinate
  32682. * @returns the face index if found (or null instead)
  32683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32684. */
  32685. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32686. /**
  32687. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32688. * @returns the parameters
  32689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32690. */
  32691. getFacetDataParameters(): any;
  32692. /**
  32693. * Disables the feature FacetData and frees the related memory
  32694. * @returns the current mesh
  32695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32696. */
  32697. disableFacetData(): AbstractMesh;
  32698. /**
  32699. * Updates the AbstractMesh indices array
  32700. * @param indices defines the data source
  32701. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32702. * @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)
  32703. * @returns the current mesh
  32704. */
  32705. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32706. /**
  32707. * Creates new normals data for the mesh
  32708. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32709. * @returns the current mesh
  32710. */
  32711. createNormals(updatable: boolean): AbstractMesh;
  32712. /**
  32713. * Align the mesh with a normal
  32714. * @param normal defines the normal to use
  32715. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32716. * @returns the current mesh
  32717. */
  32718. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32719. /** @hidden */
  32720. _checkOcclusionQuery(): boolean;
  32721. /**
  32722. * Disables the mesh edge rendering mode
  32723. * @returns the currentAbstractMesh
  32724. */
  32725. disableEdgesRendering(): AbstractMesh;
  32726. /**
  32727. * Enables the edge rendering mode on the mesh.
  32728. * This mode makes the mesh edges visible
  32729. * @param epsilon defines the maximal distance between two angles to detect a face
  32730. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32731. * @returns the currentAbstractMesh
  32732. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32733. */
  32734. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32735. }
  32736. }
  32737. declare module "babylonjs/Actions/actionEvent" {
  32738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32739. import { Nullable } from "babylonjs/types";
  32740. import { Sprite } from "babylonjs/Sprites/sprite";
  32741. import { Scene } from "babylonjs/scene";
  32742. import { Vector2 } from "babylonjs/Maths/math.vector";
  32743. /**
  32744. * Interface used to define ActionEvent
  32745. */
  32746. export interface IActionEvent {
  32747. /** The mesh or sprite that triggered the action */
  32748. source: any;
  32749. /** The X mouse cursor position at the time of the event */
  32750. pointerX: number;
  32751. /** The Y mouse cursor position at the time of the event */
  32752. pointerY: number;
  32753. /** The mesh that is currently pointed at (can be null) */
  32754. meshUnderPointer: Nullable<AbstractMesh>;
  32755. /** the original (browser) event that triggered the ActionEvent */
  32756. sourceEvent?: any;
  32757. /** additional data for the event */
  32758. additionalData?: any;
  32759. }
  32760. /**
  32761. * ActionEvent is the event being sent when an action is triggered.
  32762. */
  32763. export class ActionEvent implements IActionEvent {
  32764. /** The mesh or sprite that triggered the action */
  32765. source: any;
  32766. /** The X mouse cursor position at the time of the event */
  32767. pointerX: number;
  32768. /** The Y mouse cursor position at the time of the event */
  32769. pointerY: number;
  32770. /** The mesh that is currently pointed at (can be null) */
  32771. meshUnderPointer: Nullable<AbstractMesh>;
  32772. /** the original (browser) event that triggered the ActionEvent */
  32773. sourceEvent?: any;
  32774. /** additional data for the event */
  32775. additionalData?: any;
  32776. /**
  32777. * Creates a new ActionEvent
  32778. * @param source The mesh or sprite that triggered the action
  32779. * @param pointerX The X mouse cursor position at the time of the event
  32780. * @param pointerY The Y mouse cursor position at the time of the event
  32781. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32782. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32783. * @param additionalData additional data for the event
  32784. */
  32785. constructor(
  32786. /** The mesh or sprite that triggered the action */
  32787. source: any,
  32788. /** The X mouse cursor position at the time of the event */
  32789. pointerX: number,
  32790. /** The Y mouse cursor position at the time of the event */
  32791. pointerY: number,
  32792. /** The mesh that is currently pointed at (can be null) */
  32793. meshUnderPointer: Nullable<AbstractMesh>,
  32794. /** the original (browser) event that triggered the ActionEvent */
  32795. sourceEvent?: any,
  32796. /** additional data for the event */
  32797. additionalData?: any);
  32798. /**
  32799. * Helper function to auto-create an ActionEvent from a source mesh.
  32800. * @param source The source mesh that triggered the event
  32801. * @param evt The original (browser) event
  32802. * @param additionalData additional data for the event
  32803. * @returns the new ActionEvent
  32804. */
  32805. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32806. /**
  32807. * Helper function to auto-create an ActionEvent from a source sprite
  32808. * @param source The source sprite that triggered the event
  32809. * @param scene Scene associated with the sprite
  32810. * @param evt The original (browser) event
  32811. * @param additionalData additional data for the event
  32812. * @returns the new ActionEvent
  32813. */
  32814. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32815. /**
  32816. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32817. * @param scene the scene where the event occurred
  32818. * @param evt The original (browser) event
  32819. * @returns the new ActionEvent
  32820. */
  32821. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32822. /**
  32823. * Helper function to auto-create an ActionEvent from a primitive
  32824. * @param prim defines the target primitive
  32825. * @param pointerPos defines the pointer position
  32826. * @param evt The original (browser) event
  32827. * @param additionalData additional data for the event
  32828. * @returns the new ActionEvent
  32829. */
  32830. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32831. }
  32832. }
  32833. declare module "babylonjs/Actions/abstractActionManager" {
  32834. import { IDisposable } from "babylonjs/scene";
  32835. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32836. import { IAction } from "babylonjs/Actions/action";
  32837. import { Nullable } from "babylonjs/types";
  32838. /**
  32839. * Abstract class used to decouple action Manager from scene and meshes.
  32840. * Do not instantiate.
  32841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32842. */
  32843. export abstract class AbstractActionManager implements IDisposable {
  32844. /** Gets the list of active triggers */
  32845. static Triggers: {
  32846. [key: string]: number;
  32847. };
  32848. /** Gets the cursor to use when hovering items */
  32849. hoverCursor: string;
  32850. /** Gets the list of actions */
  32851. actions: IAction[];
  32852. /**
  32853. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32854. */
  32855. isRecursive: boolean;
  32856. /**
  32857. * Releases all associated resources
  32858. */
  32859. abstract dispose(): void;
  32860. /**
  32861. * Does this action manager has pointer triggers
  32862. */
  32863. abstract get hasPointerTriggers(): boolean;
  32864. /**
  32865. * Does this action manager has pick triggers
  32866. */
  32867. abstract get hasPickTriggers(): boolean;
  32868. /**
  32869. * Process a specific trigger
  32870. * @param trigger defines the trigger to process
  32871. * @param evt defines the event details to be processed
  32872. */
  32873. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32874. /**
  32875. * Does this action manager handles actions of any of the given triggers
  32876. * @param triggers defines the triggers to be tested
  32877. * @return a boolean indicating whether one (or more) of the triggers is handled
  32878. */
  32879. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32880. /**
  32881. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32882. * speed.
  32883. * @param triggerA defines the trigger to be tested
  32884. * @param triggerB defines the trigger to be tested
  32885. * @return a boolean indicating whether one (or more) of the triggers is handled
  32886. */
  32887. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32888. /**
  32889. * Does this action manager handles actions of a given trigger
  32890. * @param trigger defines the trigger to be tested
  32891. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32892. * @return whether the trigger is handled
  32893. */
  32894. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32895. /**
  32896. * Serialize this manager to a JSON object
  32897. * @param name defines the property name to store this manager
  32898. * @returns a JSON representation of this manager
  32899. */
  32900. abstract serialize(name: string): any;
  32901. /**
  32902. * Registers an action to this action manager
  32903. * @param action defines the action to be registered
  32904. * @return the action amended (prepared) after registration
  32905. */
  32906. abstract registerAction(action: IAction): Nullable<IAction>;
  32907. /**
  32908. * Unregisters an action to this action manager
  32909. * @param action defines the action to be unregistered
  32910. * @return a boolean indicating whether the action has been unregistered
  32911. */
  32912. abstract unregisterAction(action: IAction): Boolean;
  32913. /**
  32914. * Does exist one action manager with at least one trigger
  32915. **/
  32916. static get HasTriggers(): boolean;
  32917. /**
  32918. * Does exist one action manager with at least one pick trigger
  32919. **/
  32920. static get HasPickTriggers(): boolean;
  32921. /**
  32922. * Does exist one action manager that handles actions of a given trigger
  32923. * @param trigger defines the trigger to be tested
  32924. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32925. **/
  32926. static HasSpecificTrigger(trigger: number): boolean;
  32927. }
  32928. }
  32929. declare module "babylonjs/node" {
  32930. import { Scene } from "babylonjs/scene";
  32931. import { Nullable } from "babylonjs/types";
  32932. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32933. import { Engine } from "babylonjs/Engines/engine";
  32934. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  32935. import { Observable } from "babylonjs/Misc/observable";
  32936. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32937. import { IInspectable } from "babylonjs/Misc/iInspectable";
  32938. import { Animatable } from "babylonjs/Animations/animatable";
  32939. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32940. import { Animation } from "babylonjs/Animations/animation";
  32941. import { AnimationRange } from "babylonjs/Animations/animationRange";
  32942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32943. /**
  32944. * Defines how a node can be built from a string name.
  32945. */
  32946. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32947. /**
  32948. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32949. */
  32950. export class Node implements IBehaviorAware<Node> {
  32951. /** @hidden */
  32952. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  32953. private static _NodeConstructors;
  32954. /**
  32955. * Add a new node constructor
  32956. * @param type defines the type name of the node to construct
  32957. * @param constructorFunc defines the constructor function
  32958. */
  32959. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32960. /**
  32961. * Returns a node constructor based on type name
  32962. * @param type defines the type name
  32963. * @param name defines the new node name
  32964. * @param scene defines the hosting scene
  32965. * @param options defines optional options to transmit to constructors
  32966. * @returns the new constructor or null
  32967. */
  32968. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32969. /**
  32970. * Gets or sets the name of the node
  32971. */
  32972. name: string;
  32973. /**
  32974. * Gets or sets the id of the node
  32975. */
  32976. id: string;
  32977. /**
  32978. * Gets or sets the unique id of the node
  32979. */
  32980. uniqueId: number;
  32981. /**
  32982. * Gets or sets a string used to store user defined state for the node
  32983. */
  32984. state: string;
  32985. /**
  32986. * Gets or sets an object used to store user defined information for the node
  32987. */
  32988. metadata: any;
  32989. /**
  32990. * For internal use only. Please do not use.
  32991. */
  32992. reservedDataStore: any;
  32993. /**
  32994. * List of inspectable custom properties (used by the Inspector)
  32995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32996. */
  32997. inspectableCustomProperties: IInspectable[];
  32998. private _doNotSerialize;
  32999. /**
  33000. * Gets or sets a boolean used to define if the node must be serialized
  33001. */
  33002. get doNotSerialize(): boolean;
  33003. set doNotSerialize(value: boolean);
  33004. /** @hidden */
  33005. _isDisposed: boolean;
  33006. /**
  33007. * Gets a list of Animations associated with the node
  33008. */
  33009. animations: import("babylonjs/Animations/animation").Animation[];
  33010. protected _ranges: {
  33011. [name: string]: Nullable<AnimationRange>;
  33012. };
  33013. /**
  33014. * Callback raised when the node is ready to be used
  33015. */
  33016. onReady: Nullable<(node: Node) => void>;
  33017. private _isEnabled;
  33018. private _isParentEnabled;
  33019. private _isReady;
  33020. /** @hidden */
  33021. _currentRenderId: number;
  33022. private _parentUpdateId;
  33023. /** @hidden */
  33024. _childUpdateId: number;
  33025. /** @hidden */
  33026. _waitingParentId: Nullable<string>;
  33027. /** @hidden */
  33028. _scene: Scene;
  33029. /** @hidden */
  33030. _cache: any;
  33031. private _parentNode;
  33032. private _children;
  33033. /** @hidden */
  33034. _worldMatrix: Matrix;
  33035. /** @hidden */
  33036. _worldMatrixDeterminant: number;
  33037. /** @hidden */
  33038. _worldMatrixDeterminantIsDirty: boolean;
  33039. /** @hidden */
  33040. private _sceneRootNodesIndex;
  33041. /**
  33042. * Gets a boolean indicating if the node has been disposed
  33043. * @returns true if the node was disposed
  33044. */
  33045. isDisposed(): boolean;
  33046. /**
  33047. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33048. * @see https://doc.babylonjs.com/how_to/parenting
  33049. */
  33050. set parent(parent: Nullable<Node>);
  33051. get parent(): Nullable<Node>;
  33052. /** @hidden */
  33053. _addToSceneRootNodes(): void;
  33054. /** @hidden */
  33055. _removeFromSceneRootNodes(): void;
  33056. private _animationPropertiesOverride;
  33057. /**
  33058. * Gets or sets the animation properties override
  33059. */
  33060. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33061. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33062. /**
  33063. * Gets a string idenfifying the name of the class
  33064. * @returns "Node" string
  33065. */
  33066. getClassName(): string;
  33067. /** @hidden */
  33068. readonly _isNode: boolean;
  33069. /**
  33070. * An event triggered when the mesh is disposed
  33071. */
  33072. onDisposeObservable: Observable<Node>;
  33073. private _onDisposeObserver;
  33074. /**
  33075. * Sets a callback that will be raised when the node will be disposed
  33076. */
  33077. set onDispose(callback: () => void);
  33078. /**
  33079. * Creates a new Node
  33080. * @param name the name and id to be given to this node
  33081. * @param scene the scene this node will be added to
  33082. */
  33083. constructor(name: string, scene?: Nullable<Scene>);
  33084. /**
  33085. * Gets the scene of the node
  33086. * @returns a scene
  33087. */
  33088. getScene(): Scene;
  33089. /**
  33090. * Gets the engine of the node
  33091. * @returns a Engine
  33092. */
  33093. getEngine(): Engine;
  33094. private _behaviors;
  33095. /**
  33096. * Attach a behavior to the node
  33097. * @see http://doc.babylonjs.com/features/behaviour
  33098. * @param behavior defines the behavior to attach
  33099. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33100. * @returns the current Node
  33101. */
  33102. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33103. /**
  33104. * Remove an attached behavior
  33105. * @see http://doc.babylonjs.com/features/behaviour
  33106. * @param behavior defines the behavior to attach
  33107. * @returns the current Node
  33108. */
  33109. removeBehavior(behavior: Behavior<Node>): Node;
  33110. /**
  33111. * Gets the list of attached behaviors
  33112. * @see http://doc.babylonjs.com/features/behaviour
  33113. */
  33114. get behaviors(): Behavior<Node>[];
  33115. /**
  33116. * Gets an attached behavior by name
  33117. * @param name defines the name of the behavior to look for
  33118. * @see http://doc.babylonjs.com/features/behaviour
  33119. * @returns null if behavior was not found else the requested behavior
  33120. */
  33121. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33122. /**
  33123. * Returns the latest update of the World matrix
  33124. * @returns a Matrix
  33125. */
  33126. getWorldMatrix(): Matrix;
  33127. /** @hidden */
  33128. _getWorldMatrixDeterminant(): number;
  33129. /**
  33130. * Returns directly the latest state of the mesh World matrix.
  33131. * A Matrix is returned.
  33132. */
  33133. get worldMatrixFromCache(): Matrix;
  33134. /** @hidden */
  33135. _initCache(): void;
  33136. /** @hidden */
  33137. updateCache(force?: boolean): void;
  33138. /** @hidden */
  33139. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33140. /** @hidden */
  33141. _updateCache(ignoreParentClass?: boolean): void;
  33142. /** @hidden */
  33143. _isSynchronized(): boolean;
  33144. /** @hidden */
  33145. _markSyncedWithParent(): void;
  33146. /** @hidden */
  33147. isSynchronizedWithParent(): boolean;
  33148. /** @hidden */
  33149. isSynchronized(): boolean;
  33150. /**
  33151. * Is this node ready to be used/rendered
  33152. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33153. * @return true if the node is ready
  33154. */
  33155. isReady(completeCheck?: boolean): boolean;
  33156. /**
  33157. * Is this node enabled?
  33158. * 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
  33159. * @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
  33160. * @return whether this node (and its parent) is enabled
  33161. */
  33162. isEnabled(checkAncestors?: boolean): boolean;
  33163. /** @hidden */
  33164. protected _syncParentEnabledState(): void;
  33165. /**
  33166. * Set the enabled state of this node
  33167. * @param value defines the new enabled state
  33168. */
  33169. setEnabled(value: boolean): void;
  33170. /**
  33171. * Is this node a descendant of the given node?
  33172. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33173. * @param ancestor defines the parent node to inspect
  33174. * @returns a boolean indicating if this node is a descendant of the given node
  33175. */
  33176. isDescendantOf(ancestor: Node): boolean;
  33177. /** @hidden */
  33178. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33179. /**
  33180. * Will return all nodes that have this node as ascendant
  33181. * @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
  33182. * @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
  33183. * @return all children nodes of all types
  33184. */
  33185. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33186. /**
  33187. * Get all child-meshes of this node
  33188. * @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)
  33189. * @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
  33190. * @returns an array of AbstractMesh
  33191. */
  33192. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33193. /**
  33194. * Get all direct children of this node
  33195. * @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
  33196. * @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)
  33197. * @returns an array of Node
  33198. */
  33199. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33200. /** @hidden */
  33201. _setReady(state: boolean): void;
  33202. /**
  33203. * Get an animation by name
  33204. * @param name defines the name of the animation to look for
  33205. * @returns null if not found else the requested animation
  33206. */
  33207. getAnimationByName(name: string): Nullable<Animation>;
  33208. /**
  33209. * Creates an animation range for this node
  33210. * @param name defines the name of the range
  33211. * @param from defines the starting key
  33212. * @param to defines the end key
  33213. */
  33214. createAnimationRange(name: string, from: number, to: number): void;
  33215. /**
  33216. * Delete a specific animation range
  33217. * @param name defines the name of the range to delete
  33218. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33219. */
  33220. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33221. /**
  33222. * Get an animation range by name
  33223. * @param name defines the name of the animation range to look for
  33224. * @returns null if not found else the requested animation range
  33225. */
  33226. getAnimationRange(name: string): Nullable<AnimationRange>;
  33227. /**
  33228. * Gets the list of all animation ranges defined on this node
  33229. * @returns an array
  33230. */
  33231. getAnimationRanges(): Nullable<AnimationRange>[];
  33232. /**
  33233. * Will start the animation sequence
  33234. * @param name defines the range frames for animation sequence
  33235. * @param loop defines if the animation should loop (false by default)
  33236. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33237. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33238. * @returns the object created for this animation. If range does not exist, it will return null
  33239. */
  33240. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33241. /**
  33242. * Serialize animation ranges into a JSON compatible object
  33243. * @returns serialization object
  33244. */
  33245. serializeAnimationRanges(): any;
  33246. /**
  33247. * Computes the world matrix of the node
  33248. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33249. * @returns the world matrix
  33250. */
  33251. computeWorldMatrix(force?: boolean): Matrix;
  33252. /**
  33253. * Releases resources associated with this node.
  33254. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33255. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33256. */
  33257. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33258. /**
  33259. * Parse animation range data from a serialization object and store them into a given node
  33260. * @param node defines where to store the animation ranges
  33261. * @param parsedNode defines the serialization object to read data from
  33262. * @param scene defines the hosting scene
  33263. */
  33264. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33265. /**
  33266. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33267. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33268. * @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
  33269. * @returns the new bounding vectors
  33270. */
  33271. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33272. min: Vector3;
  33273. max: Vector3;
  33274. };
  33275. }
  33276. }
  33277. declare module "babylonjs/Animations/animation" {
  33278. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33279. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33280. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33281. import { Nullable } from "babylonjs/types";
  33282. import { Scene } from "babylonjs/scene";
  33283. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33284. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33285. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33286. import { Node } from "babylonjs/node";
  33287. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33288. import { Size } from "babylonjs/Maths/math.size";
  33289. import { Animatable } from "babylonjs/Animations/animatable";
  33290. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33291. /**
  33292. * @hidden
  33293. */
  33294. export class _IAnimationState {
  33295. key: number;
  33296. repeatCount: number;
  33297. workValue?: any;
  33298. loopMode?: number;
  33299. offsetValue?: any;
  33300. highLimitValue?: any;
  33301. }
  33302. /**
  33303. * Class used to store any kind of animation
  33304. */
  33305. export class Animation {
  33306. /**Name of the animation */
  33307. name: string;
  33308. /**Property to animate */
  33309. targetProperty: string;
  33310. /**The frames per second of the animation */
  33311. framePerSecond: number;
  33312. /**The data type of the animation */
  33313. dataType: number;
  33314. /**The loop mode of the animation */
  33315. loopMode?: number | undefined;
  33316. /**Specifies if blending should be enabled */
  33317. enableBlending?: boolean | undefined;
  33318. /**
  33319. * Use matrix interpolation instead of using direct key value when animating matrices
  33320. */
  33321. static AllowMatricesInterpolation: boolean;
  33322. /**
  33323. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33324. */
  33325. static AllowMatrixDecomposeForInterpolation: boolean;
  33326. /**
  33327. * Stores the key frames of the animation
  33328. */
  33329. private _keys;
  33330. /**
  33331. * Stores the easing function of the animation
  33332. */
  33333. private _easingFunction;
  33334. /**
  33335. * @hidden Internal use only
  33336. */
  33337. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33338. /**
  33339. * The set of event that will be linked to this animation
  33340. */
  33341. private _events;
  33342. /**
  33343. * Stores an array of target property paths
  33344. */
  33345. targetPropertyPath: string[];
  33346. /**
  33347. * Stores the blending speed of the animation
  33348. */
  33349. blendingSpeed: number;
  33350. /**
  33351. * Stores the animation ranges for the animation
  33352. */
  33353. private _ranges;
  33354. /**
  33355. * @hidden Internal use
  33356. */
  33357. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33358. /**
  33359. * Sets up an animation
  33360. * @param property The property to animate
  33361. * @param animationType The animation type to apply
  33362. * @param framePerSecond The frames per second of the animation
  33363. * @param easingFunction The easing function used in the animation
  33364. * @returns The created animation
  33365. */
  33366. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33367. /**
  33368. * Create and start an animation on a node
  33369. * @param name defines the name of the global animation that will be run on all nodes
  33370. * @param node defines the root node where the animation will take place
  33371. * @param targetProperty defines property to animate
  33372. * @param framePerSecond defines the number of frame per second yo use
  33373. * @param totalFrame defines the number of frames in total
  33374. * @param from defines the initial value
  33375. * @param to defines the final value
  33376. * @param loopMode defines which loop mode you want to use (off by default)
  33377. * @param easingFunction defines the easing function to use (linear by default)
  33378. * @param onAnimationEnd defines the callback to call when animation end
  33379. * @returns the animatable created for this animation
  33380. */
  33381. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33382. /**
  33383. * Create and start an animation on a node and its descendants
  33384. * @param name defines the name of the global animation that will be run on all nodes
  33385. * @param node defines the root node where the animation will take place
  33386. * @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
  33387. * @param targetProperty defines property to animate
  33388. * @param framePerSecond defines the number of frame per second to use
  33389. * @param totalFrame defines the number of frames in total
  33390. * @param from defines the initial value
  33391. * @param to defines the final value
  33392. * @param loopMode defines which loop mode you want to use (off by default)
  33393. * @param easingFunction defines the easing function to use (linear by default)
  33394. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33395. * @returns the list of animatables created for all nodes
  33396. * @example https://www.babylonjs-playground.com/#MH0VLI
  33397. */
  33398. 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[]>;
  33399. /**
  33400. * Creates a new animation, merges it with the existing animations and starts it
  33401. * @param name Name of the animation
  33402. * @param node Node which contains the scene that begins the animations
  33403. * @param targetProperty Specifies which property to animate
  33404. * @param framePerSecond The frames per second of the animation
  33405. * @param totalFrame The total number of frames
  33406. * @param from The frame at the beginning of the animation
  33407. * @param to The frame at the end of the animation
  33408. * @param loopMode Specifies the loop mode of the animation
  33409. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33410. * @param onAnimationEnd Callback to run once the animation is complete
  33411. * @returns Nullable animation
  33412. */
  33413. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33414. /**
  33415. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33416. * @param sourceAnimation defines the Animation containing keyframes to convert
  33417. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33418. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33419. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33420. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33421. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33422. */
  33423. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33424. /**
  33425. * Transition property of an host to the target Value
  33426. * @param property The property to transition
  33427. * @param targetValue The target Value of the property
  33428. * @param host The object where the property to animate belongs
  33429. * @param scene Scene used to run the animation
  33430. * @param frameRate Framerate (in frame/s) to use
  33431. * @param transition The transition type we want to use
  33432. * @param duration The duration of the animation, in milliseconds
  33433. * @param onAnimationEnd Callback trigger at the end of the animation
  33434. * @returns Nullable animation
  33435. */
  33436. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33437. /**
  33438. * Return the array of runtime animations currently using this animation
  33439. */
  33440. get runtimeAnimations(): RuntimeAnimation[];
  33441. /**
  33442. * Specifies if any of the runtime animations are currently running
  33443. */
  33444. get hasRunningRuntimeAnimations(): boolean;
  33445. /**
  33446. * Initializes the animation
  33447. * @param name Name of the animation
  33448. * @param targetProperty Property to animate
  33449. * @param framePerSecond The frames per second of the animation
  33450. * @param dataType The data type of the animation
  33451. * @param loopMode The loop mode of the animation
  33452. * @param enableBlending Specifies if blending should be enabled
  33453. */
  33454. constructor(
  33455. /**Name of the animation */
  33456. name: string,
  33457. /**Property to animate */
  33458. targetProperty: string,
  33459. /**The frames per second of the animation */
  33460. framePerSecond: number,
  33461. /**The data type of the animation */
  33462. dataType: number,
  33463. /**The loop mode of the animation */
  33464. loopMode?: number | undefined,
  33465. /**Specifies if blending should be enabled */
  33466. enableBlending?: boolean | undefined);
  33467. /**
  33468. * Converts the animation to a string
  33469. * @param fullDetails support for multiple levels of logging within scene loading
  33470. * @returns String form of the animation
  33471. */
  33472. toString(fullDetails?: boolean): string;
  33473. /**
  33474. * Add an event to this animation
  33475. * @param event Event to add
  33476. */
  33477. addEvent(event: AnimationEvent): void;
  33478. /**
  33479. * Remove all events found at the given frame
  33480. * @param frame The frame to remove events from
  33481. */
  33482. removeEvents(frame: number): void;
  33483. /**
  33484. * Retrieves all the events from the animation
  33485. * @returns Events from the animation
  33486. */
  33487. getEvents(): AnimationEvent[];
  33488. /**
  33489. * Creates an animation range
  33490. * @param name Name of the animation range
  33491. * @param from Starting frame of the animation range
  33492. * @param to Ending frame of the animation
  33493. */
  33494. createRange(name: string, from: number, to: number): void;
  33495. /**
  33496. * Deletes an animation range by name
  33497. * @param name Name of the animation range to delete
  33498. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33499. */
  33500. deleteRange(name: string, deleteFrames?: boolean): void;
  33501. /**
  33502. * Gets the animation range by name, or null if not defined
  33503. * @param name Name of the animation range
  33504. * @returns Nullable animation range
  33505. */
  33506. getRange(name: string): Nullable<AnimationRange>;
  33507. /**
  33508. * Gets the key frames from the animation
  33509. * @returns The key frames of the animation
  33510. */
  33511. getKeys(): Array<IAnimationKey>;
  33512. /**
  33513. * Gets the highest frame rate of the animation
  33514. * @returns Highest frame rate of the animation
  33515. */
  33516. getHighestFrame(): number;
  33517. /**
  33518. * Gets the easing function of the animation
  33519. * @returns Easing function of the animation
  33520. */
  33521. getEasingFunction(): IEasingFunction;
  33522. /**
  33523. * Sets the easing function of the animation
  33524. * @param easingFunction A custom mathematical formula for animation
  33525. */
  33526. setEasingFunction(easingFunction: EasingFunction): void;
  33527. /**
  33528. * Interpolates a scalar linearly
  33529. * @param startValue Start value of the animation curve
  33530. * @param endValue End value of the animation curve
  33531. * @param gradient Scalar amount to interpolate
  33532. * @returns Interpolated scalar value
  33533. */
  33534. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33535. /**
  33536. * Interpolates a scalar cubically
  33537. * @param startValue Start value of the animation curve
  33538. * @param outTangent End tangent of the animation
  33539. * @param endValue End value of the animation curve
  33540. * @param inTangent Start tangent of the animation curve
  33541. * @param gradient Scalar amount to interpolate
  33542. * @returns Interpolated scalar value
  33543. */
  33544. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33545. /**
  33546. * Interpolates a quaternion using a spherical linear interpolation
  33547. * @param startValue Start value of the animation curve
  33548. * @param endValue End value of the animation curve
  33549. * @param gradient Scalar amount to interpolate
  33550. * @returns Interpolated quaternion value
  33551. */
  33552. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33553. /**
  33554. * Interpolates a quaternion cubically
  33555. * @param startValue Start value of the animation curve
  33556. * @param outTangent End tangent of the animation curve
  33557. * @param endValue End value of the animation curve
  33558. * @param inTangent Start tangent of the animation curve
  33559. * @param gradient Scalar amount to interpolate
  33560. * @returns Interpolated quaternion value
  33561. */
  33562. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33563. /**
  33564. * Interpolates a Vector3 linearl
  33565. * @param startValue Start value of the animation curve
  33566. * @param endValue End value of the animation curve
  33567. * @param gradient Scalar amount to interpolate
  33568. * @returns Interpolated scalar value
  33569. */
  33570. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33571. /**
  33572. * Interpolates a Vector3 cubically
  33573. * @param startValue Start value of the animation curve
  33574. * @param outTangent End tangent of the animation
  33575. * @param endValue End value of the animation curve
  33576. * @param inTangent Start tangent of the animation curve
  33577. * @param gradient Scalar amount to interpolate
  33578. * @returns InterpolatedVector3 value
  33579. */
  33580. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33581. /**
  33582. * Interpolates a Vector2 linearly
  33583. * @param startValue Start value of the animation curve
  33584. * @param endValue End value of the animation curve
  33585. * @param gradient Scalar amount to interpolate
  33586. * @returns Interpolated Vector2 value
  33587. */
  33588. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33589. /**
  33590. * Interpolates a Vector2 cubically
  33591. * @param startValue Start value of the animation curve
  33592. * @param outTangent End tangent of the animation
  33593. * @param endValue End value of the animation curve
  33594. * @param inTangent Start tangent of the animation curve
  33595. * @param gradient Scalar amount to interpolate
  33596. * @returns Interpolated Vector2 value
  33597. */
  33598. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33599. /**
  33600. * Interpolates a size linearly
  33601. * @param startValue Start value of the animation curve
  33602. * @param endValue End value of the animation curve
  33603. * @param gradient Scalar amount to interpolate
  33604. * @returns Interpolated Size value
  33605. */
  33606. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33607. /**
  33608. * Interpolates a Color3 linearly
  33609. * @param startValue Start value of the animation curve
  33610. * @param endValue End value of the animation curve
  33611. * @param gradient Scalar amount to interpolate
  33612. * @returns Interpolated Color3 value
  33613. */
  33614. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33615. /**
  33616. * Interpolates a Color4 linearly
  33617. * @param startValue Start value of the animation curve
  33618. * @param endValue End value of the animation curve
  33619. * @param gradient Scalar amount to interpolate
  33620. * @returns Interpolated Color3 value
  33621. */
  33622. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33623. /**
  33624. * @hidden Internal use only
  33625. */
  33626. _getKeyValue(value: any): any;
  33627. /**
  33628. * @hidden Internal use only
  33629. */
  33630. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33631. /**
  33632. * Defines the function to use to interpolate matrices
  33633. * @param startValue defines the start matrix
  33634. * @param endValue defines the end matrix
  33635. * @param gradient defines the gradient between both matrices
  33636. * @param result defines an optional target matrix where to store the interpolation
  33637. * @returns the interpolated matrix
  33638. */
  33639. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33640. /**
  33641. * Makes a copy of the animation
  33642. * @returns Cloned animation
  33643. */
  33644. clone(): Animation;
  33645. /**
  33646. * Sets the key frames of the animation
  33647. * @param values The animation key frames to set
  33648. */
  33649. setKeys(values: Array<IAnimationKey>): void;
  33650. /**
  33651. * Serializes the animation to an object
  33652. * @returns Serialized object
  33653. */
  33654. serialize(): any;
  33655. /**
  33656. * Float animation type
  33657. */
  33658. static readonly ANIMATIONTYPE_FLOAT: number;
  33659. /**
  33660. * Vector3 animation type
  33661. */
  33662. static readonly ANIMATIONTYPE_VECTOR3: number;
  33663. /**
  33664. * Quaternion animation type
  33665. */
  33666. static readonly ANIMATIONTYPE_QUATERNION: number;
  33667. /**
  33668. * Matrix animation type
  33669. */
  33670. static readonly ANIMATIONTYPE_MATRIX: number;
  33671. /**
  33672. * Color3 animation type
  33673. */
  33674. static readonly ANIMATIONTYPE_COLOR3: number;
  33675. /**
  33676. * Color3 animation type
  33677. */
  33678. static readonly ANIMATIONTYPE_COLOR4: number;
  33679. /**
  33680. * Vector2 animation type
  33681. */
  33682. static readonly ANIMATIONTYPE_VECTOR2: number;
  33683. /**
  33684. * Size animation type
  33685. */
  33686. static readonly ANIMATIONTYPE_SIZE: number;
  33687. /**
  33688. * Relative Loop Mode
  33689. */
  33690. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33691. /**
  33692. * Cycle Loop Mode
  33693. */
  33694. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33695. /**
  33696. * Constant Loop Mode
  33697. */
  33698. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33699. /** @hidden */
  33700. static _UniversalLerp(left: any, right: any, amount: number): any;
  33701. /**
  33702. * Parses an animation object and creates an animation
  33703. * @param parsedAnimation Parsed animation object
  33704. * @returns Animation object
  33705. */
  33706. static Parse(parsedAnimation: any): Animation;
  33707. /**
  33708. * Appends the serialized animations from the source animations
  33709. * @param source Source containing the animations
  33710. * @param destination Target to store the animations
  33711. */
  33712. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33713. }
  33714. }
  33715. declare module "babylonjs/Animations/animatable.interface" {
  33716. import { Nullable } from "babylonjs/types";
  33717. import { Animation } from "babylonjs/Animations/animation";
  33718. /**
  33719. * Interface containing an array of animations
  33720. */
  33721. export interface IAnimatable {
  33722. /**
  33723. * Array of animations
  33724. */
  33725. animations: Nullable<Array<Animation>>;
  33726. }
  33727. }
  33728. declare module "babylonjs/Misc/decorators" {
  33729. import { Nullable } from "babylonjs/types";
  33730. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33731. import { Scene } from "babylonjs/scene";
  33732. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33733. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33734. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33735. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33736. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33737. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33738. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33739. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33740. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33741. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33742. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33743. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33744. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33745. /**
  33746. * Decorator used to define property that can be serialized as reference to a camera
  33747. * @param sourceName defines the name of the property to decorate
  33748. */
  33749. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33750. /**
  33751. * Class used to help serialization objects
  33752. */
  33753. export class SerializationHelper {
  33754. /** @hidden */
  33755. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33756. /** @hidden */
  33757. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33758. /** @hidden */
  33759. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33760. /** @hidden */
  33761. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33762. /**
  33763. * Appends the serialized animations from the source animations
  33764. * @param source Source containing the animations
  33765. * @param destination Target to store the animations
  33766. */
  33767. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33768. /**
  33769. * Static function used to serialized a specific entity
  33770. * @param entity defines the entity to serialize
  33771. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33772. * @returns a JSON compatible object representing the serialization of the entity
  33773. */
  33774. static Serialize<T>(entity: T, serializationObject?: any): any;
  33775. /**
  33776. * Creates a new entity from a serialization data object
  33777. * @param creationFunction defines a function used to instanciated the new entity
  33778. * @param source defines the source serialization data
  33779. * @param scene defines the hosting scene
  33780. * @param rootUrl defines the root url for resources
  33781. * @returns a new entity
  33782. */
  33783. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33784. /**
  33785. * Clones an object
  33786. * @param creationFunction defines the function used to instanciate the new object
  33787. * @param source defines the source object
  33788. * @returns the cloned object
  33789. */
  33790. static Clone<T>(creationFunction: () => T, source: T): T;
  33791. /**
  33792. * Instanciates a new object based on a source one (some data will be shared between both object)
  33793. * @param creationFunction defines the function used to instanciate the new object
  33794. * @param source defines the source object
  33795. * @returns the new object
  33796. */
  33797. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33798. }
  33799. }
  33800. declare module "babylonjs/Materials/Textures/baseTexture" {
  33801. import { Observable } from "babylonjs/Misc/observable";
  33802. import { Nullable } from "babylonjs/types";
  33803. import { Scene } from "babylonjs/scene";
  33804. import { Matrix } from "babylonjs/Maths/math.vector";
  33805. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33806. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33807. import { ISize } from "babylonjs/Maths/math.size";
  33808. import "babylonjs/Misc/fileTools";
  33809. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33810. /**
  33811. * Base class of all the textures in babylon.
  33812. * It groups all the common properties the materials, post process, lights... might need
  33813. * in order to make a correct use of the texture.
  33814. */
  33815. export class BaseTexture implements IAnimatable {
  33816. /**
  33817. * Default anisotropic filtering level for the application.
  33818. * It is set to 4 as a good tradeoff between perf and quality.
  33819. */
  33820. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33821. /**
  33822. * Gets or sets the unique id of the texture
  33823. */
  33824. uniqueId: number;
  33825. /**
  33826. * Define the name of the texture.
  33827. */
  33828. name: string;
  33829. /**
  33830. * Gets or sets an object used to store user defined information.
  33831. */
  33832. metadata: any;
  33833. /**
  33834. * For internal use only. Please do not use.
  33835. */
  33836. reservedDataStore: any;
  33837. private _hasAlpha;
  33838. /**
  33839. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33840. */
  33841. set hasAlpha(value: boolean);
  33842. get hasAlpha(): boolean;
  33843. /**
  33844. * Defines if the alpha value should be determined via the rgb values.
  33845. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33846. */
  33847. getAlphaFromRGB: boolean;
  33848. /**
  33849. * Intensity or strength of the texture.
  33850. * It is commonly used by materials to fine tune the intensity of the texture
  33851. */
  33852. level: number;
  33853. /**
  33854. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33855. * This is part of the texture as textures usually maps to one uv set.
  33856. */
  33857. coordinatesIndex: number;
  33858. private _coordinatesMode;
  33859. /**
  33860. * How a texture is mapped.
  33861. *
  33862. * | Value | Type | Description |
  33863. * | ----- | ----------------------------------- | ----------- |
  33864. * | 0 | EXPLICIT_MODE | |
  33865. * | 1 | SPHERICAL_MODE | |
  33866. * | 2 | PLANAR_MODE | |
  33867. * | 3 | CUBIC_MODE | |
  33868. * | 4 | PROJECTION_MODE | |
  33869. * | 5 | SKYBOX_MODE | |
  33870. * | 6 | INVCUBIC_MODE | |
  33871. * | 7 | EQUIRECTANGULAR_MODE | |
  33872. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33873. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33874. */
  33875. set coordinatesMode(value: number);
  33876. get coordinatesMode(): number;
  33877. /**
  33878. * | Value | Type | Description |
  33879. * | ----- | ------------------ | ----------- |
  33880. * | 0 | CLAMP_ADDRESSMODE | |
  33881. * | 1 | WRAP_ADDRESSMODE | |
  33882. * | 2 | MIRROR_ADDRESSMODE | |
  33883. */
  33884. wrapU: number;
  33885. /**
  33886. * | Value | Type | Description |
  33887. * | ----- | ------------------ | ----------- |
  33888. * | 0 | CLAMP_ADDRESSMODE | |
  33889. * | 1 | WRAP_ADDRESSMODE | |
  33890. * | 2 | MIRROR_ADDRESSMODE | |
  33891. */
  33892. wrapV: number;
  33893. /**
  33894. * | Value | Type | Description |
  33895. * | ----- | ------------------ | ----------- |
  33896. * | 0 | CLAMP_ADDRESSMODE | |
  33897. * | 1 | WRAP_ADDRESSMODE | |
  33898. * | 2 | MIRROR_ADDRESSMODE | |
  33899. */
  33900. wrapR: number;
  33901. /**
  33902. * With compliant hardware and browser (supporting anisotropic filtering)
  33903. * this defines the level of anisotropic filtering in the texture.
  33904. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33905. */
  33906. anisotropicFilteringLevel: number;
  33907. /**
  33908. * Define if the texture is a cube texture or if false a 2d texture.
  33909. */
  33910. get isCube(): boolean;
  33911. set isCube(value: boolean);
  33912. /**
  33913. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33914. */
  33915. get is3D(): boolean;
  33916. set is3D(value: boolean);
  33917. /**
  33918. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33919. */
  33920. get is2DArray(): boolean;
  33921. set is2DArray(value: boolean);
  33922. /**
  33923. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33924. * HDR texture are usually stored in linear space.
  33925. * This only impacts the PBR and Background materials
  33926. */
  33927. gammaSpace: boolean;
  33928. /**
  33929. * Gets or sets whether or not the texture contains RGBD data.
  33930. */
  33931. get isRGBD(): boolean;
  33932. set isRGBD(value: boolean);
  33933. /**
  33934. * Is Z inverted in the texture (useful in a cube texture).
  33935. */
  33936. invertZ: boolean;
  33937. /**
  33938. * Are mip maps generated for this texture or not.
  33939. */
  33940. get noMipmap(): boolean;
  33941. /**
  33942. * @hidden
  33943. */
  33944. lodLevelInAlpha: boolean;
  33945. /**
  33946. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33947. */
  33948. get lodGenerationOffset(): number;
  33949. set lodGenerationOffset(value: number);
  33950. /**
  33951. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33952. */
  33953. get lodGenerationScale(): number;
  33954. set lodGenerationScale(value: number);
  33955. /**
  33956. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33957. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33958. * average roughness values.
  33959. */
  33960. get linearSpecularLOD(): boolean;
  33961. set linearSpecularLOD(value: boolean);
  33962. /**
  33963. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33964. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33965. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33966. */
  33967. get irradianceTexture(): Nullable<BaseTexture>;
  33968. set irradianceTexture(value: Nullable<BaseTexture>);
  33969. /**
  33970. * Define if the texture is a render target.
  33971. */
  33972. isRenderTarget: boolean;
  33973. /**
  33974. * Define the unique id of the texture in the scene.
  33975. */
  33976. get uid(): string;
  33977. /** @hidden */
  33978. _prefiltered: boolean;
  33979. /**
  33980. * Return a string representation of the texture.
  33981. * @returns the texture as a string
  33982. */
  33983. toString(): string;
  33984. /**
  33985. * Get the class name of the texture.
  33986. * @returns "BaseTexture"
  33987. */
  33988. getClassName(): string;
  33989. /**
  33990. * Define the list of animation attached to the texture.
  33991. */
  33992. animations: import("babylonjs/Animations/animation").Animation[];
  33993. /**
  33994. * An event triggered when the texture is disposed.
  33995. */
  33996. onDisposeObservable: Observable<BaseTexture>;
  33997. private _onDisposeObserver;
  33998. /**
  33999. * Callback triggered when the texture has been disposed.
  34000. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34001. */
  34002. set onDispose(callback: () => void);
  34003. /**
  34004. * Define the current state of the loading sequence when in delayed load mode.
  34005. */
  34006. delayLoadState: number;
  34007. private _scene;
  34008. private _engine;
  34009. /** @hidden */
  34010. _texture: Nullable<InternalTexture>;
  34011. private _uid;
  34012. /**
  34013. * Define if the texture is preventinga material to render or not.
  34014. * If not and the texture is not ready, the engine will use a default black texture instead.
  34015. */
  34016. get isBlocking(): boolean;
  34017. /**
  34018. * Instantiates a new BaseTexture.
  34019. * Base class of all the textures in babylon.
  34020. * It groups all the common properties the materials, post process, lights... might need
  34021. * in order to make a correct use of the texture.
  34022. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34023. */
  34024. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34025. /**
  34026. * Get the scene the texture belongs to.
  34027. * @returns the scene or null if undefined
  34028. */
  34029. getScene(): Nullable<Scene>;
  34030. /** @hidden */
  34031. protected _getEngine(): Nullable<ThinEngine>;
  34032. /**
  34033. * Get the texture transform matrix used to offset tile the texture for istance.
  34034. * @returns the transformation matrix
  34035. */
  34036. getTextureMatrix(): Matrix;
  34037. /**
  34038. * Get the texture reflection matrix used to rotate/transform the reflection.
  34039. * @returns the reflection matrix
  34040. */
  34041. getReflectionTextureMatrix(): Matrix;
  34042. /**
  34043. * Get the underlying lower level texture from Babylon.
  34044. * @returns the insternal texture
  34045. */
  34046. getInternalTexture(): Nullable<InternalTexture>;
  34047. /**
  34048. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34049. * @returns true if ready or not blocking
  34050. */
  34051. isReadyOrNotBlocking(): boolean;
  34052. /**
  34053. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34054. * @returns true if fully ready
  34055. */
  34056. isReady(): boolean;
  34057. private _cachedSize;
  34058. /**
  34059. * Get the size of the texture.
  34060. * @returns the texture size.
  34061. */
  34062. getSize(): ISize;
  34063. /**
  34064. * Get the base size of the texture.
  34065. * It can be different from the size if the texture has been resized for POT for instance
  34066. * @returns the base size
  34067. */
  34068. getBaseSize(): ISize;
  34069. /**
  34070. * Update the sampling mode of the texture.
  34071. * Default is Trilinear mode.
  34072. *
  34073. * | Value | Type | Description |
  34074. * | ----- | ------------------ | ----------- |
  34075. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34076. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34077. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34078. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34079. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34080. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34081. * | 7 | NEAREST_LINEAR | |
  34082. * | 8 | NEAREST_NEAREST | |
  34083. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34084. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34085. * | 11 | LINEAR_LINEAR | |
  34086. * | 12 | LINEAR_NEAREST | |
  34087. *
  34088. * > _mag_: magnification filter (close to the viewer)
  34089. * > _min_: minification filter (far from the viewer)
  34090. * > _mip_: filter used between mip map levels
  34091. *@param samplingMode Define the new sampling mode of the texture
  34092. */
  34093. updateSamplingMode(samplingMode: number): void;
  34094. /**
  34095. * Scales the texture if is `canRescale()`
  34096. * @param ratio the resize factor we want to use to rescale
  34097. */
  34098. scale(ratio: number): void;
  34099. /**
  34100. * Get if the texture can rescale.
  34101. */
  34102. get canRescale(): boolean;
  34103. /** @hidden */
  34104. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34105. /** @hidden */
  34106. _rebuild(): void;
  34107. /**
  34108. * Triggers the load sequence in delayed load mode.
  34109. */
  34110. delayLoad(): void;
  34111. /**
  34112. * Clones the texture.
  34113. * @returns the cloned texture
  34114. */
  34115. clone(): Nullable<BaseTexture>;
  34116. /**
  34117. * Get the texture underlying type (INT, FLOAT...)
  34118. */
  34119. get textureType(): number;
  34120. /**
  34121. * Get the texture underlying format (RGB, RGBA...)
  34122. */
  34123. get textureFormat(): number;
  34124. /**
  34125. * Indicates that textures need to be re-calculated for all materials
  34126. */
  34127. protected _markAllSubMeshesAsTexturesDirty(): void;
  34128. /**
  34129. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34130. * This will returns an RGBA array buffer containing either in values (0-255) or
  34131. * float values (0-1) depending of the underlying buffer type.
  34132. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34133. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34134. * @param buffer defines a user defined buffer to fill with data (can be null)
  34135. * @returns The Array buffer containing the pixels data.
  34136. */
  34137. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34138. /**
  34139. * Release and destroy the underlying lower level texture aka internalTexture.
  34140. */
  34141. releaseInternalTexture(): void;
  34142. /** @hidden */
  34143. get _lodTextureHigh(): Nullable<BaseTexture>;
  34144. /** @hidden */
  34145. get _lodTextureMid(): Nullable<BaseTexture>;
  34146. /** @hidden */
  34147. get _lodTextureLow(): Nullable<BaseTexture>;
  34148. /**
  34149. * Dispose the texture and release its associated resources.
  34150. */
  34151. dispose(): void;
  34152. /**
  34153. * Serialize the texture into a JSON representation that can be parsed later on.
  34154. * @returns the JSON representation of the texture
  34155. */
  34156. serialize(): any;
  34157. /**
  34158. * Helper function to be called back once a list of texture contains only ready textures.
  34159. * @param textures Define the list of textures to wait for
  34160. * @param callback Define the callback triggered once the entire list will be ready
  34161. */
  34162. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34163. private static _isScene;
  34164. }
  34165. }
  34166. declare module "babylonjs/Materials/effect" {
  34167. import { Observable } from "babylonjs/Misc/observable";
  34168. import { Nullable } from "babylonjs/types";
  34169. import { IDisposable } from "babylonjs/scene";
  34170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34171. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34172. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34173. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34174. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34175. import { Engine } from "babylonjs/Engines/engine";
  34176. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34178. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34179. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34180. /**
  34181. * Options to be used when creating an effect.
  34182. */
  34183. export interface IEffectCreationOptions {
  34184. /**
  34185. * Atrributes that will be used in the shader.
  34186. */
  34187. attributes: string[];
  34188. /**
  34189. * Uniform varible names that will be set in the shader.
  34190. */
  34191. uniformsNames: string[];
  34192. /**
  34193. * Uniform buffer variable names that will be set in the shader.
  34194. */
  34195. uniformBuffersNames: string[];
  34196. /**
  34197. * Sampler texture variable names that will be set in the shader.
  34198. */
  34199. samplers: string[];
  34200. /**
  34201. * Define statements that will be set in the shader.
  34202. */
  34203. defines: any;
  34204. /**
  34205. * Possible fallbacks for this effect to improve performance when needed.
  34206. */
  34207. fallbacks: Nullable<IEffectFallbacks>;
  34208. /**
  34209. * Callback that will be called when the shader is compiled.
  34210. */
  34211. onCompiled: Nullable<(effect: Effect) => void>;
  34212. /**
  34213. * Callback that will be called if an error occurs during shader compilation.
  34214. */
  34215. onError: Nullable<(effect: Effect, errors: string) => void>;
  34216. /**
  34217. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34218. */
  34219. indexParameters?: any;
  34220. /**
  34221. * Max number of lights that can be used in the shader.
  34222. */
  34223. maxSimultaneousLights?: number;
  34224. /**
  34225. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34226. */
  34227. transformFeedbackVaryings?: Nullable<string[]>;
  34228. /**
  34229. * 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
  34230. */
  34231. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34232. }
  34233. /**
  34234. * Effect containing vertex and fragment shader that can be executed on an object.
  34235. */
  34236. export class Effect implements IDisposable {
  34237. /**
  34238. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34239. */
  34240. static ShadersRepository: string;
  34241. /**
  34242. * Enable logging of the shader code when a compilation error occurs
  34243. */
  34244. static LogShaderCodeOnCompilationError: boolean;
  34245. /**
  34246. * Name of the effect.
  34247. */
  34248. name: any;
  34249. /**
  34250. * String container all the define statements that should be set on the shader.
  34251. */
  34252. defines: string;
  34253. /**
  34254. * Callback that will be called when the shader is compiled.
  34255. */
  34256. onCompiled: Nullable<(effect: Effect) => void>;
  34257. /**
  34258. * Callback that will be called if an error occurs during shader compilation.
  34259. */
  34260. onError: Nullable<(effect: Effect, errors: string) => void>;
  34261. /**
  34262. * Callback that will be called when effect is bound.
  34263. */
  34264. onBind: Nullable<(effect: Effect) => void>;
  34265. /**
  34266. * Unique ID of the effect.
  34267. */
  34268. uniqueId: number;
  34269. /**
  34270. * Observable that will be called when the shader is compiled.
  34271. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34272. */
  34273. onCompileObservable: Observable<Effect>;
  34274. /**
  34275. * Observable that will be called if an error occurs during shader compilation.
  34276. */
  34277. onErrorObservable: Observable<Effect>;
  34278. /** @hidden */
  34279. _onBindObservable: Nullable<Observable<Effect>>;
  34280. /**
  34281. * @hidden
  34282. * Specifies if the effect was previously ready
  34283. */
  34284. _wasPreviouslyReady: boolean;
  34285. /**
  34286. * Observable that will be called when effect is bound.
  34287. */
  34288. get onBindObservable(): Observable<Effect>;
  34289. /** @hidden */
  34290. _bonesComputationForcedToCPU: boolean;
  34291. private static _uniqueIdSeed;
  34292. private _engine;
  34293. private _uniformBuffersNames;
  34294. private _uniformBuffersNamesList;
  34295. private _uniformsNames;
  34296. private _samplerList;
  34297. private _samplers;
  34298. private _isReady;
  34299. private _compilationError;
  34300. private _allFallbacksProcessed;
  34301. private _attributesNames;
  34302. private _attributes;
  34303. private _attributeLocationByName;
  34304. private _uniforms;
  34305. /**
  34306. * Key for the effect.
  34307. * @hidden
  34308. */
  34309. _key: string;
  34310. private _indexParameters;
  34311. private _fallbacks;
  34312. private _vertexSourceCode;
  34313. private _fragmentSourceCode;
  34314. private _vertexSourceCodeOverride;
  34315. private _fragmentSourceCodeOverride;
  34316. private _transformFeedbackVaryings;
  34317. /**
  34318. * Compiled shader to webGL program.
  34319. * @hidden
  34320. */
  34321. _pipelineContext: Nullable<IPipelineContext>;
  34322. private _valueCache;
  34323. private static _baseCache;
  34324. /**
  34325. * Instantiates an effect.
  34326. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34327. * @param baseName Name of the effect.
  34328. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34329. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34330. * @param samplers List of sampler variables that will be passed to the shader.
  34331. * @param engine Engine to be used to render the effect
  34332. * @param defines Define statements to be added to the shader.
  34333. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34334. * @param onCompiled Callback that will be called when the shader is compiled.
  34335. * @param onError Callback that will be called if an error occurs during shader compilation.
  34336. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34337. */
  34338. 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);
  34339. private _useFinalCode;
  34340. /**
  34341. * Unique key for this effect
  34342. */
  34343. get key(): string;
  34344. /**
  34345. * If the effect has been compiled and prepared.
  34346. * @returns if the effect is compiled and prepared.
  34347. */
  34348. isReady(): boolean;
  34349. private _isReadyInternal;
  34350. /**
  34351. * The engine the effect was initialized with.
  34352. * @returns the engine.
  34353. */
  34354. getEngine(): Engine;
  34355. /**
  34356. * The pipeline context for this effect
  34357. * @returns the associated pipeline context
  34358. */
  34359. getPipelineContext(): Nullable<IPipelineContext>;
  34360. /**
  34361. * The set of names of attribute variables for the shader.
  34362. * @returns An array of attribute names.
  34363. */
  34364. getAttributesNames(): string[];
  34365. /**
  34366. * Returns the attribute at the given index.
  34367. * @param index The index of the attribute.
  34368. * @returns The location of the attribute.
  34369. */
  34370. getAttributeLocation(index: number): number;
  34371. /**
  34372. * Returns the attribute based on the name of the variable.
  34373. * @param name of the attribute to look up.
  34374. * @returns the attribute location.
  34375. */
  34376. getAttributeLocationByName(name: string): number;
  34377. /**
  34378. * The number of attributes.
  34379. * @returns the numnber of attributes.
  34380. */
  34381. getAttributesCount(): number;
  34382. /**
  34383. * Gets the index of a uniform variable.
  34384. * @param uniformName of the uniform to look up.
  34385. * @returns the index.
  34386. */
  34387. getUniformIndex(uniformName: string): number;
  34388. /**
  34389. * Returns the attribute based on the name of the variable.
  34390. * @param uniformName of the uniform to look up.
  34391. * @returns the location of the uniform.
  34392. */
  34393. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34394. /**
  34395. * Returns an array of sampler variable names
  34396. * @returns The array of sampler variable names.
  34397. */
  34398. getSamplers(): string[];
  34399. /**
  34400. * Returns an array of uniform variable names
  34401. * @returns The array of uniform variable names.
  34402. */
  34403. getUniformNames(): string[];
  34404. /**
  34405. * Returns an array of uniform buffer variable names
  34406. * @returns The array of uniform buffer variable names.
  34407. */
  34408. getUniformBuffersNames(): string[];
  34409. /**
  34410. * Returns the index parameters used to create the effect
  34411. * @returns The index parameters object
  34412. */
  34413. getIndexParameters(): any;
  34414. /**
  34415. * The error from the last compilation.
  34416. * @returns the error string.
  34417. */
  34418. getCompilationError(): string;
  34419. /**
  34420. * Gets a boolean indicating that all fallbacks were used during compilation
  34421. * @returns true if all fallbacks were used
  34422. */
  34423. allFallbacksProcessed(): boolean;
  34424. /**
  34425. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34426. * @param func The callback to be used.
  34427. */
  34428. executeWhenCompiled(func: (effect: Effect) => void): void;
  34429. private _checkIsReady;
  34430. private _loadShader;
  34431. /**
  34432. * Gets the vertex shader source code of this effect
  34433. */
  34434. get vertexSourceCode(): string;
  34435. /**
  34436. * Gets the fragment shader source code of this effect
  34437. */
  34438. get fragmentSourceCode(): string;
  34439. /**
  34440. * Recompiles the webGL program
  34441. * @param vertexSourceCode The source code for the vertex shader.
  34442. * @param fragmentSourceCode The source code for the fragment shader.
  34443. * @param onCompiled Callback called when completed.
  34444. * @param onError Callback called on error.
  34445. * @hidden
  34446. */
  34447. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34448. /**
  34449. * Prepares the effect
  34450. * @hidden
  34451. */
  34452. _prepareEffect(): void;
  34453. private _getShaderCodeAndErrorLine;
  34454. private _processCompilationErrors;
  34455. /**
  34456. * Checks if the effect is supported. (Must be called after compilation)
  34457. */
  34458. get isSupported(): boolean;
  34459. /**
  34460. * Binds a texture to the engine to be used as output of the shader.
  34461. * @param channel Name of the output variable.
  34462. * @param texture Texture to bind.
  34463. * @hidden
  34464. */
  34465. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34466. /**
  34467. * Sets a texture on the engine to be used in the shader.
  34468. * @param channel Name of the sampler variable.
  34469. * @param texture Texture to set.
  34470. */
  34471. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34472. /**
  34473. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34474. * @param channel Name of the sampler variable.
  34475. * @param texture Texture to set.
  34476. */
  34477. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34478. /**
  34479. * Sets an array of textures on the engine to be used in the shader.
  34480. * @param channel Name of the variable.
  34481. * @param textures Textures to set.
  34482. */
  34483. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34484. /**
  34485. * 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)
  34486. * @param channel Name of the sampler variable.
  34487. * @param postProcess Post process to get the input texture from.
  34488. */
  34489. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34490. /**
  34491. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34492. * 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)
  34493. * @param channel Name of the sampler variable.
  34494. * @param postProcess Post process to get the output texture from.
  34495. */
  34496. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34497. /** @hidden */
  34498. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34499. /** @hidden */
  34500. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34501. /** @hidden */
  34502. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34503. /** @hidden */
  34504. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34505. /**
  34506. * Binds a buffer to a uniform.
  34507. * @param buffer Buffer to bind.
  34508. * @param name Name of the uniform variable to bind to.
  34509. */
  34510. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34511. /**
  34512. * Binds block to a uniform.
  34513. * @param blockName Name of the block to bind.
  34514. * @param index Index to bind.
  34515. */
  34516. bindUniformBlock(blockName: string, index: number): void;
  34517. /**
  34518. * Sets an interger value on a uniform variable.
  34519. * @param uniformName Name of the variable.
  34520. * @param value Value to be set.
  34521. * @returns this effect.
  34522. */
  34523. setInt(uniformName: string, value: number): Effect;
  34524. /**
  34525. * Sets an int array on a uniform variable.
  34526. * @param uniformName Name of the variable.
  34527. * @param array array to be set.
  34528. * @returns this effect.
  34529. */
  34530. setIntArray(uniformName: string, array: Int32Array): Effect;
  34531. /**
  34532. * 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)
  34533. * @param uniformName Name of the variable.
  34534. * @param array array to be set.
  34535. * @returns this effect.
  34536. */
  34537. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34538. /**
  34539. * 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)
  34540. * @param uniformName Name of the variable.
  34541. * @param array array to be set.
  34542. * @returns this effect.
  34543. */
  34544. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34545. /**
  34546. * 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)
  34547. * @param uniformName Name of the variable.
  34548. * @param array array to be set.
  34549. * @returns this effect.
  34550. */
  34551. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34552. /**
  34553. * Sets an float array on a uniform variable.
  34554. * @param uniformName Name of the variable.
  34555. * @param array array to be set.
  34556. * @returns this effect.
  34557. */
  34558. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34559. /**
  34560. * 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)
  34561. * @param uniformName Name of the variable.
  34562. * @param array array to be set.
  34563. * @returns this effect.
  34564. */
  34565. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34566. /**
  34567. * 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)
  34568. * @param uniformName Name of the variable.
  34569. * @param array array to be set.
  34570. * @returns this effect.
  34571. */
  34572. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34573. /**
  34574. * 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)
  34575. * @param uniformName Name of the variable.
  34576. * @param array array to be set.
  34577. * @returns this effect.
  34578. */
  34579. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34580. /**
  34581. * Sets an array on a uniform variable.
  34582. * @param uniformName Name of the variable.
  34583. * @param array array to be set.
  34584. * @returns this effect.
  34585. */
  34586. setArray(uniformName: string, array: number[]): Effect;
  34587. /**
  34588. * 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)
  34589. * @param uniformName Name of the variable.
  34590. * @param array array to be set.
  34591. * @returns this effect.
  34592. */
  34593. setArray2(uniformName: string, array: number[]): Effect;
  34594. /**
  34595. * 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)
  34596. * @param uniformName Name of the variable.
  34597. * @param array array to be set.
  34598. * @returns this effect.
  34599. */
  34600. setArray3(uniformName: string, array: number[]): Effect;
  34601. /**
  34602. * 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)
  34603. * @param uniformName Name of the variable.
  34604. * @param array array to be set.
  34605. * @returns this effect.
  34606. */
  34607. setArray4(uniformName: string, array: number[]): Effect;
  34608. /**
  34609. * Sets matrices on a uniform variable.
  34610. * @param uniformName Name of the variable.
  34611. * @param matrices matrices to be set.
  34612. * @returns this effect.
  34613. */
  34614. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34615. /**
  34616. * Sets matrix on a uniform variable.
  34617. * @param uniformName Name of the variable.
  34618. * @param matrix matrix to be set.
  34619. * @returns this effect.
  34620. */
  34621. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34622. /**
  34623. * 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)
  34624. * @param uniformName Name of the variable.
  34625. * @param matrix matrix to be set.
  34626. * @returns this effect.
  34627. */
  34628. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34629. /**
  34630. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34631. * @param uniformName Name of the variable.
  34632. * @param matrix matrix to be set.
  34633. * @returns this effect.
  34634. */
  34635. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34636. /**
  34637. * Sets a float on a uniform variable.
  34638. * @param uniformName Name of the variable.
  34639. * @param value value to be set.
  34640. * @returns this effect.
  34641. */
  34642. setFloat(uniformName: string, value: number): Effect;
  34643. /**
  34644. * Sets a boolean on a uniform variable.
  34645. * @param uniformName Name of the variable.
  34646. * @param bool value to be set.
  34647. * @returns this effect.
  34648. */
  34649. setBool(uniformName: string, bool: boolean): Effect;
  34650. /**
  34651. * Sets a Vector2 on a uniform variable.
  34652. * @param uniformName Name of the variable.
  34653. * @param vector2 vector2 to be set.
  34654. * @returns this effect.
  34655. */
  34656. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34657. /**
  34658. * Sets a float2 on a uniform variable.
  34659. * @param uniformName Name of the variable.
  34660. * @param x First float in float2.
  34661. * @param y Second float in float2.
  34662. * @returns this effect.
  34663. */
  34664. setFloat2(uniformName: string, x: number, y: number): Effect;
  34665. /**
  34666. * Sets a Vector3 on a uniform variable.
  34667. * @param uniformName Name of the variable.
  34668. * @param vector3 Value to be set.
  34669. * @returns this effect.
  34670. */
  34671. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34672. /**
  34673. * Sets a float3 on a uniform variable.
  34674. * @param uniformName Name of the variable.
  34675. * @param x First float in float3.
  34676. * @param y Second float in float3.
  34677. * @param z Third float in float3.
  34678. * @returns this effect.
  34679. */
  34680. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34681. /**
  34682. * Sets a Vector4 on a uniform variable.
  34683. * @param uniformName Name of the variable.
  34684. * @param vector4 Value to be set.
  34685. * @returns this effect.
  34686. */
  34687. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34688. /**
  34689. * Sets a float4 on a uniform variable.
  34690. * @param uniformName Name of the variable.
  34691. * @param x First float in float4.
  34692. * @param y Second float in float4.
  34693. * @param z Third float in float4.
  34694. * @param w Fourth float in float4.
  34695. * @returns this effect.
  34696. */
  34697. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34698. /**
  34699. * Sets a Color3 on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param color3 Value to be set.
  34702. * @returns this effect.
  34703. */
  34704. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34705. /**
  34706. * Sets a Color4 on a uniform variable.
  34707. * @param uniformName Name of the variable.
  34708. * @param color3 Value to be set.
  34709. * @param alpha Alpha value to be set.
  34710. * @returns this effect.
  34711. */
  34712. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34713. /**
  34714. * Sets a Color4 on a uniform variable
  34715. * @param uniformName defines the name of the variable
  34716. * @param color4 defines the value to be set
  34717. * @returns this effect.
  34718. */
  34719. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34720. /** Release all associated resources */
  34721. dispose(): void;
  34722. /**
  34723. * This function will add a new shader to the shader store
  34724. * @param name the name of the shader
  34725. * @param pixelShader optional pixel shader content
  34726. * @param vertexShader optional vertex shader content
  34727. */
  34728. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34729. /**
  34730. * Store of each shader (The can be looked up using effect.key)
  34731. */
  34732. static ShadersStore: {
  34733. [key: string]: string;
  34734. };
  34735. /**
  34736. * Store of each included file for a shader (The can be looked up using effect.key)
  34737. */
  34738. static IncludesShadersStore: {
  34739. [key: string]: string;
  34740. };
  34741. /**
  34742. * Resets the cache of effects.
  34743. */
  34744. static ResetCache(): void;
  34745. }
  34746. }
  34747. declare module "babylonjs/Engines/engineCapabilities" {
  34748. /**
  34749. * Interface used to describe the capabilities of the engine relatively to the current browser
  34750. */
  34751. export interface EngineCapabilities {
  34752. /** Maximum textures units per fragment shader */
  34753. maxTexturesImageUnits: number;
  34754. /** Maximum texture units per vertex shader */
  34755. maxVertexTextureImageUnits: number;
  34756. /** Maximum textures units in the entire pipeline */
  34757. maxCombinedTexturesImageUnits: number;
  34758. /** Maximum texture size */
  34759. maxTextureSize: number;
  34760. /** Maximum texture samples */
  34761. maxSamples?: number;
  34762. /** Maximum cube texture size */
  34763. maxCubemapTextureSize: number;
  34764. /** Maximum render texture size */
  34765. maxRenderTextureSize: number;
  34766. /** Maximum number of vertex attributes */
  34767. maxVertexAttribs: number;
  34768. /** Maximum number of varyings */
  34769. maxVaryingVectors: number;
  34770. /** Maximum number of uniforms per vertex shader */
  34771. maxVertexUniformVectors: number;
  34772. /** Maximum number of uniforms per fragment shader */
  34773. maxFragmentUniformVectors: number;
  34774. /** Defines if standard derivates (dx/dy) are supported */
  34775. standardDerivatives: boolean;
  34776. /** Defines if s3tc texture compression is supported */
  34777. s3tc?: WEBGL_compressed_texture_s3tc;
  34778. /** Defines if pvrtc texture compression is supported */
  34779. pvrtc: any;
  34780. /** Defines if etc1 texture compression is supported */
  34781. etc1: any;
  34782. /** Defines if etc2 texture compression is supported */
  34783. etc2: any;
  34784. /** Defines if astc texture compression is supported */
  34785. astc: any;
  34786. /** Defines if float textures are supported */
  34787. textureFloat: boolean;
  34788. /** Defines if vertex array objects are supported */
  34789. vertexArrayObject: boolean;
  34790. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34791. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34792. /** Gets the maximum level of anisotropy supported */
  34793. maxAnisotropy: number;
  34794. /** Defines if instancing is supported */
  34795. instancedArrays: boolean;
  34796. /** Defines if 32 bits indices are supported */
  34797. uintIndices: boolean;
  34798. /** Defines if high precision shaders are supported */
  34799. highPrecisionShaderSupported: boolean;
  34800. /** Defines if depth reading in the fragment shader is supported */
  34801. fragmentDepthSupported: boolean;
  34802. /** Defines if float texture linear filtering is supported*/
  34803. textureFloatLinearFiltering: boolean;
  34804. /** Defines if rendering to float textures is supported */
  34805. textureFloatRender: boolean;
  34806. /** Defines if half float textures are supported*/
  34807. textureHalfFloat: boolean;
  34808. /** Defines if half float texture linear filtering is supported*/
  34809. textureHalfFloatLinearFiltering: boolean;
  34810. /** Defines if rendering to half float textures is supported */
  34811. textureHalfFloatRender: boolean;
  34812. /** Defines if textureLOD shader command is supported */
  34813. textureLOD: boolean;
  34814. /** Defines if draw buffers extension is supported */
  34815. drawBuffersExtension: boolean;
  34816. /** Defines if depth textures are supported */
  34817. depthTextureExtension: boolean;
  34818. /** Defines if float color buffer are supported */
  34819. colorBufferFloat: boolean;
  34820. /** Gets disjoint timer query extension (null if not supported) */
  34821. timerQuery?: EXT_disjoint_timer_query;
  34822. /** Defines if timestamp can be used with timer query */
  34823. canUseTimestampForTimerQuery: boolean;
  34824. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34825. multiview?: any;
  34826. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34827. oculusMultiview?: any;
  34828. /** Function used to let the system compiles shaders in background */
  34829. parallelShaderCompile?: {
  34830. COMPLETION_STATUS_KHR: number;
  34831. };
  34832. /** Max number of texture samples for MSAA */
  34833. maxMSAASamples: number;
  34834. /** Defines if the blend min max extension is supported */
  34835. blendMinMax: boolean;
  34836. }
  34837. }
  34838. declare module "babylonjs/States/depthCullingState" {
  34839. import { Nullable } from "babylonjs/types";
  34840. /**
  34841. * @hidden
  34842. **/
  34843. export class DepthCullingState {
  34844. private _isDepthTestDirty;
  34845. private _isDepthMaskDirty;
  34846. private _isDepthFuncDirty;
  34847. private _isCullFaceDirty;
  34848. private _isCullDirty;
  34849. private _isZOffsetDirty;
  34850. private _isFrontFaceDirty;
  34851. private _depthTest;
  34852. private _depthMask;
  34853. private _depthFunc;
  34854. private _cull;
  34855. private _cullFace;
  34856. private _zOffset;
  34857. private _frontFace;
  34858. /**
  34859. * Initializes the state.
  34860. */
  34861. constructor();
  34862. get isDirty(): boolean;
  34863. get zOffset(): number;
  34864. set zOffset(value: number);
  34865. get cullFace(): Nullable<number>;
  34866. set cullFace(value: Nullable<number>);
  34867. get cull(): Nullable<boolean>;
  34868. set cull(value: Nullable<boolean>);
  34869. get depthFunc(): Nullable<number>;
  34870. set depthFunc(value: Nullable<number>);
  34871. get depthMask(): boolean;
  34872. set depthMask(value: boolean);
  34873. get depthTest(): boolean;
  34874. set depthTest(value: boolean);
  34875. get frontFace(): Nullable<number>;
  34876. set frontFace(value: Nullable<number>);
  34877. reset(): void;
  34878. apply(gl: WebGLRenderingContext): void;
  34879. }
  34880. }
  34881. declare module "babylonjs/States/stencilState" {
  34882. /**
  34883. * @hidden
  34884. **/
  34885. export class StencilState {
  34886. /** 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 */
  34887. static readonly ALWAYS: number;
  34888. /** Passed to stencilOperation to specify that stencil value must be kept */
  34889. static readonly KEEP: number;
  34890. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34891. static readonly REPLACE: number;
  34892. private _isStencilTestDirty;
  34893. private _isStencilMaskDirty;
  34894. private _isStencilFuncDirty;
  34895. private _isStencilOpDirty;
  34896. private _stencilTest;
  34897. private _stencilMask;
  34898. private _stencilFunc;
  34899. private _stencilFuncRef;
  34900. private _stencilFuncMask;
  34901. private _stencilOpStencilFail;
  34902. private _stencilOpDepthFail;
  34903. private _stencilOpStencilDepthPass;
  34904. get isDirty(): boolean;
  34905. get stencilFunc(): number;
  34906. set stencilFunc(value: number);
  34907. get stencilFuncRef(): number;
  34908. set stencilFuncRef(value: number);
  34909. get stencilFuncMask(): number;
  34910. set stencilFuncMask(value: number);
  34911. get stencilOpStencilFail(): number;
  34912. set stencilOpStencilFail(value: number);
  34913. get stencilOpDepthFail(): number;
  34914. set stencilOpDepthFail(value: number);
  34915. get stencilOpStencilDepthPass(): number;
  34916. set stencilOpStencilDepthPass(value: number);
  34917. get stencilMask(): number;
  34918. set stencilMask(value: number);
  34919. get stencilTest(): boolean;
  34920. set stencilTest(value: boolean);
  34921. constructor();
  34922. reset(): void;
  34923. apply(gl: WebGLRenderingContext): void;
  34924. }
  34925. }
  34926. declare module "babylonjs/States/alphaCullingState" {
  34927. /**
  34928. * @hidden
  34929. **/
  34930. export class AlphaState {
  34931. private _isAlphaBlendDirty;
  34932. private _isBlendFunctionParametersDirty;
  34933. private _isBlendEquationParametersDirty;
  34934. private _isBlendConstantsDirty;
  34935. private _alphaBlend;
  34936. private _blendFunctionParameters;
  34937. private _blendEquationParameters;
  34938. private _blendConstants;
  34939. /**
  34940. * Initializes the state.
  34941. */
  34942. constructor();
  34943. get isDirty(): boolean;
  34944. get alphaBlend(): boolean;
  34945. set alphaBlend(value: boolean);
  34946. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34947. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34948. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34949. reset(): void;
  34950. apply(gl: WebGLRenderingContext): void;
  34951. }
  34952. }
  34953. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  34954. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  34955. /** @hidden */
  34956. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34957. attributeProcessor(attribute: string): string;
  34958. varyingProcessor(varying: string, isFragment: boolean): string;
  34959. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34960. }
  34961. }
  34962. declare module "babylonjs/Engines/instancingAttributeInfo" {
  34963. /**
  34964. * Interface for attribute information associated with buffer instanciation
  34965. */
  34966. export interface InstancingAttributeInfo {
  34967. /**
  34968. * Name of the GLSL attribute
  34969. * if attribute index is not specified, this is used to retrieve the index from the effect
  34970. */
  34971. attributeName: string;
  34972. /**
  34973. * Index/offset of the attribute in the vertex shader
  34974. * if not specified, this will be computes from the name.
  34975. */
  34976. index?: number;
  34977. /**
  34978. * size of the attribute, 1, 2, 3 or 4
  34979. */
  34980. attributeSize: number;
  34981. /**
  34982. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34983. */
  34984. offset: number;
  34985. /**
  34986. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34987. * default to 1
  34988. */
  34989. divisor?: number;
  34990. /**
  34991. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34992. * default is FLOAT
  34993. */
  34994. attributeType?: number;
  34995. /**
  34996. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34997. */
  34998. normalized?: boolean;
  34999. }
  35000. }
  35001. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35002. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35003. import { Nullable } from "babylonjs/types";
  35004. module "babylonjs/Engines/thinEngine" {
  35005. interface ThinEngine {
  35006. /**
  35007. * Update a video texture
  35008. * @param texture defines the texture to update
  35009. * @param video defines the video element to use
  35010. * @param invertY defines if data must be stored with Y axis inverted
  35011. */
  35012. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35013. }
  35014. }
  35015. }
  35016. declare module "babylonjs/Materials/Textures/videoTexture" {
  35017. import { Observable } from "babylonjs/Misc/observable";
  35018. import { Nullable } from "babylonjs/types";
  35019. import { Scene } from "babylonjs/scene";
  35020. import { Texture } from "babylonjs/Materials/Textures/texture";
  35021. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35022. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35023. /**
  35024. * Settings for finer control over video usage
  35025. */
  35026. export interface VideoTextureSettings {
  35027. /**
  35028. * Applies `autoplay` to video, if specified
  35029. */
  35030. autoPlay?: boolean;
  35031. /**
  35032. * Applies `loop` to video, if specified
  35033. */
  35034. loop?: boolean;
  35035. /**
  35036. * Automatically updates internal texture from video at every frame in the render loop
  35037. */
  35038. autoUpdateTexture: boolean;
  35039. /**
  35040. * Image src displayed during the video loading or until the user interacts with the video.
  35041. */
  35042. poster?: string;
  35043. }
  35044. /**
  35045. * If you want to display a video in your scene, this is the special texture for that.
  35046. * This special texture works similar to other textures, with the exception of a few parameters.
  35047. * @see https://doc.babylonjs.com/how_to/video_texture
  35048. */
  35049. export class VideoTexture extends Texture {
  35050. /**
  35051. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35052. */
  35053. readonly autoUpdateTexture: boolean;
  35054. /**
  35055. * The video instance used by the texture internally
  35056. */
  35057. readonly video: HTMLVideoElement;
  35058. private _onUserActionRequestedObservable;
  35059. /**
  35060. * Event triggerd when a dom action is required by the user to play the video.
  35061. * This happens due to recent changes in browser policies preventing video to auto start.
  35062. */
  35063. get onUserActionRequestedObservable(): Observable<Texture>;
  35064. private _generateMipMaps;
  35065. private _stillImageCaptured;
  35066. private _displayingPosterTexture;
  35067. private _settings;
  35068. private _createInternalTextureOnEvent;
  35069. private _frameId;
  35070. private _currentSrc;
  35071. /**
  35072. * Creates a video texture.
  35073. * If you want to display a video in your scene, this is the special texture for that.
  35074. * This special texture works similar to other textures, with the exception of a few parameters.
  35075. * @see https://doc.babylonjs.com/how_to/video_texture
  35076. * @param name optional name, will detect from video source, if not defined
  35077. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35078. * @param scene is obviously the current scene.
  35079. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35080. * @param invertY is false by default but can be used to invert video on Y axis
  35081. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35082. * @param settings allows finer control over video usage
  35083. */
  35084. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35085. private _getName;
  35086. private _getVideo;
  35087. private _createInternalTexture;
  35088. private reset;
  35089. /**
  35090. * @hidden Internal method to initiate `update`.
  35091. */
  35092. _rebuild(): void;
  35093. /**
  35094. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35095. */
  35096. update(): void;
  35097. /**
  35098. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35099. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35100. */
  35101. updateTexture(isVisible: boolean): void;
  35102. protected _updateInternalTexture: () => void;
  35103. /**
  35104. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35105. * @param url New url.
  35106. */
  35107. updateURL(url: string): void;
  35108. /**
  35109. * Clones the texture.
  35110. * @returns the cloned texture
  35111. */
  35112. clone(): VideoTexture;
  35113. /**
  35114. * Dispose the texture and release its associated resources.
  35115. */
  35116. dispose(): void;
  35117. /**
  35118. * Creates a video texture straight from a stream.
  35119. * @param scene Define the scene the texture should be created in
  35120. * @param stream Define the stream the texture should be created from
  35121. * @returns The created video texture as a promise
  35122. */
  35123. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35124. /**
  35125. * Creates a video texture straight from your WebCam video feed.
  35126. * @param scene Define the scene the texture should be created in
  35127. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35128. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35129. * @returns The created video texture as a promise
  35130. */
  35131. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35132. minWidth: number;
  35133. maxWidth: number;
  35134. minHeight: number;
  35135. maxHeight: number;
  35136. deviceId: string;
  35137. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35138. /**
  35139. * Creates a video texture straight from your WebCam video feed.
  35140. * @param scene Define the scene the texture should be created in
  35141. * @param onReady Define a callback to triggered once the texture will be ready
  35142. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35143. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35144. */
  35145. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35146. minWidth: number;
  35147. maxWidth: number;
  35148. minHeight: number;
  35149. maxHeight: number;
  35150. deviceId: string;
  35151. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35152. }
  35153. }
  35154. declare module "babylonjs/Engines/thinEngine" {
  35155. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35156. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35157. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35158. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35159. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35160. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35161. import { Observable } from "babylonjs/Misc/observable";
  35162. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35163. import { StencilState } from "babylonjs/States/stencilState";
  35164. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35166. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35167. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35168. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35169. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35170. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35171. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35172. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35174. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35175. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35176. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35177. import { WebRequest } from "babylonjs/Misc/webRequest";
  35178. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35179. /**
  35180. * Defines the interface used by objects working like Scene
  35181. * @hidden
  35182. */
  35183. export interface ISceneLike {
  35184. _addPendingData(data: any): void;
  35185. _removePendingData(data: any): void;
  35186. offlineProvider: IOfflineProvider;
  35187. }
  35188. /** Interface defining initialization parameters for Engine class */
  35189. export interface EngineOptions extends WebGLContextAttributes {
  35190. /**
  35191. * Defines if the engine should no exceed a specified device ratio
  35192. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35193. */
  35194. limitDeviceRatio?: number;
  35195. /**
  35196. * Defines if webvr should be enabled automatically
  35197. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35198. */
  35199. autoEnableWebVR?: boolean;
  35200. /**
  35201. * Defines if webgl2 should be turned off even if supported
  35202. * @see http://doc.babylonjs.com/features/webgl2
  35203. */
  35204. disableWebGL2Support?: boolean;
  35205. /**
  35206. * Defines if webaudio should be initialized as well
  35207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35208. */
  35209. audioEngine?: boolean;
  35210. /**
  35211. * Defines if animations should run using a deterministic lock step
  35212. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35213. */
  35214. deterministicLockstep?: boolean;
  35215. /** Defines the maximum steps to use with deterministic lock step mode */
  35216. lockstepMaxSteps?: number;
  35217. /** Defines the seconds between each deterministic lock step */
  35218. timeStep?: number;
  35219. /**
  35220. * Defines that engine should ignore context lost events
  35221. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35222. */
  35223. doNotHandleContextLost?: boolean;
  35224. /**
  35225. * Defines that engine should ignore modifying touch action attribute and style
  35226. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35227. */
  35228. doNotHandleTouchAction?: boolean;
  35229. /**
  35230. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35231. */
  35232. useHighPrecisionFloats?: boolean;
  35233. }
  35234. /**
  35235. * The base engine class (root of all engines)
  35236. */
  35237. export class ThinEngine {
  35238. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35239. static ExceptionList: ({
  35240. key: string;
  35241. capture: string;
  35242. captureConstraint: number;
  35243. targets: string[];
  35244. } | {
  35245. key: string;
  35246. capture: null;
  35247. captureConstraint: null;
  35248. targets: string[];
  35249. })[];
  35250. /** @hidden */
  35251. static _TextureLoaders: IInternalTextureLoader[];
  35252. /**
  35253. * Returns the current npm package of the sdk
  35254. */
  35255. static get NpmPackage(): string;
  35256. /**
  35257. * Returns the current version of the framework
  35258. */
  35259. static get Version(): string;
  35260. /**
  35261. * Returns a string describing the current engine
  35262. */
  35263. get description(): string;
  35264. /**
  35265. * Gets or sets the epsilon value used by collision engine
  35266. */
  35267. static CollisionsEpsilon: number;
  35268. /**
  35269. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35270. */
  35271. static get ShadersRepository(): string;
  35272. static set ShadersRepository(value: string);
  35273. /** @hidden */
  35274. _shaderProcessor: IShaderProcessor;
  35275. /**
  35276. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35277. */
  35278. forcePOTTextures: boolean;
  35279. /**
  35280. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35281. */
  35282. isFullscreen: boolean;
  35283. /**
  35284. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35285. */
  35286. cullBackFaces: boolean;
  35287. /**
  35288. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35289. */
  35290. renderEvenInBackground: boolean;
  35291. /**
  35292. * Gets or sets a boolean indicating that cache can be kept between frames
  35293. */
  35294. preventCacheWipeBetweenFrames: boolean;
  35295. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35296. validateShaderPrograms: boolean;
  35297. /**
  35298. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35299. * This can provide greater z depth for distant objects.
  35300. */
  35301. useReverseDepthBuffer: boolean;
  35302. /**
  35303. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35304. */
  35305. disableUniformBuffers: boolean;
  35306. /** @hidden */
  35307. _uniformBuffers: UniformBuffer[];
  35308. /**
  35309. * Gets a boolean indicating that the engine supports uniform buffers
  35310. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35311. */
  35312. get supportsUniformBuffers(): boolean;
  35313. /** @hidden */
  35314. _gl: WebGLRenderingContext;
  35315. /** @hidden */
  35316. _webGLVersion: number;
  35317. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35318. protected _windowIsBackground: boolean;
  35319. protected _creationOptions: EngineOptions;
  35320. protected _highPrecisionShadersAllowed: boolean;
  35321. /** @hidden */
  35322. get _shouldUseHighPrecisionShader(): boolean;
  35323. /**
  35324. * Gets a boolean indicating that only power of 2 textures are supported
  35325. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35326. */
  35327. get needPOTTextures(): boolean;
  35328. /** @hidden */
  35329. _badOS: boolean;
  35330. /** @hidden */
  35331. _badDesktopOS: boolean;
  35332. private _hardwareScalingLevel;
  35333. /** @hidden */
  35334. _caps: EngineCapabilities;
  35335. private _isStencilEnable;
  35336. private _glVersion;
  35337. private _glRenderer;
  35338. private _glVendor;
  35339. /** @hidden */
  35340. _videoTextureSupported: boolean;
  35341. protected _renderingQueueLaunched: boolean;
  35342. protected _activeRenderLoops: (() => void)[];
  35343. /**
  35344. * Observable signaled when a context lost event is raised
  35345. */
  35346. onContextLostObservable: Observable<ThinEngine>;
  35347. /**
  35348. * Observable signaled when a context restored event is raised
  35349. */
  35350. onContextRestoredObservable: Observable<ThinEngine>;
  35351. private _onContextLost;
  35352. private _onContextRestored;
  35353. protected _contextWasLost: boolean;
  35354. /** @hidden */
  35355. _doNotHandleContextLost: boolean;
  35356. /**
  35357. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35359. */
  35360. get doNotHandleContextLost(): boolean;
  35361. set doNotHandleContextLost(value: boolean);
  35362. /**
  35363. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35364. */
  35365. disableVertexArrayObjects: boolean;
  35366. /** @hidden */
  35367. protected _colorWrite: boolean;
  35368. /** @hidden */
  35369. protected _colorWriteChanged: boolean;
  35370. /** @hidden */
  35371. protected _depthCullingState: DepthCullingState;
  35372. /** @hidden */
  35373. protected _stencilState: StencilState;
  35374. /** @hidden */
  35375. _alphaState: AlphaState;
  35376. /** @hidden */
  35377. _alphaMode: number;
  35378. /** @hidden */
  35379. _alphaEquation: number;
  35380. /** @hidden */
  35381. _internalTexturesCache: InternalTexture[];
  35382. /** @hidden */
  35383. protected _activeChannel: number;
  35384. private _currentTextureChannel;
  35385. /** @hidden */
  35386. protected _boundTexturesCache: {
  35387. [key: string]: Nullable<InternalTexture>;
  35388. };
  35389. /** @hidden */
  35390. protected _currentEffect: Nullable<Effect>;
  35391. /** @hidden */
  35392. protected _currentProgram: Nullable<WebGLProgram>;
  35393. private _compiledEffects;
  35394. private _vertexAttribArraysEnabled;
  35395. /** @hidden */
  35396. protected _cachedViewport: Nullable<IViewportLike>;
  35397. private _cachedVertexArrayObject;
  35398. /** @hidden */
  35399. protected _cachedVertexBuffers: any;
  35400. /** @hidden */
  35401. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35402. /** @hidden */
  35403. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35404. /** @hidden */
  35405. _currentRenderTarget: Nullable<InternalTexture>;
  35406. private _uintIndicesCurrentlySet;
  35407. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35408. /** @hidden */
  35409. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35410. /** @hidden */
  35411. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35412. private _currentBufferPointers;
  35413. private _currentInstanceLocations;
  35414. private _currentInstanceBuffers;
  35415. private _textureUnits;
  35416. /** @hidden */
  35417. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35418. /** @hidden */
  35419. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35420. /** @hidden */
  35421. _boundRenderFunction: any;
  35422. private _vaoRecordInProgress;
  35423. private _mustWipeVertexAttributes;
  35424. private _emptyTexture;
  35425. private _emptyCubeTexture;
  35426. private _emptyTexture3D;
  35427. private _emptyTexture2DArray;
  35428. /** @hidden */
  35429. _frameHandler: number;
  35430. private _nextFreeTextureSlots;
  35431. private _maxSimultaneousTextures;
  35432. private _activeRequests;
  35433. /** @hidden */
  35434. _transformTextureUrl: Nullable<(url: string) => string>;
  35435. protected get _supportsHardwareTextureRescaling(): boolean;
  35436. private _framebufferDimensionsObject;
  35437. /**
  35438. * sets the object from which width and height will be taken from when getting render width and height
  35439. * Will fallback to the gl object
  35440. * @param dimensions the framebuffer width and height that will be used.
  35441. */
  35442. set framebufferDimensionsObject(dimensions: Nullable<{
  35443. framebufferWidth: number;
  35444. framebufferHeight: number;
  35445. }>);
  35446. /**
  35447. * Gets the current viewport
  35448. */
  35449. get currentViewport(): Nullable<IViewportLike>;
  35450. /**
  35451. * Gets the default empty texture
  35452. */
  35453. get emptyTexture(): InternalTexture;
  35454. /**
  35455. * Gets the default empty 3D texture
  35456. */
  35457. get emptyTexture3D(): InternalTexture;
  35458. /**
  35459. * Gets the default empty 2D array texture
  35460. */
  35461. get emptyTexture2DArray(): InternalTexture;
  35462. /**
  35463. * Gets the default empty cube texture
  35464. */
  35465. get emptyCubeTexture(): InternalTexture;
  35466. /**
  35467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35468. */
  35469. readonly premultipliedAlpha: boolean;
  35470. /**
  35471. * Observable event triggered before each texture is initialized
  35472. */
  35473. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35474. /**
  35475. * Creates a new engine
  35476. * @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
  35477. * @param antialias defines enable antialiasing (default: false)
  35478. * @param options defines further options to be sent to the getContext() function
  35479. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35480. */
  35481. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35482. private _rebuildInternalTextures;
  35483. private _rebuildEffects;
  35484. /**
  35485. * Gets a boolean indicating if all created effects are ready
  35486. * @returns true if all effects are ready
  35487. */
  35488. areAllEffectsReady(): boolean;
  35489. protected _rebuildBuffers(): void;
  35490. protected _initGLContext(): void;
  35491. /**
  35492. * Gets version of the current webGL context
  35493. */
  35494. get webGLVersion(): number;
  35495. /**
  35496. * Gets a string idenfifying the name of the class
  35497. * @returns "Engine" string
  35498. */
  35499. getClassName(): string;
  35500. /**
  35501. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35502. */
  35503. get isStencilEnable(): boolean;
  35504. /** @hidden */
  35505. _prepareWorkingCanvas(): void;
  35506. /**
  35507. * Reset the texture cache to empty state
  35508. */
  35509. resetTextureCache(): void;
  35510. /**
  35511. * Gets an object containing information about the current webGL context
  35512. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35513. */
  35514. getGlInfo(): {
  35515. vendor: string;
  35516. renderer: string;
  35517. version: string;
  35518. };
  35519. /**
  35520. * Defines the hardware scaling level.
  35521. * By default the hardware scaling level is computed from the window device ratio.
  35522. * 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.
  35523. * @param level defines the level to use
  35524. */
  35525. setHardwareScalingLevel(level: number): void;
  35526. /**
  35527. * Gets the current hardware scaling level.
  35528. * By default the hardware scaling level is computed from the window device ratio.
  35529. * 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.
  35530. * @returns a number indicating the current hardware scaling level
  35531. */
  35532. getHardwareScalingLevel(): number;
  35533. /**
  35534. * Gets the list of loaded textures
  35535. * @returns an array containing all loaded textures
  35536. */
  35537. getLoadedTexturesCache(): InternalTexture[];
  35538. /**
  35539. * Gets the object containing all engine capabilities
  35540. * @returns the EngineCapabilities object
  35541. */
  35542. getCaps(): EngineCapabilities;
  35543. /**
  35544. * stop executing a render loop function and remove it from the execution array
  35545. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35546. */
  35547. stopRenderLoop(renderFunction?: () => void): void;
  35548. /** @hidden */
  35549. _renderLoop(): void;
  35550. /**
  35551. * Gets the HTML canvas attached with the current webGL context
  35552. * @returns a HTML canvas
  35553. */
  35554. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35555. /**
  35556. * Gets host window
  35557. * @returns the host window object
  35558. */
  35559. getHostWindow(): Nullable<Window>;
  35560. /**
  35561. * Gets the current render width
  35562. * @param useScreen defines if screen size must be used (or the current render target if any)
  35563. * @returns a number defining the current render width
  35564. */
  35565. getRenderWidth(useScreen?: boolean): number;
  35566. /**
  35567. * Gets the current render height
  35568. * @param useScreen defines if screen size must be used (or the current render target if any)
  35569. * @returns a number defining the current render height
  35570. */
  35571. getRenderHeight(useScreen?: boolean): number;
  35572. /**
  35573. * Can be used to override the current requestAnimationFrame requester.
  35574. * @hidden
  35575. */
  35576. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35577. /**
  35578. * Register and execute a render loop. The engine can have more than one render function
  35579. * @param renderFunction defines the function to continuously execute
  35580. */
  35581. runRenderLoop(renderFunction: () => void): void;
  35582. /**
  35583. * Clear the current render buffer or the current render target (if any is set up)
  35584. * @param color defines the color to use
  35585. * @param backBuffer defines if the back buffer must be cleared
  35586. * @param depth defines if the depth buffer must be cleared
  35587. * @param stencil defines if the stencil buffer must be cleared
  35588. */
  35589. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35590. private _viewportCached;
  35591. /** @hidden */
  35592. _viewport(x: number, y: number, width: number, height: number): void;
  35593. /**
  35594. * Set the WebGL's viewport
  35595. * @param viewport defines the viewport element to be used
  35596. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35597. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35598. */
  35599. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35600. /**
  35601. * Begin a new frame
  35602. */
  35603. beginFrame(): void;
  35604. /**
  35605. * Enf the current frame
  35606. */
  35607. endFrame(): void;
  35608. /**
  35609. * Resize the view according to the canvas' size
  35610. */
  35611. resize(): void;
  35612. /**
  35613. * Force a specific size of the canvas
  35614. * @param width defines the new canvas' width
  35615. * @param height defines the new canvas' height
  35616. */
  35617. setSize(width: number, height: number): void;
  35618. /**
  35619. * Binds the frame buffer to the specified texture.
  35620. * @param texture The texture to render to or null for the default canvas
  35621. * @param faceIndex The face of the texture to render to in case of cube texture
  35622. * @param requiredWidth The width of the target to render to
  35623. * @param requiredHeight The height of the target to render to
  35624. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35625. * @param lodLevel defines the lod level to bind to the frame buffer
  35626. * @param layer defines the 2d array index to bind to frame buffer to
  35627. */
  35628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35629. /** @hidden */
  35630. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35631. /**
  35632. * Unbind the current render target texture from the webGL context
  35633. * @param texture defines the render target texture to unbind
  35634. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35635. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35636. */
  35637. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35638. /**
  35639. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35640. */
  35641. flushFramebuffer(): void;
  35642. /**
  35643. * Unbind the current render target and bind the default framebuffer
  35644. */
  35645. restoreDefaultFramebuffer(): void;
  35646. /** @hidden */
  35647. protected _resetVertexBufferBinding(): void;
  35648. /**
  35649. * Creates a vertex buffer
  35650. * @param data the data for the vertex buffer
  35651. * @returns the new WebGL static buffer
  35652. */
  35653. createVertexBuffer(data: DataArray): DataBuffer;
  35654. private _createVertexBuffer;
  35655. /**
  35656. * Creates a dynamic vertex buffer
  35657. * @param data the data for the dynamic vertex buffer
  35658. * @returns the new WebGL dynamic buffer
  35659. */
  35660. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35661. protected _resetIndexBufferBinding(): void;
  35662. /**
  35663. * Creates a new index buffer
  35664. * @param indices defines the content of the index buffer
  35665. * @param updatable defines if the index buffer must be updatable
  35666. * @returns a new webGL buffer
  35667. */
  35668. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35669. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35670. /**
  35671. * Bind a webGL buffer to the webGL context
  35672. * @param buffer defines the buffer to bind
  35673. */
  35674. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35675. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35676. private bindBuffer;
  35677. /**
  35678. * update the bound buffer with the given data
  35679. * @param data defines the data to update
  35680. */
  35681. updateArrayBuffer(data: Float32Array): void;
  35682. private _vertexAttribPointer;
  35683. /** @hidden */
  35684. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35685. private _bindVertexBuffersAttributes;
  35686. /**
  35687. * Records a vertex array object
  35688. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35689. * @param vertexBuffers defines the list of vertex buffers to store
  35690. * @param indexBuffer defines the index buffer to store
  35691. * @param effect defines the effect to store
  35692. * @returns the new vertex array object
  35693. */
  35694. recordVertexArrayObject(vertexBuffers: {
  35695. [key: string]: VertexBuffer;
  35696. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35697. /**
  35698. * Bind a specific vertex array object
  35699. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35700. * @param vertexArrayObject defines the vertex array object to bind
  35701. * @param indexBuffer defines the index buffer to bind
  35702. */
  35703. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35704. /**
  35705. * Bind webGl buffers directly to the webGL context
  35706. * @param vertexBuffer defines the vertex buffer to bind
  35707. * @param indexBuffer defines the index buffer to bind
  35708. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35709. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35710. * @param effect defines the effect associated with the vertex buffer
  35711. */
  35712. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35713. private _unbindVertexArrayObject;
  35714. /**
  35715. * Bind a list of vertex buffers to the webGL context
  35716. * @param vertexBuffers defines the list of vertex buffers to bind
  35717. * @param indexBuffer defines the index buffer to bind
  35718. * @param effect defines the effect associated with the vertex buffers
  35719. */
  35720. bindBuffers(vertexBuffers: {
  35721. [key: string]: Nullable<VertexBuffer>;
  35722. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35723. /**
  35724. * Unbind all instance attributes
  35725. */
  35726. unbindInstanceAttributes(): void;
  35727. /**
  35728. * Release and free the memory of a vertex array object
  35729. * @param vao defines the vertex array object to delete
  35730. */
  35731. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35732. /** @hidden */
  35733. _releaseBuffer(buffer: DataBuffer): boolean;
  35734. protected _deleteBuffer(buffer: DataBuffer): void;
  35735. /**
  35736. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35737. * @param instancesBuffer defines the webGL buffer to update and bind
  35738. * @param data defines the data to store in the buffer
  35739. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35740. */
  35741. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35742. /**
  35743. * Bind the content of a webGL buffer used with instantiation
  35744. * @param instancesBuffer defines the webGL buffer to bind
  35745. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35746. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35747. */
  35748. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35749. /**
  35750. * Disable the instance attribute corresponding to the name in parameter
  35751. * @param name defines the name of the attribute to disable
  35752. */
  35753. disableInstanceAttributeByName(name: string): void;
  35754. /**
  35755. * Disable the instance attribute corresponding to the location in parameter
  35756. * @param attributeLocation defines the attribute location of the attribute to disable
  35757. */
  35758. disableInstanceAttribute(attributeLocation: number): void;
  35759. /**
  35760. * Disable the attribute corresponding to the location in parameter
  35761. * @param attributeLocation defines the attribute location of the attribute to disable
  35762. */
  35763. disableAttributeByIndex(attributeLocation: number): void;
  35764. /**
  35765. * Send a draw order
  35766. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35767. * @param indexStart defines the starting index
  35768. * @param indexCount defines the number of index to draw
  35769. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35770. */
  35771. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35772. /**
  35773. * Draw a list of points
  35774. * @param verticesStart defines the index of first vertex to draw
  35775. * @param verticesCount defines the count of vertices to draw
  35776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35777. */
  35778. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35779. /**
  35780. * Draw a list of unindexed primitives
  35781. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35782. * @param verticesStart defines the index of first vertex to draw
  35783. * @param verticesCount defines the count of vertices to draw
  35784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35785. */
  35786. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35787. /**
  35788. * Draw a list of indexed primitives
  35789. * @param fillMode defines the primitive to use
  35790. * @param indexStart defines the starting index
  35791. * @param indexCount defines the number of index to draw
  35792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35793. */
  35794. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35795. /**
  35796. * Draw a list of unindexed primitives
  35797. * @param fillMode defines the primitive to use
  35798. * @param verticesStart defines the index of first vertex to draw
  35799. * @param verticesCount defines the count of vertices to draw
  35800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35801. */
  35802. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35803. private _drawMode;
  35804. /** @hidden */
  35805. protected _reportDrawCall(): void;
  35806. /** @hidden */
  35807. _releaseEffect(effect: Effect): void;
  35808. /** @hidden */
  35809. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35810. /**
  35811. * Create a new effect (used to store vertex/fragment shaders)
  35812. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35813. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35814. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35815. * @param samplers defines an array of string used to represent textures
  35816. * @param defines defines the string containing the defines to use to compile the shaders
  35817. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35818. * @param onCompiled defines a function to call when the effect creation is successful
  35819. * @param onError defines a function to call when the effect creation has failed
  35820. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35821. * @returns the new Effect
  35822. */
  35823. 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;
  35824. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35825. private _compileShader;
  35826. private _compileRawShader;
  35827. /** @hidden */
  35828. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35829. /**
  35830. * Directly creates a webGL program
  35831. * @param pipelineContext defines the pipeline context to attach to
  35832. * @param vertexCode defines the vertex shader code to use
  35833. * @param fragmentCode defines the fragment shader code to use
  35834. * @param context defines the webGL context to use (if not set, the current one will be used)
  35835. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35836. * @returns the new webGL program
  35837. */
  35838. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35839. /**
  35840. * Creates a webGL program
  35841. * @param pipelineContext defines the pipeline context to attach to
  35842. * @param vertexCode defines the vertex shader code to use
  35843. * @param fragmentCode defines the fragment shader code to use
  35844. * @param defines defines the string containing the defines to use to compile the shaders
  35845. * @param context defines the webGL context to use (if not set, the current one will be used)
  35846. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35847. * @returns the new webGL program
  35848. */
  35849. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35850. /**
  35851. * Creates a new pipeline context
  35852. * @returns the new pipeline
  35853. */
  35854. createPipelineContext(): IPipelineContext;
  35855. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35856. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35857. /** @hidden */
  35858. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35859. /** @hidden */
  35860. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35861. /** @hidden */
  35862. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35863. /**
  35864. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35865. * @param pipelineContext defines the pipeline context to use
  35866. * @param uniformsNames defines the list of uniform names
  35867. * @returns an array of webGL uniform locations
  35868. */
  35869. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35870. /**
  35871. * Gets the lsit of active attributes for a given webGL program
  35872. * @param pipelineContext defines the pipeline context to use
  35873. * @param attributesNames defines the list of attribute names to get
  35874. * @returns an array of indices indicating the offset of each attribute
  35875. */
  35876. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35877. /**
  35878. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35879. * @param effect defines the effect to activate
  35880. */
  35881. enableEffect(effect: Nullable<Effect>): void;
  35882. /**
  35883. * Set the value of an uniform to a number (int)
  35884. * @param uniform defines the webGL uniform location where to store the value
  35885. * @param value defines the int number to store
  35886. */
  35887. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35888. /**
  35889. * Set the value of an uniform to an array of int32
  35890. * @param uniform defines the webGL uniform location where to store the value
  35891. * @param array defines the array of int32 to store
  35892. */
  35893. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35894. /**
  35895. * Set the value of an uniform to an array of int32 (stored as vec2)
  35896. * @param uniform defines the webGL uniform location where to store the value
  35897. * @param array defines the array of int32 to store
  35898. */
  35899. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35900. /**
  35901. * Set the value of an uniform to an array of int32 (stored as vec3)
  35902. * @param uniform defines the webGL uniform location where to store the value
  35903. * @param array defines the array of int32 to store
  35904. */
  35905. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35906. /**
  35907. * Set the value of an uniform to an array of int32 (stored as vec4)
  35908. * @param uniform defines the webGL uniform location where to store the value
  35909. * @param array defines the array of int32 to store
  35910. */
  35911. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35912. /**
  35913. * Set the value of an uniform to an array of number
  35914. * @param uniform defines the webGL uniform location where to store the value
  35915. * @param array defines the array of number to store
  35916. */
  35917. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35918. /**
  35919. * Set the value of an uniform to an array of number (stored as vec2)
  35920. * @param uniform defines the webGL uniform location where to store the value
  35921. * @param array defines the array of number to store
  35922. */
  35923. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35924. /**
  35925. * Set the value of an uniform to an array of number (stored as vec3)
  35926. * @param uniform defines the webGL uniform location where to store the value
  35927. * @param array defines the array of number to store
  35928. */
  35929. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35930. /**
  35931. * Set the value of an uniform to an array of number (stored as vec4)
  35932. * @param uniform defines the webGL uniform location where to store the value
  35933. * @param array defines the array of number to store
  35934. */
  35935. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35936. /**
  35937. * Set the value of an uniform to an array of float32 (stored as matrices)
  35938. * @param uniform defines the webGL uniform location where to store the value
  35939. * @param matrices defines the array of float32 to store
  35940. */
  35941. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35942. /**
  35943. * Set the value of an uniform to a matrix (3x3)
  35944. * @param uniform defines the webGL uniform location where to store the value
  35945. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35946. */
  35947. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35948. /**
  35949. * Set the value of an uniform to a matrix (2x2)
  35950. * @param uniform defines the webGL uniform location where to store the value
  35951. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35952. */
  35953. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35954. /**
  35955. * Set the value of an uniform to a number (float)
  35956. * @param uniform defines the webGL uniform location where to store the value
  35957. * @param value defines the float number to store
  35958. */
  35959. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35960. /**
  35961. * Set the value of an uniform to a vec2
  35962. * @param uniform defines the webGL uniform location where to store the value
  35963. * @param x defines the 1st component of the value
  35964. * @param y defines the 2nd component of the value
  35965. */
  35966. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35967. /**
  35968. * Set the value of an uniform to a vec3
  35969. * @param uniform defines the webGL uniform location where to store the value
  35970. * @param x defines the 1st component of the value
  35971. * @param y defines the 2nd component of the value
  35972. * @param z defines the 3rd component of the value
  35973. */
  35974. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35975. /**
  35976. * Set the value of an uniform to a vec4
  35977. * @param uniform defines the webGL uniform location where to store the value
  35978. * @param x defines the 1st component of the value
  35979. * @param y defines the 2nd component of the value
  35980. * @param z defines the 3rd component of the value
  35981. * @param w defines the 4th component of the value
  35982. */
  35983. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35984. /**
  35985. * Apply all cached states (depth, culling, stencil and alpha)
  35986. */
  35987. applyStates(): void;
  35988. /**
  35989. * Enable or disable color writing
  35990. * @param enable defines the state to set
  35991. */
  35992. setColorWrite(enable: boolean): void;
  35993. /**
  35994. * Gets a boolean indicating if color writing is enabled
  35995. * @returns the current color writing state
  35996. */
  35997. getColorWrite(): boolean;
  35998. /**
  35999. * Gets the depth culling state manager
  36000. */
  36001. get depthCullingState(): DepthCullingState;
  36002. /**
  36003. * Gets the alpha state manager
  36004. */
  36005. get alphaState(): AlphaState;
  36006. /**
  36007. * Gets the stencil state manager
  36008. */
  36009. get stencilState(): StencilState;
  36010. /**
  36011. * Clears the list of texture accessible through engine.
  36012. * This can help preventing texture load conflict due to name collision.
  36013. */
  36014. clearInternalTexturesCache(): void;
  36015. /**
  36016. * Force the entire cache to be cleared
  36017. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36018. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36019. */
  36020. wipeCaches(bruteForce?: boolean): void;
  36021. /** @hidden */
  36022. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36023. min: number;
  36024. mag: number;
  36025. };
  36026. /** @hidden */
  36027. _createTexture(): WebGLTexture;
  36028. /**
  36029. * Usually called from Texture.ts.
  36030. * Passed information to create a WebGLTexture
  36031. * @param url defines a value which contains one of the following:
  36032. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36033. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36034. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36035. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36036. * @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)
  36037. * @param scene needed for loading to the correct scene
  36038. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36039. * @param onLoad optional callback to be called upon successful completion
  36040. * @param onError optional callback to be called upon failure
  36041. * @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
  36042. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36043. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36044. * @param forcedExtension defines the extension to use to pick the right loader
  36045. * @param mimeType defines an optional mime type
  36046. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36047. */
  36048. 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;
  36049. /**
  36050. * Loads an image as an HTMLImageElement.
  36051. * @param input url string, ArrayBuffer, or Blob to load
  36052. * @param onLoad callback called when the image successfully loads
  36053. * @param onError callback called when the image fails to load
  36054. * @param offlineProvider offline provider for caching
  36055. * @param mimeType optional mime type
  36056. * @returns the HTMLImageElement of the loaded image
  36057. * @hidden
  36058. */
  36059. 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>;
  36060. /**
  36061. * @hidden
  36062. */
  36063. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36064. private _unpackFlipYCached;
  36065. /**
  36066. * In case you are sharing the context with other applications, it might
  36067. * be interested to not cache the unpack flip y state to ensure a consistent
  36068. * value would be set.
  36069. */
  36070. enableUnpackFlipYCached: boolean;
  36071. /** @hidden */
  36072. _unpackFlipY(value: boolean): void;
  36073. /** @hidden */
  36074. _getUnpackAlignement(): number;
  36075. private _getTextureTarget;
  36076. /**
  36077. * Update the sampling mode of a given texture
  36078. * @param samplingMode defines the required sampling mode
  36079. * @param texture defines the texture to update
  36080. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36081. */
  36082. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36083. /**
  36084. * Update the sampling mode of a given texture
  36085. * @param texture defines the texture to update
  36086. * @param wrapU defines the texture wrap mode of the u coordinates
  36087. * @param wrapV defines the texture wrap mode of the v coordinates
  36088. * @param wrapR defines the texture wrap mode of the r coordinates
  36089. */
  36090. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36091. /** @hidden */
  36092. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36093. width: number;
  36094. height: number;
  36095. layers?: number;
  36096. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36097. /** @hidden */
  36098. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36099. /** @hidden */
  36100. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36101. /**
  36102. * Update a portion of an internal texture
  36103. * @param texture defines the texture to update
  36104. * @param imageData defines the data to store into the texture
  36105. * @param xOffset defines the x coordinates of the update rectangle
  36106. * @param yOffset defines the y coordinates of the update rectangle
  36107. * @param width defines the width of the update rectangle
  36108. * @param height defines the height of the update rectangle
  36109. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36110. * @param lod defines the lod level to update (0 by default)
  36111. */
  36112. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36113. /** @hidden */
  36114. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36115. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36116. private _prepareWebGLTexture;
  36117. /** @hidden */
  36118. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36119. private _getDepthStencilBuffer;
  36120. /** @hidden */
  36121. _releaseFramebufferObjects(texture: InternalTexture): void;
  36122. /** @hidden */
  36123. _releaseTexture(texture: InternalTexture): void;
  36124. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36125. protected _setProgram(program: WebGLProgram): void;
  36126. protected _boundUniforms: {
  36127. [key: number]: WebGLUniformLocation;
  36128. };
  36129. /**
  36130. * Binds an effect to the webGL context
  36131. * @param effect defines the effect to bind
  36132. */
  36133. bindSamplers(effect: Effect): void;
  36134. private _activateCurrentTexture;
  36135. /** @hidden */
  36136. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36137. /** @hidden */
  36138. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36139. /**
  36140. * Unbind all textures from the webGL context
  36141. */
  36142. unbindAllTextures(): void;
  36143. /**
  36144. * Sets a texture to the according uniform.
  36145. * @param channel The texture channel
  36146. * @param uniform The uniform to set
  36147. * @param texture The texture to apply
  36148. */
  36149. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36150. private _bindSamplerUniformToChannel;
  36151. private _getTextureWrapMode;
  36152. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36153. /**
  36154. * Sets an array of texture to the webGL context
  36155. * @param channel defines the channel where the texture array must be set
  36156. * @param uniform defines the associated uniform location
  36157. * @param textures defines the array of textures to bind
  36158. */
  36159. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36160. /** @hidden */
  36161. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36162. private _setTextureParameterFloat;
  36163. private _setTextureParameterInteger;
  36164. /**
  36165. * Unbind all vertex attributes from the webGL context
  36166. */
  36167. unbindAllAttributes(): void;
  36168. /**
  36169. * 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
  36170. */
  36171. releaseEffects(): void;
  36172. /**
  36173. * Dispose and release all associated resources
  36174. */
  36175. dispose(): void;
  36176. /**
  36177. * Attach a new callback raised when context lost event is fired
  36178. * @param callback defines the callback to call
  36179. */
  36180. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36181. /**
  36182. * Attach a new callback raised when context restored event is fired
  36183. * @param callback defines the callback to call
  36184. */
  36185. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36186. /**
  36187. * Get the current error code of the webGL context
  36188. * @returns the error code
  36189. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36190. */
  36191. getError(): number;
  36192. private _canRenderToFloatFramebuffer;
  36193. private _canRenderToHalfFloatFramebuffer;
  36194. private _canRenderToFramebuffer;
  36195. /** @hidden */
  36196. _getWebGLTextureType(type: number): number;
  36197. /** @hidden */
  36198. _getInternalFormat(format: number): number;
  36199. /** @hidden */
  36200. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36201. /** @hidden */
  36202. _getRGBAMultiSampleBufferFormat(type: number): number;
  36203. /** @hidden */
  36204. _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;
  36205. /**
  36206. * Loads a file from a url
  36207. * @param url url to load
  36208. * @param onSuccess callback called when the file successfully loads
  36209. * @param onProgress callback called while file is loading (if the server supports this mode)
  36210. * @param offlineProvider defines the offline provider for caching
  36211. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36212. * @param onError callback called when the file fails to load
  36213. * @returns a file request object
  36214. * @hidden
  36215. */
  36216. 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;
  36217. /**
  36218. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36219. * @param x defines the x coordinate of the rectangle where pixels must be read
  36220. * @param y defines the y coordinate of the rectangle where pixels must be read
  36221. * @param width defines the width of the rectangle where pixels must be read
  36222. * @param height defines the height of the rectangle where pixels must be read
  36223. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36224. * @returns a Uint8Array containing RGBA colors
  36225. */
  36226. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36227. private static _isSupported;
  36228. /**
  36229. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36230. * @returns true if the engine can be created
  36231. * @ignorenaming
  36232. */
  36233. static isSupported(): boolean;
  36234. /**
  36235. * Find the next highest power of two.
  36236. * @param x Number to start search from.
  36237. * @return Next highest power of two.
  36238. */
  36239. static CeilingPOT(x: number): number;
  36240. /**
  36241. * Find the next lowest power of two.
  36242. * @param x Number to start search from.
  36243. * @return Next lowest power of two.
  36244. */
  36245. static FloorPOT(x: number): number;
  36246. /**
  36247. * Find the nearest power of two.
  36248. * @param x Number to start search from.
  36249. * @return Next nearest power of two.
  36250. */
  36251. static NearestPOT(x: number): number;
  36252. /**
  36253. * Get the closest exponent of two
  36254. * @param value defines the value to approximate
  36255. * @param max defines the maximum value to return
  36256. * @param mode defines how to define the closest value
  36257. * @returns closest exponent of two of the given value
  36258. */
  36259. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36260. /**
  36261. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36262. * @param func - the function to be called
  36263. * @param requester - the object that will request the next frame. Falls back to window.
  36264. * @returns frame number
  36265. */
  36266. static QueueNewFrame(func: () => void, requester?: any): number;
  36267. /**
  36268. * Gets host document
  36269. * @returns the host document object
  36270. */
  36271. getHostDocument(): Nullable<Document>;
  36272. }
  36273. }
  36274. declare module "babylonjs/Maths/sphericalPolynomial" {
  36275. import { Vector3 } from "babylonjs/Maths/math.vector";
  36276. import { Color3 } from "babylonjs/Maths/math.color";
  36277. /**
  36278. * Class representing spherical harmonics coefficients to the 3rd degree
  36279. */
  36280. export class SphericalHarmonics {
  36281. /**
  36282. * Defines whether or not the harmonics have been prescaled for rendering.
  36283. */
  36284. preScaled: boolean;
  36285. /**
  36286. * The l0,0 coefficients of the spherical harmonics
  36287. */
  36288. l00: Vector3;
  36289. /**
  36290. * The l1,-1 coefficients of the spherical harmonics
  36291. */
  36292. l1_1: Vector3;
  36293. /**
  36294. * The l1,0 coefficients of the spherical harmonics
  36295. */
  36296. l10: Vector3;
  36297. /**
  36298. * The l1,1 coefficients of the spherical harmonics
  36299. */
  36300. l11: Vector3;
  36301. /**
  36302. * The l2,-2 coefficients of the spherical harmonics
  36303. */
  36304. l2_2: Vector3;
  36305. /**
  36306. * The l2,-1 coefficients of the spherical harmonics
  36307. */
  36308. l2_1: Vector3;
  36309. /**
  36310. * The l2,0 coefficients of the spherical harmonics
  36311. */
  36312. l20: Vector3;
  36313. /**
  36314. * The l2,1 coefficients of the spherical harmonics
  36315. */
  36316. l21: Vector3;
  36317. /**
  36318. * The l2,2 coefficients of the spherical harmonics
  36319. */
  36320. l22: Vector3;
  36321. /**
  36322. * Adds a light to the spherical harmonics
  36323. * @param direction the direction of the light
  36324. * @param color the color of the light
  36325. * @param deltaSolidAngle the delta solid angle of the light
  36326. */
  36327. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36328. /**
  36329. * Scales the spherical harmonics by the given amount
  36330. * @param scale the amount to scale
  36331. */
  36332. scaleInPlace(scale: number): void;
  36333. /**
  36334. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36335. *
  36336. * ```
  36337. * E_lm = A_l * L_lm
  36338. * ```
  36339. *
  36340. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36341. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36342. * the scaling factors are given in equation 9.
  36343. */
  36344. convertIncidentRadianceToIrradiance(): void;
  36345. /**
  36346. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36347. *
  36348. * ```
  36349. * L = (1/pi) * E * rho
  36350. * ```
  36351. *
  36352. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36353. */
  36354. convertIrradianceToLambertianRadiance(): void;
  36355. /**
  36356. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36357. * required operations at run time.
  36358. *
  36359. * This is simply done by scaling back the SH with Ylm constants parameter.
  36360. * The trigonometric part being applied by the shader at run time.
  36361. */
  36362. preScaleForRendering(): void;
  36363. /**
  36364. * Constructs a spherical harmonics from an array.
  36365. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36366. * @returns the spherical harmonics
  36367. */
  36368. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36369. /**
  36370. * Gets the spherical harmonics from polynomial
  36371. * @param polynomial the spherical polynomial
  36372. * @returns the spherical harmonics
  36373. */
  36374. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36375. }
  36376. /**
  36377. * Class representing spherical polynomial coefficients to the 3rd degree
  36378. */
  36379. export class SphericalPolynomial {
  36380. private _harmonics;
  36381. /**
  36382. * The spherical harmonics used to create the polynomials.
  36383. */
  36384. get preScaledHarmonics(): SphericalHarmonics;
  36385. /**
  36386. * The x coefficients of the spherical polynomial
  36387. */
  36388. x: Vector3;
  36389. /**
  36390. * The y coefficients of the spherical polynomial
  36391. */
  36392. y: Vector3;
  36393. /**
  36394. * The z coefficients of the spherical polynomial
  36395. */
  36396. z: Vector3;
  36397. /**
  36398. * The xx coefficients of the spherical polynomial
  36399. */
  36400. xx: Vector3;
  36401. /**
  36402. * The yy coefficients of the spherical polynomial
  36403. */
  36404. yy: Vector3;
  36405. /**
  36406. * The zz coefficients of the spherical polynomial
  36407. */
  36408. zz: Vector3;
  36409. /**
  36410. * The xy coefficients of the spherical polynomial
  36411. */
  36412. xy: Vector3;
  36413. /**
  36414. * The yz coefficients of the spherical polynomial
  36415. */
  36416. yz: Vector3;
  36417. /**
  36418. * The zx coefficients of the spherical polynomial
  36419. */
  36420. zx: Vector3;
  36421. /**
  36422. * Adds an ambient color to the spherical polynomial
  36423. * @param color the color to add
  36424. */
  36425. addAmbient(color: Color3): void;
  36426. /**
  36427. * Scales the spherical polynomial by the given amount
  36428. * @param scale the amount to scale
  36429. */
  36430. scaleInPlace(scale: number): void;
  36431. /**
  36432. * Gets the spherical polynomial from harmonics
  36433. * @param harmonics the spherical harmonics
  36434. * @returns the spherical polynomial
  36435. */
  36436. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36437. /**
  36438. * Constructs a spherical polynomial from an array.
  36439. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36440. * @returns the spherical polynomial
  36441. */
  36442. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36443. }
  36444. }
  36445. declare module "babylonjs/Materials/Textures/internalTexture" {
  36446. import { Observable } from "babylonjs/Misc/observable";
  36447. import { Nullable, int } from "babylonjs/types";
  36448. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36450. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36451. /**
  36452. * Defines the source of the internal texture
  36453. */
  36454. export enum InternalTextureSource {
  36455. /**
  36456. * The source of the texture data is unknown
  36457. */
  36458. Unknown = 0,
  36459. /**
  36460. * Texture data comes from an URL
  36461. */
  36462. Url = 1,
  36463. /**
  36464. * Texture data is only used for temporary storage
  36465. */
  36466. Temp = 2,
  36467. /**
  36468. * Texture data comes from raw data (ArrayBuffer)
  36469. */
  36470. Raw = 3,
  36471. /**
  36472. * Texture content is dynamic (video or dynamic texture)
  36473. */
  36474. Dynamic = 4,
  36475. /**
  36476. * Texture content is generated by rendering to it
  36477. */
  36478. RenderTarget = 5,
  36479. /**
  36480. * Texture content is part of a multi render target process
  36481. */
  36482. MultiRenderTarget = 6,
  36483. /**
  36484. * Texture data comes from a cube data file
  36485. */
  36486. Cube = 7,
  36487. /**
  36488. * Texture data comes from a raw cube data
  36489. */
  36490. CubeRaw = 8,
  36491. /**
  36492. * Texture data come from a prefiltered cube data file
  36493. */
  36494. CubePrefiltered = 9,
  36495. /**
  36496. * Texture content is raw 3D data
  36497. */
  36498. Raw3D = 10,
  36499. /**
  36500. * Texture content is raw 2D array data
  36501. */
  36502. Raw2DArray = 11,
  36503. /**
  36504. * Texture content is a depth texture
  36505. */
  36506. Depth = 12,
  36507. /**
  36508. * Texture data comes from a raw cube data encoded with RGBD
  36509. */
  36510. CubeRawRGBD = 13
  36511. }
  36512. /**
  36513. * Class used to store data associated with WebGL texture data for the engine
  36514. * This class should not be used directly
  36515. */
  36516. export class InternalTexture {
  36517. /** @hidden */
  36518. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36519. /**
  36520. * Defines if the texture is ready
  36521. */
  36522. isReady: boolean;
  36523. /**
  36524. * Defines if the texture is a cube texture
  36525. */
  36526. isCube: boolean;
  36527. /**
  36528. * Defines if the texture contains 3D data
  36529. */
  36530. is3D: boolean;
  36531. /**
  36532. * Defines if the texture contains 2D array data
  36533. */
  36534. is2DArray: boolean;
  36535. /**
  36536. * Defines if the texture contains multiview data
  36537. */
  36538. isMultiview: boolean;
  36539. /**
  36540. * Gets the URL used to load this texture
  36541. */
  36542. url: string;
  36543. /**
  36544. * Gets the sampling mode of the texture
  36545. */
  36546. samplingMode: number;
  36547. /**
  36548. * Gets a boolean indicating if the texture needs mipmaps generation
  36549. */
  36550. generateMipMaps: boolean;
  36551. /**
  36552. * Gets the number of samples used by the texture (WebGL2+ only)
  36553. */
  36554. samples: number;
  36555. /**
  36556. * Gets the type of the texture (int, float...)
  36557. */
  36558. type: number;
  36559. /**
  36560. * Gets the format of the texture (RGB, RGBA...)
  36561. */
  36562. format: number;
  36563. /**
  36564. * Observable called when the texture is loaded
  36565. */
  36566. onLoadedObservable: Observable<InternalTexture>;
  36567. /**
  36568. * Gets the width of the texture
  36569. */
  36570. width: number;
  36571. /**
  36572. * Gets the height of the texture
  36573. */
  36574. height: number;
  36575. /**
  36576. * Gets the depth of the texture
  36577. */
  36578. depth: number;
  36579. /**
  36580. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36581. */
  36582. baseWidth: number;
  36583. /**
  36584. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36585. */
  36586. baseHeight: number;
  36587. /**
  36588. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36589. */
  36590. baseDepth: number;
  36591. /**
  36592. * Gets a boolean indicating if the texture is inverted on Y axis
  36593. */
  36594. invertY: boolean;
  36595. /** @hidden */
  36596. _invertVScale: boolean;
  36597. /** @hidden */
  36598. _associatedChannel: number;
  36599. /** @hidden */
  36600. _source: InternalTextureSource;
  36601. /** @hidden */
  36602. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36603. /** @hidden */
  36604. _bufferView: Nullable<ArrayBufferView>;
  36605. /** @hidden */
  36606. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36607. /** @hidden */
  36608. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36609. /** @hidden */
  36610. _size: number;
  36611. /** @hidden */
  36612. _extension: string;
  36613. /** @hidden */
  36614. _files: Nullable<string[]>;
  36615. /** @hidden */
  36616. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36617. /** @hidden */
  36618. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36619. /** @hidden */
  36620. _framebuffer: Nullable<WebGLFramebuffer>;
  36621. /** @hidden */
  36622. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36623. /** @hidden */
  36624. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36625. /** @hidden */
  36626. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36627. /** @hidden */
  36628. _attachments: Nullable<number[]>;
  36629. /** @hidden */
  36630. _cachedCoordinatesMode: Nullable<number>;
  36631. /** @hidden */
  36632. _cachedWrapU: Nullable<number>;
  36633. /** @hidden */
  36634. _cachedWrapV: Nullable<number>;
  36635. /** @hidden */
  36636. _cachedWrapR: Nullable<number>;
  36637. /** @hidden */
  36638. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36639. /** @hidden */
  36640. _isDisabled: boolean;
  36641. /** @hidden */
  36642. _compression: Nullable<string>;
  36643. /** @hidden */
  36644. _generateStencilBuffer: boolean;
  36645. /** @hidden */
  36646. _generateDepthBuffer: boolean;
  36647. /** @hidden */
  36648. _comparisonFunction: number;
  36649. /** @hidden */
  36650. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36651. /** @hidden */
  36652. _lodGenerationScale: number;
  36653. /** @hidden */
  36654. _lodGenerationOffset: number;
  36655. /** @hidden */
  36656. _depthStencilTexture: Nullable<InternalTexture>;
  36657. /** @hidden */
  36658. _colorTextureArray: Nullable<WebGLTexture>;
  36659. /** @hidden */
  36660. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36661. /** @hidden */
  36662. _lodTextureHigh: Nullable<BaseTexture>;
  36663. /** @hidden */
  36664. _lodTextureMid: Nullable<BaseTexture>;
  36665. /** @hidden */
  36666. _lodTextureLow: Nullable<BaseTexture>;
  36667. /** @hidden */
  36668. _isRGBD: boolean;
  36669. /** @hidden */
  36670. _linearSpecularLOD: boolean;
  36671. /** @hidden */
  36672. _irradianceTexture: Nullable<BaseTexture>;
  36673. /** @hidden */
  36674. _webGLTexture: Nullable<WebGLTexture>;
  36675. /** @hidden */
  36676. _references: number;
  36677. private _engine;
  36678. /**
  36679. * Gets the Engine the texture belongs to.
  36680. * @returns The babylon engine
  36681. */
  36682. getEngine(): ThinEngine;
  36683. /**
  36684. * Gets the data source type of the texture
  36685. */
  36686. get source(): InternalTextureSource;
  36687. /**
  36688. * Creates a new InternalTexture
  36689. * @param engine defines the engine to use
  36690. * @param source defines the type of data that will be used
  36691. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36692. */
  36693. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36694. /**
  36695. * Increments the number of references (ie. the number of Texture that point to it)
  36696. */
  36697. incrementReferences(): void;
  36698. /**
  36699. * Change the size of the texture (not the size of the content)
  36700. * @param width defines the new width
  36701. * @param height defines the new height
  36702. * @param depth defines the new depth (1 by default)
  36703. */
  36704. updateSize(width: int, height: int, depth?: int): void;
  36705. /** @hidden */
  36706. _rebuild(): void;
  36707. /** @hidden */
  36708. _swapAndDie(target: InternalTexture): void;
  36709. /**
  36710. * Dispose the current allocated resources
  36711. */
  36712. dispose(): void;
  36713. }
  36714. }
  36715. declare module "babylonjs/Audio/analyser" {
  36716. import { Scene } from "babylonjs/scene";
  36717. /**
  36718. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36720. */
  36721. export class Analyser {
  36722. /**
  36723. * Gets or sets the smoothing
  36724. * @ignorenaming
  36725. */
  36726. SMOOTHING: number;
  36727. /**
  36728. * Gets or sets the FFT table size
  36729. * @ignorenaming
  36730. */
  36731. FFT_SIZE: number;
  36732. /**
  36733. * Gets or sets the bar graph amplitude
  36734. * @ignorenaming
  36735. */
  36736. BARGRAPHAMPLITUDE: number;
  36737. /**
  36738. * Gets or sets the position of the debug canvas
  36739. * @ignorenaming
  36740. */
  36741. DEBUGCANVASPOS: {
  36742. x: number;
  36743. y: number;
  36744. };
  36745. /**
  36746. * Gets or sets the debug canvas size
  36747. * @ignorenaming
  36748. */
  36749. DEBUGCANVASSIZE: {
  36750. width: number;
  36751. height: number;
  36752. };
  36753. private _byteFreqs;
  36754. private _byteTime;
  36755. private _floatFreqs;
  36756. private _webAudioAnalyser;
  36757. private _debugCanvas;
  36758. private _debugCanvasContext;
  36759. private _scene;
  36760. private _registerFunc;
  36761. private _audioEngine;
  36762. /**
  36763. * Creates a new analyser
  36764. * @param scene defines hosting scene
  36765. */
  36766. constructor(scene: Scene);
  36767. /**
  36768. * Get the number of data values you will have to play with for the visualization
  36769. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36770. * @returns a number
  36771. */
  36772. getFrequencyBinCount(): number;
  36773. /**
  36774. * Gets the current frequency data as a byte array
  36775. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36776. * @returns a Uint8Array
  36777. */
  36778. getByteFrequencyData(): Uint8Array;
  36779. /**
  36780. * Gets the current waveform as a byte array
  36781. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36782. * @returns a Uint8Array
  36783. */
  36784. getByteTimeDomainData(): Uint8Array;
  36785. /**
  36786. * Gets the current frequency data as a float array
  36787. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36788. * @returns a Float32Array
  36789. */
  36790. getFloatFrequencyData(): Float32Array;
  36791. /**
  36792. * Renders the debug canvas
  36793. */
  36794. drawDebugCanvas(): void;
  36795. /**
  36796. * Stops rendering the debug canvas and removes it
  36797. */
  36798. stopDebugCanvas(): void;
  36799. /**
  36800. * Connects two audio nodes
  36801. * @param inputAudioNode defines first node to connect
  36802. * @param outputAudioNode defines second node to connect
  36803. */
  36804. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36805. /**
  36806. * Releases all associated resources
  36807. */
  36808. dispose(): void;
  36809. }
  36810. }
  36811. declare module "babylonjs/Audio/audioEngine" {
  36812. import { IDisposable } from "babylonjs/scene";
  36813. import { Analyser } from "babylonjs/Audio/analyser";
  36814. import { Nullable } from "babylonjs/types";
  36815. import { Observable } from "babylonjs/Misc/observable";
  36816. /**
  36817. * This represents an audio engine and it is responsible
  36818. * to play, synchronize and analyse sounds throughout the application.
  36819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36820. */
  36821. export interface IAudioEngine extends IDisposable {
  36822. /**
  36823. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36824. */
  36825. readonly canUseWebAudio: boolean;
  36826. /**
  36827. * Gets the current AudioContext if available.
  36828. */
  36829. readonly audioContext: Nullable<AudioContext>;
  36830. /**
  36831. * The master gain node defines the global audio volume of your audio engine.
  36832. */
  36833. readonly masterGain: GainNode;
  36834. /**
  36835. * Gets whether or not mp3 are supported by your browser.
  36836. */
  36837. readonly isMP3supported: boolean;
  36838. /**
  36839. * Gets whether or not ogg are supported by your browser.
  36840. */
  36841. readonly isOGGsupported: boolean;
  36842. /**
  36843. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36844. * @ignoreNaming
  36845. */
  36846. WarnedWebAudioUnsupported: boolean;
  36847. /**
  36848. * Defines if the audio engine relies on a custom unlocked button.
  36849. * In this case, the embedded button will not be displayed.
  36850. */
  36851. useCustomUnlockedButton: boolean;
  36852. /**
  36853. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36854. */
  36855. readonly unlocked: boolean;
  36856. /**
  36857. * Event raised when audio has been unlocked on the browser.
  36858. */
  36859. onAudioUnlockedObservable: Observable<AudioEngine>;
  36860. /**
  36861. * Event raised when audio has been locked on the browser.
  36862. */
  36863. onAudioLockedObservable: Observable<AudioEngine>;
  36864. /**
  36865. * Flags the audio engine in Locked state.
  36866. * This happens due to new browser policies preventing audio to autoplay.
  36867. */
  36868. lock(): void;
  36869. /**
  36870. * Unlocks the audio engine once a user action has been done on the dom.
  36871. * This is helpful to resume play once browser policies have been satisfied.
  36872. */
  36873. unlock(): void;
  36874. /**
  36875. * Gets the global volume sets on the master gain.
  36876. * @returns the global volume if set or -1 otherwise
  36877. */
  36878. getGlobalVolume(): number;
  36879. /**
  36880. * Sets the global volume of your experience (sets on the master gain).
  36881. * @param newVolume Defines the new global volume of the application
  36882. */
  36883. setGlobalVolume(newVolume: number): void;
  36884. /**
  36885. * Connect the audio engine to an audio analyser allowing some amazing
  36886. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36888. * @param analyser The analyser to connect to the engine
  36889. */
  36890. connectToAnalyser(analyser: Analyser): void;
  36891. }
  36892. /**
  36893. * This represents the default audio engine used in babylon.
  36894. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36896. */
  36897. export class AudioEngine implements IAudioEngine {
  36898. private _audioContext;
  36899. private _audioContextInitialized;
  36900. private _muteButton;
  36901. private _hostElement;
  36902. /**
  36903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36904. */
  36905. canUseWebAudio: boolean;
  36906. /**
  36907. * The master gain node defines the global audio volume of your audio engine.
  36908. */
  36909. masterGain: GainNode;
  36910. /**
  36911. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36912. * @ignoreNaming
  36913. */
  36914. WarnedWebAudioUnsupported: boolean;
  36915. /**
  36916. * Gets whether or not mp3 are supported by your browser.
  36917. */
  36918. isMP3supported: boolean;
  36919. /**
  36920. * Gets whether or not ogg are supported by your browser.
  36921. */
  36922. isOGGsupported: boolean;
  36923. /**
  36924. * Gets whether audio has been unlocked on the device.
  36925. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36926. * a user interaction has happened.
  36927. */
  36928. unlocked: boolean;
  36929. /**
  36930. * Defines if the audio engine relies on a custom unlocked button.
  36931. * In this case, the embedded button will not be displayed.
  36932. */
  36933. useCustomUnlockedButton: boolean;
  36934. /**
  36935. * Event raised when audio has been unlocked on the browser.
  36936. */
  36937. onAudioUnlockedObservable: Observable<AudioEngine>;
  36938. /**
  36939. * Event raised when audio has been locked on the browser.
  36940. */
  36941. onAudioLockedObservable: Observable<AudioEngine>;
  36942. /**
  36943. * Gets the current AudioContext if available.
  36944. */
  36945. get audioContext(): Nullable<AudioContext>;
  36946. private _connectedAnalyser;
  36947. /**
  36948. * Instantiates a new audio engine.
  36949. *
  36950. * There should be only one per page as some browsers restrict the number
  36951. * of audio contexts you can create.
  36952. * @param hostElement defines the host element where to display the mute icon if necessary
  36953. */
  36954. constructor(hostElement?: Nullable<HTMLElement>);
  36955. /**
  36956. * Flags the audio engine in Locked state.
  36957. * This happens due to new browser policies preventing audio to autoplay.
  36958. */
  36959. lock(): void;
  36960. /**
  36961. * Unlocks the audio engine once a user action has been done on the dom.
  36962. * This is helpful to resume play once browser policies have been satisfied.
  36963. */
  36964. unlock(): void;
  36965. private _resumeAudioContext;
  36966. private _initializeAudioContext;
  36967. private _tryToRun;
  36968. private _triggerRunningState;
  36969. private _triggerSuspendedState;
  36970. private _displayMuteButton;
  36971. private _moveButtonToTopLeft;
  36972. private _onResize;
  36973. private _hideMuteButton;
  36974. /**
  36975. * Destroy and release the resources associated with the audio ccontext.
  36976. */
  36977. dispose(): void;
  36978. /**
  36979. * Gets the global volume sets on the master gain.
  36980. * @returns the global volume if set or -1 otherwise
  36981. */
  36982. getGlobalVolume(): number;
  36983. /**
  36984. * Sets the global volume of your experience (sets on the master gain).
  36985. * @param newVolume Defines the new global volume of the application
  36986. */
  36987. setGlobalVolume(newVolume: number): void;
  36988. /**
  36989. * Connect the audio engine to an audio analyser allowing some amazing
  36990. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36992. * @param analyser The analyser to connect to the engine
  36993. */
  36994. connectToAnalyser(analyser: Analyser): void;
  36995. }
  36996. }
  36997. declare module "babylonjs/Loading/loadingScreen" {
  36998. /**
  36999. * Interface used to present a loading screen while loading a scene
  37000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37001. */
  37002. export interface ILoadingScreen {
  37003. /**
  37004. * Function called to display the loading screen
  37005. */
  37006. displayLoadingUI: () => void;
  37007. /**
  37008. * Function called to hide the loading screen
  37009. */
  37010. hideLoadingUI: () => void;
  37011. /**
  37012. * Gets or sets the color to use for the background
  37013. */
  37014. loadingUIBackgroundColor: string;
  37015. /**
  37016. * Gets or sets the text to display while loading
  37017. */
  37018. loadingUIText: string;
  37019. }
  37020. /**
  37021. * Class used for the default loading screen
  37022. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37023. */
  37024. export class DefaultLoadingScreen implements ILoadingScreen {
  37025. private _renderingCanvas;
  37026. private _loadingText;
  37027. private _loadingDivBackgroundColor;
  37028. private _loadingDiv;
  37029. private _loadingTextDiv;
  37030. /** Gets or sets the logo url to use for the default loading screen */
  37031. static DefaultLogoUrl: string;
  37032. /** Gets or sets the spinner url to use for the default loading screen */
  37033. static DefaultSpinnerUrl: string;
  37034. /**
  37035. * Creates a new default loading screen
  37036. * @param _renderingCanvas defines the canvas used to render the scene
  37037. * @param _loadingText defines the default text to display
  37038. * @param _loadingDivBackgroundColor defines the default background color
  37039. */
  37040. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37041. /**
  37042. * Function called to display the loading screen
  37043. */
  37044. displayLoadingUI(): void;
  37045. /**
  37046. * Function called to hide the loading screen
  37047. */
  37048. hideLoadingUI(): void;
  37049. /**
  37050. * Gets or sets the text to display while loading
  37051. */
  37052. set loadingUIText(text: string);
  37053. get loadingUIText(): string;
  37054. /**
  37055. * Gets or sets the color to use for the background
  37056. */
  37057. get loadingUIBackgroundColor(): string;
  37058. set loadingUIBackgroundColor(color: string);
  37059. private _resizeLoadingUI;
  37060. }
  37061. }
  37062. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37063. /**
  37064. * Interface for any object that can request an animation frame
  37065. */
  37066. export interface ICustomAnimationFrameRequester {
  37067. /**
  37068. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37069. */
  37070. renderFunction?: Function;
  37071. /**
  37072. * Called to request the next frame to render to
  37073. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37074. */
  37075. requestAnimationFrame: Function;
  37076. /**
  37077. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37078. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37079. */
  37080. requestID?: number;
  37081. }
  37082. }
  37083. declare module "babylonjs/Misc/performanceMonitor" {
  37084. /**
  37085. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37086. */
  37087. export class PerformanceMonitor {
  37088. private _enabled;
  37089. private _rollingFrameTime;
  37090. private _lastFrameTimeMs;
  37091. /**
  37092. * constructor
  37093. * @param frameSampleSize The number of samples required to saturate the sliding window
  37094. */
  37095. constructor(frameSampleSize?: number);
  37096. /**
  37097. * Samples current frame
  37098. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37099. */
  37100. sampleFrame(timeMs?: number): void;
  37101. /**
  37102. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37103. */
  37104. get averageFrameTime(): number;
  37105. /**
  37106. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37107. */
  37108. get averageFrameTimeVariance(): number;
  37109. /**
  37110. * Returns the frame time of the most recent frame
  37111. */
  37112. get instantaneousFrameTime(): number;
  37113. /**
  37114. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37115. */
  37116. get averageFPS(): number;
  37117. /**
  37118. * Returns the average framerate in frames per second using the most recent frame time
  37119. */
  37120. get instantaneousFPS(): number;
  37121. /**
  37122. * Returns true if enough samples have been taken to completely fill the sliding window
  37123. */
  37124. get isSaturated(): boolean;
  37125. /**
  37126. * Enables contributions to the sliding window sample set
  37127. */
  37128. enable(): void;
  37129. /**
  37130. * Disables contributions to the sliding window sample set
  37131. * Samples will not be interpolated over the disabled period
  37132. */
  37133. disable(): void;
  37134. /**
  37135. * Returns true if sampling is enabled
  37136. */
  37137. get isEnabled(): boolean;
  37138. /**
  37139. * Resets performance monitor
  37140. */
  37141. reset(): void;
  37142. }
  37143. /**
  37144. * RollingAverage
  37145. *
  37146. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37147. */
  37148. export class RollingAverage {
  37149. /**
  37150. * Current average
  37151. */
  37152. average: number;
  37153. /**
  37154. * Current variance
  37155. */
  37156. variance: number;
  37157. protected _samples: Array<number>;
  37158. protected _sampleCount: number;
  37159. protected _pos: number;
  37160. protected _m2: number;
  37161. /**
  37162. * constructor
  37163. * @param length The number of samples required to saturate the sliding window
  37164. */
  37165. constructor(length: number);
  37166. /**
  37167. * Adds a sample to the sample set
  37168. * @param v The sample value
  37169. */
  37170. add(v: number): void;
  37171. /**
  37172. * Returns previously added values or null if outside of history or outside the sliding window domain
  37173. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37174. * @return Value previously recorded with add() or null if outside of range
  37175. */
  37176. history(i: number): number;
  37177. /**
  37178. * Returns true if enough samples have been taken to completely fill the sliding window
  37179. * @return true if sample-set saturated
  37180. */
  37181. isSaturated(): boolean;
  37182. /**
  37183. * Resets the rolling average (equivalent to 0 samples taken so far)
  37184. */
  37185. reset(): void;
  37186. /**
  37187. * Wraps a value around the sample range boundaries
  37188. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37189. * @return Wrapped position in sample range
  37190. */
  37191. protected _wrapPosition(i: number): number;
  37192. }
  37193. }
  37194. declare module "babylonjs/Misc/perfCounter" {
  37195. /**
  37196. * This class is used to track a performance counter which is number based.
  37197. * The user has access to many properties which give statistics of different nature.
  37198. *
  37199. * The implementer can track two kinds of Performance Counter: time and count.
  37200. * 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.
  37201. * 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.
  37202. */
  37203. export class PerfCounter {
  37204. /**
  37205. * Gets or sets a global boolean to turn on and off all the counters
  37206. */
  37207. static Enabled: boolean;
  37208. /**
  37209. * Returns the smallest value ever
  37210. */
  37211. get min(): number;
  37212. /**
  37213. * Returns the biggest value ever
  37214. */
  37215. get max(): number;
  37216. /**
  37217. * Returns the average value since the performance counter is running
  37218. */
  37219. get average(): number;
  37220. /**
  37221. * Returns the average value of the last second the counter was monitored
  37222. */
  37223. get lastSecAverage(): number;
  37224. /**
  37225. * Returns the current value
  37226. */
  37227. get current(): number;
  37228. /**
  37229. * Gets the accumulated total
  37230. */
  37231. get total(): number;
  37232. /**
  37233. * Gets the total value count
  37234. */
  37235. get count(): number;
  37236. /**
  37237. * Creates a new counter
  37238. */
  37239. constructor();
  37240. /**
  37241. * Call this method to start monitoring a new frame.
  37242. * 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.
  37243. */
  37244. fetchNewFrame(): void;
  37245. /**
  37246. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37247. * @param newCount the count value to add to the monitored count
  37248. * @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.
  37249. */
  37250. addCount(newCount: number, fetchResult: boolean): void;
  37251. /**
  37252. * Start monitoring this performance counter
  37253. */
  37254. beginMonitoring(): void;
  37255. /**
  37256. * Compute the time lapsed since the previous beginMonitoring() call.
  37257. * @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
  37258. */
  37259. endMonitoring(newFrame?: boolean): void;
  37260. private _fetchResult;
  37261. private _startMonitoringTime;
  37262. private _min;
  37263. private _max;
  37264. private _average;
  37265. private _current;
  37266. private _totalValueCount;
  37267. private _totalAccumulated;
  37268. private _lastSecAverage;
  37269. private _lastSecAccumulated;
  37270. private _lastSecTime;
  37271. private _lastSecValueCount;
  37272. }
  37273. }
  37274. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37275. module "babylonjs/Engines/thinEngine" {
  37276. interface ThinEngine {
  37277. /**
  37278. * Sets alpha constants used by some alpha blending modes
  37279. * @param r defines the red component
  37280. * @param g defines the green component
  37281. * @param b defines the blue component
  37282. * @param a defines the alpha component
  37283. */
  37284. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37285. /**
  37286. * Sets the current alpha mode
  37287. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37288. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37289. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37290. */
  37291. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37292. /**
  37293. * Gets the current alpha mode
  37294. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37295. * @returns the current alpha mode
  37296. */
  37297. getAlphaMode(): number;
  37298. /**
  37299. * Sets the current alpha equation
  37300. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37301. */
  37302. setAlphaEquation(equation: number): void;
  37303. /**
  37304. * Gets the current alpha equation.
  37305. * @returns the current alpha equation
  37306. */
  37307. getAlphaEquation(): number;
  37308. }
  37309. }
  37310. }
  37311. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37312. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37313. import { Nullable } from "babylonjs/types";
  37314. module "babylonjs/Engines/thinEngine" {
  37315. interface ThinEngine {
  37316. /** @hidden */
  37317. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37318. }
  37319. }
  37320. }
  37321. declare module "babylonjs/Engines/engine" {
  37322. import { Observable } from "babylonjs/Misc/observable";
  37323. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37324. import { Scene } from "babylonjs/scene";
  37325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37326. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37327. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37328. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37329. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37330. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37331. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37332. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37333. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37334. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37335. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37336. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37337. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37338. import "babylonjs/Engines/Extensions/engine.alpha";
  37339. import "babylonjs/Engines/Extensions/engine.readTexture";
  37340. import { Material } from "babylonjs/Materials/material";
  37341. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37342. /**
  37343. * Defines the interface used by display changed events
  37344. */
  37345. export interface IDisplayChangedEventArgs {
  37346. /** Gets the vrDisplay object (if any) */
  37347. vrDisplay: Nullable<any>;
  37348. /** Gets a boolean indicating if webVR is supported */
  37349. vrSupported: boolean;
  37350. }
  37351. /**
  37352. * Defines the interface used by objects containing a viewport (like a camera)
  37353. */
  37354. interface IViewportOwnerLike {
  37355. /**
  37356. * Gets or sets the viewport
  37357. */
  37358. viewport: IViewportLike;
  37359. }
  37360. /**
  37361. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37362. */
  37363. export class Engine extends ThinEngine {
  37364. /** Defines that alpha blending is disabled */
  37365. static readonly ALPHA_DISABLE: number;
  37366. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37367. static readonly ALPHA_ADD: number;
  37368. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37369. static readonly ALPHA_COMBINE: number;
  37370. /** Defines that alpha blending to DEST - SRC * DEST */
  37371. static readonly ALPHA_SUBTRACT: number;
  37372. /** Defines that alpha blending to SRC * DEST */
  37373. static readonly ALPHA_MULTIPLY: number;
  37374. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37375. static readonly ALPHA_MAXIMIZED: number;
  37376. /** Defines that alpha blending to SRC + DEST */
  37377. static readonly ALPHA_ONEONE: number;
  37378. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37379. static readonly ALPHA_PREMULTIPLIED: number;
  37380. /**
  37381. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37382. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37383. */
  37384. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37385. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37386. static readonly ALPHA_INTERPOLATE: number;
  37387. /**
  37388. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37389. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37390. */
  37391. static readonly ALPHA_SCREENMODE: number;
  37392. /** Defines that the ressource is not delayed*/
  37393. static readonly DELAYLOADSTATE_NONE: number;
  37394. /** Defines that the ressource was successfully delay loaded */
  37395. static readonly DELAYLOADSTATE_LOADED: number;
  37396. /** Defines that the ressource is currently delay loading */
  37397. static readonly DELAYLOADSTATE_LOADING: number;
  37398. /** Defines that the ressource is delayed and has not started loading */
  37399. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37400. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37401. static readonly NEVER: number;
  37402. /** 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 */
  37403. static readonly ALWAYS: number;
  37404. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37405. static readonly LESS: number;
  37406. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37407. static readonly EQUAL: number;
  37408. /** 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 */
  37409. static readonly LEQUAL: number;
  37410. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37411. static readonly GREATER: number;
  37412. /** 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 */
  37413. static readonly GEQUAL: number;
  37414. /** 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 */
  37415. static readonly NOTEQUAL: number;
  37416. /** Passed to stencilOperation to specify that stencil value must be kept */
  37417. static readonly KEEP: number;
  37418. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37419. static readonly REPLACE: number;
  37420. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37421. static readonly INCR: number;
  37422. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37423. static readonly DECR: number;
  37424. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37425. static readonly INVERT: number;
  37426. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37427. static readonly INCR_WRAP: number;
  37428. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37429. static readonly DECR_WRAP: number;
  37430. /** Texture is not repeating outside of 0..1 UVs */
  37431. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37432. /** Texture is repeating outside of 0..1 UVs */
  37433. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37434. /** Texture is repeating and mirrored */
  37435. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37436. /** ALPHA */
  37437. static readonly TEXTUREFORMAT_ALPHA: number;
  37438. /** LUMINANCE */
  37439. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37440. /** LUMINANCE_ALPHA */
  37441. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37442. /** RGB */
  37443. static readonly TEXTUREFORMAT_RGB: number;
  37444. /** RGBA */
  37445. static readonly TEXTUREFORMAT_RGBA: number;
  37446. /** RED */
  37447. static readonly TEXTUREFORMAT_RED: number;
  37448. /** RED (2nd reference) */
  37449. static readonly TEXTUREFORMAT_R: number;
  37450. /** RG */
  37451. static readonly TEXTUREFORMAT_RG: number;
  37452. /** RED_INTEGER */
  37453. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37454. /** RED_INTEGER (2nd reference) */
  37455. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37456. /** RG_INTEGER */
  37457. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37458. /** RGB_INTEGER */
  37459. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37460. /** RGBA_INTEGER */
  37461. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37462. /** UNSIGNED_BYTE */
  37463. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37464. /** UNSIGNED_BYTE (2nd reference) */
  37465. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37466. /** FLOAT */
  37467. static readonly TEXTURETYPE_FLOAT: number;
  37468. /** HALF_FLOAT */
  37469. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37470. /** BYTE */
  37471. static readonly TEXTURETYPE_BYTE: number;
  37472. /** SHORT */
  37473. static readonly TEXTURETYPE_SHORT: number;
  37474. /** UNSIGNED_SHORT */
  37475. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37476. /** INT */
  37477. static readonly TEXTURETYPE_INT: number;
  37478. /** UNSIGNED_INT */
  37479. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37480. /** UNSIGNED_SHORT_4_4_4_4 */
  37481. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37482. /** UNSIGNED_SHORT_5_5_5_1 */
  37483. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37484. /** UNSIGNED_SHORT_5_6_5 */
  37485. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37486. /** UNSIGNED_INT_2_10_10_10_REV */
  37487. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37488. /** UNSIGNED_INT_24_8 */
  37489. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37490. /** UNSIGNED_INT_10F_11F_11F_REV */
  37491. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37492. /** UNSIGNED_INT_5_9_9_9_REV */
  37493. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37494. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37495. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37496. /** nearest is mag = nearest and min = nearest and mip = linear */
  37497. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37498. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37499. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37500. /** Trilinear is mag = linear and min = linear and mip = linear */
  37501. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37502. /** nearest is mag = nearest and min = nearest and mip = linear */
  37503. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37504. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37505. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37506. /** Trilinear is mag = linear and min = linear and mip = linear */
  37507. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37508. /** mag = nearest and min = nearest and mip = nearest */
  37509. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37510. /** mag = nearest and min = linear and mip = nearest */
  37511. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37512. /** mag = nearest and min = linear and mip = linear */
  37513. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37514. /** mag = nearest and min = linear and mip = none */
  37515. static readonly TEXTURE_NEAREST_LINEAR: number;
  37516. /** mag = nearest and min = nearest and mip = none */
  37517. static readonly TEXTURE_NEAREST_NEAREST: number;
  37518. /** mag = linear and min = nearest and mip = nearest */
  37519. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37520. /** mag = linear and min = nearest and mip = linear */
  37521. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37522. /** mag = linear and min = linear and mip = none */
  37523. static readonly TEXTURE_LINEAR_LINEAR: number;
  37524. /** mag = linear and min = nearest and mip = none */
  37525. static readonly TEXTURE_LINEAR_NEAREST: number;
  37526. /** Explicit coordinates mode */
  37527. static readonly TEXTURE_EXPLICIT_MODE: number;
  37528. /** Spherical coordinates mode */
  37529. static readonly TEXTURE_SPHERICAL_MODE: number;
  37530. /** Planar coordinates mode */
  37531. static readonly TEXTURE_PLANAR_MODE: number;
  37532. /** Cubic coordinates mode */
  37533. static readonly TEXTURE_CUBIC_MODE: number;
  37534. /** Projection coordinates mode */
  37535. static readonly TEXTURE_PROJECTION_MODE: number;
  37536. /** Skybox coordinates mode */
  37537. static readonly TEXTURE_SKYBOX_MODE: number;
  37538. /** Inverse Cubic coordinates mode */
  37539. static readonly TEXTURE_INVCUBIC_MODE: number;
  37540. /** Equirectangular coordinates mode */
  37541. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37542. /** Equirectangular Fixed coordinates mode */
  37543. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37544. /** Equirectangular Fixed Mirrored coordinates mode */
  37545. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37546. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37547. static readonly SCALEMODE_FLOOR: number;
  37548. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37549. static readonly SCALEMODE_NEAREST: number;
  37550. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37551. static readonly SCALEMODE_CEILING: number;
  37552. /**
  37553. * Returns the current npm package of the sdk
  37554. */
  37555. static get NpmPackage(): string;
  37556. /**
  37557. * Returns the current version of the framework
  37558. */
  37559. static get Version(): string;
  37560. /** Gets the list of created engines */
  37561. static get Instances(): Engine[];
  37562. /**
  37563. * Gets the latest created engine
  37564. */
  37565. static get LastCreatedEngine(): Nullable<Engine>;
  37566. /**
  37567. * Gets the latest created scene
  37568. */
  37569. static get LastCreatedScene(): Nullable<Scene>;
  37570. /**
  37571. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37572. * @param flag defines which part of the materials must be marked as dirty
  37573. * @param predicate defines a predicate used to filter which materials should be affected
  37574. */
  37575. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37576. /**
  37577. * Method called to create the default loading screen.
  37578. * This can be overriden in your own app.
  37579. * @param canvas The rendering canvas element
  37580. * @returns The loading screen
  37581. */
  37582. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37583. /**
  37584. * Method called to create the default rescale post process on each engine.
  37585. */
  37586. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37587. /**
  37588. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37589. **/
  37590. enableOfflineSupport: boolean;
  37591. /**
  37592. * 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)
  37593. **/
  37594. disableManifestCheck: boolean;
  37595. /**
  37596. * Gets the list of created scenes
  37597. */
  37598. scenes: Scene[];
  37599. /**
  37600. * Event raised when a new scene is created
  37601. */
  37602. onNewSceneAddedObservable: Observable<Scene>;
  37603. /**
  37604. * Gets the list of created postprocesses
  37605. */
  37606. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37607. /**
  37608. * Gets a boolean indicating if the pointer is currently locked
  37609. */
  37610. isPointerLock: boolean;
  37611. /**
  37612. * Observable event triggered each time the rendering canvas is resized
  37613. */
  37614. onResizeObservable: Observable<Engine>;
  37615. /**
  37616. * Observable event triggered each time the canvas loses focus
  37617. */
  37618. onCanvasBlurObservable: Observable<Engine>;
  37619. /**
  37620. * Observable event triggered each time the canvas gains focus
  37621. */
  37622. onCanvasFocusObservable: Observable<Engine>;
  37623. /**
  37624. * Observable event triggered each time the canvas receives pointerout event
  37625. */
  37626. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37627. /**
  37628. * Observable raised when the engine begins a new frame
  37629. */
  37630. onBeginFrameObservable: Observable<Engine>;
  37631. /**
  37632. * If set, will be used to request the next animation frame for the render loop
  37633. */
  37634. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37635. /**
  37636. * Observable raised when the engine ends the current frame
  37637. */
  37638. onEndFrameObservable: Observable<Engine>;
  37639. /**
  37640. * Observable raised when the engine is about to compile a shader
  37641. */
  37642. onBeforeShaderCompilationObservable: Observable<Engine>;
  37643. /**
  37644. * Observable raised when the engine has jsut compiled a shader
  37645. */
  37646. onAfterShaderCompilationObservable: Observable<Engine>;
  37647. /**
  37648. * Gets the audio engine
  37649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37650. * @ignorenaming
  37651. */
  37652. static audioEngine: IAudioEngine;
  37653. /**
  37654. * Default AudioEngine factory responsible of creating the Audio Engine.
  37655. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37656. */
  37657. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37658. /**
  37659. * Default offline support factory responsible of creating a tool used to store data locally.
  37660. * By default, this will create a Database object if the workload has been embedded.
  37661. */
  37662. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37663. private _loadingScreen;
  37664. private _pointerLockRequested;
  37665. private _rescalePostProcess;
  37666. private _deterministicLockstep;
  37667. private _lockstepMaxSteps;
  37668. private _timeStep;
  37669. protected get _supportsHardwareTextureRescaling(): boolean;
  37670. private _fps;
  37671. private _deltaTime;
  37672. /** @hidden */
  37673. _drawCalls: PerfCounter;
  37674. /** 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 */
  37675. canvasTabIndex: number;
  37676. /**
  37677. * Turn this value on if you want to pause FPS computation when in background
  37678. */
  37679. disablePerformanceMonitorInBackground: boolean;
  37680. private _performanceMonitor;
  37681. /**
  37682. * Gets the performance monitor attached to this engine
  37683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37684. */
  37685. get performanceMonitor(): PerformanceMonitor;
  37686. private _onFocus;
  37687. private _onBlur;
  37688. private _onCanvasPointerOut;
  37689. private _onCanvasBlur;
  37690. private _onCanvasFocus;
  37691. private _onFullscreenChange;
  37692. private _onPointerLockChange;
  37693. /**
  37694. * Gets the HTML element used to attach event listeners
  37695. * @returns a HTML element
  37696. */
  37697. getInputElement(): Nullable<HTMLElement>;
  37698. /**
  37699. * Creates a new engine
  37700. * @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
  37701. * @param antialias defines enable antialiasing (default: false)
  37702. * @param options defines further options to be sent to the getContext() function
  37703. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37704. */
  37705. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37706. /**
  37707. * Gets current aspect ratio
  37708. * @param viewportOwner defines the camera to use to get the aspect ratio
  37709. * @param useScreen defines if screen size must be used (or the current render target if any)
  37710. * @returns a number defining the aspect ratio
  37711. */
  37712. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37713. /**
  37714. * Gets current screen aspect ratio
  37715. * @returns a number defining the aspect ratio
  37716. */
  37717. getScreenAspectRatio(): number;
  37718. /**
  37719. * Gets the client rect of the HTML canvas attached with the current webGL context
  37720. * @returns a client rectanglee
  37721. */
  37722. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37723. /**
  37724. * Gets the client rect of the HTML element used for events
  37725. * @returns a client rectanglee
  37726. */
  37727. getInputElementClientRect(): Nullable<ClientRect>;
  37728. /**
  37729. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37731. * @returns true if engine is in deterministic lock step mode
  37732. */
  37733. isDeterministicLockStep(): boolean;
  37734. /**
  37735. * Gets the max steps when engine is running in deterministic lock step
  37736. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37737. * @returns the max steps
  37738. */
  37739. getLockstepMaxSteps(): number;
  37740. /**
  37741. * Returns the time in ms between steps when using deterministic lock step.
  37742. * @returns time step in (ms)
  37743. */
  37744. getTimeStep(): number;
  37745. /**
  37746. * Force the mipmap generation for the given render target texture
  37747. * @param texture defines the render target texture to use
  37748. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37749. */
  37750. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37751. /** States */
  37752. /**
  37753. * Set various states to the webGL context
  37754. * @param culling defines backface culling state
  37755. * @param zOffset defines the value to apply to zOffset (0 by default)
  37756. * @param force defines if states must be applied even if cache is up to date
  37757. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37758. */
  37759. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37760. /**
  37761. * Set the z offset to apply to current rendering
  37762. * @param value defines the offset to apply
  37763. */
  37764. setZOffset(value: number): void;
  37765. /**
  37766. * Gets the current value of the zOffset
  37767. * @returns the current zOffset state
  37768. */
  37769. getZOffset(): number;
  37770. /**
  37771. * Enable or disable depth buffering
  37772. * @param enable defines the state to set
  37773. */
  37774. setDepthBuffer(enable: boolean): void;
  37775. /**
  37776. * Gets a boolean indicating if depth writing is enabled
  37777. * @returns the current depth writing state
  37778. */
  37779. getDepthWrite(): boolean;
  37780. /**
  37781. * Enable or disable depth writing
  37782. * @param enable defines the state to set
  37783. */
  37784. setDepthWrite(enable: boolean): void;
  37785. /**
  37786. * Gets a boolean indicating if stencil buffer is enabled
  37787. * @returns the current stencil buffer state
  37788. */
  37789. getStencilBuffer(): boolean;
  37790. /**
  37791. * Enable or disable the stencil buffer
  37792. * @param enable defines if the stencil buffer must be enabled or disabled
  37793. */
  37794. setStencilBuffer(enable: boolean): void;
  37795. /**
  37796. * Gets the current stencil mask
  37797. * @returns a number defining the new stencil mask to use
  37798. */
  37799. getStencilMask(): number;
  37800. /**
  37801. * Sets the current stencil mask
  37802. * @param mask defines the new stencil mask to use
  37803. */
  37804. setStencilMask(mask: number): void;
  37805. /**
  37806. * Gets the current stencil function
  37807. * @returns a number defining the stencil function to use
  37808. */
  37809. getStencilFunction(): number;
  37810. /**
  37811. * Gets the current stencil reference value
  37812. * @returns a number defining the stencil reference value to use
  37813. */
  37814. getStencilFunctionReference(): number;
  37815. /**
  37816. * Gets the current stencil mask
  37817. * @returns a number defining the stencil mask to use
  37818. */
  37819. getStencilFunctionMask(): number;
  37820. /**
  37821. * Sets the current stencil function
  37822. * @param stencilFunc defines the new stencil function to use
  37823. */
  37824. setStencilFunction(stencilFunc: number): void;
  37825. /**
  37826. * Sets the current stencil reference
  37827. * @param reference defines the new stencil reference to use
  37828. */
  37829. setStencilFunctionReference(reference: number): void;
  37830. /**
  37831. * Sets the current stencil mask
  37832. * @param mask defines the new stencil mask to use
  37833. */
  37834. setStencilFunctionMask(mask: number): void;
  37835. /**
  37836. * Gets the current stencil operation when stencil fails
  37837. * @returns a number defining stencil operation to use when stencil fails
  37838. */
  37839. getStencilOperationFail(): number;
  37840. /**
  37841. * Gets the current stencil operation when depth fails
  37842. * @returns a number defining stencil operation to use when depth fails
  37843. */
  37844. getStencilOperationDepthFail(): number;
  37845. /**
  37846. * Gets the current stencil operation when stencil passes
  37847. * @returns a number defining stencil operation to use when stencil passes
  37848. */
  37849. getStencilOperationPass(): number;
  37850. /**
  37851. * Sets the stencil operation to use when stencil fails
  37852. * @param operation defines the stencil operation to use when stencil fails
  37853. */
  37854. setStencilOperationFail(operation: number): void;
  37855. /**
  37856. * Sets the stencil operation to use when depth fails
  37857. * @param operation defines the stencil operation to use when depth fails
  37858. */
  37859. setStencilOperationDepthFail(operation: number): void;
  37860. /**
  37861. * Sets the stencil operation to use when stencil passes
  37862. * @param operation defines the stencil operation to use when stencil passes
  37863. */
  37864. setStencilOperationPass(operation: number): void;
  37865. /**
  37866. * Sets a boolean indicating if the dithering state is enabled or disabled
  37867. * @param value defines the dithering state
  37868. */
  37869. setDitheringState(value: boolean): void;
  37870. /**
  37871. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37872. * @param value defines the rasterizer state
  37873. */
  37874. setRasterizerState(value: boolean): void;
  37875. /**
  37876. * Gets the current depth function
  37877. * @returns a number defining the depth function
  37878. */
  37879. getDepthFunction(): Nullable<number>;
  37880. /**
  37881. * Sets the current depth function
  37882. * @param depthFunc defines the function to use
  37883. */
  37884. setDepthFunction(depthFunc: number): void;
  37885. /**
  37886. * Sets the current depth function to GREATER
  37887. */
  37888. setDepthFunctionToGreater(): void;
  37889. /**
  37890. * Sets the current depth function to GEQUAL
  37891. */
  37892. setDepthFunctionToGreaterOrEqual(): void;
  37893. /**
  37894. * Sets the current depth function to LESS
  37895. */
  37896. setDepthFunctionToLess(): void;
  37897. /**
  37898. * Sets the current depth function to LEQUAL
  37899. */
  37900. setDepthFunctionToLessOrEqual(): void;
  37901. private _cachedStencilBuffer;
  37902. private _cachedStencilFunction;
  37903. private _cachedStencilMask;
  37904. private _cachedStencilOperationPass;
  37905. private _cachedStencilOperationFail;
  37906. private _cachedStencilOperationDepthFail;
  37907. private _cachedStencilReference;
  37908. /**
  37909. * Caches the the state of the stencil buffer
  37910. */
  37911. cacheStencilState(): void;
  37912. /**
  37913. * Restores the state of the stencil buffer
  37914. */
  37915. restoreStencilState(): void;
  37916. /**
  37917. * Directly set the WebGL Viewport
  37918. * @param x defines the x coordinate of the viewport (in screen space)
  37919. * @param y defines the y coordinate of the viewport (in screen space)
  37920. * @param width defines the width of the viewport (in screen space)
  37921. * @param height defines the height of the viewport (in screen space)
  37922. * @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
  37923. */
  37924. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37925. /**
  37926. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37927. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37928. * @param y defines the y-coordinate of the corner of the clear rectangle
  37929. * @param width defines the width of the clear rectangle
  37930. * @param height defines the height of the clear rectangle
  37931. * @param clearColor defines the clear color
  37932. */
  37933. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37934. /**
  37935. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37936. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37937. * @param y defines the y-coordinate of the corner of the clear rectangle
  37938. * @param width defines the width of the clear rectangle
  37939. * @param height defines the height of the clear rectangle
  37940. */
  37941. enableScissor(x: number, y: number, width: number, height: number): void;
  37942. /**
  37943. * Disable previously set scissor test rectangle
  37944. */
  37945. disableScissor(): void;
  37946. protected _reportDrawCall(): void;
  37947. /**
  37948. * Initializes a webVR display and starts listening to display change events
  37949. * The onVRDisplayChangedObservable will be notified upon these changes
  37950. * @returns The onVRDisplayChangedObservable
  37951. */
  37952. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37953. /** @hidden */
  37954. _prepareVRComponent(): void;
  37955. /** @hidden */
  37956. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37957. /** @hidden */
  37958. _submitVRFrame(): void;
  37959. /**
  37960. * Call this function to leave webVR mode
  37961. * Will do nothing if webVR is not supported or if there is no webVR device
  37962. * @see http://doc.babylonjs.com/how_to/webvr_camera
  37963. */
  37964. disableVR(): void;
  37965. /**
  37966. * Gets a boolean indicating that the system is in VR mode and is presenting
  37967. * @returns true if VR mode is engaged
  37968. */
  37969. isVRPresenting(): boolean;
  37970. /** @hidden */
  37971. _requestVRFrame(): void;
  37972. /** @hidden */
  37973. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37974. /**
  37975. * Gets the source code of the vertex shader associated with a specific webGL program
  37976. * @param program defines the program to use
  37977. * @returns a string containing the source code of the vertex shader associated with the program
  37978. */
  37979. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37980. /**
  37981. * Gets the source code of the fragment shader associated with a specific webGL program
  37982. * @param program defines the program to use
  37983. * @returns a string containing the source code of the fragment shader associated with the program
  37984. */
  37985. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37986. /**
  37987. * Sets a depth stencil texture from a render target to the according uniform.
  37988. * @param channel The texture channel
  37989. * @param uniform The uniform to set
  37990. * @param texture The render target texture containing the depth stencil texture to apply
  37991. */
  37992. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37993. /**
  37994. * Sets a texture to the webGL context from a postprocess
  37995. * @param channel defines the channel to use
  37996. * @param postProcess defines the source postprocess
  37997. */
  37998. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37999. /**
  38000. * Binds the output of the passed in post process to the texture channel specified
  38001. * @param channel The channel the texture should be bound to
  38002. * @param postProcess The post process which's output should be bound
  38003. */
  38004. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38005. protected _rebuildBuffers(): void;
  38006. /** @hidden */
  38007. _renderFrame(): void;
  38008. _renderLoop(): void;
  38009. /** @hidden */
  38010. _renderViews(): boolean;
  38011. /**
  38012. * Toggle full screen mode
  38013. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38014. */
  38015. switchFullscreen(requestPointerLock: boolean): void;
  38016. /**
  38017. * Enters full screen mode
  38018. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38019. */
  38020. enterFullscreen(requestPointerLock: boolean): void;
  38021. /**
  38022. * Exits full screen mode
  38023. */
  38024. exitFullscreen(): void;
  38025. /**
  38026. * Enters Pointerlock mode
  38027. */
  38028. enterPointerlock(): void;
  38029. /**
  38030. * Exits Pointerlock mode
  38031. */
  38032. exitPointerlock(): void;
  38033. /**
  38034. * Begin a new frame
  38035. */
  38036. beginFrame(): void;
  38037. /**
  38038. * Enf the current frame
  38039. */
  38040. endFrame(): void;
  38041. resize(): void;
  38042. /**
  38043. * Force a specific size of the canvas
  38044. * @param width defines the new canvas' width
  38045. * @param height defines the new canvas' height
  38046. */
  38047. setSize(width: number, height: number): void;
  38048. /**
  38049. * Updates a dynamic vertex buffer.
  38050. * @param vertexBuffer the vertex buffer to update
  38051. * @param data the data used to update the vertex buffer
  38052. * @param byteOffset the byte offset of the data
  38053. * @param byteLength the byte length of the data
  38054. */
  38055. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38056. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38057. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38058. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38059. _releaseTexture(texture: InternalTexture): void;
  38060. /**
  38061. * @hidden
  38062. * Rescales a texture
  38063. * @param source input texutre
  38064. * @param destination destination texture
  38065. * @param scene scene to use to render the resize
  38066. * @param internalFormat format to use when resizing
  38067. * @param onComplete callback to be called when resize has completed
  38068. */
  38069. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38070. /**
  38071. * Gets the current framerate
  38072. * @returns a number representing the framerate
  38073. */
  38074. getFps(): number;
  38075. /**
  38076. * Gets the time spent between current and previous frame
  38077. * @returns a number representing the delta time in ms
  38078. */
  38079. getDeltaTime(): number;
  38080. private _measureFps;
  38081. /** @hidden */
  38082. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38083. /**
  38084. * Update a dynamic index buffer
  38085. * @param indexBuffer defines the target index buffer
  38086. * @param indices defines the data to update
  38087. * @param offset defines the offset in the target index buffer where update should start
  38088. */
  38089. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38090. /**
  38091. * Updates the sample count of a render target texture
  38092. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38093. * @param texture defines the texture to update
  38094. * @param samples defines the sample count to set
  38095. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38096. */
  38097. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38098. /**
  38099. * Updates a depth texture Comparison Mode and Function.
  38100. * If the comparison Function is equal to 0, the mode will be set to none.
  38101. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38102. * @param texture The texture to set the comparison function for
  38103. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38104. */
  38105. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38106. /**
  38107. * Creates a webGL buffer to use with instanciation
  38108. * @param capacity defines the size of the buffer
  38109. * @returns the webGL buffer
  38110. */
  38111. createInstancesBuffer(capacity: number): DataBuffer;
  38112. /**
  38113. * Delete a webGL buffer used with instanciation
  38114. * @param buffer defines the webGL buffer to delete
  38115. */
  38116. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38117. private _clientWaitAsync;
  38118. /** @hidden */
  38119. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38120. dispose(): void;
  38121. private _disableTouchAction;
  38122. /**
  38123. * Display the loading screen
  38124. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38125. */
  38126. displayLoadingUI(): void;
  38127. /**
  38128. * Hide the loading screen
  38129. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38130. */
  38131. hideLoadingUI(): void;
  38132. /**
  38133. * Gets the current loading screen object
  38134. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38135. */
  38136. get loadingScreen(): ILoadingScreen;
  38137. /**
  38138. * Sets the current loading screen object
  38139. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38140. */
  38141. set loadingScreen(loadingScreen: ILoadingScreen);
  38142. /**
  38143. * Sets the current loading screen text
  38144. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38145. */
  38146. set loadingUIText(text: string);
  38147. /**
  38148. * Sets the current loading screen background color
  38149. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38150. */
  38151. set loadingUIBackgroundColor(color: string);
  38152. /** Pointerlock and fullscreen */
  38153. /**
  38154. * Ask the browser to promote the current element to pointerlock mode
  38155. * @param element defines the DOM element to promote
  38156. */
  38157. static _RequestPointerlock(element: HTMLElement): void;
  38158. /**
  38159. * Asks the browser to exit pointerlock mode
  38160. */
  38161. static _ExitPointerlock(): void;
  38162. /**
  38163. * Ask the browser to promote the current element to fullscreen rendering mode
  38164. * @param element defines the DOM element to promote
  38165. */
  38166. static _RequestFullscreen(element: HTMLElement): void;
  38167. /**
  38168. * Asks the browser to exit fullscreen mode
  38169. */
  38170. static _ExitFullscreen(): void;
  38171. }
  38172. }
  38173. declare module "babylonjs/Engines/engineStore" {
  38174. import { Nullable } from "babylonjs/types";
  38175. import { Engine } from "babylonjs/Engines/engine";
  38176. import { Scene } from "babylonjs/scene";
  38177. /**
  38178. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38179. * during the life time of the application.
  38180. */
  38181. export class EngineStore {
  38182. /** Gets the list of created engines */
  38183. static Instances: import("babylonjs/Engines/engine").Engine[];
  38184. /** @hidden */
  38185. static _LastCreatedScene: Nullable<Scene>;
  38186. /**
  38187. * Gets the latest created engine
  38188. */
  38189. static get LastCreatedEngine(): Nullable<Engine>;
  38190. /**
  38191. * Gets the latest created scene
  38192. */
  38193. static get LastCreatedScene(): Nullable<Scene>;
  38194. /**
  38195. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38196. * @ignorenaming
  38197. */
  38198. static UseFallbackTexture: boolean;
  38199. /**
  38200. * Texture content used if a texture cannot loaded
  38201. * @ignorenaming
  38202. */
  38203. static FallbackTexture: string;
  38204. }
  38205. }
  38206. declare module "babylonjs/Misc/promise" {
  38207. /**
  38208. * Helper class that provides a small promise polyfill
  38209. */
  38210. export class PromisePolyfill {
  38211. /**
  38212. * Static function used to check if the polyfill is required
  38213. * If this is the case then the function will inject the polyfill to window.Promise
  38214. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38215. */
  38216. static Apply(force?: boolean): void;
  38217. }
  38218. }
  38219. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38220. /**
  38221. * Interface for screenshot methods with describe argument called `size` as object with options
  38222. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38223. */
  38224. export interface IScreenshotSize {
  38225. /**
  38226. * number in pixels for canvas height
  38227. */
  38228. height?: number;
  38229. /**
  38230. * multiplier allowing render at a higher or lower resolution
  38231. * If value is defined then height and width will be ignored and taken from camera
  38232. */
  38233. precision?: number;
  38234. /**
  38235. * number in pixels for canvas width
  38236. */
  38237. width?: number;
  38238. }
  38239. }
  38240. declare module "babylonjs/Misc/tools" {
  38241. import { Nullable, float } from "babylonjs/types";
  38242. import { DomManagement } from "babylonjs/Misc/domManagement";
  38243. import { WebRequest } from "babylonjs/Misc/webRequest";
  38244. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38245. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38246. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38247. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38248. import { Camera } from "babylonjs/Cameras/camera";
  38249. import { Engine } from "babylonjs/Engines/engine";
  38250. interface IColor4Like {
  38251. r: float;
  38252. g: float;
  38253. b: float;
  38254. a: float;
  38255. }
  38256. /**
  38257. * Class containing a set of static utilities functions
  38258. */
  38259. export class Tools {
  38260. /**
  38261. * Gets or sets the base URL to use to load assets
  38262. */
  38263. static get BaseUrl(): string;
  38264. static set BaseUrl(value: string);
  38265. /**
  38266. * Enable/Disable Custom HTTP Request Headers globally.
  38267. * default = false
  38268. * @see CustomRequestHeaders
  38269. */
  38270. static UseCustomRequestHeaders: boolean;
  38271. /**
  38272. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38273. * i.e. when loading files, where the server/service expects an Authorization header
  38274. */
  38275. static CustomRequestHeaders: {
  38276. [key: string]: string;
  38277. };
  38278. /**
  38279. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38280. */
  38281. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38282. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38283. /**
  38284. * Default behaviour for cors in the application.
  38285. * It can be a string if the expected behavior is identical in the entire app.
  38286. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38287. */
  38288. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38289. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38290. /**
  38291. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38292. * @ignorenaming
  38293. */
  38294. static get UseFallbackTexture(): boolean;
  38295. static set UseFallbackTexture(value: boolean);
  38296. /**
  38297. * Use this object to register external classes like custom textures or material
  38298. * to allow the laoders to instantiate them
  38299. */
  38300. static get RegisteredExternalClasses(): {
  38301. [key: string]: Object;
  38302. };
  38303. static set RegisteredExternalClasses(classes: {
  38304. [key: string]: Object;
  38305. });
  38306. /**
  38307. * Texture content used if a texture cannot loaded
  38308. * @ignorenaming
  38309. */
  38310. static get fallbackTexture(): string;
  38311. static set fallbackTexture(value: string);
  38312. /**
  38313. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38314. * @param u defines the coordinate on X axis
  38315. * @param v defines the coordinate on Y axis
  38316. * @param width defines the width of the source data
  38317. * @param height defines the height of the source data
  38318. * @param pixels defines the source byte array
  38319. * @param color defines the output color
  38320. */
  38321. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38322. /**
  38323. * Interpolates between a and b via alpha
  38324. * @param a The lower value (returned when alpha = 0)
  38325. * @param b The upper value (returned when alpha = 1)
  38326. * @param alpha The interpolation-factor
  38327. * @return The mixed value
  38328. */
  38329. static Mix(a: number, b: number, alpha: number): number;
  38330. /**
  38331. * Tries to instantiate a new object from a given class name
  38332. * @param className defines the class name to instantiate
  38333. * @returns the new object or null if the system was not able to do the instantiation
  38334. */
  38335. static Instantiate(className: string): any;
  38336. /**
  38337. * Provides a slice function that will work even on IE
  38338. * @param data defines the array to slice
  38339. * @param start defines the start of the data (optional)
  38340. * @param end defines the end of the data (optional)
  38341. * @returns the new sliced array
  38342. */
  38343. static Slice<T>(data: T, start?: number, end?: number): T;
  38344. /**
  38345. * Polyfill for setImmediate
  38346. * @param action defines the action to execute after the current execution block
  38347. */
  38348. static SetImmediate(action: () => void): void;
  38349. /**
  38350. * Function indicating if a number is an exponent of 2
  38351. * @param value defines the value to test
  38352. * @returns true if the value is an exponent of 2
  38353. */
  38354. static IsExponentOfTwo(value: number): boolean;
  38355. private static _tmpFloatArray;
  38356. /**
  38357. * Returns the nearest 32-bit single precision float representation of a Number
  38358. * @param value A Number. If the parameter is of a different type, it will get converted
  38359. * to a number or to NaN if it cannot be converted
  38360. * @returns number
  38361. */
  38362. static FloatRound(value: number): number;
  38363. /**
  38364. * Extracts the filename from a path
  38365. * @param path defines the path to use
  38366. * @returns the filename
  38367. */
  38368. static GetFilename(path: string): string;
  38369. /**
  38370. * Extracts the "folder" part of a path (everything before the filename).
  38371. * @param uri The URI to extract the info from
  38372. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38373. * @returns The "folder" part of the path
  38374. */
  38375. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38376. /**
  38377. * Extracts text content from a DOM element hierarchy
  38378. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38379. */
  38380. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38381. /**
  38382. * Convert an angle in radians to degrees
  38383. * @param angle defines the angle to convert
  38384. * @returns the angle in degrees
  38385. */
  38386. static ToDegrees(angle: number): number;
  38387. /**
  38388. * Convert an angle in degrees to radians
  38389. * @param angle defines the angle to convert
  38390. * @returns the angle in radians
  38391. */
  38392. static ToRadians(angle: number): number;
  38393. /**
  38394. * Returns an array if obj is not an array
  38395. * @param obj defines the object to evaluate as an array
  38396. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38397. * @returns either obj directly if obj is an array or a new array containing obj
  38398. */
  38399. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38400. /**
  38401. * Gets the pointer prefix to use
  38402. * @param engine defines the engine we are finding the prefix for
  38403. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38404. */
  38405. static GetPointerPrefix(engine: Engine): string;
  38406. /**
  38407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38408. * @param url define the url we are trying
  38409. * @param element define the dom element where to configure the cors policy
  38410. */
  38411. static SetCorsBehavior(url: string | string[], element: {
  38412. crossOrigin: string | null;
  38413. }): void;
  38414. /**
  38415. * Removes unwanted characters from an url
  38416. * @param url defines the url to clean
  38417. * @returns the cleaned url
  38418. */
  38419. static CleanUrl(url: string): string;
  38420. /**
  38421. * Gets or sets a function used to pre-process url before using them to load assets
  38422. */
  38423. static get PreprocessUrl(): (url: string) => string;
  38424. static set PreprocessUrl(processor: (url: string) => string);
  38425. /**
  38426. * Loads an image as an HTMLImageElement.
  38427. * @param input url string, ArrayBuffer, or Blob to load
  38428. * @param onLoad callback called when the image successfully loads
  38429. * @param onError callback called when the image fails to load
  38430. * @param offlineProvider offline provider for caching
  38431. * @param mimeType optional mime type
  38432. * @returns the HTMLImageElement of the loaded image
  38433. */
  38434. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38435. /**
  38436. * Loads a file from a url
  38437. * @param url url string, ArrayBuffer, or Blob to load
  38438. * @param onSuccess callback called when the file successfully loads
  38439. * @param onProgress callback called while file is loading (if the server supports this mode)
  38440. * @param offlineProvider defines the offline provider for caching
  38441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38442. * @param onError callback called when the file fails to load
  38443. * @returns a file request object
  38444. */
  38445. 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;
  38446. /**
  38447. * Loads a file from a url
  38448. * @param url the file url to load
  38449. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38450. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38451. */
  38452. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38453. /**
  38454. * Load a script (identified by an url). When the url returns, the
  38455. * content of this file is added into a new script element, attached to the DOM (body element)
  38456. * @param scriptUrl defines the url of the script to laod
  38457. * @param onSuccess defines the callback called when the script is loaded
  38458. * @param onError defines the callback to call if an error occurs
  38459. * @param scriptId defines the id of the script element
  38460. */
  38461. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38462. /**
  38463. * Load an asynchronous script (identified by an url). When the url returns, the
  38464. * content of this file is added into a new script element, attached to the DOM (body element)
  38465. * @param scriptUrl defines the url of the script to laod
  38466. * @param scriptId defines the id of the script element
  38467. * @returns a promise request object
  38468. */
  38469. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38470. /**
  38471. * Loads a file from a blob
  38472. * @param fileToLoad defines the blob to use
  38473. * @param callback defines the callback to call when data is loaded
  38474. * @param progressCallback defines the callback to call during loading process
  38475. * @returns a file request object
  38476. */
  38477. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38478. /**
  38479. * Reads a file from a File object
  38480. * @param file defines the file to load
  38481. * @param onSuccess defines the callback to call when data is loaded
  38482. * @param onProgress defines the callback to call during loading process
  38483. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38484. * @param onError defines the callback to call when an error occurs
  38485. * @returns a file request object
  38486. */
  38487. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38488. /**
  38489. * Creates a data url from a given string content
  38490. * @param content defines the content to convert
  38491. * @returns the new data url link
  38492. */
  38493. static FileAsURL(content: string): string;
  38494. /**
  38495. * Format the given number to a specific decimal format
  38496. * @param value defines the number to format
  38497. * @param decimals defines the number of decimals to use
  38498. * @returns the formatted string
  38499. */
  38500. static Format(value: number, decimals?: number): string;
  38501. /**
  38502. * Tries to copy an object by duplicating every property
  38503. * @param source defines the source object
  38504. * @param destination defines the target object
  38505. * @param doNotCopyList defines a list of properties to avoid
  38506. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38507. */
  38508. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38509. /**
  38510. * Gets a boolean indicating if the given object has no own property
  38511. * @param obj defines the object to test
  38512. * @returns true if object has no own property
  38513. */
  38514. static IsEmpty(obj: any): boolean;
  38515. /**
  38516. * Function used to register events at window level
  38517. * @param windowElement defines the Window object to use
  38518. * @param events defines the events to register
  38519. */
  38520. static RegisterTopRootEvents(windowElement: Window, events: {
  38521. name: string;
  38522. handler: Nullable<(e: FocusEvent) => any>;
  38523. }[]): void;
  38524. /**
  38525. * Function used to unregister events from window level
  38526. * @param windowElement defines the Window object to use
  38527. * @param events defines the events to unregister
  38528. */
  38529. static UnregisterTopRootEvents(windowElement: Window, events: {
  38530. name: string;
  38531. handler: Nullable<(e: FocusEvent) => any>;
  38532. }[]): void;
  38533. /**
  38534. * @ignore
  38535. */
  38536. static _ScreenshotCanvas: HTMLCanvasElement;
  38537. /**
  38538. * Dumps the current bound framebuffer
  38539. * @param width defines the rendering width
  38540. * @param height defines the rendering height
  38541. * @param engine defines the hosting engine
  38542. * @param successCallback defines the callback triggered once the data are available
  38543. * @param mimeType defines the mime type of the result
  38544. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38545. */
  38546. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38547. /**
  38548. * Converts the canvas data to blob.
  38549. * This acts as a polyfill for browsers not supporting the to blob function.
  38550. * @param canvas Defines the canvas to extract the data from
  38551. * @param successCallback Defines the callback triggered once the data are available
  38552. * @param mimeType Defines the mime type of the result
  38553. */
  38554. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38555. /**
  38556. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38557. * @param successCallback defines the callback triggered once the data are available
  38558. * @param mimeType defines the mime type of the result
  38559. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38560. */
  38561. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38562. /**
  38563. * Downloads a blob in the browser
  38564. * @param blob defines the blob to download
  38565. * @param fileName defines the name of the downloaded file
  38566. */
  38567. static Download(blob: Blob, fileName: string): void;
  38568. /**
  38569. * Captures a screenshot of the current rendering
  38570. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38571. * @param engine defines the rendering engine
  38572. * @param camera defines the source camera
  38573. * @param size This parameter can be set to a single number or to an object with the
  38574. * following (optional) properties: precision, width, height. If a single number is passed,
  38575. * it will be used for both width and height. If an object is passed, the screenshot size
  38576. * will be derived from the parameters. The precision property is a multiplier allowing
  38577. * rendering at a higher or lower resolution
  38578. * @param successCallback defines the callback receives a single parameter which contains the
  38579. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38580. * src parameter of an <img> to display it
  38581. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38582. * Check your browser for supported MIME types
  38583. */
  38584. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38585. /**
  38586. * Captures a screenshot of the current rendering
  38587. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38588. * @param engine defines the rendering engine
  38589. * @param camera defines the source camera
  38590. * @param size This parameter can be set to a single number or to an object with the
  38591. * following (optional) properties: precision, width, height. If a single number is passed,
  38592. * it will be used for both width and height. If an object is passed, the screenshot size
  38593. * will be derived from the parameters. The precision property is a multiplier allowing
  38594. * rendering at a higher or lower resolution
  38595. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38596. * Check your browser for supported MIME types
  38597. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38598. * to the src parameter of an <img> to display it
  38599. */
  38600. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38601. /**
  38602. * Generates an image screenshot from the specified camera.
  38603. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38604. * @param engine The engine to use for rendering
  38605. * @param camera The camera to use for rendering
  38606. * @param size This parameter can be set to a single number or to an object with the
  38607. * following (optional) properties: precision, width, height. If a single number is passed,
  38608. * it will be used for both width and height. If an object is passed, the screenshot size
  38609. * will be derived from the parameters. The precision property is a multiplier allowing
  38610. * rendering at a higher or lower resolution
  38611. * @param successCallback The callback receives a single parameter which contains the
  38612. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38613. * src parameter of an <img> to display it
  38614. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38615. * Check your browser for supported MIME types
  38616. * @param samples Texture samples (default: 1)
  38617. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38618. * @param fileName A name for for the downloaded file.
  38619. */
  38620. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38621. /**
  38622. * Generates an image screenshot from the specified camera.
  38623. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38624. * @param engine The engine to use for rendering
  38625. * @param camera The camera to use for rendering
  38626. * @param size This parameter can be set to a single number or to an object with the
  38627. * following (optional) properties: precision, width, height. If a single number is passed,
  38628. * it will be used for both width and height. If an object is passed, the screenshot size
  38629. * will be derived from the parameters. The precision property is a multiplier allowing
  38630. * rendering at a higher or lower resolution
  38631. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38632. * Check your browser for supported MIME types
  38633. * @param samples Texture samples (default: 1)
  38634. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38635. * @param fileName A name for for the downloaded file.
  38636. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38637. * to the src parameter of an <img> to display it
  38638. */
  38639. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38640. /**
  38641. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38642. * Be aware Math.random() could cause collisions, but:
  38643. * "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"
  38644. * @returns a pseudo random id
  38645. */
  38646. static RandomId(): string;
  38647. /**
  38648. * Test if the given uri is a base64 string
  38649. * @param uri The uri to test
  38650. * @return True if the uri is a base64 string or false otherwise
  38651. */
  38652. static IsBase64(uri: string): boolean;
  38653. /**
  38654. * Decode the given base64 uri.
  38655. * @param uri The uri to decode
  38656. * @return The decoded base64 data.
  38657. */
  38658. static DecodeBase64(uri: string): ArrayBuffer;
  38659. /**
  38660. * Gets the absolute url.
  38661. * @param url the input url
  38662. * @return the absolute url
  38663. */
  38664. static GetAbsoluteUrl(url: string): string;
  38665. /**
  38666. * No log
  38667. */
  38668. static readonly NoneLogLevel: number;
  38669. /**
  38670. * Only message logs
  38671. */
  38672. static readonly MessageLogLevel: number;
  38673. /**
  38674. * Only warning logs
  38675. */
  38676. static readonly WarningLogLevel: number;
  38677. /**
  38678. * Only error logs
  38679. */
  38680. static readonly ErrorLogLevel: number;
  38681. /**
  38682. * All logs
  38683. */
  38684. static readonly AllLogLevel: number;
  38685. /**
  38686. * Gets a value indicating the number of loading errors
  38687. * @ignorenaming
  38688. */
  38689. static get errorsCount(): number;
  38690. /**
  38691. * Callback called when a new log is added
  38692. */
  38693. static OnNewCacheEntry: (entry: string) => void;
  38694. /**
  38695. * Log a message to the console
  38696. * @param message defines the message to log
  38697. */
  38698. static Log(message: string): void;
  38699. /**
  38700. * Write a warning message to the console
  38701. * @param message defines the message to log
  38702. */
  38703. static Warn(message: string): void;
  38704. /**
  38705. * Write an error message to the console
  38706. * @param message defines the message to log
  38707. */
  38708. static Error(message: string): void;
  38709. /**
  38710. * Gets current log cache (list of logs)
  38711. */
  38712. static get LogCache(): string;
  38713. /**
  38714. * Clears the log cache
  38715. */
  38716. static ClearLogCache(): void;
  38717. /**
  38718. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38719. */
  38720. static set LogLevels(level: number);
  38721. /**
  38722. * Checks if the window object exists
  38723. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38724. */
  38725. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38726. /**
  38727. * No performance log
  38728. */
  38729. static readonly PerformanceNoneLogLevel: number;
  38730. /**
  38731. * Use user marks to log performance
  38732. */
  38733. static readonly PerformanceUserMarkLogLevel: number;
  38734. /**
  38735. * Log performance to the console
  38736. */
  38737. static readonly PerformanceConsoleLogLevel: number;
  38738. private static _performance;
  38739. /**
  38740. * Sets the current performance log level
  38741. */
  38742. static set PerformanceLogLevel(level: number);
  38743. private static _StartPerformanceCounterDisabled;
  38744. private static _EndPerformanceCounterDisabled;
  38745. private static _StartUserMark;
  38746. private static _EndUserMark;
  38747. private static _StartPerformanceConsole;
  38748. private static _EndPerformanceConsole;
  38749. /**
  38750. * Starts a performance counter
  38751. */
  38752. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38753. /**
  38754. * Ends a specific performance coutner
  38755. */
  38756. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38757. /**
  38758. * Gets either window.performance.now() if supported or Date.now() else
  38759. */
  38760. static get Now(): number;
  38761. /**
  38762. * This method will return the name of the class used to create the instance of the given object.
  38763. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38764. * @param object the object to get the class name from
  38765. * @param isType defines if the object is actually a type
  38766. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38767. */
  38768. static GetClassName(object: any, isType?: boolean): string;
  38769. /**
  38770. * Gets the first element of an array satisfying a given predicate
  38771. * @param array defines the array to browse
  38772. * @param predicate defines the predicate to use
  38773. * @returns null if not found or the element
  38774. */
  38775. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38776. /**
  38777. * This method will return the name of the full name of the class, including its owning module (if any).
  38778. * 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).
  38779. * @param object the object to get the class name from
  38780. * @param isType defines if the object is actually a type
  38781. * @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.
  38782. * @ignorenaming
  38783. */
  38784. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38785. /**
  38786. * Returns a promise that resolves after the given amount of time.
  38787. * @param delay Number of milliseconds to delay
  38788. * @returns Promise that resolves after the given amount of time
  38789. */
  38790. static DelayAsync(delay: number): Promise<void>;
  38791. /**
  38792. * Utility function to detect if the current user agent is Safari
  38793. * @returns whether or not the current user agent is safari
  38794. */
  38795. static IsSafari(): boolean;
  38796. }
  38797. /**
  38798. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38799. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38800. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38801. * @param name The name of the class, case should be preserved
  38802. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38803. */
  38804. export function className(name: string, module?: string): (target: Object) => void;
  38805. /**
  38806. * An implementation of a loop for asynchronous functions.
  38807. */
  38808. export class AsyncLoop {
  38809. /**
  38810. * Defines the number of iterations for the loop
  38811. */
  38812. iterations: number;
  38813. /**
  38814. * Defines the current index of the loop.
  38815. */
  38816. index: number;
  38817. private _done;
  38818. private _fn;
  38819. private _successCallback;
  38820. /**
  38821. * Constructor.
  38822. * @param iterations the number of iterations.
  38823. * @param func the function to run each iteration
  38824. * @param successCallback the callback that will be called upon succesful execution
  38825. * @param offset starting offset.
  38826. */
  38827. constructor(
  38828. /**
  38829. * Defines the number of iterations for the loop
  38830. */
  38831. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38832. /**
  38833. * Execute the next iteration. Must be called after the last iteration was finished.
  38834. */
  38835. executeNext(): void;
  38836. /**
  38837. * Break the loop and run the success callback.
  38838. */
  38839. breakLoop(): void;
  38840. /**
  38841. * Create and run an async loop.
  38842. * @param iterations the number of iterations.
  38843. * @param fn the function to run each iteration
  38844. * @param successCallback the callback that will be called upon succesful execution
  38845. * @param offset starting offset.
  38846. * @returns the created async loop object
  38847. */
  38848. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38849. /**
  38850. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38851. * @param iterations total number of iterations
  38852. * @param syncedIterations number of synchronous iterations in each async iteration.
  38853. * @param fn the function to call each iteration.
  38854. * @param callback a success call back that will be called when iterating stops.
  38855. * @param breakFunction a break condition (optional)
  38856. * @param timeout timeout settings for the setTimeout function. default - 0.
  38857. * @returns the created async loop object
  38858. */
  38859. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38860. }
  38861. }
  38862. declare module "babylonjs/Misc/stringDictionary" {
  38863. import { Nullable } from "babylonjs/types";
  38864. /**
  38865. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38866. * The underlying implementation relies on an associative array to ensure the best performances.
  38867. * The value can be anything including 'null' but except 'undefined'
  38868. */
  38869. export class StringDictionary<T> {
  38870. /**
  38871. * This will clear this dictionary and copy the content from the 'source' one.
  38872. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38873. * @param source the dictionary to take the content from and copy to this dictionary
  38874. */
  38875. copyFrom(source: StringDictionary<T>): void;
  38876. /**
  38877. * Get a value based from its key
  38878. * @param key the given key to get the matching value from
  38879. * @return the value if found, otherwise undefined is returned
  38880. */
  38881. get(key: string): T | undefined;
  38882. /**
  38883. * Get a value from its key or add it if it doesn't exist.
  38884. * This method will ensure you that a given key/data will be present in the dictionary.
  38885. * @param key the given key to get the matching value from
  38886. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38887. * The factory will only be invoked if there's no data for the given key.
  38888. * @return the value corresponding to the key.
  38889. */
  38890. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38891. /**
  38892. * Get a value from its key if present in the dictionary otherwise add it
  38893. * @param key the key to get the value from
  38894. * @param val if there's no such key/value pair in the dictionary add it with this value
  38895. * @return the value corresponding to the key
  38896. */
  38897. getOrAdd(key: string, val: T): T;
  38898. /**
  38899. * Check if there's a given key in the dictionary
  38900. * @param key the key to check for
  38901. * @return true if the key is present, false otherwise
  38902. */
  38903. contains(key: string): boolean;
  38904. /**
  38905. * Add a new key and its corresponding value
  38906. * @param key the key to add
  38907. * @param value the value corresponding to the key
  38908. * @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
  38909. */
  38910. add(key: string, value: T): boolean;
  38911. /**
  38912. * Update a specific value associated to a key
  38913. * @param key defines the key to use
  38914. * @param value defines the value to store
  38915. * @returns true if the value was updated (or false if the key was not found)
  38916. */
  38917. set(key: string, value: T): boolean;
  38918. /**
  38919. * Get the element of the given key and remove it from the dictionary
  38920. * @param key defines the key to search
  38921. * @returns the value associated with the key or null if not found
  38922. */
  38923. getAndRemove(key: string): Nullable<T>;
  38924. /**
  38925. * Remove a key/value from the dictionary.
  38926. * @param key the key to remove
  38927. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38928. */
  38929. remove(key: string): boolean;
  38930. /**
  38931. * Clear the whole content of the dictionary
  38932. */
  38933. clear(): void;
  38934. /**
  38935. * Gets the current count
  38936. */
  38937. get count(): number;
  38938. /**
  38939. * Execute a callback on each key/val of the dictionary.
  38940. * Note that you can remove any element in this dictionary in the callback implementation
  38941. * @param callback the callback to execute on a given key/value pair
  38942. */
  38943. forEach(callback: (key: string, val: T) => void): void;
  38944. /**
  38945. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38946. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38947. * Note that you can remove any element in this dictionary in the callback implementation
  38948. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38949. * @returns the first item
  38950. */
  38951. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38952. private _count;
  38953. private _data;
  38954. }
  38955. }
  38956. declare module "babylonjs/Collisions/collisionCoordinator" {
  38957. import { Nullable } from "babylonjs/types";
  38958. import { Scene } from "babylonjs/scene";
  38959. import { Vector3 } from "babylonjs/Maths/math.vector";
  38960. import { Collider } from "babylonjs/Collisions/collider";
  38961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38962. /** @hidden */
  38963. export interface ICollisionCoordinator {
  38964. createCollider(): Collider;
  38965. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38966. init(scene: Scene): void;
  38967. }
  38968. /** @hidden */
  38969. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38970. private _scene;
  38971. private _scaledPosition;
  38972. private _scaledVelocity;
  38973. private _finalPosition;
  38974. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38975. createCollider(): Collider;
  38976. init(scene: Scene): void;
  38977. private _collideWithWorld;
  38978. }
  38979. }
  38980. declare module "babylonjs/Inputs/scene.inputManager" {
  38981. import { Nullable } from "babylonjs/types";
  38982. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  38983. import { Vector2 } from "babylonjs/Maths/math.vector";
  38984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38985. import { Scene } from "babylonjs/scene";
  38986. /**
  38987. * Class used to manage all inputs for the scene.
  38988. */
  38989. export class InputManager {
  38990. /** The distance in pixel that you have to move to prevent some events */
  38991. static DragMovementThreshold: number;
  38992. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38993. static LongPressDelay: number;
  38994. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38995. static DoubleClickDelay: number;
  38996. /** If you need to check double click without raising a single click at first click, enable this flag */
  38997. static ExclusiveDoubleClickMode: boolean;
  38998. private _wheelEventName;
  38999. private _onPointerMove;
  39000. private _onPointerDown;
  39001. private _onPointerUp;
  39002. private _initClickEvent;
  39003. private _initActionManager;
  39004. private _delayedSimpleClick;
  39005. private _delayedSimpleClickTimeout;
  39006. private _previousDelayedSimpleClickTimeout;
  39007. private _meshPickProceed;
  39008. private _previousButtonPressed;
  39009. private _currentPickResult;
  39010. private _previousPickResult;
  39011. private _totalPointersPressed;
  39012. private _doubleClickOccured;
  39013. private _pointerOverMesh;
  39014. private _pickedDownMesh;
  39015. private _pickedUpMesh;
  39016. private _pointerX;
  39017. private _pointerY;
  39018. private _unTranslatedPointerX;
  39019. private _unTranslatedPointerY;
  39020. private _startingPointerPosition;
  39021. private _previousStartingPointerPosition;
  39022. private _startingPointerTime;
  39023. private _previousStartingPointerTime;
  39024. private _pointerCaptures;
  39025. private _onKeyDown;
  39026. private _onKeyUp;
  39027. private _onCanvasFocusObserver;
  39028. private _onCanvasBlurObserver;
  39029. private _scene;
  39030. /**
  39031. * Creates a new InputManager
  39032. * @param scene defines the hosting scene
  39033. */
  39034. constructor(scene: Scene);
  39035. /**
  39036. * Gets the mesh that is currently under the pointer
  39037. */
  39038. get meshUnderPointer(): Nullable<AbstractMesh>;
  39039. /**
  39040. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39041. */
  39042. get unTranslatedPointer(): Vector2;
  39043. /**
  39044. * Gets or sets the current on-screen X position of the pointer
  39045. */
  39046. get pointerX(): number;
  39047. set pointerX(value: number);
  39048. /**
  39049. * Gets or sets the current on-screen Y position of the pointer
  39050. */
  39051. get pointerY(): number;
  39052. set pointerY(value: number);
  39053. private _updatePointerPosition;
  39054. private _processPointerMove;
  39055. private _setRayOnPointerInfo;
  39056. private _checkPrePointerObservable;
  39057. /**
  39058. * Use this method to simulate a pointer move on a mesh
  39059. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39060. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39061. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39062. */
  39063. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39064. /**
  39065. * Use this method to simulate a pointer down on a mesh
  39066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39069. */
  39070. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39071. private _processPointerDown;
  39072. /** @hidden */
  39073. _isPointerSwiping(): boolean;
  39074. /**
  39075. * Use this method to simulate a pointer up on a mesh
  39076. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39077. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39078. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39079. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39080. */
  39081. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39082. private _processPointerUp;
  39083. /**
  39084. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39085. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39086. * @returns true if the pointer was captured
  39087. */
  39088. isPointerCaptured(pointerId?: number): boolean;
  39089. /**
  39090. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39091. * @param attachUp defines if you want to attach events to pointerup
  39092. * @param attachDown defines if you want to attach events to pointerdown
  39093. * @param attachMove defines if you want to attach events to pointermove
  39094. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39095. */
  39096. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39097. /**
  39098. * Detaches all event handlers
  39099. */
  39100. detachControl(): void;
  39101. /**
  39102. * Force the value of meshUnderPointer
  39103. * @param mesh defines the mesh to use
  39104. */
  39105. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39106. /**
  39107. * Gets the mesh under the pointer
  39108. * @returns a Mesh or null if no mesh is under the pointer
  39109. */
  39110. getPointerOverMesh(): Nullable<AbstractMesh>;
  39111. }
  39112. }
  39113. declare module "babylonjs/Animations/animationGroup" {
  39114. import { Animatable } from "babylonjs/Animations/animatable";
  39115. import { Animation } from "babylonjs/Animations/animation";
  39116. import { Scene, IDisposable } from "babylonjs/scene";
  39117. import { Observable } from "babylonjs/Misc/observable";
  39118. import { Nullable } from "babylonjs/types";
  39119. import "babylonjs/Animations/animatable";
  39120. /**
  39121. * This class defines the direct association between an animation and a target
  39122. */
  39123. export class TargetedAnimation {
  39124. /**
  39125. * Animation to perform
  39126. */
  39127. animation: Animation;
  39128. /**
  39129. * Target to animate
  39130. */
  39131. target: any;
  39132. /**
  39133. * Returns the string "TargetedAnimation"
  39134. * @returns "TargetedAnimation"
  39135. */
  39136. getClassName(): string;
  39137. /**
  39138. * Serialize the object
  39139. * @returns the JSON object representing the current entity
  39140. */
  39141. serialize(): any;
  39142. }
  39143. /**
  39144. * Use this class to create coordinated animations on multiple targets
  39145. */
  39146. export class AnimationGroup implements IDisposable {
  39147. /** The name of the animation group */
  39148. name: string;
  39149. private _scene;
  39150. private _targetedAnimations;
  39151. private _animatables;
  39152. private _from;
  39153. private _to;
  39154. private _isStarted;
  39155. private _isPaused;
  39156. private _speedRatio;
  39157. private _loopAnimation;
  39158. private _isAdditive;
  39159. /**
  39160. * Gets or sets the unique id of the node
  39161. */
  39162. uniqueId: number;
  39163. /**
  39164. * This observable will notify when one animation have ended
  39165. */
  39166. onAnimationEndObservable: Observable<TargetedAnimation>;
  39167. /**
  39168. * Observer raised when one animation loops
  39169. */
  39170. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39171. /**
  39172. * Observer raised when all animations have looped
  39173. */
  39174. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39175. /**
  39176. * This observable will notify when all animations have ended.
  39177. */
  39178. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39179. /**
  39180. * This observable will notify when all animations have paused.
  39181. */
  39182. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39183. /**
  39184. * This observable will notify when all animations are playing.
  39185. */
  39186. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39187. /**
  39188. * Gets the first frame
  39189. */
  39190. get from(): number;
  39191. /**
  39192. * Gets the last frame
  39193. */
  39194. get to(): number;
  39195. /**
  39196. * Define if the animations are started
  39197. */
  39198. get isStarted(): boolean;
  39199. /**
  39200. * Gets a value indicating that the current group is playing
  39201. */
  39202. get isPlaying(): boolean;
  39203. /**
  39204. * Gets or sets the speed ratio to use for all animations
  39205. */
  39206. get speedRatio(): number;
  39207. /**
  39208. * Gets or sets the speed ratio to use for all animations
  39209. */
  39210. set speedRatio(value: number);
  39211. /**
  39212. * Gets or sets if all animations should loop or not
  39213. */
  39214. get loopAnimation(): boolean;
  39215. set loopAnimation(value: boolean);
  39216. /**
  39217. * Gets or sets if all animations should be evaluated additively
  39218. */
  39219. get isAdditive(): boolean;
  39220. set isAdditive(value: boolean);
  39221. /**
  39222. * Gets the targeted animations for this animation group
  39223. */
  39224. get targetedAnimations(): Array<TargetedAnimation>;
  39225. /**
  39226. * returning the list of animatables controlled by this animation group.
  39227. */
  39228. get animatables(): Array<Animatable>;
  39229. /**
  39230. * Gets the list of target animations
  39231. */
  39232. get children(): TargetedAnimation[];
  39233. /**
  39234. * Instantiates a new Animation Group.
  39235. * This helps managing several animations at once.
  39236. * @see http://doc.babylonjs.com/how_to/group
  39237. * @param name Defines the name of the group
  39238. * @param scene Defines the scene the group belongs to
  39239. */
  39240. constructor(
  39241. /** The name of the animation group */
  39242. name: string, scene?: Nullable<Scene>);
  39243. /**
  39244. * Add an animation (with its target) in the group
  39245. * @param animation defines the animation we want to add
  39246. * @param target defines the target of the animation
  39247. * @returns the TargetedAnimation object
  39248. */
  39249. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39250. /**
  39251. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39252. * It can add constant keys at begin or end
  39253. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39254. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39255. * @returns the animation group
  39256. */
  39257. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39258. private _animationLoopCount;
  39259. private _animationLoopFlags;
  39260. private _processLoop;
  39261. /**
  39262. * Start all animations on given targets
  39263. * @param loop defines if animations must loop
  39264. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39265. * @param from defines the from key (optional)
  39266. * @param to defines the to key (optional)
  39267. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39268. * @returns the current animation group
  39269. */
  39270. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39271. /**
  39272. * Pause all animations
  39273. * @returns the animation group
  39274. */
  39275. pause(): AnimationGroup;
  39276. /**
  39277. * Play all animations to initial state
  39278. * This function will start() the animations if they were not started or will restart() them if they were paused
  39279. * @param loop defines if animations must loop
  39280. * @returns the animation group
  39281. */
  39282. play(loop?: boolean): AnimationGroup;
  39283. /**
  39284. * Reset all animations to initial state
  39285. * @returns the animation group
  39286. */
  39287. reset(): AnimationGroup;
  39288. /**
  39289. * Restart animations from key 0
  39290. * @returns the animation group
  39291. */
  39292. restart(): AnimationGroup;
  39293. /**
  39294. * Stop all animations
  39295. * @returns the animation group
  39296. */
  39297. stop(): AnimationGroup;
  39298. /**
  39299. * Set animation weight for all animatables
  39300. * @param weight defines the weight to use
  39301. * @return the animationGroup
  39302. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39303. */
  39304. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39305. /**
  39306. * Synchronize and normalize all animatables with a source animatable
  39307. * @param root defines the root animatable to synchronize with
  39308. * @return the animationGroup
  39309. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39310. */
  39311. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39312. /**
  39313. * Goes to a specific frame in this animation group
  39314. * @param frame the frame number to go to
  39315. * @return the animationGroup
  39316. */
  39317. goToFrame(frame: number): AnimationGroup;
  39318. /**
  39319. * Dispose all associated resources
  39320. */
  39321. dispose(): void;
  39322. private _checkAnimationGroupEnded;
  39323. /**
  39324. * Clone the current animation group and returns a copy
  39325. * @param newName defines the name of the new group
  39326. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39327. * @returns the new aniamtion group
  39328. */
  39329. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39330. /**
  39331. * Serializes the animationGroup to an object
  39332. * @returns Serialized object
  39333. */
  39334. serialize(): any;
  39335. /**
  39336. * Returns a new AnimationGroup object parsed from the source provided.
  39337. * @param parsedAnimationGroup defines the source
  39338. * @param scene defines the scene that will receive the animationGroup
  39339. * @returns a new AnimationGroup
  39340. */
  39341. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39342. /**
  39343. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39344. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39345. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39346. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39347. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39348. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39349. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39350. */
  39351. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39352. /**
  39353. * Returns the string "AnimationGroup"
  39354. * @returns "AnimationGroup"
  39355. */
  39356. getClassName(): string;
  39357. /**
  39358. * Creates a detailled string about the object
  39359. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39360. * @returns a string representing the object
  39361. */
  39362. toString(fullDetails?: boolean): string;
  39363. }
  39364. }
  39365. declare module "babylonjs/scene" {
  39366. import { Nullable } from "babylonjs/types";
  39367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39368. import { Observable } from "babylonjs/Misc/observable";
  39369. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39370. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39371. import { Geometry } from "babylonjs/Meshes/geometry";
  39372. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39375. import { Mesh } from "babylonjs/Meshes/mesh";
  39376. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39377. import { Bone } from "babylonjs/Bones/bone";
  39378. import { Skeleton } from "babylonjs/Bones/skeleton";
  39379. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39380. import { Camera } from "babylonjs/Cameras/camera";
  39381. import { AbstractScene } from "babylonjs/abstractScene";
  39382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39384. import { Material } from "babylonjs/Materials/material";
  39385. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39386. import { Effect } from "babylonjs/Materials/effect";
  39387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39388. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39389. import { Light } from "babylonjs/Lights/light";
  39390. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39391. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39392. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39393. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39395. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39396. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39397. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39398. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39399. import { Engine } from "babylonjs/Engines/engine";
  39400. import { Node } from "babylonjs/node";
  39401. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39402. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39403. import { WebRequest } from "babylonjs/Misc/webRequest";
  39404. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39405. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39406. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39407. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39408. import { Plane } from "babylonjs/Maths/math.plane";
  39409. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39410. import { Ray } from "babylonjs/Culling/ray";
  39411. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39412. import { Animation } from "babylonjs/Animations/animation";
  39413. import { Animatable } from "babylonjs/Animations/animatable";
  39414. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39415. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39416. import { Collider } from "babylonjs/Collisions/collider";
  39417. /**
  39418. * Define an interface for all classes that will hold resources
  39419. */
  39420. export interface IDisposable {
  39421. /**
  39422. * Releases all held resources
  39423. */
  39424. dispose(): void;
  39425. }
  39426. /** Interface defining initialization parameters for Scene class */
  39427. export interface SceneOptions {
  39428. /**
  39429. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39430. * It will improve performance when the number of geometries becomes important.
  39431. */
  39432. useGeometryUniqueIdsMap?: boolean;
  39433. /**
  39434. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39435. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39436. */
  39437. useMaterialMeshMap?: boolean;
  39438. /**
  39439. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39440. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39441. */
  39442. useClonedMeshMap?: boolean;
  39443. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39444. virtual?: boolean;
  39445. }
  39446. /**
  39447. * Represents a scene to be rendered by the engine.
  39448. * @see http://doc.babylonjs.com/features/scene
  39449. */
  39450. export class Scene extends AbstractScene implements IAnimatable {
  39451. /** The fog is deactivated */
  39452. static readonly FOGMODE_NONE: number;
  39453. /** The fog density is following an exponential function */
  39454. static readonly FOGMODE_EXP: number;
  39455. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39456. static readonly FOGMODE_EXP2: number;
  39457. /** The fog density is following a linear function. */
  39458. static readonly FOGMODE_LINEAR: number;
  39459. /**
  39460. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39462. */
  39463. static MinDeltaTime: number;
  39464. /**
  39465. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39467. */
  39468. static MaxDeltaTime: number;
  39469. /**
  39470. * Factory used to create the default material.
  39471. * @param name The name of the material to create
  39472. * @param scene The scene to create the material for
  39473. * @returns The default material
  39474. */
  39475. static DefaultMaterialFactory(scene: Scene): Material;
  39476. /**
  39477. * Factory used to create the a collision coordinator.
  39478. * @returns The collision coordinator
  39479. */
  39480. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39481. /** @hidden */
  39482. _inputManager: InputManager;
  39483. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39484. cameraToUseForPointers: Nullable<Camera>;
  39485. /** @hidden */
  39486. readonly _isScene: boolean;
  39487. /** @hidden */
  39488. _blockEntityCollection: boolean;
  39489. /**
  39490. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39491. */
  39492. autoClear: boolean;
  39493. /**
  39494. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39495. */
  39496. autoClearDepthAndStencil: boolean;
  39497. /**
  39498. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39499. */
  39500. clearColor: Color4;
  39501. /**
  39502. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39503. */
  39504. ambientColor: Color3;
  39505. /**
  39506. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39507. * It should only be one of the following (if not the default embedded one):
  39508. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39509. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39510. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39511. * The material properties need to be setup according to the type of texture in use.
  39512. */
  39513. environmentBRDFTexture: BaseTexture;
  39514. /** @hidden */
  39515. protected _environmentTexture: Nullable<BaseTexture>;
  39516. /**
  39517. * Texture used in all pbr material as the reflection texture.
  39518. * As in the majority of the scene they are the same (exception for multi room and so on),
  39519. * this is easier to reference from here than from all the materials.
  39520. */
  39521. get environmentTexture(): Nullable<BaseTexture>;
  39522. /**
  39523. * Texture used in all pbr material as the reflection texture.
  39524. * As in the majority of the scene they are the same (exception for multi room and so on),
  39525. * this is easier to set here than in all the materials.
  39526. */
  39527. set environmentTexture(value: Nullable<BaseTexture>);
  39528. /** @hidden */
  39529. protected _environmentIntensity: number;
  39530. /**
  39531. * Intensity of the environment in all pbr material.
  39532. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39533. * As in the majority of the scene they are the same (exception for multi room and so on),
  39534. * this is easier to reference from here than from all the materials.
  39535. */
  39536. get environmentIntensity(): number;
  39537. /**
  39538. * Intensity of the environment in all pbr material.
  39539. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39540. * As in the majority of the scene they are the same (exception for multi room and so on),
  39541. * this is easier to set here than in all the materials.
  39542. */
  39543. set environmentIntensity(value: number);
  39544. /** @hidden */
  39545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39546. /**
  39547. * Default image processing configuration used either in the rendering
  39548. * Forward main pass or through the imageProcessingPostProcess if present.
  39549. * As in the majority of the scene they are the same (exception for multi camera),
  39550. * this is easier to reference from here than from all the materials and post process.
  39551. *
  39552. * No setter as we it is a shared configuration, you can set the values instead.
  39553. */
  39554. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39555. private _forceWireframe;
  39556. /**
  39557. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39558. */
  39559. set forceWireframe(value: boolean);
  39560. get forceWireframe(): boolean;
  39561. private _skipFrustumClipping;
  39562. /**
  39563. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39564. */
  39565. set skipFrustumClipping(value: boolean);
  39566. get skipFrustumClipping(): boolean;
  39567. private _forcePointsCloud;
  39568. /**
  39569. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39570. */
  39571. set forcePointsCloud(value: boolean);
  39572. get forcePointsCloud(): boolean;
  39573. /**
  39574. * Gets or sets the active clipplane 1
  39575. */
  39576. clipPlane: Nullable<Plane>;
  39577. /**
  39578. * Gets or sets the active clipplane 2
  39579. */
  39580. clipPlane2: Nullable<Plane>;
  39581. /**
  39582. * Gets or sets the active clipplane 3
  39583. */
  39584. clipPlane3: Nullable<Plane>;
  39585. /**
  39586. * Gets or sets the active clipplane 4
  39587. */
  39588. clipPlane4: Nullable<Plane>;
  39589. /**
  39590. * Gets or sets the active clipplane 5
  39591. */
  39592. clipPlane5: Nullable<Plane>;
  39593. /**
  39594. * Gets or sets the active clipplane 6
  39595. */
  39596. clipPlane6: Nullable<Plane>;
  39597. /**
  39598. * Gets or sets a boolean indicating if animations are enabled
  39599. */
  39600. animationsEnabled: boolean;
  39601. private _animationPropertiesOverride;
  39602. /**
  39603. * Gets or sets the animation properties override
  39604. */
  39605. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39606. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39607. /**
  39608. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39609. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39610. */
  39611. useConstantAnimationDeltaTime: boolean;
  39612. /**
  39613. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39614. * Please note that it requires to run a ray cast through the scene on every frame
  39615. */
  39616. constantlyUpdateMeshUnderPointer: boolean;
  39617. /**
  39618. * Defines the HTML cursor to use when hovering over interactive elements
  39619. */
  39620. hoverCursor: string;
  39621. /**
  39622. * Defines the HTML default cursor to use (empty by default)
  39623. */
  39624. defaultCursor: string;
  39625. /**
  39626. * Defines whether cursors are handled by the scene.
  39627. */
  39628. doNotHandleCursors: boolean;
  39629. /**
  39630. * This is used to call preventDefault() on pointer down
  39631. * in order to block unwanted artifacts like system double clicks
  39632. */
  39633. preventDefaultOnPointerDown: boolean;
  39634. /**
  39635. * This is used to call preventDefault() on pointer up
  39636. * in order to block unwanted artifacts like system double clicks
  39637. */
  39638. preventDefaultOnPointerUp: boolean;
  39639. /**
  39640. * Gets or sets user defined metadata
  39641. */
  39642. metadata: any;
  39643. /**
  39644. * For internal use only. Please do not use.
  39645. */
  39646. reservedDataStore: any;
  39647. /**
  39648. * Gets the name of the plugin used to load this scene (null by default)
  39649. */
  39650. loadingPluginName: string;
  39651. /**
  39652. * Use this array to add regular expressions used to disable offline support for specific urls
  39653. */
  39654. disableOfflineSupportExceptionRules: RegExp[];
  39655. /**
  39656. * An event triggered when the scene is disposed.
  39657. */
  39658. onDisposeObservable: Observable<Scene>;
  39659. private _onDisposeObserver;
  39660. /** Sets a function to be executed when this scene is disposed. */
  39661. set onDispose(callback: () => void);
  39662. /**
  39663. * An event triggered before rendering the scene (right after animations and physics)
  39664. */
  39665. onBeforeRenderObservable: Observable<Scene>;
  39666. private _onBeforeRenderObserver;
  39667. /** Sets a function to be executed before rendering this scene */
  39668. set beforeRender(callback: Nullable<() => void>);
  39669. /**
  39670. * An event triggered after rendering the scene
  39671. */
  39672. onAfterRenderObservable: Observable<Scene>;
  39673. /**
  39674. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39675. */
  39676. onAfterRenderCameraObservable: Observable<Camera>;
  39677. private _onAfterRenderObserver;
  39678. /** Sets a function to be executed after rendering this scene */
  39679. set afterRender(callback: Nullable<() => void>);
  39680. /**
  39681. * An event triggered before animating the scene
  39682. */
  39683. onBeforeAnimationsObservable: Observable<Scene>;
  39684. /**
  39685. * An event triggered after animations processing
  39686. */
  39687. onAfterAnimationsObservable: Observable<Scene>;
  39688. /**
  39689. * An event triggered before draw calls are ready to be sent
  39690. */
  39691. onBeforeDrawPhaseObservable: Observable<Scene>;
  39692. /**
  39693. * An event triggered after draw calls have been sent
  39694. */
  39695. onAfterDrawPhaseObservable: Observable<Scene>;
  39696. /**
  39697. * An event triggered when the scene is ready
  39698. */
  39699. onReadyObservable: Observable<Scene>;
  39700. /**
  39701. * An event triggered before rendering a camera
  39702. */
  39703. onBeforeCameraRenderObservable: Observable<Camera>;
  39704. private _onBeforeCameraRenderObserver;
  39705. /** Sets a function to be executed before rendering a camera*/
  39706. set beforeCameraRender(callback: () => void);
  39707. /**
  39708. * An event triggered after rendering a camera
  39709. */
  39710. onAfterCameraRenderObservable: Observable<Camera>;
  39711. private _onAfterCameraRenderObserver;
  39712. /** Sets a function to be executed after rendering a camera*/
  39713. set afterCameraRender(callback: () => void);
  39714. /**
  39715. * An event triggered when active meshes evaluation is about to start
  39716. */
  39717. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39718. /**
  39719. * An event triggered when active meshes evaluation is done
  39720. */
  39721. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39722. /**
  39723. * An event triggered when particles rendering is about to start
  39724. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39725. */
  39726. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39727. /**
  39728. * An event triggered when particles rendering is done
  39729. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39730. */
  39731. onAfterParticlesRenderingObservable: Observable<Scene>;
  39732. /**
  39733. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39734. */
  39735. onDataLoadedObservable: Observable<Scene>;
  39736. /**
  39737. * An event triggered when a camera is created
  39738. */
  39739. onNewCameraAddedObservable: Observable<Camera>;
  39740. /**
  39741. * An event triggered when a camera is removed
  39742. */
  39743. onCameraRemovedObservable: Observable<Camera>;
  39744. /**
  39745. * An event triggered when a light is created
  39746. */
  39747. onNewLightAddedObservable: Observable<Light>;
  39748. /**
  39749. * An event triggered when a light is removed
  39750. */
  39751. onLightRemovedObservable: Observable<Light>;
  39752. /**
  39753. * An event triggered when a geometry is created
  39754. */
  39755. onNewGeometryAddedObservable: Observable<Geometry>;
  39756. /**
  39757. * An event triggered when a geometry is removed
  39758. */
  39759. onGeometryRemovedObservable: Observable<Geometry>;
  39760. /**
  39761. * An event triggered when a transform node is created
  39762. */
  39763. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39764. /**
  39765. * An event triggered when a transform node is removed
  39766. */
  39767. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39768. /**
  39769. * An event triggered when a mesh is created
  39770. */
  39771. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39772. /**
  39773. * An event triggered when a mesh is removed
  39774. */
  39775. onMeshRemovedObservable: Observable<AbstractMesh>;
  39776. /**
  39777. * An event triggered when a skeleton is created
  39778. */
  39779. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39780. /**
  39781. * An event triggered when a skeleton is removed
  39782. */
  39783. onSkeletonRemovedObservable: Observable<Skeleton>;
  39784. /**
  39785. * An event triggered when a material is created
  39786. */
  39787. onNewMaterialAddedObservable: Observable<Material>;
  39788. /**
  39789. * An event triggered when a material is removed
  39790. */
  39791. onMaterialRemovedObservable: Observable<Material>;
  39792. /**
  39793. * An event triggered when a texture is created
  39794. */
  39795. onNewTextureAddedObservable: Observable<BaseTexture>;
  39796. /**
  39797. * An event triggered when a texture is removed
  39798. */
  39799. onTextureRemovedObservable: Observable<BaseTexture>;
  39800. /**
  39801. * An event triggered when render targets are about to be rendered
  39802. * Can happen multiple times per frame.
  39803. */
  39804. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39805. /**
  39806. * An event triggered when render targets were rendered.
  39807. * Can happen multiple times per frame.
  39808. */
  39809. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39810. /**
  39811. * An event triggered before calculating deterministic simulation step
  39812. */
  39813. onBeforeStepObservable: Observable<Scene>;
  39814. /**
  39815. * An event triggered after calculating deterministic simulation step
  39816. */
  39817. onAfterStepObservable: Observable<Scene>;
  39818. /**
  39819. * An event triggered when the activeCamera property is updated
  39820. */
  39821. onActiveCameraChanged: Observable<Scene>;
  39822. /**
  39823. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39824. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39825. * 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)
  39826. */
  39827. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39828. /**
  39829. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39830. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39831. * 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)
  39832. */
  39833. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39834. /**
  39835. * This Observable will when a mesh has been imported into the scene.
  39836. */
  39837. onMeshImportedObservable: Observable<AbstractMesh>;
  39838. /**
  39839. * This Observable will when an animation file has been imported into the scene.
  39840. */
  39841. onAnimationFileImportedObservable: Observable<Scene>;
  39842. /**
  39843. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39844. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39845. */
  39846. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39847. /** @hidden */
  39848. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39849. /**
  39850. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39851. */
  39852. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39853. /**
  39854. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39855. */
  39856. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39857. /**
  39858. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39859. */
  39860. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39861. /** Callback called when a pointer move is detected */
  39862. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39863. /** Callback called when a pointer down is detected */
  39864. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39865. /** Callback called when a pointer up is detected */
  39866. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39867. /** Callback called when a pointer pick is detected */
  39868. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39869. /**
  39870. * 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).
  39871. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39872. */
  39873. onPrePointerObservable: Observable<PointerInfoPre>;
  39874. /**
  39875. * Observable event triggered each time an input event is received from the rendering canvas
  39876. */
  39877. onPointerObservable: Observable<PointerInfo>;
  39878. /**
  39879. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39880. */
  39881. get unTranslatedPointer(): Vector2;
  39882. /**
  39883. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39884. */
  39885. static get DragMovementThreshold(): number;
  39886. static set DragMovementThreshold(value: number);
  39887. /**
  39888. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39889. */
  39890. static get LongPressDelay(): number;
  39891. static set LongPressDelay(value: number);
  39892. /**
  39893. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39894. */
  39895. static get DoubleClickDelay(): number;
  39896. static set DoubleClickDelay(value: number);
  39897. /** If you need to check double click without raising a single click at first click, enable this flag */
  39898. static get ExclusiveDoubleClickMode(): boolean;
  39899. static set ExclusiveDoubleClickMode(value: boolean);
  39900. /** @hidden */
  39901. _mirroredCameraPosition: Nullable<Vector3>;
  39902. /**
  39903. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39904. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39905. */
  39906. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39907. /**
  39908. * Observable event triggered each time an keyboard event is received from the hosting window
  39909. */
  39910. onKeyboardObservable: Observable<KeyboardInfo>;
  39911. private _useRightHandedSystem;
  39912. /**
  39913. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39914. */
  39915. set useRightHandedSystem(value: boolean);
  39916. get useRightHandedSystem(): boolean;
  39917. private _timeAccumulator;
  39918. private _currentStepId;
  39919. private _currentInternalStep;
  39920. /**
  39921. * Sets the step Id used by deterministic lock step
  39922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39923. * @param newStepId defines the step Id
  39924. */
  39925. setStepId(newStepId: number): void;
  39926. /**
  39927. * Gets the step Id used by deterministic lock step
  39928. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39929. * @returns the step Id
  39930. */
  39931. getStepId(): number;
  39932. /**
  39933. * Gets the internal step used by deterministic lock step
  39934. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39935. * @returns the internal step
  39936. */
  39937. getInternalStep(): number;
  39938. private _fogEnabled;
  39939. /**
  39940. * Gets or sets a boolean indicating if fog is enabled on this scene
  39941. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39942. * (Default is true)
  39943. */
  39944. set fogEnabled(value: boolean);
  39945. get fogEnabled(): boolean;
  39946. private _fogMode;
  39947. /**
  39948. * Gets or sets the fog mode to use
  39949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39950. * | mode | value |
  39951. * | --- | --- |
  39952. * | FOGMODE_NONE | 0 |
  39953. * | FOGMODE_EXP | 1 |
  39954. * | FOGMODE_EXP2 | 2 |
  39955. * | FOGMODE_LINEAR | 3 |
  39956. */
  39957. set fogMode(value: number);
  39958. get fogMode(): number;
  39959. /**
  39960. * Gets or sets the fog color to use
  39961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39962. * (Default is Color3(0.2, 0.2, 0.3))
  39963. */
  39964. fogColor: Color3;
  39965. /**
  39966. * Gets or sets the fog density to use
  39967. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39968. * (Default is 0.1)
  39969. */
  39970. fogDensity: number;
  39971. /**
  39972. * Gets or sets the fog start distance to use
  39973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39974. * (Default is 0)
  39975. */
  39976. fogStart: number;
  39977. /**
  39978. * Gets or sets the fog end distance to use
  39979. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39980. * (Default is 1000)
  39981. */
  39982. fogEnd: number;
  39983. private _shadowsEnabled;
  39984. /**
  39985. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39986. */
  39987. set shadowsEnabled(value: boolean);
  39988. get shadowsEnabled(): boolean;
  39989. private _lightsEnabled;
  39990. /**
  39991. * Gets or sets a boolean indicating if lights are enabled on this scene
  39992. */
  39993. set lightsEnabled(value: boolean);
  39994. get lightsEnabled(): boolean;
  39995. /** All of the active cameras added to this scene. */
  39996. activeCameras: Camera[];
  39997. /** @hidden */
  39998. _activeCamera: Nullable<Camera>;
  39999. /** Gets or sets the current active camera */
  40000. get activeCamera(): Nullable<Camera>;
  40001. set activeCamera(value: Nullable<Camera>);
  40002. private _defaultMaterial;
  40003. /** The default material used on meshes when no material is affected */
  40004. get defaultMaterial(): Material;
  40005. /** The default material used on meshes when no material is affected */
  40006. set defaultMaterial(value: Material);
  40007. private _texturesEnabled;
  40008. /**
  40009. * Gets or sets a boolean indicating if textures are enabled on this scene
  40010. */
  40011. set texturesEnabled(value: boolean);
  40012. get texturesEnabled(): boolean;
  40013. /**
  40014. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40015. */
  40016. physicsEnabled: boolean;
  40017. /**
  40018. * Gets or sets a boolean indicating if particles are enabled on this scene
  40019. */
  40020. particlesEnabled: boolean;
  40021. /**
  40022. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40023. */
  40024. spritesEnabled: boolean;
  40025. private _skeletonsEnabled;
  40026. /**
  40027. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40028. */
  40029. set skeletonsEnabled(value: boolean);
  40030. get skeletonsEnabled(): boolean;
  40031. /**
  40032. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40033. */
  40034. lensFlaresEnabled: boolean;
  40035. /**
  40036. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40038. */
  40039. collisionsEnabled: boolean;
  40040. private _collisionCoordinator;
  40041. /** @hidden */
  40042. get collisionCoordinator(): ICollisionCoordinator;
  40043. /**
  40044. * Defines the gravity applied to this scene (used only for collisions)
  40045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40046. */
  40047. gravity: Vector3;
  40048. /**
  40049. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40050. */
  40051. postProcessesEnabled: boolean;
  40052. /**
  40053. * The list of postprocesses added to the scene
  40054. */
  40055. postProcesses: PostProcess[];
  40056. /**
  40057. * Gets the current postprocess manager
  40058. */
  40059. postProcessManager: PostProcessManager;
  40060. /**
  40061. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40062. */
  40063. renderTargetsEnabled: boolean;
  40064. /**
  40065. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40066. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40067. */
  40068. dumpNextRenderTargets: boolean;
  40069. /**
  40070. * The list of user defined render targets added to the scene
  40071. */
  40072. customRenderTargets: RenderTargetTexture[];
  40073. /**
  40074. * Defines if texture loading must be delayed
  40075. * If true, textures will only be loaded when they need to be rendered
  40076. */
  40077. useDelayedTextureLoading: boolean;
  40078. /**
  40079. * Gets the list of meshes imported to the scene through SceneLoader
  40080. */
  40081. importedMeshesFiles: String[];
  40082. /**
  40083. * Gets or sets a boolean indicating if probes are enabled on this scene
  40084. */
  40085. probesEnabled: boolean;
  40086. /**
  40087. * Gets or sets the current offline provider to use to store scene data
  40088. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40089. */
  40090. offlineProvider: IOfflineProvider;
  40091. /**
  40092. * Gets or sets the action manager associated with the scene
  40093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40094. */
  40095. actionManager: AbstractActionManager;
  40096. private _meshesForIntersections;
  40097. /**
  40098. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40099. */
  40100. proceduralTexturesEnabled: boolean;
  40101. private _engine;
  40102. private _totalVertices;
  40103. /** @hidden */
  40104. _activeIndices: PerfCounter;
  40105. /** @hidden */
  40106. _activeParticles: PerfCounter;
  40107. /** @hidden */
  40108. _activeBones: PerfCounter;
  40109. private _animationRatio;
  40110. /** @hidden */
  40111. _animationTimeLast: number;
  40112. /** @hidden */
  40113. _animationTime: number;
  40114. /**
  40115. * Gets or sets a general scale for animation speed
  40116. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40117. */
  40118. animationTimeScale: number;
  40119. /** @hidden */
  40120. _cachedMaterial: Nullable<Material>;
  40121. /** @hidden */
  40122. _cachedEffect: Nullable<Effect>;
  40123. /** @hidden */
  40124. _cachedVisibility: Nullable<number>;
  40125. private _renderId;
  40126. private _frameId;
  40127. private _executeWhenReadyTimeoutId;
  40128. private _intermediateRendering;
  40129. private _viewUpdateFlag;
  40130. private _projectionUpdateFlag;
  40131. /** @hidden */
  40132. _toBeDisposed: Nullable<IDisposable>[];
  40133. private _activeRequests;
  40134. /** @hidden */
  40135. _pendingData: any[];
  40136. private _isDisposed;
  40137. /**
  40138. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40139. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40140. */
  40141. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40142. private _activeMeshes;
  40143. private _processedMaterials;
  40144. private _renderTargets;
  40145. /** @hidden */
  40146. _activeParticleSystems: SmartArray<IParticleSystem>;
  40147. private _activeSkeletons;
  40148. private _softwareSkinnedMeshes;
  40149. private _renderingManager;
  40150. /** @hidden */
  40151. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40152. private _transformMatrix;
  40153. private _sceneUbo;
  40154. /** @hidden */
  40155. _viewMatrix: Matrix;
  40156. private _projectionMatrix;
  40157. /** @hidden */
  40158. _forcedViewPosition: Nullable<Vector3>;
  40159. /** @hidden */
  40160. _frustumPlanes: Plane[];
  40161. /**
  40162. * Gets the list of frustum planes (built from the active camera)
  40163. */
  40164. get frustumPlanes(): Plane[];
  40165. /**
  40166. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40167. * This is useful if there are more lights that the maximum simulteanous authorized
  40168. */
  40169. requireLightSorting: boolean;
  40170. /** @hidden */
  40171. readonly useMaterialMeshMap: boolean;
  40172. /** @hidden */
  40173. readonly useClonedMeshMap: boolean;
  40174. private _externalData;
  40175. private _uid;
  40176. /**
  40177. * @hidden
  40178. * Backing store of defined scene components.
  40179. */
  40180. _components: ISceneComponent[];
  40181. /**
  40182. * @hidden
  40183. * Backing store of defined scene components.
  40184. */
  40185. _serializableComponents: ISceneSerializableComponent[];
  40186. /**
  40187. * List of components to register on the next registration step.
  40188. */
  40189. private _transientComponents;
  40190. /**
  40191. * Registers the transient components if needed.
  40192. */
  40193. private _registerTransientComponents;
  40194. /**
  40195. * @hidden
  40196. * Add a component to the scene.
  40197. * Note that the ccomponent could be registered on th next frame if this is called after
  40198. * the register component stage.
  40199. * @param component Defines the component to add to the scene
  40200. */
  40201. _addComponent(component: ISceneComponent): void;
  40202. /**
  40203. * @hidden
  40204. * Gets a component from the scene.
  40205. * @param name defines the name of the component to retrieve
  40206. * @returns the component or null if not present
  40207. */
  40208. _getComponent(name: string): Nullable<ISceneComponent>;
  40209. /**
  40210. * @hidden
  40211. * Defines the actions happening before camera updates.
  40212. */
  40213. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40214. /**
  40215. * @hidden
  40216. * Defines the actions happening before clear the canvas.
  40217. */
  40218. _beforeClearStage: Stage<SimpleStageAction>;
  40219. /**
  40220. * @hidden
  40221. * Defines the actions when collecting render targets for the frame.
  40222. */
  40223. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40224. /**
  40225. * @hidden
  40226. * Defines the actions happening for one camera in the frame.
  40227. */
  40228. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40229. /**
  40230. * @hidden
  40231. * Defines the actions happening during the per mesh ready checks.
  40232. */
  40233. _isReadyForMeshStage: Stage<MeshStageAction>;
  40234. /**
  40235. * @hidden
  40236. * Defines the actions happening before evaluate active mesh checks.
  40237. */
  40238. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40239. /**
  40240. * @hidden
  40241. * Defines the actions happening during the evaluate sub mesh checks.
  40242. */
  40243. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40244. /**
  40245. * @hidden
  40246. * Defines the actions happening during the active mesh stage.
  40247. */
  40248. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40249. /**
  40250. * @hidden
  40251. * Defines the actions happening during the per camera render target step.
  40252. */
  40253. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40254. /**
  40255. * @hidden
  40256. * Defines the actions happening just before the active camera is drawing.
  40257. */
  40258. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40259. /**
  40260. * @hidden
  40261. * Defines the actions happening just before a render target is drawing.
  40262. */
  40263. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40264. /**
  40265. * @hidden
  40266. * Defines the actions happening just before a rendering group is drawing.
  40267. */
  40268. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40269. /**
  40270. * @hidden
  40271. * Defines the actions happening just before a mesh is drawing.
  40272. */
  40273. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40274. /**
  40275. * @hidden
  40276. * Defines the actions happening just after a mesh has been drawn.
  40277. */
  40278. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40279. /**
  40280. * @hidden
  40281. * Defines the actions happening just after a rendering group has been drawn.
  40282. */
  40283. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40284. /**
  40285. * @hidden
  40286. * Defines the actions happening just after the active camera has been drawn.
  40287. */
  40288. _afterCameraDrawStage: Stage<CameraStageAction>;
  40289. /**
  40290. * @hidden
  40291. * Defines the actions happening just after a render target has been drawn.
  40292. */
  40293. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40294. /**
  40295. * @hidden
  40296. * Defines the actions happening just after rendering all cameras and computing intersections.
  40297. */
  40298. _afterRenderStage: Stage<SimpleStageAction>;
  40299. /**
  40300. * @hidden
  40301. * Defines the actions happening when a pointer move event happens.
  40302. */
  40303. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40304. /**
  40305. * @hidden
  40306. * Defines the actions happening when a pointer down event happens.
  40307. */
  40308. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40309. /**
  40310. * @hidden
  40311. * Defines the actions happening when a pointer up event happens.
  40312. */
  40313. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40314. /**
  40315. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40316. */
  40317. private geometriesByUniqueId;
  40318. /**
  40319. * Creates a new Scene
  40320. * @param engine defines the engine to use to render this scene
  40321. * @param options defines the scene options
  40322. */
  40323. constructor(engine: Engine, options?: SceneOptions);
  40324. /**
  40325. * Gets a string idenfifying the name of the class
  40326. * @returns "Scene" string
  40327. */
  40328. getClassName(): string;
  40329. private _defaultMeshCandidates;
  40330. /**
  40331. * @hidden
  40332. */
  40333. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40334. private _defaultSubMeshCandidates;
  40335. /**
  40336. * @hidden
  40337. */
  40338. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40339. /**
  40340. * Sets the default candidate providers for the scene.
  40341. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40342. * and getCollidingSubMeshCandidates to their default function
  40343. */
  40344. setDefaultCandidateProviders(): void;
  40345. /**
  40346. * Gets the mesh that is currently under the pointer
  40347. */
  40348. get meshUnderPointer(): Nullable<AbstractMesh>;
  40349. /**
  40350. * Gets or sets the current on-screen X position of the pointer
  40351. */
  40352. get pointerX(): number;
  40353. set pointerX(value: number);
  40354. /**
  40355. * Gets or sets the current on-screen Y position of the pointer
  40356. */
  40357. get pointerY(): number;
  40358. set pointerY(value: number);
  40359. /**
  40360. * Gets the cached material (ie. the latest rendered one)
  40361. * @returns the cached material
  40362. */
  40363. getCachedMaterial(): Nullable<Material>;
  40364. /**
  40365. * Gets the cached effect (ie. the latest rendered one)
  40366. * @returns the cached effect
  40367. */
  40368. getCachedEffect(): Nullable<Effect>;
  40369. /**
  40370. * Gets the cached visibility state (ie. the latest rendered one)
  40371. * @returns the cached visibility state
  40372. */
  40373. getCachedVisibility(): Nullable<number>;
  40374. /**
  40375. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40376. * @param material defines the current material
  40377. * @param effect defines the current effect
  40378. * @param visibility defines the current visibility state
  40379. * @returns true if one parameter is not cached
  40380. */
  40381. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40382. /**
  40383. * Gets the engine associated with the scene
  40384. * @returns an Engine
  40385. */
  40386. getEngine(): Engine;
  40387. /**
  40388. * Gets the total number of vertices rendered per frame
  40389. * @returns the total number of vertices rendered per frame
  40390. */
  40391. getTotalVertices(): number;
  40392. /**
  40393. * Gets the performance counter for total vertices
  40394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40395. */
  40396. get totalVerticesPerfCounter(): PerfCounter;
  40397. /**
  40398. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40399. * @returns the total number of active indices rendered per frame
  40400. */
  40401. getActiveIndices(): number;
  40402. /**
  40403. * Gets the performance counter for active indices
  40404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40405. */
  40406. get totalActiveIndicesPerfCounter(): PerfCounter;
  40407. /**
  40408. * Gets the total number of active particles rendered per frame
  40409. * @returns the total number of active particles rendered per frame
  40410. */
  40411. getActiveParticles(): number;
  40412. /**
  40413. * Gets the performance counter for active particles
  40414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40415. */
  40416. get activeParticlesPerfCounter(): PerfCounter;
  40417. /**
  40418. * Gets the total number of active bones rendered per frame
  40419. * @returns the total number of active bones rendered per frame
  40420. */
  40421. getActiveBones(): number;
  40422. /**
  40423. * Gets the performance counter for active bones
  40424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40425. */
  40426. get activeBonesPerfCounter(): PerfCounter;
  40427. /**
  40428. * Gets the array of active meshes
  40429. * @returns an array of AbstractMesh
  40430. */
  40431. getActiveMeshes(): SmartArray<AbstractMesh>;
  40432. /**
  40433. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40434. * @returns a number
  40435. */
  40436. getAnimationRatio(): number;
  40437. /**
  40438. * Gets an unique Id for the current render phase
  40439. * @returns a number
  40440. */
  40441. getRenderId(): number;
  40442. /**
  40443. * Gets an unique Id for the current frame
  40444. * @returns a number
  40445. */
  40446. getFrameId(): number;
  40447. /** Call this function if you want to manually increment the render Id*/
  40448. incrementRenderId(): void;
  40449. private _createUbo;
  40450. /**
  40451. * Use this method to simulate a pointer move on a mesh
  40452. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40453. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40454. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40455. * @returns the current scene
  40456. */
  40457. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40458. /**
  40459. * Use this method to simulate a pointer down on a mesh
  40460. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40461. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40462. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40463. * @returns the current scene
  40464. */
  40465. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40466. /**
  40467. * Use this method to simulate a pointer up on a mesh
  40468. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40469. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40470. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40471. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40472. * @returns the current scene
  40473. */
  40474. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40475. /**
  40476. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40477. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40478. * @returns true if the pointer was captured
  40479. */
  40480. isPointerCaptured(pointerId?: number): boolean;
  40481. /**
  40482. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40483. * @param attachUp defines if you want to attach events to pointerup
  40484. * @param attachDown defines if you want to attach events to pointerdown
  40485. * @param attachMove defines if you want to attach events to pointermove
  40486. */
  40487. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40488. /** Detaches all event handlers*/
  40489. detachControl(): void;
  40490. /**
  40491. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40492. * Delay loaded resources are not taking in account
  40493. * @return true if all required resources are ready
  40494. */
  40495. isReady(): boolean;
  40496. /** Resets all cached information relative to material (including effect and visibility) */
  40497. resetCachedMaterial(): void;
  40498. /**
  40499. * Registers a function to be called before every frame render
  40500. * @param func defines the function to register
  40501. */
  40502. registerBeforeRender(func: () => void): void;
  40503. /**
  40504. * Unregisters a function called before every frame render
  40505. * @param func defines the function to unregister
  40506. */
  40507. unregisterBeforeRender(func: () => void): void;
  40508. /**
  40509. * Registers a function to be called after every frame render
  40510. * @param func defines the function to register
  40511. */
  40512. registerAfterRender(func: () => void): void;
  40513. /**
  40514. * Unregisters a function called after every frame render
  40515. * @param func defines the function to unregister
  40516. */
  40517. unregisterAfterRender(func: () => void): void;
  40518. private _executeOnceBeforeRender;
  40519. /**
  40520. * The provided function will run before render once and will be disposed afterwards.
  40521. * A timeout delay can be provided so that the function will be executed in N ms.
  40522. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40523. * @param func The function to be executed.
  40524. * @param timeout optional delay in ms
  40525. */
  40526. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40527. /** @hidden */
  40528. _addPendingData(data: any): void;
  40529. /** @hidden */
  40530. _removePendingData(data: any): void;
  40531. /**
  40532. * Returns the number of items waiting to be loaded
  40533. * @returns the number of items waiting to be loaded
  40534. */
  40535. getWaitingItemsCount(): number;
  40536. /**
  40537. * Returns a boolean indicating if the scene is still loading data
  40538. */
  40539. get isLoading(): boolean;
  40540. /**
  40541. * Registers a function to be executed when the scene is ready
  40542. * @param {Function} func - the function to be executed
  40543. */
  40544. executeWhenReady(func: () => void): void;
  40545. /**
  40546. * Returns a promise that resolves when the scene is ready
  40547. * @returns A promise that resolves when the scene is ready
  40548. */
  40549. whenReadyAsync(): Promise<void>;
  40550. /** @hidden */
  40551. _checkIsReady(): void;
  40552. /**
  40553. * Gets all animatable attached to the scene
  40554. */
  40555. get animatables(): Animatable[];
  40556. /**
  40557. * Resets the last animation time frame.
  40558. * Useful to override when animations start running when loading a scene for the first time.
  40559. */
  40560. resetLastAnimationTimeFrame(): void;
  40561. /**
  40562. * Gets the current view matrix
  40563. * @returns a Matrix
  40564. */
  40565. getViewMatrix(): Matrix;
  40566. /**
  40567. * Gets the current projection matrix
  40568. * @returns a Matrix
  40569. */
  40570. getProjectionMatrix(): Matrix;
  40571. /**
  40572. * Gets the current transform matrix
  40573. * @returns a Matrix made of View * Projection
  40574. */
  40575. getTransformMatrix(): Matrix;
  40576. /**
  40577. * Sets the current transform matrix
  40578. * @param viewL defines the View matrix to use
  40579. * @param projectionL defines the Projection matrix to use
  40580. * @param viewR defines the right View matrix to use (if provided)
  40581. * @param projectionR defines the right Projection matrix to use (if provided)
  40582. */
  40583. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40584. /**
  40585. * Gets the uniform buffer used to store scene data
  40586. * @returns a UniformBuffer
  40587. */
  40588. getSceneUniformBuffer(): UniformBuffer;
  40589. /**
  40590. * Gets an unique (relatively to the current scene) Id
  40591. * @returns an unique number for the scene
  40592. */
  40593. getUniqueId(): number;
  40594. /**
  40595. * Add a mesh to the list of scene's meshes
  40596. * @param newMesh defines the mesh to add
  40597. * @param recursive if all child meshes should also be added to the scene
  40598. */
  40599. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40600. /**
  40601. * Remove a mesh for the list of scene's meshes
  40602. * @param toRemove defines the mesh to remove
  40603. * @param recursive if all child meshes should also be removed from the scene
  40604. * @returns the index where the mesh was in the mesh list
  40605. */
  40606. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40607. /**
  40608. * Add a transform node to the list of scene's transform nodes
  40609. * @param newTransformNode defines the transform node to add
  40610. */
  40611. addTransformNode(newTransformNode: TransformNode): void;
  40612. /**
  40613. * Remove a transform node for the list of scene's transform nodes
  40614. * @param toRemove defines the transform node to remove
  40615. * @returns the index where the transform node was in the transform node list
  40616. */
  40617. removeTransformNode(toRemove: TransformNode): number;
  40618. /**
  40619. * Remove a skeleton for the list of scene's skeletons
  40620. * @param toRemove defines the skeleton to remove
  40621. * @returns the index where the skeleton was in the skeleton list
  40622. */
  40623. removeSkeleton(toRemove: Skeleton): number;
  40624. /**
  40625. * Remove a morph target for the list of scene's morph targets
  40626. * @param toRemove defines the morph target to remove
  40627. * @returns the index where the morph target was in the morph target list
  40628. */
  40629. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40630. /**
  40631. * Remove a light for the list of scene's lights
  40632. * @param toRemove defines the light to remove
  40633. * @returns the index where the light was in the light list
  40634. */
  40635. removeLight(toRemove: Light): number;
  40636. /**
  40637. * Remove a camera for the list of scene's cameras
  40638. * @param toRemove defines the camera to remove
  40639. * @returns the index where the camera was in the camera list
  40640. */
  40641. removeCamera(toRemove: Camera): number;
  40642. /**
  40643. * Remove a particle system for the list of scene's particle systems
  40644. * @param toRemove defines the particle system to remove
  40645. * @returns the index where the particle system was in the particle system list
  40646. */
  40647. removeParticleSystem(toRemove: IParticleSystem): number;
  40648. /**
  40649. * Remove a animation for the list of scene's animations
  40650. * @param toRemove defines the animation to remove
  40651. * @returns the index where the animation was in the animation list
  40652. */
  40653. removeAnimation(toRemove: Animation): number;
  40654. /**
  40655. * Will stop the animation of the given target
  40656. * @param target - the target
  40657. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40658. * @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)
  40659. */
  40660. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40661. /**
  40662. * Removes the given animation group from this scene.
  40663. * @param toRemove The animation group to remove
  40664. * @returns The index of the removed animation group
  40665. */
  40666. removeAnimationGroup(toRemove: AnimationGroup): number;
  40667. /**
  40668. * Removes the given multi-material from this scene.
  40669. * @param toRemove The multi-material to remove
  40670. * @returns The index of the removed multi-material
  40671. */
  40672. removeMultiMaterial(toRemove: MultiMaterial): number;
  40673. /**
  40674. * Removes the given material from this scene.
  40675. * @param toRemove The material to remove
  40676. * @returns The index of the removed material
  40677. */
  40678. removeMaterial(toRemove: Material): number;
  40679. /**
  40680. * Removes the given action manager from this scene.
  40681. * @param toRemove The action manager to remove
  40682. * @returns The index of the removed action manager
  40683. */
  40684. removeActionManager(toRemove: AbstractActionManager): number;
  40685. /**
  40686. * Removes the given texture from this scene.
  40687. * @param toRemove The texture to remove
  40688. * @returns The index of the removed texture
  40689. */
  40690. removeTexture(toRemove: BaseTexture): number;
  40691. /**
  40692. * Adds the given light to this scene
  40693. * @param newLight The light to add
  40694. */
  40695. addLight(newLight: Light): void;
  40696. /**
  40697. * Sorts the list list based on light priorities
  40698. */
  40699. sortLightsByPriority(): void;
  40700. /**
  40701. * Adds the given camera to this scene
  40702. * @param newCamera The camera to add
  40703. */
  40704. addCamera(newCamera: Camera): void;
  40705. /**
  40706. * Adds the given skeleton to this scene
  40707. * @param newSkeleton The skeleton to add
  40708. */
  40709. addSkeleton(newSkeleton: Skeleton): void;
  40710. /**
  40711. * Adds the given particle system to this scene
  40712. * @param newParticleSystem The particle system to add
  40713. */
  40714. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40715. /**
  40716. * Adds the given animation to this scene
  40717. * @param newAnimation The animation to add
  40718. */
  40719. addAnimation(newAnimation: Animation): void;
  40720. /**
  40721. * Adds the given animation group to this scene.
  40722. * @param newAnimationGroup The animation group to add
  40723. */
  40724. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40725. /**
  40726. * Adds the given multi-material to this scene
  40727. * @param newMultiMaterial The multi-material to add
  40728. */
  40729. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40730. /**
  40731. * Adds the given material to this scene
  40732. * @param newMaterial The material to add
  40733. */
  40734. addMaterial(newMaterial: Material): void;
  40735. /**
  40736. * Adds the given morph target to this scene
  40737. * @param newMorphTargetManager The morph target to add
  40738. */
  40739. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40740. /**
  40741. * Adds the given geometry to this scene
  40742. * @param newGeometry The geometry to add
  40743. */
  40744. addGeometry(newGeometry: Geometry): void;
  40745. /**
  40746. * Adds the given action manager to this scene
  40747. * @param newActionManager The action manager to add
  40748. */
  40749. addActionManager(newActionManager: AbstractActionManager): void;
  40750. /**
  40751. * Adds the given texture to this scene.
  40752. * @param newTexture The texture to add
  40753. */
  40754. addTexture(newTexture: BaseTexture): void;
  40755. /**
  40756. * Switch active camera
  40757. * @param newCamera defines the new active camera
  40758. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40759. */
  40760. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40761. /**
  40762. * sets the active camera of the scene using its ID
  40763. * @param id defines the camera's ID
  40764. * @return the new active camera or null if none found.
  40765. */
  40766. setActiveCameraByID(id: string): Nullable<Camera>;
  40767. /**
  40768. * sets the active camera of the scene using its name
  40769. * @param name defines the camera's name
  40770. * @returns the new active camera or null if none found.
  40771. */
  40772. setActiveCameraByName(name: string): Nullable<Camera>;
  40773. /**
  40774. * get an animation group using its name
  40775. * @param name defines the material's name
  40776. * @return the animation group or null if none found.
  40777. */
  40778. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40779. /**
  40780. * Get a material using its unique id
  40781. * @param uniqueId defines the material's unique id
  40782. * @return the material or null if none found.
  40783. */
  40784. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40785. /**
  40786. * get a material using its id
  40787. * @param id defines the material's ID
  40788. * @return the material or null if none found.
  40789. */
  40790. getMaterialByID(id: string): Nullable<Material>;
  40791. /**
  40792. * Gets a the last added material using a given id
  40793. * @param id defines the material's ID
  40794. * @return the last material with the given id or null if none found.
  40795. */
  40796. getLastMaterialByID(id: string): Nullable<Material>;
  40797. /**
  40798. * Gets a material using its name
  40799. * @param name defines the material's name
  40800. * @return the material or null if none found.
  40801. */
  40802. getMaterialByName(name: string): Nullable<Material>;
  40803. /**
  40804. * Get a texture using its unique id
  40805. * @param uniqueId defines the texture's unique id
  40806. * @return the texture or null if none found.
  40807. */
  40808. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40809. /**
  40810. * Gets a camera using its id
  40811. * @param id defines the id to look for
  40812. * @returns the camera or null if not found
  40813. */
  40814. getCameraByID(id: string): Nullable<Camera>;
  40815. /**
  40816. * Gets a camera using its unique id
  40817. * @param uniqueId defines the unique id to look for
  40818. * @returns the camera or null if not found
  40819. */
  40820. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40821. /**
  40822. * Gets a camera using its name
  40823. * @param name defines the camera's name
  40824. * @return the camera or null if none found.
  40825. */
  40826. getCameraByName(name: string): Nullable<Camera>;
  40827. /**
  40828. * Gets a bone using its id
  40829. * @param id defines the bone's id
  40830. * @return the bone or null if not found
  40831. */
  40832. getBoneByID(id: string): Nullable<Bone>;
  40833. /**
  40834. * Gets a bone using its id
  40835. * @param name defines the bone's name
  40836. * @return the bone or null if not found
  40837. */
  40838. getBoneByName(name: string): Nullable<Bone>;
  40839. /**
  40840. * Gets a light node using its name
  40841. * @param name defines the the light's name
  40842. * @return the light or null if none found.
  40843. */
  40844. getLightByName(name: string): Nullable<Light>;
  40845. /**
  40846. * Gets a light node using its id
  40847. * @param id defines the light's id
  40848. * @return the light or null if none found.
  40849. */
  40850. getLightByID(id: string): Nullable<Light>;
  40851. /**
  40852. * Gets a light node using its scene-generated unique ID
  40853. * @param uniqueId defines the light's unique id
  40854. * @return the light or null if none found.
  40855. */
  40856. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40857. /**
  40858. * Gets a particle system by id
  40859. * @param id defines the particle system id
  40860. * @return the corresponding system or null if none found
  40861. */
  40862. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40863. /**
  40864. * Gets a geometry using its ID
  40865. * @param id defines the geometry's id
  40866. * @return the geometry or null if none found.
  40867. */
  40868. getGeometryByID(id: string): Nullable<Geometry>;
  40869. private _getGeometryByUniqueID;
  40870. /**
  40871. * Add a new geometry to this scene
  40872. * @param geometry defines the geometry to be added to the scene.
  40873. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40874. * @return a boolean defining if the geometry was added or not
  40875. */
  40876. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40877. /**
  40878. * Removes an existing geometry
  40879. * @param geometry defines the geometry to be removed from the scene
  40880. * @return a boolean defining if the geometry was removed or not
  40881. */
  40882. removeGeometry(geometry: Geometry): boolean;
  40883. /**
  40884. * Gets the list of geometries attached to the scene
  40885. * @returns an array of Geometry
  40886. */
  40887. getGeometries(): Geometry[];
  40888. /**
  40889. * Gets the first added mesh found of a given ID
  40890. * @param id defines the id to search for
  40891. * @return the mesh found or null if not found at all
  40892. */
  40893. getMeshByID(id: string): Nullable<AbstractMesh>;
  40894. /**
  40895. * Gets a list of meshes using their id
  40896. * @param id defines the id to search for
  40897. * @returns a list of meshes
  40898. */
  40899. getMeshesByID(id: string): Array<AbstractMesh>;
  40900. /**
  40901. * Gets the first added transform node found of a given ID
  40902. * @param id defines the id to search for
  40903. * @return the found transform node or null if not found at all.
  40904. */
  40905. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40906. /**
  40907. * Gets a transform node with its auto-generated unique id
  40908. * @param uniqueId efines the unique id to search for
  40909. * @return the found transform node or null if not found at all.
  40910. */
  40911. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40912. /**
  40913. * Gets a list of transform nodes using their id
  40914. * @param id defines the id to search for
  40915. * @returns a list of transform nodes
  40916. */
  40917. getTransformNodesByID(id: string): Array<TransformNode>;
  40918. /**
  40919. * Gets a mesh with its auto-generated unique id
  40920. * @param uniqueId defines the unique id to search for
  40921. * @return the found mesh or null if not found at all.
  40922. */
  40923. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40924. /**
  40925. * Gets a the last added mesh using a given id
  40926. * @param id defines the id to search for
  40927. * @return the found mesh or null if not found at all.
  40928. */
  40929. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40930. /**
  40931. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40932. * @param id defines the id to search for
  40933. * @return the found node or null if not found at all
  40934. */
  40935. getLastEntryByID(id: string): Nullable<Node>;
  40936. /**
  40937. * Gets a node (Mesh, Camera, Light) using a given id
  40938. * @param id defines the id to search for
  40939. * @return the found node or null if not found at all
  40940. */
  40941. getNodeByID(id: string): Nullable<Node>;
  40942. /**
  40943. * Gets a node (Mesh, Camera, Light) using a given name
  40944. * @param name defines the name to search for
  40945. * @return the found node or null if not found at all.
  40946. */
  40947. getNodeByName(name: string): Nullable<Node>;
  40948. /**
  40949. * Gets a mesh using a given name
  40950. * @param name defines the name to search for
  40951. * @return the found mesh or null if not found at all.
  40952. */
  40953. getMeshByName(name: string): Nullable<AbstractMesh>;
  40954. /**
  40955. * Gets a transform node using a given name
  40956. * @param name defines the name to search for
  40957. * @return the found transform node or null if not found at all.
  40958. */
  40959. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40960. /**
  40961. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40962. * @param id defines the id to search for
  40963. * @return the found skeleton or null if not found at all.
  40964. */
  40965. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40966. /**
  40967. * Gets a skeleton using a given auto generated unique id
  40968. * @param uniqueId defines the unique id to search for
  40969. * @return the found skeleton or null if not found at all.
  40970. */
  40971. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40972. /**
  40973. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40974. * @param id defines the id to search for
  40975. * @return the found skeleton or null if not found at all.
  40976. */
  40977. getSkeletonById(id: string): Nullable<Skeleton>;
  40978. /**
  40979. * Gets a skeleton using a given name
  40980. * @param name defines the name to search for
  40981. * @return the found skeleton or null if not found at all.
  40982. */
  40983. getSkeletonByName(name: string): Nullable<Skeleton>;
  40984. /**
  40985. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40986. * @param id defines the id to search for
  40987. * @return the found morph target manager or null if not found at all.
  40988. */
  40989. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40990. /**
  40991. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40992. * @param id defines the id to search for
  40993. * @return the found morph target or null if not found at all.
  40994. */
  40995. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40996. /**
  40997. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40998. * @param name defines the name to search for
  40999. * @return the found morph target or null if not found at all.
  41000. */
  41001. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41002. /**
  41003. * Gets a boolean indicating if the given mesh is active
  41004. * @param mesh defines the mesh to look for
  41005. * @returns true if the mesh is in the active list
  41006. */
  41007. isActiveMesh(mesh: AbstractMesh): boolean;
  41008. /**
  41009. * Return a unique id as a string which can serve as an identifier for the scene
  41010. */
  41011. get uid(): string;
  41012. /**
  41013. * Add an externaly attached data from its key.
  41014. * This method call will fail and return false, if such key already exists.
  41015. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41016. * @param key the unique key that identifies the data
  41017. * @param data the data object to associate to the key for this Engine instance
  41018. * @return true if no such key were already present and the data was added successfully, false otherwise
  41019. */
  41020. addExternalData<T>(key: string, data: T): boolean;
  41021. /**
  41022. * Get an externaly attached data from its key
  41023. * @param key the unique key that identifies the data
  41024. * @return the associated data, if present (can be null), or undefined if not present
  41025. */
  41026. getExternalData<T>(key: string): Nullable<T>;
  41027. /**
  41028. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41029. * @param key the unique key that identifies the data
  41030. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41031. * @return the associated data, can be null if the factory returned null.
  41032. */
  41033. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41034. /**
  41035. * Remove an externaly attached data from the Engine instance
  41036. * @param key the unique key that identifies the data
  41037. * @return true if the data was successfully removed, false if it doesn't exist
  41038. */
  41039. removeExternalData(key: string): boolean;
  41040. private _evaluateSubMesh;
  41041. /**
  41042. * Clear the processed materials smart array preventing retention point in material dispose.
  41043. */
  41044. freeProcessedMaterials(): void;
  41045. private _preventFreeActiveMeshesAndRenderingGroups;
  41046. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41047. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41048. * when disposing several meshes in a row or a hierarchy of meshes.
  41049. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41050. */
  41051. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41052. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41053. /**
  41054. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41055. */
  41056. freeActiveMeshes(): void;
  41057. /**
  41058. * Clear the info related to rendering groups preventing retention points during dispose.
  41059. */
  41060. freeRenderingGroups(): void;
  41061. /** @hidden */
  41062. _isInIntermediateRendering(): boolean;
  41063. /**
  41064. * Lambda returning the list of potentially active meshes.
  41065. */
  41066. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41067. /**
  41068. * Lambda returning the list of potentially active sub meshes.
  41069. */
  41070. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41071. /**
  41072. * Lambda returning the list of potentially intersecting sub meshes.
  41073. */
  41074. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41075. /**
  41076. * Lambda returning the list of potentially colliding sub meshes.
  41077. */
  41078. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41079. private _activeMeshesFrozen;
  41080. private _skipEvaluateActiveMeshesCompletely;
  41081. /**
  41082. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41083. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41084. * @returns the current scene
  41085. */
  41086. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41087. /**
  41088. * Use this function to restart evaluating active meshes on every frame
  41089. * @returns the current scene
  41090. */
  41091. unfreezeActiveMeshes(): Scene;
  41092. private _evaluateActiveMeshes;
  41093. private _activeMesh;
  41094. /**
  41095. * Update the transform matrix to update from the current active camera
  41096. * @param force defines a boolean used to force the update even if cache is up to date
  41097. */
  41098. updateTransformMatrix(force?: boolean): void;
  41099. private _bindFrameBuffer;
  41100. /** @hidden */
  41101. _allowPostProcessClearColor: boolean;
  41102. /** @hidden */
  41103. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41104. private _processSubCameras;
  41105. private _checkIntersections;
  41106. /** @hidden */
  41107. _advancePhysicsEngineStep(step: number): void;
  41108. /**
  41109. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41110. */
  41111. getDeterministicFrameTime: () => number;
  41112. /** @hidden */
  41113. _animate(): void;
  41114. /** Execute all animations (for a frame) */
  41115. animate(): void;
  41116. /**
  41117. * Render the scene
  41118. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41119. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41120. */
  41121. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41122. /**
  41123. * Freeze all materials
  41124. * A frozen material will not be updatable but should be faster to render
  41125. */
  41126. freezeMaterials(): void;
  41127. /**
  41128. * Unfreeze all materials
  41129. * A frozen material will not be updatable but should be faster to render
  41130. */
  41131. unfreezeMaterials(): void;
  41132. /**
  41133. * Releases all held ressources
  41134. */
  41135. dispose(): void;
  41136. /**
  41137. * Gets if the scene is already disposed
  41138. */
  41139. get isDisposed(): boolean;
  41140. /**
  41141. * Call this function to reduce memory footprint of the scene.
  41142. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41143. */
  41144. clearCachedVertexData(): void;
  41145. /**
  41146. * This function will remove the local cached buffer data from texture.
  41147. * It will save memory but will prevent the texture from being rebuilt
  41148. */
  41149. cleanCachedTextureBuffer(): void;
  41150. /**
  41151. * Get the world extend vectors with an optional filter
  41152. *
  41153. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41154. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41155. */
  41156. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41157. min: Vector3;
  41158. max: Vector3;
  41159. };
  41160. /**
  41161. * Creates a ray that can be used to pick in the scene
  41162. * @param x defines the x coordinate of the origin (on-screen)
  41163. * @param y defines the y coordinate of the origin (on-screen)
  41164. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41165. * @param camera defines the camera to use for the picking
  41166. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41167. * @returns a Ray
  41168. */
  41169. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41170. /**
  41171. * Creates a ray that can be used to pick in the scene
  41172. * @param x defines the x coordinate of the origin (on-screen)
  41173. * @param y defines the y coordinate of the origin (on-screen)
  41174. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41175. * @param result defines the ray where to store the picking ray
  41176. * @param camera defines the camera to use for the picking
  41177. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41178. * @returns the current scene
  41179. */
  41180. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41181. /**
  41182. * Creates a ray that can be used to pick in the scene
  41183. * @param x defines the x coordinate of the origin (on-screen)
  41184. * @param y defines the y coordinate of the origin (on-screen)
  41185. * @param camera defines the camera to use for the picking
  41186. * @returns a Ray
  41187. */
  41188. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41189. /**
  41190. * Creates a ray that can be used to pick in the scene
  41191. * @param x defines the x coordinate of the origin (on-screen)
  41192. * @param y defines the y coordinate of the origin (on-screen)
  41193. * @param result defines the ray where to store the picking ray
  41194. * @param camera defines the camera to use for the picking
  41195. * @returns the current scene
  41196. */
  41197. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41198. /** Launch a ray to try to pick a mesh in the scene
  41199. * @param x position on screen
  41200. * @param y position on screen
  41201. * @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
  41202. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41203. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41204. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41205. * @returns a PickingInfo
  41206. */
  41207. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41208. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41209. * @param x position on screen
  41210. * @param y position on screen
  41211. * @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
  41212. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41213. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41214. * @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)
  41215. */
  41216. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41217. /** Use the given ray to pick a mesh in the scene
  41218. * @param ray The ray to use to pick meshes
  41219. * @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
  41220. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41221. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41222. * @returns a PickingInfo
  41223. */
  41224. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41225. /**
  41226. * Launch a ray to try to pick a mesh in the scene
  41227. * @param x X position on screen
  41228. * @param y Y position on screen
  41229. * @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
  41230. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41231. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41232. * @returns an array of PickingInfo
  41233. */
  41234. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41235. /**
  41236. * Launch a ray to try to pick a mesh in the scene
  41237. * @param ray Ray to use
  41238. * @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
  41239. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41240. * @returns an array of PickingInfo
  41241. */
  41242. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41243. /**
  41244. * Force the value of meshUnderPointer
  41245. * @param mesh defines the mesh to use
  41246. */
  41247. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41248. /**
  41249. * Gets the mesh under the pointer
  41250. * @returns a Mesh or null if no mesh is under the pointer
  41251. */
  41252. getPointerOverMesh(): Nullable<AbstractMesh>;
  41253. /** @hidden */
  41254. _rebuildGeometries(): void;
  41255. /** @hidden */
  41256. _rebuildTextures(): void;
  41257. private _getByTags;
  41258. /**
  41259. * Get a list of meshes by tags
  41260. * @param tagsQuery defines the tags query to use
  41261. * @param forEach defines a predicate used to filter results
  41262. * @returns an array of Mesh
  41263. */
  41264. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41265. /**
  41266. * Get a list of cameras by tags
  41267. * @param tagsQuery defines the tags query to use
  41268. * @param forEach defines a predicate used to filter results
  41269. * @returns an array of Camera
  41270. */
  41271. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41272. /**
  41273. * Get a list of lights by tags
  41274. * @param tagsQuery defines the tags query to use
  41275. * @param forEach defines a predicate used to filter results
  41276. * @returns an array of Light
  41277. */
  41278. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41279. /**
  41280. * Get a list of materials by tags
  41281. * @param tagsQuery defines the tags query to use
  41282. * @param forEach defines a predicate used to filter results
  41283. * @returns an array of Material
  41284. */
  41285. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41286. /**
  41287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41288. * This allowed control for front to back rendering or reversly depending of the special needs.
  41289. *
  41290. * @param renderingGroupId The rendering group id corresponding to its index
  41291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41294. */
  41295. 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;
  41296. /**
  41297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41298. *
  41299. * @param renderingGroupId The rendering group id corresponding to its index
  41300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41303. */
  41304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41305. /**
  41306. * Gets the current auto clear configuration for one rendering group of the rendering
  41307. * manager.
  41308. * @param index the rendering group index to get the information for
  41309. * @returns The auto clear setup for the requested rendering group
  41310. */
  41311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41312. private _blockMaterialDirtyMechanism;
  41313. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41314. get blockMaterialDirtyMechanism(): boolean;
  41315. set blockMaterialDirtyMechanism(value: boolean);
  41316. /**
  41317. * Will flag all materials as dirty to trigger new shader compilation
  41318. * @param flag defines the flag used to specify which material part must be marked as dirty
  41319. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41320. */
  41321. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41322. /** @hidden */
  41323. _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;
  41324. /** @hidden */
  41325. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41326. /** @hidden */
  41327. _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;
  41328. /** @hidden */
  41329. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41330. /** @hidden */
  41331. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41332. /** @hidden */
  41333. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41334. }
  41335. }
  41336. declare module "babylonjs/assetContainer" {
  41337. import { AbstractScene } from "babylonjs/abstractScene";
  41338. import { Scene } from "babylonjs/scene";
  41339. import { Mesh } from "babylonjs/Meshes/mesh";
  41340. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41341. import { Skeleton } from "babylonjs/Bones/skeleton";
  41342. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41343. import { Animatable } from "babylonjs/Animations/animatable";
  41344. import { Nullable } from "babylonjs/types";
  41345. import { Node } from "babylonjs/node";
  41346. /**
  41347. * Set of assets to keep when moving a scene into an asset container.
  41348. */
  41349. export class KeepAssets extends AbstractScene {
  41350. }
  41351. /**
  41352. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41353. */
  41354. export class InstantiatedEntries {
  41355. /**
  41356. * List of new root nodes (eg. nodes with no parent)
  41357. */
  41358. rootNodes: TransformNode[];
  41359. /**
  41360. * List of new skeletons
  41361. */
  41362. skeletons: Skeleton[];
  41363. /**
  41364. * List of new animation groups
  41365. */
  41366. animationGroups: AnimationGroup[];
  41367. }
  41368. /**
  41369. * Container with a set of assets that can be added or removed from a scene.
  41370. */
  41371. export class AssetContainer extends AbstractScene {
  41372. private _wasAddedToScene;
  41373. /**
  41374. * The scene the AssetContainer belongs to.
  41375. */
  41376. scene: Scene;
  41377. /**
  41378. * Instantiates an AssetContainer.
  41379. * @param scene The scene the AssetContainer belongs to.
  41380. */
  41381. constructor(scene: Scene);
  41382. /**
  41383. * Instantiate or clone all meshes and add the new ones to the scene.
  41384. * Skeletons and animation groups will all be cloned
  41385. * @param nameFunction defines an optional function used to get new names for clones
  41386. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41387. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41388. */
  41389. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41390. /**
  41391. * Adds all the assets from the container to the scene.
  41392. */
  41393. addAllToScene(): void;
  41394. /**
  41395. * Removes all the assets in the container from the scene
  41396. */
  41397. removeAllFromScene(): void;
  41398. /**
  41399. * Disposes all the assets in the container
  41400. */
  41401. dispose(): void;
  41402. private _moveAssets;
  41403. /**
  41404. * Removes all the assets contained in the scene and adds them to the container.
  41405. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41406. */
  41407. moveAllFromScene(keepAssets?: KeepAssets): void;
  41408. /**
  41409. * 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.
  41410. * @returns the root mesh
  41411. */
  41412. createRootMesh(): Mesh;
  41413. /**
  41414. * Merge animations (direct and animation groups) from this asset container into a scene
  41415. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41416. * @param animatables set of animatables to retarget to a node from the scene
  41417. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41418. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41419. */
  41420. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41421. }
  41422. }
  41423. declare module "babylonjs/abstractScene" {
  41424. import { Scene } from "babylonjs/scene";
  41425. import { Nullable } from "babylonjs/types";
  41426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41428. import { Geometry } from "babylonjs/Meshes/geometry";
  41429. import { Skeleton } from "babylonjs/Bones/skeleton";
  41430. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41431. import { AssetContainer } from "babylonjs/assetContainer";
  41432. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41433. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41435. import { Material } from "babylonjs/Materials/material";
  41436. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41437. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41438. import { Camera } from "babylonjs/Cameras/camera";
  41439. import { Light } from "babylonjs/Lights/light";
  41440. import { Node } from "babylonjs/node";
  41441. import { Animation } from "babylonjs/Animations/animation";
  41442. /**
  41443. * Defines how the parser contract is defined.
  41444. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41445. */
  41446. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41447. /**
  41448. * Defines how the individual parser contract is defined.
  41449. * These parser can parse an individual asset
  41450. */
  41451. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41452. /**
  41453. * Base class of the scene acting as a container for the different elements composing a scene.
  41454. * This class is dynamically extended by the different components of the scene increasing
  41455. * flexibility and reducing coupling
  41456. */
  41457. export abstract class AbstractScene {
  41458. /**
  41459. * Stores the list of available parsers in the application.
  41460. */
  41461. private static _BabylonFileParsers;
  41462. /**
  41463. * Stores the list of available individual parsers in the application.
  41464. */
  41465. private static _IndividualBabylonFileParsers;
  41466. /**
  41467. * Adds a parser in the list of available ones
  41468. * @param name Defines the name of the parser
  41469. * @param parser Defines the parser to add
  41470. */
  41471. static AddParser(name: string, parser: BabylonFileParser): void;
  41472. /**
  41473. * Gets a general parser from the list of avaialble ones
  41474. * @param name Defines the name of the parser
  41475. * @returns the requested parser or null
  41476. */
  41477. static GetParser(name: string): Nullable<BabylonFileParser>;
  41478. /**
  41479. * Adds n individual parser in the list of available ones
  41480. * @param name Defines the name of the parser
  41481. * @param parser Defines the parser to add
  41482. */
  41483. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41484. /**
  41485. * Gets an individual parser from the list of avaialble ones
  41486. * @param name Defines the name of the parser
  41487. * @returns the requested parser or null
  41488. */
  41489. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41490. /**
  41491. * Parser json data and populate both a scene and its associated container object
  41492. * @param jsonData Defines the data to parse
  41493. * @param scene Defines the scene to parse the data for
  41494. * @param container Defines the container attached to the parsing sequence
  41495. * @param rootUrl Defines the root url of the data
  41496. */
  41497. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41498. /**
  41499. * Gets the list of root nodes (ie. nodes with no parent)
  41500. */
  41501. rootNodes: Node[];
  41502. /** All of the cameras added to this scene
  41503. * @see http://doc.babylonjs.com/babylon101/cameras
  41504. */
  41505. cameras: Camera[];
  41506. /**
  41507. * All of the lights added to this scene
  41508. * @see http://doc.babylonjs.com/babylon101/lights
  41509. */
  41510. lights: Light[];
  41511. /**
  41512. * All of the (abstract) meshes added to this scene
  41513. */
  41514. meshes: AbstractMesh[];
  41515. /**
  41516. * The list of skeletons added to the scene
  41517. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41518. */
  41519. skeletons: Skeleton[];
  41520. /**
  41521. * All of the particle systems added to this scene
  41522. * @see http://doc.babylonjs.com/babylon101/particles
  41523. */
  41524. particleSystems: IParticleSystem[];
  41525. /**
  41526. * Gets a list of Animations associated with the scene
  41527. */
  41528. animations: Animation[];
  41529. /**
  41530. * All of the animation groups added to this scene
  41531. * @see http://doc.babylonjs.com/how_to/group
  41532. */
  41533. animationGroups: AnimationGroup[];
  41534. /**
  41535. * All of the multi-materials added to this scene
  41536. * @see http://doc.babylonjs.com/how_to/multi_materials
  41537. */
  41538. multiMaterials: MultiMaterial[];
  41539. /**
  41540. * All of the materials added to this scene
  41541. * In the context of a Scene, it is not supposed to be modified manually.
  41542. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41543. * Note also that the order of the Material within the array is not significant and might change.
  41544. * @see http://doc.babylonjs.com/babylon101/materials
  41545. */
  41546. materials: Material[];
  41547. /**
  41548. * The list of morph target managers added to the scene
  41549. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41550. */
  41551. morphTargetManagers: MorphTargetManager[];
  41552. /**
  41553. * The list of geometries used in the scene.
  41554. */
  41555. geometries: Geometry[];
  41556. /**
  41557. * All of the tranform nodes added to this scene
  41558. * In the context of a Scene, it is not supposed to be modified manually.
  41559. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41560. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41561. * @see http://doc.babylonjs.com/how_to/transformnode
  41562. */
  41563. transformNodes: TransformNode[];
  41564. /**
  41565. * ActionManagers available on the scene.
  41566. */
  41567. actionManagers: AbstractActionManager[];
  41568. /**
  41569. * Textures to keep.
  41570. */
  41571. textures: BaseTexture[];
  41572. /**
  41573. * Environment texture for the scene
  41574. */
  41575. environmentTexture: Nullable<BaseTexture>;
  41576. /**
  41577. * @returns all meshes, lights, cameras, transformNodes and bones
  41578. */
  41579. getNodes(): Array<Node>;
  41580. }
  41581. }
  41582. declare module "babylonjs/Audio/sound" {
  41583. import { Observable } from "babylonjs/Misc/observable";
  41584. import { Vector3 } from "babylonjs/Maths/math.vector";
  41585. import { Nullable } from "babylonjs/types";
  41586. import { Scene } from "babylonjs/scene";
  41587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41588. /**
  41589. * Interface used to define options for Sound class
  41590. */
  41591. export interface ISoundOptions {
  41592. /**
  41593. * Does the sound autoplay once loaded.
  41594. */
  41595. autoplay?: boolean;
  41596. /**
  41597. * Does the sound loop after it finishes playing once.
  41598. */
  41599. loop?: boolean;
  41600. /**
  41601. * Sound's volume
  41602. */
  41603. volume?: number;
  41604. /**
  41605. * Is it a spatial sound?
  41606. */
  41607. spatialSound?: boolean;
  41608. /**
  41609. * Maximum distance to hear that sound
  41610. */
  41611. maxDistance?: number;
  41612. /**
  41613. * Uses user defined attenuation function
  41614. */
  41615. useCustomAttenuation?: boolean;
  41616. /**
  41617. * Define the roll off factor of spatial sounds.
  41618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41619. */
  41620. rolloffFactor?: number;
  41621. /**
  41622. * Define the reference distance the sound should be heard perfectly.
  41623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41624. */
  41625. refDistance?: number;
  41626. /**
  41627. * Define the distance attenuation model the sound will follow.
  41628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41629. */
  41630. distanceModel?: string;
  41631. /**
  41632. * Defines the playback speed (1 by default)
  41633. */
  41634. playbackRate?: number;
  41635. /**
  41636. * Defines if the sound is from a streaming source
  41637. */
  41638. streaming?: boolean;
  41639. /**
  41640. * Defines an optional length (in seconds) inside the sound file
  41641. */
  41642. length?: number;
  41643. /**
  41644. * Defines an optional offset (in seconds) inside the sound file
  41645. */
  41646. offset?: number;
  41647. /**
  41648. * If true, URLs will not be required to state the audio file codec to use.
  41649. */
  41650. skipCodecCheck?: boolean;
  41651. }
  41652. /**
  41653. * Defines a sound that can be played in the application.
  41654. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41656. */
  41657. export class Sound {
  41658. /**
  41659. * The name of the sound in the scene.
  41660. */
  41661. name: string;
  41662. /**
  41663. * Does the sound autoplay once loaded.
  41664. */
  41665. autoplay: boolean;
  41666. /**
  41667. * Does the sound loop after it finishes playing once.
  41668. */
  41669. loop: boolean;
  41670. /**
  41671. * Does the sound use a custom attenuation curve to simulate the falloff
  41672. * happening when the source gets further away from the camera.
  41673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41674. */
  41675. useCustomAttenuation: boolean;
  41676. /**
  41677. * The sound track id this sound belongs to.
  41678. */
  41679. soundTrackId: number;
  41680. /**
  41681. * Is this sound currently played.
  41682. */
  41683. isPlaying: boolean;
  41684. /**
  41685. * Is this sound currently paused.
  41686. */
  41687. isPaused: boolean;
  41688. /**
  41689. * Does this sound enables spatial sound.
  41690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41691. */
  41692. spatialSound: boolean;
  41693. /**
  41694. * Define the reference distance the sound should be heard perfectly.
  41695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41696. */
  41697. refDistance: number;
  41698. /**
  41699. * Define the roll off factor of spatial sounds.
  41700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41701. */
  41702. rolloffFactor: number;
  41703. /**
  41704. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41706. */
  41707. maxDistance: number;
  41708. /**
  41709. * Define the distance attenuation model the sound will follow.
  41710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41711. */
  41712. distanceModel: string;
  41713. /**
  41714. * @hidden
  41715. * Back Compat
  41716. **/
  41717. onended: () => any;
  41718. /**
  41719. * Gets or sets an object used to store user defined information for the sound.
  41720. */
  41721. metadata: any;
  41722. /**
  41723. * Observable event when the current playing sound finishes.
  41724. */
  41725. onEndedObservable: Observable<Sound>;
  41726. private _panningModel;
  41727. private _playbackRate;
  41728. private _streaming;
  41729. private _startTime;
  41730. private _startOffset;
  41731. private _position;
  41732. /** @hidden */
  41733. _positionInEmitterSpace: boolean;
  41734. private _localDirection;
  41735. private _volume;
  41736. private _isReadyToPlay;
  41737. private _isDirectional;
  41738. private _readyToPlayCallback;
  41739. private _audioBuffer;
  41740. private _soundSource;
  41741. private _streamingSource;
  41742. private _soundPanner;
  41743. private _soundGain;
  41744. private _inputAudioNode;
  41745. private _outputAudioNode;
  41746. private _coneInnerAngle;
  41747. private _coneOuterAngle;
  41748. private _coneOuterGain;
  41749. private _scene;
  41750. private _connectedTransformNode;
  41751. private _customAttenuationFunction;
  41752. private _registerFunc;
  41753. private _isOutputConnected;
  41754. private _htmlAudioElement;
  41755. private _urlType;
  41756. private _length?;
  41757. private _offset?;
  41758. /** @hidden */
  41759. static _SceneComponentInitialization: (scene: Scene) => void;
  41760. /**
  41761. * Create a sound and attach it to a scene
  41762. * @param name Name of your sound
  41763. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41764. * @param scene defines the scene the sound belongs to
  41765. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41766. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41767. */
  41768. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41769. /**
  41770. * Release the sound and its associated resources
  41771. */
  41772. dispose(): void;
  41773. /**
  41774. * Gets if the sounds is ready to be played or not.
  41775. * @returns true if ready, otherwise false
  41776. */
  41777. isReady(): boolean;
  41778. private _soundLoaded;
  41779. /**
  41780. * Sets the data of the sound from an audiobuffer
  41781. * @param audioBuffer The audioBuffer containing the data
  41782. */
  41783. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41784. /**
  41785. * Updates the current sounds options such as maxdistance, loop...
  41786. * @param options A JSON object containing values named as the object properties
  41787. */
  41788. updateOptions(options: ISoundOptions): void;
  41789. private _createSpatialParameters;
  41790. private _updateSpatialParameters;
  41791. /**
  41792. * Switch the panning model to HRTF:
  41793. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41795. */
  41796. switchPanningModelToHRTF(): void;
  41797. /**
  41798. * Switch the panning model to Equal Power:
  41799. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41801. */
  41802. switchPanningModelToEqualPower(): void;
  41803. private _switchPanningModel;
  41804. /**
  41805. * Connect this sound to a sound track audio node like gain...
  41806. * @param soundTrackAudioNode the sound track audio node to connect to
  41807. */
  41808. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41809. /**
  41810. * Transform this sound into a directional source
  41811. * @param coneInnerAngle Size of the inner cone in degree
  41812. * @param coneOuterAngle Size of the outer cone in degree
  41813. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41814. */
  41815. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41816. /**
  41817. * Gets or sets the inner angle for the directional cone.
  41818. */
  41819. get directionalConeInnerAngle(): number;
  41820. /**
  41821. * Gets or sets the inner angle for the directional cone.
  41822. */
  41823. set directionalConeInnerAngle(value: number);
  41824. /**
  41825. * Gets or sets the outer angle for the directional cone.
  41826. */
  41827. get directionalConeOuterAngle(): number;
  41828. /**
  41829. * Gets or sets the outer angle for the directional cone.
  41830. */
  41831. set directionalConeOuterAngle(value: number);
  41832. /**
  41833. * Sets the position of the emitter if spatial sound is enabled
  41834. * @param newPosition Defines the new posisiton
  41835. */
  41836. setPosition(newPosition: Vector3): void;
  41837. /**
  41838. * Sets the local direction of the emitter if spatial sound is enabled
  41839. * @param newLocalDirection Defines the new local direction
  41840. */
  41841. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41842. private _updateDirection;
  41843. /** @hidden */
  41844. updateDistanceFromListener(): void;
  41845. /**
  41846. * Sets a new custom attenuation function for the sound.
  41847. * @param callback Defines the function used for the attenuation
  41848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41849. */
  41850. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41851. /**
  41852. * Play the sound
  41853. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41854. * @param offset (optional) Start the sound at a specific time in seconds
  41855. * @param length (optional) Sound duration (in seconds)
  41856. */
  41857. play(time?: number, offset?: number, length?: number): void;
  41858. private _onended;
  41859. /**
  41860. * Stop the sound
  41861. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41862. */
  41863. stop(time?: number): void;
  41864. /**
  41865. * Put the sound in pause
  41866. */
  41867. pause(): void;
  41868. /**
  41869. * Sets a dedicated volume for this sounds
  41870. * @param newVolume Define the new volume of the sound
  41871. * @param time Define time for gradual change to new volume
  41872. */
  41873. setVolume(newVolume: number, time?: number): void;
  41874. /**
  41875. * Set the sound play back rate
  41876. * @param newPlaybackRate Define the playback rate the sound should be played at
  41877. */
  41878. setPlaybackRate(newPlaybackRate: number): void;
  41879. /**
  41880. * Gets the volume of the sound.
  41881. * @returns the volume of the sound
  41882. */
  41883. getVolume(): number;
  41884. /**
  41885. * Attach the sound to a dedicated mesh
  41886. * @param transformNode The transform node to connect the sound with
  41887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41888. */
  41889. attachToMesh(transformNode: TransformNode): void;
  41890. /**
  41891. * Detach the sound from the previously attached mesh
  41892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41893. */
  41894. detachFromMesh(): void;
  41895. private _onRegisterAfterWorldMatrixUpdate;
  41896. /**
  41897. * Clone the current sound in the scene.
  41898. * @returns the new sound clone
  41899. */
  41900. clone(): Nullable<Sound>;
  41901. /**
  41902. * Gets the current underlying audio buffer containing the data
  41903. * @returns the audio buffer
  41904. */
  41905. getAudioBuffer(): Nullable<AudioBuffer>;
  41906. /**
  41907. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41908. * @returns the source node
  41909. */
  41910. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41911. /**
  41912. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41913. * @returns the gain node
  41914. */
  41915. getSoundGain(): Nullable<GainNode>;
  41916. /**
  41917. * Serializes the Sound in a JSON representation
  41918. * @returns the JSON representation of the sound
  41919. */
  41920. serialize(): any;
  41921. /**
  41922. * Parse a JSON representation of a sound to innstantiate in a given scene
  41923. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41924. * @param scene Define the scene the new parsed sound should be created in
  41925. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41926. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41927. * @returns the newly parsed sound
  41928. */
  41929. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41930. }
  41931. }
  41932. declare module "babylonjs/Actions/directAudioActions" {
  41933. import { Action } from "babylonjs/Actions/action";
  41934. import { Condition } from "babylonjs/Actions/condition";
  41935. import { Sound } from "babylonjs/Audio/sound";
  41936. /**
  41937. * This defines an action helpful to play a defined sound on a triggered action.
  41938. */
  41939. export class PlaySoundAction extends Action {
  41940. private _sound;
  41941. /**
  41942. * Instantiate the action
  41943. * @param triggerOptions defines the trigger options
  41944. * @param sound defines the sound to play
  41945. * @param condition defines the trigger related conditions
  41946. */
  41947. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41948. /** @hidden */
  41949. _prepare(): void;
  41950. /**
  41951. * Execute the action and play the sound.
  41952. */
  41953. execute(): void;
  41954. /**
  41955. * Serializes the actions and its related information.
  41956. * @param parent defines the object to serialize in
  41957. * @returns the serialized object
  41958. */
  41959. serialize(parent: any): any;
  41960. }
  41961. /**
  41962. * This defines an action helpful to stop a defined sound on a triggered action.
  41963. */
  41964. export class StopSoundAction extends Action {
  41965. private _sound;
  41966. /**
  41967. * Instantiate the action
  41968. * @param triggerOptions defines the trigger options
  41969. * @param sound defines the sound to stop
  41970. * @param condition defines the trigger related conditions
  41971. */
  41972. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41973. /** @hidden */
  41974. _prepare(): void;
  41975. /**
  41976. * Execute the action and stop the sound.
  41977. */
  41978. execute(): void;
  41979. /**
  41980. * Serializes the actions and its related information.
  41981. * @param parent defines the object to serialize in
  41982. * @returns the serialized object
  41983. */
  41984. serialize(parent: any): any;
  41985. }
  41986. }
  41987. declare module "babylonjs/Actions/interpolateValueAction" {
  41988. import { Action } from "babylonjs/Actions/action";
  41989. import { Condition } from "babylonjs/Actions/condition";
  41990. import { Observable } from "babylonjs/Misc/observable";
  41991. /**
  41992. * This defines an action responsible to change the value of a property
  41993. * by interpolating between its current value and the newly set one once triggered.
  41994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  41995. */
  41996. export class InterpolateValueAction extends Action {
  41997. /**
  41998. * Defines the path of the property where the value should be interpolated
  41999. */
  42000. propertyPath: string;
  42001. /**
  42002. * Defines the target value at the end of the interpolation.
  42003. */
  42004. value: any;
  42005. /**
  42006. * Defines the time it will take for the property to interpolate to the value.
  42007. */
  42008. duration: number;
  42009. /**
  42010. * Defines if the other scene animations should be stopped when the action has been triggered
  42011. */
  42012. stopOtherAnimations?: boolean;
  42013. /**
  42014. * Defines a callback raised once the interpolation animation has been done.
  42015. */
  42016. onInterpolationDone?: () => void;
  42017. /**
  42018. * Observable triggered once the interpolation animation has been done.
  42019. */
  42020. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42021. private _target;
  42022. private _effectiveTarget;
  42023. private _property;
  42024. /**
  42025. * Instantiate the action
  42026. * @param triggerOptions defines the trigger options
  42027. * @param target defines the object containing the value to interpolate
  42028. * @param propertyPath defines the path to the property in the target object
  42029. * @param value defines the target value at the end of the interpolation
  42030. * @param duration deines the time it will take for the property to interpolate to the value.
  42031. * @param condition defines the trigger related conditions
  42032. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42033. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42034. */
  42035. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42036. /** @hidden */
  42037. _prepare(): void;
  42038. /**
  42039. * Execute the action starts the value interpolation.
  42040. */
  42041. execute(): void;
  42042. /**
  42043. * Serializes the actions and its related information.
  42044. * @param parent defines the object to serialize in
  42045. * @returns the serialized object
  42046. */
  42047. serialize(parent: any): any;
  42048. }
  42049. }
  42050. declare module "babylonjs/Actions/index" {
  42051. export * from "babylonjs/Actions/abstractActionManager";
  42052. export * from "babylonjs/Actions/action";
  42053. export * from "babylonjs/Actions/actionEvent";
  42054. export * from "babylonjs/Actions/actionManager";
  42055. export * from "babylonjs/Actions/condition";
  42056. export * from "babylonjs/Actions/directActions";
  42057. export * from "babylonjs/Actions/directAudioActions";
  42058. export * from "babylonjs/Actions/interpolateValueAction";
  42059. }
  42060. declare module "babylonjs/Animations/index" {
  42061. export * from "babylonjs/Animations/animatable";
  42062. export * from "babylonjs/Animations/animation";
  42063. export * from "babylonjs/Animations/animationGroup";
  42064. export * from "babylonjs/Animations/animationPropertiesOverride";
  42065. export * from "babylonjs/Animations/easing";
  42066. export * from "babylonjs/Animations/runtimeAnimation";
  42067. export * from "babylonjs/Animations/animationEvent";
  42068. export * from "babylonjs/Animations/animationGroup";
  42069. export * from "babylonjs/Animations/animationKey";
  42070. export * from "babylonjs/Animations/animationRange";
  42071. export * from "babylonjs/Animations/animatable.interface";
  42072. }
  42073. declare module "babylonjs/Audio/soundTrack" {
  42074. import { Sound } from "babylonjs/Audio/sound";
  42075. import { Analyser } from "babylonjs/Audio/analyser";
  42076. import { Scene } from "babylonjs/scene";
  42077. /**
  42078. * Options allowed during the creation of a sound track.
  42079. */
  42080. export interface ISoundTrackOptions {
  42081. /**
  42082. * The volume the sound track should take during creation
  42083. */
  42084. volume?: number;
  42085. /**
  42086. * Define if the sound track is the main sound track of the scene
  42087. */
  42088. mainTrack?: boolean;
  42089. }
  42090. /**
  42091. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42092. * It will be also used in a future release to apply effects on a specific track.
  42093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42094. */
  42095. export class SoundTrack {
  42096. /**
  42097. * The unique identifier of the sound track in the scene.
  42098. */
  42099. id: number;
  42100. /**
  42101. * The list of sounds included in the sound track.
  42102. */
  42103. soundCollection: Array<Sound>;
  42104. private _outputAudioNode;
  42105. private _scene;
  42106. private _connectedAnalyser;
  42107. private _options;
  42108. private _isInitialized;
  42109. /**
  42110. * Creates a new sound track.
  42111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42112. * @param scene Define the scene the sound track belongs to
  42113. * @param options
  42114. */
  42115. constructor(scene: Scene, options?: ISoundTrackOptions);
  42116. private _initializeSoundTrackAudioGraph;
  42117. /**
  42118. * Release the sound track and its associated resources
  42119. */
  42120. dispose(): void;
  42121. /**
  42122. * Adds a sound to this sound track
  42123. * @param sound define the cound to add
  42124. * @ignoreNaming
  42125. */
  42126. AddSound(sound: Sound): void;
  42127. /**
  42128. * Removes a sound to this sound track
  42129. * @param sound define the cound to remove
  42130. * @ignoreNaming
  42131. */
  42132. RemoveSound(sound: Sound): void;
  42133. /**
  42134. * Set a global volume for the full sound track.
  42135. * @param newVolume Define the new volume of the sound track
  42136. */
  42137. setVolume(newVolume: number): void;
  42138. /**
  42139. * Switch the panning model to HRTF:
  42140. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42142. */
  42143. switchPanningModelToHRTF(): void;
  42144. /**
  42145. * Switch the panning model to Equal Power:
  42146. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42148. */
  42149. switchPanningModelToEqualPower(): void;
  42150. /**
  42151. * Connect the sound track to an audio analyser allowing some amazing
  42152. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42154. * @param analyser The analyser to connect to the engine
  42155. */
  42156. connectToAnalyser(analyser: Analyser): void;
  42157. }
  42158. }
  42159. declare module "babylonjs/Audio/audioSceneComponent" {
  42160. import { Sound } from "babylonjs/Audio/sound";
  42161. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42162. import { Nullable } from "babylonjs/types";
  42163. import { Vector3 } from "babylonjs/Maths/math.vector";
  42164. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42165. import { Scene } from "babylonjs/scene";
  42166. import { AbstractScene } from "babylonjs/abstractScene";
  42167. import "babylonjs/Audio/audioEngine";
  42168. module "babylonjs/abstractScene" {
  42169. interface AbstractScene {
  42170. /**
  42171. * The list of sounds used in the scene.
  42172. */
  42173. sounds: Nullable<Array<Sound>>;
  42174. }
  42175. }
  42176. module "babylonjs/scene" {
  42177. interface Scene {
  42178. /**
  42179. * @hidden
  42180. * Backing field
  42181. */
  42182. _mainSoundTrack: SoundTrack;
  42183. /**
  42184. * The main sound track played by the scene.
  42185. * It cotains your primary collection of sounds.
  42186. */
  42187. mainSoundTrack: SoundTrack;
  42188. /**
  42189. * The list of sound tracks added to the scene
  42190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42191. */
  42192. soundTracks: Nullable<Array<SoundTrack>>;
  42193. /**
  42194. * Gets a sound using a given name
  42195. * @param name defines the name to search for
  42196. * @return the found sound or null if not found at all.
  42197. */
  42198. getSoundByName(name: string): Nullable<Sound>;
  42199. /**
  42200. * Gets or sets if audio support is enabled
  42201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42202. */
  42203. audioEnabled: boolean;
  42204. /**
  42205. * Gets or sets if audio will be output to headphones
  42206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42207. */
  42208. headphone: boolean;
  42209. /**
  42210. * Gets or sets custom audio listener position provider
  42211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42212. */
  42213. audioListenerPositionProvider: Nullable<() => Vector3>;
  42214. /**
  42215. * Gets or sets a refresh rate when using 3D audio positioning
  42216. */
  42217. audioPositioningRefreshRate: number;
  42218. }
  42219. }
  42220. /**
  42221. * Defines the sound scene component responsible to manage any sounds
  42222. * in a given scene.
  42223. */
  42224. export class AudioSceneComponent implements ISceneSerializableComponent {
  42225. /**
  42226. * The component name helpfull to identify the component in the list of scene components.
  42227. */
  42228. readonly name: string;
  42229. /**
  42230. * The scene the component belongs to.
  42231. */
  42232. scene: Scene;
  42233. private _audioEnabled;
  42234. /**
  42235. * Gets whether audio is enabled or not.
  42236. * Please use related enable/disable method to switch state.
  42237. */
  42238. get audioEnabled(): boolean;
  42239. private _headphone;
  42240. /**
  42241. * Gets whether audio is outputing to headphone or not.
  42242. * Please use the according Switch methods to change output.
  42243. */
  42244. get headphone(): boolean;
  42245. /**
  42246. * Gets or sets a refresh rate when using 3D audio positioning
  42247. */
  42248. audioPositioningRefreshRate: number;
  42249. private _audioListenerPositionProvider;
  42250. /**
  42251. * Gets the current audio listener position provider
  42252. */
  42253. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42254. /**
  42255. * Sets a custom listener position for all sounds in the scene
  42256. * By default, this is the position of the first active camera
  42257. */
  42258. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42259. /**
  42260. * Creates a new instance of the component for the given scene
  42261. * @param scene Defines the scene to register the component in
  42262. */
  42263. constructor(scene: Scene);
  42264. /**
  42265. * Registers the component in a given scene
  42266. */
  42267. register(): void;
  42268. /**
  42269. * Rebuilds the elements related to this component in case of
  42270. * context lost for instance.
  42271. */
  42272. rebuild(): void;
  42273. /**
  42274. * Serializes the component data to the specified json object
  42275. * @param serializationObject The object to serialize to
  42276. */
  42277. serialize(serializationObject: any): void;
  42278. /**
  42279. * Adds all the elements from the container to the scene
  42280. * @param container the container holding the elements
  42281. */
  42282. addFromContainer(container: AbstractScene): void;
  42283. /**
  42284. * Removes all the elements in the container from the scene
  42285. * @param container contains the elements to remove
  42286. * @param dispose if the removed element should be disposed (default: false)
  42287. */
  42288. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42289. /**
  42290. * Disposes the component and the associated ressources.
  42291. */
  42292. dispose(): void;
  42293. /**
  42294. * Disables audio in the associated scene.
  42295. */
  42296. disableAudio(): void;
  42297. /**
  42298. * Enables audio in the associated scene.
  42299. */
  42300. enableAudio(): void;
  42301. /**
  42302. * Switch audio to headphone output.
  42303. */
  42304. switchAudioModeForHeadphones(): void;
  42305. /**
  42306. * Switch audio to normal speakers.
  42307. */
  42308. switchAudioModeForNormalSpeakers(): void;
  42309. private _cachedCameraDirection;
  42310. private _cachedCameraPosition;
  42311. private _lastCheck;
  42312. private _afterRender;
  42313. }
  42314. }
  42315. declare module "babylonjs/Audio/weightedsound" {
  42316. import { Sound } from "babylonjs/Audio/sound";
  42317. /**
  42318. * Wraps one or more Sound objects and selects one with random weight for playback.
  42319. */
  42320. export class WeightedSound {
  42321. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42322. loop: boolean;
  42323. private _coneInnerAngle;
  42324. private _coneOuterAngle;
  42325. private _volume;
  42326. /** A Sound is currently playing. */
  42327. isPlaying: boolean;
  42328. /** A Sound is currently paused. */
  42329. isPaused: boolean;
  42330. private _sounds;
  42331. private _weights;
  42332. private _currentIndex?;
  42333. /**
  42334. * Creates a new WeightedSound from the list of sounds given.
  42335. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42336. * @param sounds Array of Sounds that will be selected from.
  42337. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42338. */
  42339. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42340. /**
  42341. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42342. */
  42343. get directionalConeInnerAngle(): number;
  42344. /**
  42345. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42346. */
  42347. set directionalConeInnerAngle(value: number);
  42348. /**
  42349. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42350. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42351. */
  42352. get directionalConeOuterAngle(): number;
  42353. /**
  42354. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42355. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42356. */
  42357. set directionalConeOuterAngle(value: number);
  42358. /**
  42359. * Playback volume.
  42360. */
  42361. get volume(): number;
  42362. /**
  42363. * Playback volume.
  42364. */
  42365. set volume(value: number);
  42366. private _onended;
  42367. /**
  42368. * Suspend playback
  42369. */
  42370. pause(): void;
  42371. /**
  42372. * Stop playback
  42373. */
  42374. stop(): void;
  42375. /**
  42376. * Start playback.
  42377. * @param startOffset Position the clip head at a specific time in seconds.
  42378. */
  42379. play(startOffset?: number): void;
  42380. }
  42381. }
  42382. declare module "babylonjs/Audio/index" {
  42383. export * from "babylonjs/Audio/analyser";
  42384. export * from "babylonjs/Audio/audioEngine";
  42385. export * from "babylonjs/Audio/audioSceneComponent";
  42386. export * from "babylonjs/Audio/sound";
  42387. export * from "babylonjs/Audio/soundTrack";
  42388. export * from "babylonjs/Audio/weightedsound";
  42389. }
  42390. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42391. import { Behavior } from "babylonjs/Behaviors/behavior";
  42392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42393. import { BackEase } from "babylonjs/Animations/easing";
  42394. /**
  42395. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42397. */
  42398. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42399. /**
  42400. * Gets the name of the behavior.
  42401. */
  42402. get name(): string;
  42403. /**
  42404. * The easing function used by animations
  42405. */
  42406. static EasingFunction: BackEase;
  42407. /**
  42408. * The easing mode used by animations
  42409. */
  42410. static EasingMode: number;
  42411. /**
  42412. * The duration of the animation, in milliseconds
  42413. */
  42414. transitionDuration: number;
  42415. /**
  42416. * Length of the distance animated by the transition when lower radius is reached
  42417. */
  42418. lowerRadiusTransitionRange: number;
  42419. /**
  42420. * Length of the distance animated by the transition when upper radius is reached
  42421. */
  42422. upperRadiusTransitionRange: number;
  42423. private _autoTransitionRange;
  42424. /**
  42425. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42426. */
  42427. get autoTransitionRange(): boolean;
  42428. /**
  42429. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42430. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42431. */
  42432. set autoTransitionRange(value: boolean);
  42433. private _attachedCamera;
  42434. private _onAfterCheckInputsObserver;
  42435. private _onMeshTargetChangedObserver;
  42436. /**
  42437. * Initializes the behavior.
  42438. */
  42439. init(): void;
  42440. /**
  42441. * Attaches the behavior to its arc rotate camera.
  42442. * @param camera Defines the camera to attach the behavior to
  42443. */
  42444. attach(camera: ArcRotateCamera): void;
  42445. /**
  42446. * Detaches the behavior from its current arc rotate camera.
  42447. */
  42448. detach(): void;
  42449. private _radiusIsAnimating;
  42450. private _radiusBounceTransition;
  42451. private _animatables;
  42452. private _cachedWheelPrecision;
  42453. /**
  42454. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42455. * @param radiusLimit The limit to check against.
  42456. * @return Bool to indicate if at limit.
  42457. */
  42458. private _isRadiusAtLimit;
  42459. /**
  42460. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42461. * @param radiusDelta The delta by which to animate to. Can be negative.
  42462. */
  42463. private _applyBoundRadiusAnimation;
  42464. /**
  42465. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42466. */
  42467. protected _clearAnimationLocks(): void;
  42468. /**
  42469. * Stops and removes all animations that have been applied to the camera
  42470. */
  42471. stopAllAnimations(): void;
  42472. }
  42473. }
  42474. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42475. import { Behavior } from "babylonjs/Behaviors/behavior";
  42476. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42477. import { ExponentialEase } from "babylonjs/Animations/easing";
  42478. import { Nullable } from "babylonjs/types";
  42479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42480. import { Vector3 } from "babylonjs/Maths/math.vector";
  42481. /**
  42482. * 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.
  42483. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42484. */
  42485. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42486. /**
  42487. * Gets the name of the behavior.
  42488. */
  42489. get name(): string;
  42490. private _mode;
  42491. private _radiusScale;
  42492. private _positionScale;
  42493. private _defaultElevation;
  42494. private _elevationReturnTime;
  42495. private _elevationReturnWaitTime;
  42496. private _zoomStopsAnimation;
  42497. private _framingTime;
  42498. /**
  42499. * The easing function used by animations
  42500. */
  42501. static EasingFunction: ExponentialEase;
  42502. /**
  42503. * The easing mode used by animations
  42504. */
  42505. static EasingMode: number;
  42506. /**
  42507. * Sets the current mode used by the behavior
  42508. */
  42509. set mode(mode: number);
  42510. /**
  42511. * Gets current mode used by the behavior.
  42512. */
  42513. get mode(): number;
  42514. /**
  42515. * Sets the scale applied to the radius (1 by default)
  42516. */
  42517. set radiusScale(radius: number);
  42518. /**
  42519. * Gets the scale applied to the radius
  42520. */
  42521. get radiusScale(): number;
  42522. /**
  42523. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42524. */
  42525. set positionScale(scale: number);
  42526. /**
  42527. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42528. */
  42529. get positionScale(): number;
  42530. /**
  42531. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42532. * behaviour is triggered, in radians.
  42533. */
  42534. set defaultElevation(elevation: number);
  42535. /**
  42536. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42537. * behaviour is triggered, in radians.
  42538. */
  42539. get defaultElevation(): number;
  42540. /**
  42541. * Sets the time (in milliseconds) taken to return to the default beta position.
  42542. * Negative value indicates camera should not return to default.
  42543. */
  42544. set elevationReturnTime(speed: number);
  42545. /**
  42546. * Gets the time (in milliseconds) taken to return to the default beta position.
  42547. * Negative value indicates camera should not return to default.
  42548. */
  42549. get elevationReturnTime(): number;
  42550. /**
  42551. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42552. */
  42553. set elevationReturnWaitTime(time: number);
  42554. /**
  42555. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42556. */
  42557. get elevationReturnWaitTime(): number;
  42558. /**
  42559. * Sets the flag that indicates if user zooming should stop animation.
  42560. */
  42561. set zoomStopsAnimation(flag: boolean);
  42562. /**
  42563. * Gets the flag that indicates if user zooming should stop animation.
  42564. */
  42565. get zoomStopsAnimation(): boolean;
  42566. /**
  42567. * Sets the transition time when framing the mesh, in milliseconds
  42568. */
  42569. set framingTime(time: number);
  42570. /**
  42571. * Gets the transition time when framing the mesh, in milliseconds
  42572. */
  42573. get framingTime(): number;
  42574. /**
  42575. * Define if the behavior should automatically change the configured
  42576. * camera limits and sensibilities.
  42577. */
  42578. autoCorrectCameraLimitsAndSensibility: boolean;
  42579. private _onPrePointerObservableObserver;
  42580. private _onAfterCheckInputsObserver;
  42581. private _onMeshTargetChangedObserver;
  42582. private _attachedCamera;
  42583. private _isPointerDown;
  42584. private _lastInteractionTime;
  42585. /**
  42586. * Initializes the behavior.
  42587. */
  42588. init(): void;
  42589. /**
  42590. * Attaches the behavior to its arc rotate camera.
  42591. * @param camera Defines the camera to attach the behavior to
  42592. */
  42593. attach(camera: ArcRotateCamera): void;
  42594. /**
  42595. * Detaches the behavior from its current arc rotate camera.
  42596. */
  42597. detach(): void;
  42598. private _animatables;
  42599. private _betaIsAnimating;
  42600. private _betaTransition;
  42601. private _radiusTransition;
  42602. private _vectorTransition;
  42603. /**
  42604. * Targets the given mesh and updates zoom level accordingly.
  42605. * @param mesh The mesh to target.
  42606. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42607. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42608. */
  42609. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42610. /**
  42611. * Targets the given mesh with its children and updates zoom level accordingly.
  42612. * @param mesh The mesh to target.
  42613. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42614. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42615. */
  42616. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42617. /**
  42618. * Targets the given meshes with their children and updates zoom level accordingly.
  42619. * @param meshes The mesh to target.
  42620. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42621. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42622. */
  42623. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42624. /**
  42625. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42626. * @param minimumWorld Determines the smaller position of the bounding box extend
  42627. * @param maximumWorld Determines the bigger position of the bounding box extend
  42628. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42629. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42630. */
  42631. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42632. /**
  42633. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42634. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42635. * frustum width.
  42636. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42637. * to fully enclose the mesh in the viewing frustum.
  42638. */
  42639. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42640. /**
  42641. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42642. * is automatically returned to its default position (expected to be above ground plane).
  42643. */
  42644. private _maintainCameraAboveGround;
  42645. /**
  42646. * Returns the frustum slope based on the canvas ratio and camera FOV
  42647. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42648. */
  42649. private _getFrustumSlope;
  42650. /**
  42651. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42652. */
  42653. private _clearAnimationLocks;
  42654. /**
  42655. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42656. */
  42657. private _applyUserInteraction;
  42658. /**
  42659. * Stops and removes all animations that have been applied to the camera
  42660. */
  42661. stopAllAnimations(): void;
  42662. /**
  42663. * Gets a value indicating if the user is moving the camera
  42664. */
  42665. get isUserIsMoving(): boolean;
  42666. /**
  42667. * The camera can move all the way towards the mesh.
  42668. */
  42669. static IgnoreBoundsSizeMode: number;
  42670. /**
  42671. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42672. */
  42673. static FitFrustumSidesMode: number;
  42674. }
  42675. }
  42676. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42677. import { Nullable } from "babylonjs/types";
  42678. import { Camera } from "babylonjs/Cameras/camera";
  42679. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42680. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42681. /**
  42682. * Base class for Camera Pointer Inputs.
  42683. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42684. * for example usage.
  42685. */
  42686. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42687. /**
  42688. * Defines the camera the input is attached to.
  42689. */
  42690. abstract camera: Camera;
  42691. /**
  42692. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42693. */
  42694. protected _altKey: boolean;
  42695. protected _ctrlKey: boolean;
  42696. protected _metaKey: boolean;
  42697. protected _shiftKey: boolean;
  42698. /**
  42699. * Which mouse buttons were pressed at time of last mouse event.
  42700. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42701. */
  42702. protected _buttonsPressed: number;
  42703. /**
  42704. * Defines the buttons associated with the input to handle camera move.
  42705. */
  42706. buttons: number[];
  42707. /**
  42708. * Attach the input controls to a specific dom element to get the input from.
  42709. * @param element Defines the element the controls should be listened from
  42710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42711. */
  42712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42713. /**
  42714. * Detach the current controls from the specified dom element.
  42715. * @param element Defines the element to stop listening the inputs from
  42716. */
  42717. detachControl(element: Nullable<HTMLElement>): void;
  42718. /**
  42719. * Gets the class name of the current input.
  42720. * @returns the class name
  42721. */
  42722. getClassName(): string;
  42723. /**
  42724. * Get the friendly name associated with the input class.
  42725. * @returns the input friendly name
  42726. */
  42727. getSimpleName(): string;
  42728. /**
  42729. * Called on pointer POINTERDOUBLETAP event.
  42730. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42731. */
  42732. protected onDoubleTap(type: string): void;
  42733. /**
  42734. * Called on pointer POINTERMOVE event if only a single touch is active.
  42735. * Override this method to provide functionality.
  42736. */
  42737. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42738. /**
  42739. * Called on pointer POINTERMOVE event if multiple touches are active.
  42740. * Override this method to provide functionality.
  42741. */
  42742. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42743. /**
  42744. * Called on JS contextmenu event.
  42745. * Override this method to provide functionality.
  42746. */
  42747. protected onContextMenu(evt: PointerEvent): void;
  42748. /**
  42749. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42750. * press.
  42751. * Override this method to provide functionality.
  42752. */
  42753. protected onButtonDown(evt: PointerEvent): void;
  42754. /**
  42755. * Called each time a new POINTERUP event occurs. Ie, for each button
  42756. * release.
  42757. * Override this method to provide functionality.
  42758. */
  42759. protected onButtonUp(evt: PointerEvent): void;
  42760. /**
  42761. * Called when window becomes inactive.
  42762. * Override this method to provide functionality.
  42763. */
  42764. protected onLostFocus(): void;
  42765. private _pointerInput;
  42766. private _observer;
  42767. private _onLostFocus;
  42768. private pointA;
  42769. private pointB;
  42770. }
  42771. }
  42772. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42773. import { Nullable } from "babylonjs/types";
  42774. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42775. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42776. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42777. /**
  42778. * Manage the pointers inputs to control an arc rotate camera.
  42779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42780. */
  42781. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42782. /**
  42783. * Defines the camera the input is attached to.
  42784. */
  42785. camera: ArcRotateCamera;
  42786. /**
  42787. * Gets the class name of the current input.
  42788. * @returns the class name
  42789. */
  42790. getClassName(): string;
  42791. /**
  42792. * Defines the buttons associated with the input to handle camera move.
  42793. */
  42794. buttons: number[];
  42795. /**
  42796. * Defines the pointer angular sensibility along the X axis or how fast is
  42797. * the camera rotating.
  42798. */
  42799. angularSensibilityX: number;
  42800. /**
  42801. * Defines the pointer angular sensibility along the Y axis or how fast is
  42802. * the camera rotating.
  42803. */
  42804. angularSensibilityY: number;
  42805. /**
  42806. * Defines the pointer pinch precision or how fast is the camera zooming.
  42807. */
  42808. pinchPrecision: number;
  42809. /**
  42810. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42811. * from 0.
  42812. * It defines the percentage of current camera.radius to use as delta when
  42813. * pinch zoom is used.
  42814. */
  42815. pinchDeltaPercentage: number;
  42816. /**
  42817. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42818. * that any object in the plane at the camera's target point will scale
  42819. * perfectly with finger motion.
  42820. * Overrides pinchDeltaPercentage and pinchPrecision.
  42821. */
  42822. useNaturalPinchZoom: boolean;
  42823. /**
  42824. * Defines the pointer panning sensibility or how fast is the camera moving.
  42825. */
  42826. panningSensibility: number;
  42827. /**
  42828. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42829. */
  42830. multiTouchPanning: boolean;
  42831. /**
  42832. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42833. * zoom (pinch) through multitouch.
  42834. */
  42835. multiTouchPanAndZoom: boolean;
  42836. /**
  42837. * Revers pinch action direction.
  42838. */
  42839. pinchInwards: boolean;
  42840. private _isPanClick;
  42841. private _twoFingerActivityCount;
  42842. private _isPinching;
  42843. /**
  42844. * Called on pointer POINTERMOVE event if only a single touch is active.
  42845. */
  42846. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42847. /**
  42848. * Called on pointer POINTERDOUBLETAP event.
  42849. */
  42850. protected onDoubleTap(type: string): void;
  42851. /**
  42852. * Called on pointer POINTERMOVE event if multiple touches are active.
  42853. */
  42854. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42855. /**
  42856. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42857. * press.
  42858. */
  42859. protected onButtonDown(evt: PointerEvent): void;
  42860. /**
  42861. * Called each time a new POINTERUP event occurs. Ie, for each button
  42862. * release.
  42863. */
  42864. protected onButtonUp(evt: PointerEvent): void;
  42865. /**
  42866. * Called when window becomes inactive.
  42867. */
  42868. protected onLostFocus(): void;
  42869. }
  42870. }
  42871. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  42872. import { Nullable } from "babylonjs/types";
  42873. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42874. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42875. /**
  42876. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42878. */
  42879. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42880. /**
  42881. * Defines the camera the input is attached to.
  42882. */
  42883. camera: ArcRotateCamera;
  42884. /**
  42885. * Defines the list of key codes associated with the up action (increase alpha)
  42886. */
  42887. keysUp: number[];
  42888. /**
  42889. * Defines the list of key codes associated with the down action (decrease alpha)
  42890. */
  42891. keysDown: number[];
  42892. /**
  42893. * Defines the list of key codes associated with the left action (increase beta)
  42894. */
  42895. keysLeft: number[];
  42896. /**
  42897. * Defines the list of key codes associated with the right action (decrease beta)
  42898. */
  42899. keysRight: number[];
  42900. /**
  42901. * Defines the list of key codes associated with the reset action.
  42902. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42903. */
  42904. keysReset: number[];
  42905. /**
  42906. * Defines the panning sensibility of the inputs.
  42907. * (How fast is the camera panning)
  42908. */
  42909. panningSensibility: number;
  42910. /**
  42911. * Defines the zooming sensibility of the inputs.
  42912. * (How fast is the camera zooming)
  42913. */
  42914. zoomingSensibility: number;
  42915. /**
  42916. * Defines whether maintaining the alt key down switch the movement mode from
  42917. * orientation to zoom.
  42918. */
  42919. useAltToZoom: boolean;
  42920. /**
  42921. * Rotation speed of the camera
  42922. */
  42923. angularSpeed: number;
  42924. private _keys;
  42925. private _ctrlPressed;
  42926. private _altPressed;
  42927. private _onCanvasBlurObserver;
  42928. private _onKeyboardObserver;
  42929. private _engine;
  42930. private _scene;
  42931. /**
  42932. * Attach the input controls to a specific dom element to get the input from.
  42933. * @param element Defines the element the controls should be listened from
  42934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42935. */
  42936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42937. /**
  42938. * Detach the current controls from the specified dom element.
  42939. * @param element Defines the element to stop listening the inputs from
  42940. */
  42941. detachControl(element: Nullable<HTMLElement>): void;
  42942. /**
  42943. * Update the current camera state depending on the inputs that have been used this frame.
  42944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42945. */
  42946. checkInputs(): void;
  42947. /**
  42948. * Gets the class name of the current intput.
  42949. * @returns the class name
  42950. */
  42951. getClassName(): string;
  42952. /**
  42953. * Get the friendly name associated with the input class.
  42954. * @returns the input friendly name
  42955. */
  42956. getSimpleName(): string;
  42957. }
  42958. }
  42959. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  42960. import { Nullable } from "babylonjs/types";
  42961. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42963. /**
  42964. * Manage the mouse wheel inputs to control an arc rotate camera.
  42965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42966. */
  42967. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42968. /**
  42969. * Defines the camera the input is attached to.
  42970. */
  42971. camera: ArcRotateCamera;
  42972. /**
  42973. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42974. */
  42975. wheelPrecision: number;
  42976. /**
  42977. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42978. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42979. */
  42980. wheelDeltaPercentage: number;
  42981. private _wheel;
  42982. private _observer;
  42983. private computeDeltaFromMouseWheelLegacyEvent;
  42984. /**
  42985. * Attach the input controls to a specific dom element to get the input from.
  42986. * @param element Defines the element the controls should be listened from
  42987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42988. */
  42989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42990. /**
  42991. * Detach the current controls from the specified dom element.
  42992. * @param element Defines the element to stop listening the inputs from
  42993. */
  42994. detachControl(element: Nullable<HTMLElement>): void;
  42995. /**
  42996. * Gets the class name of the current intput.
  42997. * @returns the class name
  42998. */
  42999. getClassName(): string;
  43000. /**
  43001. * Get the friendly name associated with the input class.
  43002. * @returns the input friendly name
  43003. */
  43004. getSimpleName(): string;
  43005. }
  43006. }
  43007. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43008. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43009. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43010. /**
  43011. * Default Inputs manager for the ArcRotateCamera.
  43012. * It groups all the default supported inputs for ease of use.
  43013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43014. */
  43015. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43016. /**
  43017. * Instantiates a new ArcRotateCameraInputsManager.
  43018. * @param camera Defines the camera the inputs belong to
  43019. */
  43020. constructor(camera: ArcRotateCamera);
  43021. /**
  43022. * Add mouse wheel input support to the input manager.
  43023. * @returns the current input manager
  43024. */
  43025. addMouseWheel(): ArcRotateCameraInputsManager;
  43026. /**
  43027. * Add pointers input support to the input manager.
  43028. * @returns the current input manager
  43029. */
  43030. addPointers(): ArcRotateCameraInputsManager;
  43031. /**
  43032. * Add keyboard input support to the input manager.
  43033. * @returns the current input manager
  43034. */
  43035. addKeyboard(): ArcRotateCameraInputsManager;
  43036. }
  43037. }
  43038. declare module "babylonjs/Cameras/arcRotateCamera" {
  43039. import { Observable } from "babylonjs/Misc/observable";
  43040. import { Nullable } from "babylonjs/types";
  43041. import { Scene } from "babylonjs/scene";
  43042. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43044. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43045. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43046. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43047. import { Camera } from "babylonjs/Cameras/camera";
  43048. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43049. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43050. import { Collider } from "babylonjs/Collisions/collider";
  43051. /**
  43052. * This represents an orbital type of camera.
  43053. *
  43054. * 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.
  43055. * 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.
  43056. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43057. */
  43058. export class ArcRotateCamera extends TargetCamera {
  43059. /**
  43060. * Defines the rotation angle of the camera along the longitudinal axis.
  43061. */
  43062. alpha: number;
  43063. /**
  43064. * Defines the rotation angle of the camera along the latitudinal axis.
  43065. */
  43066. beta: number;
  43067. /**
  43068. * Defines the radius of the camera from it s target point.
  43069. */
  43070. radius: number;
  43071. protected _target: Vector3;
  43072. protected _targetHost: Nullable<AbstractMesh>;
  43073. /**
  43074. * Defines the target point of the camera.
  43075. * The camera looks towards it form the radius distance.
  43076. */
  43077. get target(): Vector3;
  43078. set target(value: Vector3);
  43079. /**
  43080. * Define the current local position of the camera in the scene
  43081. */
  43082. get position(): Vector3;
  43083. set position(newPosition: Vector3);
  43084. protected _upVector: Vector3;
  43085. protected _upToYMatrix: Matrix;
  43086. protected _YToUpMatrix: Matrix;
  43087. /**
  43088. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43089. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43090. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43091. */
  43092. set upVector(vec: Vector3);
  43093. get upVector(): Vector3;
  43094. /**
  43095. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43096. */
  43097. setMatUp(): void;
  43098. /**
  43099. * Current inertia value on the longitudinal axis.
  43100. * The bigger this number the longer it will take for the camera to stop.
  43101. */
  43102. inertialAlphaOffset: number;
  43103. /**
  43104. * Current inertia value on the latitudinal axis.
  43105. * The bigger this number the longer it will take for the camera to stop.
  43106. */
  43107. inertialBetaOffset: number;
  43108. /**
  43109. * Current inertia value on the radius axis.
  43110. * The bigger this number the longer it will take for the camera to stop.
  43111. */
  43112. inertialRadiusOffset: number;
  43113. /**
  43114. * Minimum allowed angle on the longitudinal axis.
  43115. * This can help limiting how the Camera is able to move in the scene.
  43116. */
  43117. lowerAlphaLimit: Nullable<number>;
  43118. /**
  43119. * Maximum allowed angle on the longitudinal axis.
  43120. * This can help limiting how the Camera is able to move in the scene.
  43121. */
  43122. upperAlphaLimit: Nullable<number>;
  43123. /**
  43124. * Minimum allowed angle on the latitudinal axis.
  43125. * This can help limiting how the Camera is able to move in the scene.
  43126. */
  43127. lowerBetaLimit: number;
  43128. /**
  43129. * Maximum allowed angle on the latitudinal axis.
  43130. * This can help limiting how the Camera is able to move in the scene.
  43131. */
  43132. upperBetaLimit: number;
  43133. /**
  43134. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43135. * This can help limiting how the Camera is able to move in the scene.
  43136. */
  43137. lowerRadiusLimit: Nullable<number>;
  43138. /**
  43139. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43140. * This can help limiting how the Camera is able to move in the scene.
  43141. */
  43142. upperRadiusLimit: Nullable<number>;
  43143. /**
  43144. * Defines the current inertia value used during panning of the camera along the X axis.
  43145. */
  43146. inertialPanningX: number;
  43147. /**
  43148. * Defines the current inertia value used during panning of the camera along the Y axis.
  43149. */
  43150. inertialPanningY: number;
  43151. /**
  43152. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43153. * Basically if your fingers moves away from more than this distance you will be considered
  43154. * in pinch mode.
  43155. */
  43156. pinchToPanMaxDistance: number;
  43157. /**
  43158. * Defines the maximum distance the camera can pan.
  43159. * This could help keeping the cammera always in your scene.
  43160. */
  43161. panningDistanceLimit: Nullable<number>;
  43162. /**
  43163. * Defines the target of the camera before paning.
  43164. */
  43165. panningOriginTarget: Vector3;
  43166. /**
  43167. * Defines the value of the inertia used during panning.
  43168. * 0 would mean stop inertia and one would mean no decelleration at all.
  43169. */
  43170. panningInertia: number;
  43171. /**
  43172. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43173. */
  43174. get angularSensibilityX(): number;
  43175. set angularSensibilityX(value: number);
  43176. /**
  43177. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43178. */
  43179. get angularSensibilityY(): number;
  43180. set angularSensibilityY(value: number);
  43181. /**
  43182. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43183. */
  43184. get pinchPrecision(): number;
  43185. set pinchPrecision(value: number);
  43186. /**
  43187. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43188. * It will be used instead of pinchDeltaPrecision if different from 0.
  43189. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43190. */
  43191. get pinchDeltaPercentage(): number;
  43192. set pinchDeltaPercentage(value: number);
  43193. /**
  43194. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43195. * and pinch delta percentage.
  43196. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43197. * that any object in the plane at the camera's target point will scale
  43198. * perfectly with finger motion.
  43199. */
  43200. get useNaturalPinchZoom(): boolean;
  43201. set useNaturalPinchZoom(value: boolean);
  43202. /**
  43203. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43204. */
  43205. get panningSensibility(): number;
  43206. set panningSensibility(value: number);
  43207. /**
  43208. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43209. */
  43210. get keysUp(): number[];
  43211. set keysUp(value: number[]);
  43212. /**
  43213. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43214. */
  43215. get keysDown(): number[];
  43216. set keysDown(value: number[]);
  43217. /**
  43218. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43219. */
  43220. get keysLeft(): number[];
  43221. set keysLeft(value: number[]);
  43222. /**
  43223. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43224. */
  43225. get keysRight(): number[];
  43226. set keysRight(value: number[]);
  43227. /**
  43228. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43229. */
  43230. get wheelPrecision(): number;
  43231. set wheelPrecision(value: number);
  43232. /**
  43233. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43234. * It will be used instead of pinchDeltaPrecision if different from 0.
  43235. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43236. */
  43237. get wheelDeltaPercentage(): number;
  43238. set wheelDeltaPercentage(value: number);
  43239. /**
  43240. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43241. */
  43242. zoomOnFactor: number;
  43243. /**
  43244. * Defines a screen offset for the camera position.
  43245. */
  43246. targetScreenOffset: Vector2;
  43247. /**
  43248. * Allows the camera to be completely reversed.
  43249. * If false the camera can not arrive upside down.
  43250. */
  43251. allowUpsideDown: boolean;
  43252. /**
  43253. * Define if double tap/click is used to restore the previously saved state of the camera.
  43254. */
  43255. useInputToRestoreState: boolean;
  43256. /** @hidden */
  43257. _viewMatrix: Matrix;
  43258. /** @hidden */
  43259. _useCtrlForPanning: boolean;
  43260. /** @hidden */
  43261. _panningMouseButton: number;
  43262. /**
  43263. * Defines the input associated to the camera.
  43264. */
  43265. inputs: ArcRotateCameraInputsManager;
  43266. /** @hidden */
  43267. _reset: () => void;
  43268. /**
  43269. * Defines the allowed panning axis.
  43270. */
  43271. panningAxis: Vector3;
  43272. protected _localDirection: Vector3;
  43273. protected _transformedDirection: Vector3;
  43274. private _bouncingBehavior;
  43275. /**
  43276. * Gets the bouncing behavior of the camera if it has been enabled.
  43277. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43278. */
  43279. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43280. /**
  43281. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43282. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43283. */
  43284. get useBouncingBehavior(): boolean;
  43285. set useBouncingBehavior(value: boolean);
  43286. private _framingBehavior;
  43287. /**
  43288. * Gets the framing behavior of the camera if it has been enabled.
  43289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43290. */
  43291. get framingBehavior(): Nullable<FramingBehavior>;
  43292. /**
  43293. * Defines if the framing behavior of the camera is enabled on the camera.
  43294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43295. */
  43296. get useFramingBehavior(): boolean;
  43297. set useFramingBehavior(value: boolean);
  43298. private _autoRotationBehavior;
  43299. /**
  43300. * Gets the auto rotation behavior of the camera if it has been enabled.
  43301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43302. */
  43303. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43304. /**
  43305. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43306. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43307. */
  43308. get useAutoRotationBehavior(): boolean;
  43309. set useAutoRotationBehavior(value: boolean);
  43310. /**
  43311. * Observable triggered when the mesh target has been changed on the camera.
  43312. */
  43313. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43314. /**
  43315. * Event raised when the camera is colliding with a mesh.
  43316. */
  43317. onCollide: (collidedMesh: AbstractMesh) => void;
  43318. /**
  43319. * Defines whether the camera should check collision with the objects oh the scene.
  43320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43321. */
  43322. checkCollisions: boolean;
  43323. /**
  43324. * Defines the collision radius of the camera.
  43325. * This simulates a sphere around the camera.
  43326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43327. */
  43328. collisionRadius: Vector3;
  43329. protected _collider: Collider;
  43330. protected _previousPosition: Vector3;
  43331. protected _collisionVelocity: Vector3;
  43332. protected _newPosition: Vector3;
  43333. protected _previousAlpha: number;
  43334. protected _previousBeta: number;
  43335. protected _previousRadius: number;
  43336. protected _collisionTriggered: boolean;
  43337. protected _targetBoundingCenter: Nullable<Vector3>;
  43338. private _computationVector;
  43339. /**
  43340. * Instantiates a new ArcRotateCamera in a given scene
  43341. * @param name Defines the name of the camera
  43342. * @param alpha Defines the camera rotation along the logitudinal axis
  43343. * @param beta Defines the camera rotation along the latitudinal axis
  43344. * @param radius Defines the camera distance from its target
  43345. * @param target Defines the camera target
  43346. * @param scene Defines the scene the camera belongs to
  43347. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43348. */
  43349. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43350. /** @hidden */
  43351. _initCache(): void;
  43352. /** @hidden */
  43353. _updateCache(ignoreParentClass?: boolean): void;
  43354. protected _getTargetPosition(): Vector3;
  43355. private _storedAlpha;
  43356. private _storedBeta;
  43357. private _storedRadius;
  43358. private _storedTarget;
  43359. private _storedTargetScreenOffset;
  43360. /**
  43361. * Stores the current state of the camera (alpha, beta, radius and target)
  43362. * @returns the camera itself
  43363. */
  43364. storeState(): Camera;
  43365. /**
  43366. * @hidden
  43367. * Restored camera state. You must call storeState() first
  43368. */
  43369. _restoreStateValues(): boolean;
  43370. /** @hidden */
  43371. _isSynchronizedViewMatrix(): boolean;
  43372. /**
  43373. * Attached controls to the current camera.
  43374. * @param element Defines the element the controls should be listened from
  43375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43376. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43377. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43378. */
  43379. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43380. /**
  43381. * Detach the current controls from the camera.
  43382. * The camera will stop reacting to inputs.
  43383. * @param element Defines the element to stop listening the inputs from
  43384. */
  43385. detachControl(element: HTMLElement): void;
  43386. /** @hidden */
  43387. _checkInputs(): void;
  43388. protected _checkLimits(): void;
  43389. /**
  43390. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43391. */
  43392. rebuildAnglesAndRadius(): void;
  43393. /**
  43394. * Use a position to define the current camera related information like alpha, beta and radius
  43395. * @param position Defines the position to set the camera at
  43396. */
  43397. setPosition(position: Vector3): void;
  43398. /**
  43399. * Defines the target the camera should look at.
  43400. * This will automatically adapt alpha beta and radius to fit within the new target.
  43401. * @param target Defines the new target as a Vector or a mesh
  43402. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43403. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43404. */
  43405. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43406. /** @hidden */
  43407. _getViewMatrix(): Matrix;
  43408. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43409. /**
  43410. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43411. * @param meshes Defines the mesh to zoom on
  43412. * @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)
  43413. */
  43414. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43415. /**
  43416. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43417. * The target will be changed but the radius
  43418. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43419. * @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)
  43420. */
  43421. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43422. min: Vector3;
  43423. max: Vector3;
  43424. distance: number;
  43425. }, doNotUpdateMaxZ?: boolean): void;
  43426. /**
  43427. * @override
  43428. * Override Camera.createRigCamera
  43429. */
  43430. createRigCamera(name: string, cameraIndex: number): Camera;
  43431. /**
  43432. * @hidden
  43433. * @override
  43434. * Override Camera._updateRigCameras
  43435. */
  43436. _updateRigCameras(): void;
  43437. /**
  43438. * Destroy the camera and release the current resources hold by it.
  43439. */
  43440. dispose(): void;
  43441. /**
  43442. * Gets the current object class name.
  43443. * @return the class name
  43444. */
  43445. getClassName(): string;
  43446. }
  43447. }
  43448. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43449. import { Behavior } from "babylonjs/Behaviors/behavior";
  43450. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43451. /**
  43452. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43453. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43454. */
  43455. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43456. /**
  43457. * Gets the name of the behavior.
  43458. */
  43459. get name(): string;
  43460. private _zoomStopsAnimation;
  43461. private _idleRotationSpeed;
  43462. private _idleRotationWaitTime;
  43463. private _idleRotationSpinupTime;
  43464. /**
  43465. * Sets the flag that indicates if user zooming should stop animation.
  43466. */
  43467. set zoomStopsAnimation(flag: boolean);
  43468. /**
  43469. * Gets the flag that indicates if user zooming should stop animation.
  43470. */
  43471. get zoomStopsAnimation(): boolean;
  43472. /**
  43473. * Sets the default speed at which the camera rotates around the model.
  43474. */
  43475. set idleRotationSpeed(speed: number);
  43476. /**
  43477. * Gets the default speed at which the camera rotates around the model.
  43478. */
  43479. get idleRotationSpeed(): number;
  43480. /**
  43481. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43482. */
  43483. set idleRotationWaitTime(time: number);
  43484. /**
  43485. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43486. */
  43487. get idleRotationWaitTime(): number;
  43488. /**
  43489. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43490. */
  43491. set idleRotationSpinupTime(time: number);
  43492. /**
  43493. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43494. */
  43495. get idleRotationSpinupTime(): number;
  43496. /**
  43497. * Gets a value indicating if the camera is currently rotating because of this behavior
  43498. */
  43499. get rotationInProgress(): boolean;
  43500. private _onPrePointerObservableObserver;
  43501. private _onAfterCheckInputsObserver;
  43502. private _attachedCamera;
  43503. private _isPointerDown;
  43504. private _lastFrameTime;
  43505. private _lastInteractionTime;
  43506. private _cameraRotationSpeed;
  43507. /**
  43508. * Initializes the behavior.
  43509. */
  43510. init(): void;
  43511. /**
  43512. * Attaches the behavior to its arc rotate camera.
  43513. * @param camera Defines the camera to attach the behavior to
  43514. */
  43515. attach(camera: ArcRotateCamera): void;
  43516. /**
  43517. * Detaches the behavior from its current arc rotate camera.
  43518. */
  43519. detach(): void;
  43520. /**
  43521. * Returns true if user is scrolling.
  43522. * @return true if user is scrolling.
  43523. */
  43524. private _userIsZooming;
  43525. private _lastFrameRadius;
  43526. private _shouldAnimationStopForInteraction;
  43527. /**
  43528. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43529. */
  43530. private _applyUserInteraction;
  43531. private _userIsMoving;
  43532. }
  43533. }
  43534. declare module "babylonjs/Behaviors/Cameras/index" {
  43535. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43536. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43537. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43538. }
  43539. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43540. import { Mesh } from "babylonjs/Meshes/mesh";
  43541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43542. import { Behavior } from "babylonjs/Behaviors/behavior";
  43543. /**
  43544. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43545. */
  43546. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43547. private ui;
  43548. /**
  43549. * The name of the behavior
  43550. */
  43551. name: string;
  43552. /**
  43553. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43554. */
  43555. distanceAwayFromFace: number;
  43556. /**
  43557. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43558. */
  43559. distanceAwayFromBottomOfFace: number;
  43560. private _faceVectors;
  43561. private _target;
  43562. private _scene;
  43563. private _onRenderObserver;
  43564. private _tmpMatrix;
  43565. private _tmpVector;
  43566. /**
  43567. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43568. * @param ui The transform node that should be attched to the mesh
  43569. */
  43570. constructor(ui: TransformNode);
  43571. /**
  43572. * Initializes the behavior
  43573. */
  43574. init(): void;
  43575. private _closestFace;
  43576. private _zeroVector;
  43577. private _lookAtTmpMatrix;
  43578. private _lookAtToRef;
  43579. /**
  43580. * Attaches the AttachToBoxBehavior to the passed in mesh
  43581. * @param target The mesh that the specified node will be attached to
  43582. */
  43583. attach(target: Mesh): void;
  43584. /**
  43585. * Detaches the behavior from the mesh
  43586. */
  43587. detach(): void;
  43588. }
  43589. }
  43590. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43591. import { Behavior } from "babylonjs/Behaviors/behavior";
  43592. import { Mesh } from "babylonjs/Meshes/mesh";
  43593. /**
  43594. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43595. */
  43596. export class FadeInOutBehavior implements Behavior<Mesh> {
  43597. /**
  43598. * Time in milliseconds to delay before fading in (Default: 0)
  43599. */
  43600. delay: number;
  43601. /**
  43602. * Time in milliseconds for the mesh to fade in (Default: 300)
  43603. */
  43604. fadeInTime: number;
  43605. private _millisecondsPerFrame;
  43606. private _hovered;
  43607. private _hoverValue;
  43608. private _ownerNode;
  43609. /**
  43610. * Instatiates the FadeInOutBehavior
  43611. */
  43612. constructor();
  43613. /**
  43614. * The name of the behavior
  43615. */
  43616. get name(): string;
  43617. /**
  43618. * Initializes the behavior
  43619. */
  43620. init(): void;
  43621. /**
  43622. * Attaches the fade behavior on the passed in mesh
  43623. * @param ownerNode The mesh that will be faded in/out once attached
  43624. */
  43625. attach(ownerNode: Mesh): void;
  43626. /**
  43627. * Detaches the behavior from the mesh
  43628. */
  43629. detach(): void;
  43630. /**
  43631. * Triggers the mesh to begin fading in or out
  43632. * @param value if the object should fade in or out (true to fade in)
  43633. */
  43634. fadeIn(value: boolean): void;
  43635. private _update;
  43636. private _setAllVisibility;
  43637. }
  43638. }
  43639. declare module "babylonjs/Misc/pivotTools" {
  43640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43641. /**
  43642. * Class containing a set of static utilities functions for managing Pivots
  43643. * @hidden
  43644. */
  43645. export class PivotTools {
  43646. private static _PivotCached;
  43647. private static _OldPivotPoint;
  43648. private static _PivotTranslation;
  43649. private static _PivotTmpVector;
  43650. /** @hidden */
  43651. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43652. /** @hidden */
  43653. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43654. }
  43655. }
  43656. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43657. import { Scene } from "babylonjs/scene";
  43658. import { Vector4 } from "babylonjs/Maths/math.vector";
  43659. import { Mesh } from "babylonjs/Meshes/mesh";
  43660. import { Nullable } from "babylonjs/types";
  43661. import { Plane } from "babylonjs/Maths/math.plane";
  43662. /**
  43663. * Class containing static functions to help procedurally build meshes
  43664. */
  43665. export class PlaneBuilder {
  43666. /**
  43667. * Creates a plane mesh
  43668. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43669. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43670. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43674. * @param name defines the name of the mesh
  43675. * @param options defines the options used to create the mesh
  43676. * @param scene defines the hosting scene
  43677. * @returns the plane mesh
  43678. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43679. */
  43680. static CreatePlane(name: string, options: {
  43681. size?: number;
  43682. width?: number;
  43683. height?: number;
  43684. sideOrientation?: number;
  43685. frontUVs?: Vector4;
  43686. backUVs?: Vector4;
  43687. updatable?: boolean;
  43688. sourcePlane?: Plane;
  43689. }, scene?: Nullable<Scene>): Mesh;
  43690. }
  43691. }
  43692. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43693. import { Behavior } from "babylonjs/Behaviors/behavior";
  43694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43695. import { Observable } from "babylonjs/Misc/observable";
  43696. import { Vector3 } from "babylonjs/Maths/math.vector";
  43697. import { Ray } from "babylonjs/Culling/ray";
  43698. import "babylonjs/Meshes/Builders/planeBuilder";
  43699. /**
  43700. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43701. */
  43702. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43703. private static _AnyMouseID;
  43704. /**
  43705. * Abstract mesh the behavior is set on
  43706. */
  43707. attachedNode: AbstractMesh;
  43708. private _dragPlane;
  43709. private _scene;
  43710. private _pointerObserver;
  43711. private _beforeRenderObserver;
  43712. private static _planeScene;
  43713. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43714. /**
  43715. * 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)
  43716. */
  43717. maxDragAngle: number;
  43718. /**
  43719. * @hidden
  43720. */
  43721. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43722. /**
  43723. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43724. */
  43725. currentDraggingPointerID: number;
  43726. /**
  43727. * The last position where the pointer hit the drag plane in world space
  43728. */
  43729. lastDragPosition: Vector3;
  43730. /**
  43731. * If the behavior is currently in a dragging state
  43732. */
  43733. dragging: boolean;
  43734. /**
  43735. * 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)
  43736. */
  43737. dragDeltaRatio: number;
  43738. /**
  43739. * If the drag plane orientation should be updated during the dragging (Default: true)
  43740. */
  43741. updateDragPlane: boolean;
  43742. private _debugMode;
  43743. private _moving;
  43744. /**
  43745. * Fires each time the attached mesh is dragged with the pointer
  43746. * * delta between last drag position and current drag position in world space
  43747. * * dragDistance along the drag axis
  43748. * * dragPlaneNormal normal of the current drag plane used during the drag
  43749. * * dragPlanePoint in world space where the drag intersects the drag plane
  43750. */
  43751. onDragObservable: Observable<{
  43752. delta: Vector3;
  43753. dragPlanePoint: Vector3;
  43754. dragPlaneNormal: Vector3;
  43755. dragDistance: number;
  43756. pointerId: number;
  43757. }>;
  43758. /**
  43759. * Fires each time a drag begins (eg. mouse down on mesh)
  43760. */
  43761. onDragStartObservable: Observable<{
  43762. dragPlanePoint: Vector3;
  43763. pointerId: number;
  43764. }>;
  43765. /**
  43766. * Fires each time a drag ends (eg. mouse release after drag)
  43767. */
  43768. onDragEndObservable: Observable<{
  43769. dragPlanePoint: Vector3;
  43770. pointerId: number;
  43771. }>;
  43772. /**
  43773. * If the attached mesh should be moved when dragged
  43774. */
  43775. moveAttached: boolean;
  43776. /**
  43777. * If the drag behavior will react to drag events (Default: true)
  43778. */
  43779. enabled: boolean;
  43780. /**
  43781. * If pointer events should start and release the drag (Default: true)
  43782. */
  43783. startAndReleaseDragOnPointerEvents: boolean;
  43784. /**
  43785. * If camera controls should be detached during the drag
  43786. */
  43787. detachCameraControls: boolean;
  43788. /**
  43789. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43790. */
  43791. useObjectOrientationForDragging: boolean;
  43792. private _options;
  43793. /**
  43794. * Gets the options used by the behavior
  43795. */
  43796. get options(): {
  43797. dragAxis?: Vector3;
  43798. dragPlaneNormal?: Vector3;
  43799. };
  43800. /**
  43801. * Sets the options used by the behavior
  43802. */
  43803. set options(options: {
  43804. dragAxis?: Vector3;
  43805. dragPlaneNormal?: Vector3;
  43806. });
  43807. /**
  43808. * Creates a pointer drag behavior that can be attached to a mesh
  43809. * @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)
  43810. */
  43811. constructor(options?: {
  43812. dragAxis?: Vector3;
  43813. dragPlaneNormal?: Vector3;
  43814. });
  43815. /**
  43816. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43817. */
  43818. validateDrag: (targetPosition: Vector3) => boolean;
  43819. /**
  43820. * The name of the behavior
  43821. */
  43822. get name(): string;
  43823. /**
  43824. * Initializes the behavior
  43825. */
  43826. init(): void;
  43827. private _tmpVector;
  43828. private _alternatePickedPoint;
  43829. private _worldDragAxis;
  43830. private _targetPosition;
  43831. private _attachedElement;
  43832. /**
  43833. * Attaches the drag behavior the passed in mesh
  43834. * @param ownerNode The mesh that will be dragged around once attached
  43835. * @param predicate Predicate to use for pick filtering
  43836. */
  43837. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43838. /**
  43839. * Force relase the drag action by code.
  43840. */
  43841. releaseDrag(): void;
  43842. private _startDragRay;
  43843. private _lastPointerRay;
  43844. /**
  43845. * Simulates the start of a pointer drag event on the behavior
  43846. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43847. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43848. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43849. */
  43850. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43851. private _startDrag;
  43852. private _dragDelta;
  43853. private _moveDrag;
  43854. private _pickWithRayOnDragPlane;
  43855. private _pointA;
  43856. private _pointB;
  43857. private _pointC;
  43858. private _lineA;
  43859. private _lineB;
  43860. private _localAxis;
  43861. private _lookAt;
  43862. private _updateDragPlanePosition;
  43863. /**
  43864. * Detaches the behavior from the mesh
  43865. */
  43866. detach(): void;
  43867. }
  43868. }
  43869. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  43870. import { Mesh } from "babylonjs/Meshes/mesh";
  43871. import { Behavior } from "babylonjs/Behaviors/behavior";
  43872. /**
  43873. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43874. */
  43875. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43876. private _dragBehaviorA;
  43877. private _dragBehaviorB;
  43878. private _startDistance;
  43879. private _initialScale;
  43880. private _targetScale;
  43881. private _ownerNode;
  43882. private _sceneRenderObserver;
  43883. /**
  43884. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43885. */
  43886. constructor();
  43887. /**
  43888. * The name of the behavior
  43889. */
  43890. get name(): string;
  43891. /**
  43892. * Initializes the behavior
  43893. */
  43894. init(): void;
  43895. private _getCurrentDistance;
  43896. /**
  43897. * Attaches the scale behavior the passed in mesh
  43898. * @param ownerNode The mesh that will be scaled around once attached
  43899. */
  43900. attach(ownerNode: Mesh): void;
  43901. /**
  43902. * Detaches the behavior from the mesh
  43903. */
  43904. detach(): void;
  43905. }
  43906. }
  43907. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  43908. import { Behavior } from "babylonjs/Behaviors/behavior";
  43909. import { Mesh } from "babylonjs/Meshes/mesh";
  43910. import { Observable } from "babylonjs/Misc/observable";
  43911. /**
  43912. * 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
  43913. */
  43914. export class SixDofDragBehavior implements Behavior<Mesh> {
  43915. private static _virtualScene;
  43916. private _ownerNode;
  43917. private _sceneRenderObserver;
  43918. private _scene;
  43919. private _targetPosition;
  43920. private _virtualOriginMesh;
  43921. private _virtualDragMesh;
  43922. private _pointerObserver;
  43923. private _moving;
  43924. private _startingOrientation;
  43925. private _attachedElement;
  43926. /**
  43927. * 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)
  43928. */
  43929. private zDragFactor;
  43930. /**
  43931. * If the object should rotate to face the drag origin
  43932. */
  43933. rotateDraggedObject: boolean;
  43934. /**
  43935. * If the behavior is currently in a dragging state
  43936. */
  43937. dragging: boolean;
  43938. /**
  43939. * 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)
  43940. */
  43941. dragDeltaRatio: number;
  43942. /**
  43943. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43944. */
  43945. currentDraggingPointerID: number;
  43946. /**
  43947. * If camera controls should be detached during the drag
  43948. */
  43949. detachCameraControls: boolean;
  43950. /**
  43951. * Fires each time a drag starts
  43952. */
  43953. onDragStartObservable: Observable<{}>;
  43954. /**
  43955. * Fires each time a drag ends (eg. mouse release after drag)
  43956. */
  43957. onDragEndObservable: Observable<{}>;
  43958. /**
  43959. * 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
  43960. */
  43961. constructor();
  43962. /**
  43963. * The name of the behavior
  43964. */
  43965. get name(): string;
  43966. /**
  43967. * Initializes the behavior
  43968. */
  43969. init(): void;
  43970. /**
  43971. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43972. */
  43973. private get _pointerCamera();
  43974. /**
  43975. * Attaches the scale behavior the passed in mesh
  43976. * @param ownerNode The mesh that will be scaled around once attached
  43977. */
  43978. attach(ownerNode: Mesh): void;
  43979. /**
  43980. * Detaches the behavior from the mesh
  43981. */
  43982. detach(): void;
  43983. }
  43984. }
  43985. declare module "babylonjs/Behaviors/Meshes/index" {
  43986. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  43987. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  43988. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  43989. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43990. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43991. }
  43992. declare module "babylonjs/Behaviors/index" {
  43993. export * from "babylonjs/Behaviors/behavior";
  43994. export * from "babylonjs/Behaviors/Cameras/index";
  43995. export * from "babylonjs/Behaviors/Meshes/index";
  43996. }
  43997. declare module "babylonjs/Bones/boneIKController" {
  43998. import { Bone } from "babylonjs/Bones/bone";
  43999. import { Vector3 } from "babylonjs/Maths/math.vector";
  44000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44001. import { Nullable } from "babylonjs/types";
  44002. /**
  44003. * Class used to apply inverse kinematics to bones
  44004. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44005. */
  44006. export class BoneIKController {
  44007. private static _tmpVecs;
  44008. private static _tmpQuat;
  44009. private static _tmpMats;
  44010. /**
  44011. * Gets or sets the target mesh
  44012. */
  44013. targetMesh: AbstractMesh;
  44014. /** Gets or sets the mesh used as pole */
  44015. poleTargetMesh: AbstractMesh;
  44016. /**
  44017. * Gets or sets the bone used as pole
  44018. */
  44019. poleTargetBone: Nullable<Bone>;
  44020. /**
  44021. * Gets or sets the target position
  44022. */
  44023. targetPosition: Vector3;
  44024. /**
  44025. * Gets or sets the pole target position
  44026. */
  44027. poleTargetPosition: Vector3;
  44028. /**
  44029. * Gets or sets the pole target local offset
  44030. */
  44031. poleTargetLocalOffset: Vector3;
  44032. /**
  44033. * Gets or sets the pole angle
  44034. */
  44035. poleAngle: number;
  44036. /**
  44037. * Gets or sets the mesh associated with the controller
  44038. */
  44039. mesh: AbstractMesh;
  44040. /**
  44041. * 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)
  44042. */
  44043. slerpAmount: number;
  44044. private _bone1Quat;
  44045. private _bone1Mat;
  44046. private _bone2Ang;
  44047. private _bone1;
  44048. private _bone2;
  44049. private _bone1Length;
  44050. private _bone2Length;
  44051. private _maxAngle;
  44052. private _maxReach;
  44053. private _rightHandedSystem;
  44054. private _bendAxis;
  44055. private _slerping;
  44056. private _adjustRoll;
  44057. /**
  44058. * Gets or sets maximum allowed angle
  44059. */
  44060. get maxAngle(): number;
  44061. set maxAngle(value: number);
  44062. /**
  44063. * Creates a new BoneIKController
  44064. * @param mesh defines the mesh to control
  44065. * @param bone defines the bone to control
  44066. * @param options defines options to set up the controller
  44067. */
  44068. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44069. targetMesh?: AbstractMesh;
  44070. poleTargetMesh?: AbstractMesh;
  44071. poleTargetBone?: Bone;
  44072. poleTargetLocalOffset?: Vector3;
  44073. poleAngle?: number;
  44074. bendAxis?: Vector3;
  44075. maxAngle?: number;
  44076. slerpAmount?: number;
  44077. });
  44078. private _setMaxAngle;
  44079. /**
  44080. * Force the controller to update the bones
  44081. */
  44082. update(): void;
  44083. }
  44084. }
  44085. declare module "babylonjs/Bones/boneLookController" {
  44086. import { Vector3 } from "babylonjs/Maths/math.vector";
  44087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44088. import { Bone } from "babylonjs/Bones/bone";
  44089. import { Space } from "babylonjs/Maths/math.axis";
  44090. /**
  44091. * Class used to make a bone look toward a point in space
  44092. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44093. */
  44094. export class BoneLookController {
  44095. private static _tmpVecs;
  44096. private static _tmpQuat;
  44097. private static _tmpMats;
  44098. /**
  44099. * The target Vector3 that the bone will look at
  44100. */
  44101. target: Vector3;
  44102. /**
  44103. * The mesh that the bone is attached to
  44104. */
  44105. mesh: AbstractMesh;
  44106. /**
  44107. * The bone that will be looking to the target
  44108. */
  44109. bone: Bone;
  44110. /**
  44111. * The up axis of the coordinate system that is used when the bone is rotated
  44112. */
  44113. upAxis: Vector3;
  44114. /**
  44115. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44116. */
  44117. upAxisSpace: Space;
  44118. /**
  44119. * Used to make an adjustment to the yaw of the bone
  44120. */
  44121. adjustYaw: number;
  44122. /**
  44123. * Used to make an adjustment to the pitch of the bone
  44124. */
  44125. adjustPitch: number;
  44126. /**
  44127. * Used to make an adjustment to the roll of the bone
  44128. */
  44129. adjustRoll: number;
  44130. /**
  44131. * 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)
  44132. */
  44133. slerpAmount: number;
  44134. private _minYaw;
  44135. private _maxYaw;
  44136. private _minPitch;
  44137. private _maxPitch;
  44138. private _minYawSin;
  44139. private _minYawCos;
  44140. private _maxYawSin;
  44141. private _maxYawCos;
  44142. private _midYawConstraint;
  44143. private _minPitchTan;
  44144. private _maxPitchTan;
  44145. private _boneQuat;
  44146. private _slerping;
  44147. private _transformYawPitch;
  44148. private _transformYawPitchInv;
  44149. private _firstFrameSkipped;
  44150. private _yawRange;
  44151. private _fowardAxis;
  44152. /**
  44153. * Gets or sets the minimum yaw angle that the bone can look to
  44154. */
  44155. get minYaw(): number;
  44156. set minYaw(value: number);
  44157. /**
  44158. * Gets or sets the maximum yaw angle that the bone can look to
  44159. */
  44160. get maxYaw(): number;
  44161. set maxYaw(value: number);
  44162. /**
  44163. * Gets or sets the minimum pitch angle that the bone can look to
  44164. */
  44165. get minPitch(): number;
  44166. set minPitch(value: number);
  44167. /**
  44168. * Gets or sets the maximum pitch angle that the bone can look to
  44169. */
  44170. get maxPitch(): number;
  44171. set maxPitch(value: number);
  44172. /**
  44173. * Create a BoneLookController
  44174. * @param mesh the mesh that the bone belongs to
  44175. * @param bone the bone that will be looking to the target
  44176. * @param target the target Vector3 to look at
  44177. * @param options optional settings:
  44178. * * maxYaw: the maximum angle the bone will yaw to
  44179. * * minYaw: the minimum angle the bone will yaw to
  44180. * * maxPitch: the maximum angle the bone will pitch to
  44181. * * minPitch: the minimum angle the bone will yaw to
  44182. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44183. * * upAxis: the up axis of the coordinate system
  44184. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44185. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44186. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44187. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44188. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44189. * * adjustRoll: used to make an adjustment to the roll of the bone
  44190. **/
  44191. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44192. maxYaw?: number;
  44193. minYaw?: number;
  44194. maxPitch?: number;
  44195. minPitch?: number;
  44196. slerpAmount?: number;
  44197. upAxis?: Vector3;
  44198. upAxisSpace?: Space;
  44199. yawAxis?: Vector3;
  44200. pitchAxis?: Vector3;
  44201. adjustYaw?: number;
  44202. adjustPitch?: number;
  44203. adjustRoll?: number;
  44204. });
  44205. /**
  44206. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44207. */
  44208. update(): void;
  44209. private _getAngleDiff;
  44210. private _getAngleBetween;
  44211. private _isAngleBetween;
  44212. }
  44213. }
  44214. declare module "babylonjs/Bones/index" {
  44215. export * from "babylonjs/Bones/bone";
  44216. export * from "babylonjs/Bones/boneIKController";
  44217. export * from "babylonjs/Bones/boneLookController";
  44218. export * from "babylonjs/Bones/skeleton";
  44219. }
  44220. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44221. import { Nullable } from "babylonjs/types";
  44222. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44223. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44224. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44225. /**
  44226. * Manage the gamepad inputs to control an arc rotate camera.
  44227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44228. */
  44229. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44230. /**
  44231. * Defines the camera the input is attached to.
  44232. */
  44233. camera: ArcRotateCamera;
  44234. /**
  44235. * Defines the gamepad the input is gathering event from.
  44236. */
  44237. gamepad: Nullable<Gamepad>;
  44238. /**
  44239. * Defines the gamepad rotation sensiblity.
  44240. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44241. */
  44242. gamepadRotationSensibility: number;
  44243. /**
  44244. * Defines the gamepad move sensiblity.
  44245. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44246. */
  44247. gamepadMoveSensibility: number;
  44248. private _yAxisScale;
  44249. /**
  44250. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44251. */
  44252. get invertYAxis(): boolean;
  44253. set invertYAxis(value: boolean);
  44254. private _onGamepadConnectedObserver;
  44255. private _onGamepadDisconnectedObserver;
  44256. /**
  44257. * Attach the input controls to a specific dom element to get the input from.
  44258. * @param element Defines the element the controls should be listened from
  44259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44260. */
  44261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44262. /**
  44263. * Detach the current controls from the specified dom element.
  44264. * @param element Defines the element to stop listening the inputs from
  44265. */
  44266. detachControl(element: Nullable<HTMLElement>): void;
  44267. /**
  44268. * Update the current camera state depending on the inputs that have been used this frame.
  44269. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44270. */
  44271. checkInputs(): void;
  44272. /**
  44273. * Gets the class name of the current intput.
  44274. * @returns the class name
  44275. */
  44276. getClassName(): string;
  44277. /**
  44278. * Get the friendly name associated with the input class.
  44279. * @returns the input friendly name
  44280. */
  44281. getSimpleName(): string;
  44282. }
  44283. }
  44284. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44285. import { Nullable } from "babylonjs/types";
  44286. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44287. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44288. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44289. interface ArcRotateCameraInputsManager {
  44290. /**
  44291. * Add orientation input support to the input manager.
  44292. * @returns the current input manager
  44293. */
  44294. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44295. }
  44296. }
  44297. /**
  44298. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44300. */
  44301. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44302. /**
  44303. * Defines the camera the input is attached to.
  44304. */
  44305. camera: ArcRotateCamera;
  44306. /**
  44307. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44308. */
  44309. alphaCorrection: number;
  44310. /**
  44311. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44312. */
  44313. gammaCorrection: number;
  44314. private _alpha;
  44315. private _gamma;
  44316. private _dirty;
  44317. private _deviceOrientationHandler;
  44318. /**
  44319. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44320. */
  44321. constructor();
  44322. /**
  44323. * Attach the input controls to a specific dom element to get the input from.
  44324. * @param element Defines the element the controls should be listened from
  44325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44326. */
  44327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44328. /** @hidden */
  44329. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44330. /**
  44331. * Update the current camera state depending on the inputs that have been used this frame.
  44332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44333. */
  44334. checkInputs(): void;
  44335. /**
  44336. * Detach the current controls from the specified dom element.
  44337. * @param element Defines the element to stop listening the inputs from
  44338. */
  44339. detachControl(element: Nullable<HTMLElement>): void;
  44340. /**
  44341. * Gets the class name of the current intput.
  44342. * @returns the class name
  44343. */
  44344. getClassName(): string;
  44345. /**
  44346. * Get the friendly name associated with the input class.
  44347. * @returns the input friendly name
  44348. */
  44349. getSimpleName(): string;
  44350. }
  44351. }
  44352. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44353. import { Nullable } from "babylonjs/types";
  44354. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44355. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44356. /**
  44357. * Listen to mouse events to control the camera.
  44358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44359. */
  44360. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44361. /**
  44362. * Defines the camera the input is attached to.
  44363. */
  44364. camera: FlyCamera;
  44365. /**
  44366. * Defines if touch is enabled. (Default is true.)
  44367. */
  44368. touchEnabled: boolean;
  44369. /**
  44370. * Defines the buttons associated with the input to handle camera rotation.
  44371. */
  44372. buttons: number[];
  44373. /**
  44374. * Assign buttons for Yaw control.
  44375. */
  44376. buttonsYaw: number[];
  44377. /**
  44378. * Assign buttons for Pitch control.
  44379. */
  44380. buttonsPitch: number[];
  44381. /**
  44382. * Assign buttons for Roll control.
  44383. */
  44384. buttonsRoll: number[];
  44385. /**
  44386. * Detect if any button is being pressed while mouse is moved.
  44387. * -1 = Mouse locked.
  44388. * 0 = Left button.
  44389. * 1 = Middle Button.
  44390. * 2 = Right Button.
  44391. */
  44392. activeButton: number;
  44393. /**
  44394. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44395. * Higher values reduce its sensitivity.
  44396. */
  44397. angularSensibility: number;
  44398. private _mousemoveCallback;
  44399. private _observer;
  44400. private _rollObserver;
  44401. private previousPosition;
  44402. private noPreventDefault;
  44403. private element;
  44404. /**
  44405. * Listen to mouse events to control the camera.
  44406. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44408. */
  44409. constructor(touchEnabled?: boolean);
  44410. /**
  44411. * Attach the mouse control to the HTML DOM element.
  44412. * @param element Defines the element that listens to the input events.
  44413. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44414. */
  44415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44416. /**
  44417. * Detach the current controls from the specified dom element.
  44418. * @param element Defines the element to stop listening the inputs from
  44419. */
  44420. detachControl(element: Nullable<HTMLElement>): void;
  44421. /**
  44422. * Gets the class name of the current input.
  44423. * @returns the class name.
  44424. */
  44425. getClassName(): string;
  44426. /**
  44427. * Get the friendly name associated with the input class.
  44428. * @returns the input's friendly name.
  44429. */
  44430. getSimpleName(): string;
  44431. private _pointerInput;
  44432. private _onMouseMove;
  44433. /**
  44434. * Rotate camera by mouse offset.
  44435. */
  44436. private rotateCamera;
  44437. }
  44438. }
  44439. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44440. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44441. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44442. /**
  44443. * Default Inputs manager for the FlyCamera.
  44444. * It groups all the default supported inputs for ease of use.
  44445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44446. */
  44447. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44448. /**
  44449. * Instantiates a new FlyCameraInputsManager.
  44450. * @param camera Defines the camera the inputs belong to.
  44451. */
  44452. constructor(camera: FlyCamera);
  44453. /**
  44454. * Add keyboard input support to the input manager.
  44455. * @returns the new FlyCameraKeyboardMoveInput().
  44456. */
  44457. addKeyboard(): FlyCameraInputsManager;
  44458. /**
  44459. * Add mouse input support to the input manager.
  44460. * @param touchEnabled Enable touch screen support.
  44461. * @returns the new FlyCameraMouseInput().
  44462. */
  44463. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44464. }
  44465. }
  44466. declare module "babylonjs/Cameras/flyCamera" {
  44467. import { Scene } from "babylonjs/scene";
  44468. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44470. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44471. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44472. /**
  44473. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44474. * such as in a 3D Space Shooter or a Flight Simulator.
  44475. */
  44476. export class FlyCamera extends TargetCamera {
  44477. /**
  44478. * Define the collision ellipsoid of the camera.
  44479. * This is helpful for simulating a camera body, like a player's body.
  44480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44481. */
  44482. ellipsoid: Vector3;
  44483. /**
  44484. * Define an offset for the position of the ellipsoid around the camera.
  44485. * This can be helpful if the camera is attached away from the player's body center,
  44486. * such as at its head.
  44487. */
  44488. ellipsoidOffset: Vector3;
  44489. /**
  44490. * Enable or disable collisions of the camera with the rest of the scene objects.
  44491. */
  44492. checkCollisions: boolean;
  44493. /**
  44494. * Enable or disable gravity on the camera.
  44495. */
  44496. applyGravity: boolean;
  44497. /**
  44498. * Define the current direction the camera is moving to.
  44499. */
  44500. cameraDirection: Vector3;
  44501. /**
  44502. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44503. * This overrides and empties cameraRotation.
  44504. */
  44505. rotationQuaternion: Quaternion;
  44506. /**
  44507. * Track Roll to maintain the wanted Rolling when looking around.
  44508. */
  44509. _trackRoll: number;
  44510. /**
  44511. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44512. */
  44513. rollCorrect: number;
  44514. /**
  44515. * Mimic a banked turn, Rolling the camera when Yawing.
  44516. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44517. */
  44518. bankedTurn: boolean;
  44519. /**
  44520. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44521. */
  44522. bankedTurnLimit: number;
  44523. /**
  44524. * Value of 0 disables the banked Roll.
  44525. * Value of 1 is equal to the Yaw angle in radians.
  44526. */
  44527. bankedTurnMultiplier: number;
  44528. /**
  44529. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44530. */
  44531. inputs: FlyCameraInputsManager;
  44532. /**
  44533. * Gets the input sensibility for mouse input.
  44534. * Higher values reduce sensitivity.
  44535. */
  44536. get angularSensibility(): number;
  44537. /**
  44538. * Sets the input sensibility for a mouse input.
  44539. * Higher values reduce sensitivity.
  44540. */
  44541. set angularSensibility(value: number);
  44542. /**
  44543. * Get the keys for camera movement forward.
  44544. */
  44545. get keysForward(): number[];
  44546. /**
  44547. * Set the keys for camera movement forward.
  44548. */
  44549. set keysForward(value: number[]);
  44550. /**
  44551. * Get the keys for camera movement backward.
  44552. */
  44553. get keysBackward(): number[];
  44554. set keysBackward(value: number[]);
  44555. /**
  44556. * Get the keys for camera movement up.
  44557. */
  44558. get keysUp(): number[];
  44559. /**
  44560. * Set the keys for camera movement up.
  44561. */
  44562. set keysUp(value: number[]);
  44563. /**
  44564. * Get the keys for camera movement down.
  44565. */
  44566. get keysDown(): number[];
  44567. /**
  44568. * Set the keys for camera movement down.
  44569. */
  44570. set keysDown(value: number[]);
  44571. /**
  44572. * Get the keys for camera movement left.
  44573. */
  44574. get keysLeft(): number[];
  44575. /**
  44576. * Set the keys for camera movement left.
  44577. */
  44578. set keysLeft(value: number[]);
  44579. /**
  44580. * Set the keys for camera movement right.
  44581. */
  44582. get keysRight(): number[];
  44583. /**
  44584. * Set the keys for camera movement right.
  44585. */
  44586. set keysRight(value: number[]);
  44587. /**
  44588. * Event raised when the camera collides with a mesh in the scene.
  44589. */
  44590. onCollide: (collidedMesh: AbstractMesh) => void;
  44591. private _collider;
  44592. private _needMoveForGravity;
  44593. private _oldPosition;
  44594. private _diffPosition;
  44595. private _newPosition;
  44596. /** @hidden */
  44597. _localDirection: Vector3;
  44598. /** @hidden */
  44599. _transformedDirection: Vector3;
  44600. /**
  44601. * Instantiates a FlyCamera.
  44602. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44603. * such as in a 3D Space Shooter or a Flight Simulator.
  44604. * @param name Define the name of the camera in the scene.
  44605. * @param position Define the starting position of the camera in the scene.
  44606. * @param scene Define the scene the camera belongs to.
  44607. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44608. */
  44609. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44610. /**
  44611. * Attach a control to the HTML DOM element.
  44612. * @param element Defines the element that listens to the input events.
  44613. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44614. */
  44615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44616. /**
  44617. * Detach a control from the HTML DOM element.
  44618. * The camera will stop reacting to that input.
  44619. * @param element Defines the element that listens to the input events.
  44620. */
  44621. detachControl(element: HTMLElement): void;
  44622. private _collisionMask;
  44623. /**
  44624. * Get the mask that the camera ignores in collision events.
  44625. */
  44626. get collisionMask(): number;
  44627. /**
  44628. * Set the mask that the camera ignores in collision events.
  44629. */
  44630. set collisionMask(mask: number);
  44631. /** @hidden */
  44632. _collideWithWorld(displacement: Vector3): void;
  44633. /** @hidden */
  44634. private _onCollisionPositionChange;
  44635. /** @hidden */
  44636. _checkInputs(): void;
  44637. /** @hidden */
  44638. _decideIfNeedsToMove(): boolean;
  44639. /** @hidden */
  44640. _updatePosition(): void;
  44641. /**
  44642. * Restore the Roll to its target value at the rate specified.
  44643. * @param rate - Higher means slower restoring.
  44644. * @hidden
  44645. */
  44646. restoreRoll(rate: number): void;
  44647. /**
  44648. * Destroy the camera and release the current resources held by it.
  44649. */
  44650. dispose(): void;
  44651. /**
  44652. * Get the current object class name.
  44653. * @returns the class name.
  44654. */
  44655. getClassName(): string;
  44656. }
  44657. }
  44658. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44659. import { Nullable } from "babylonjs/types";
  44660. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44661. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44662. /**
  44663. * Listen to keyboard events to control the camera.
  44664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44665. */
  44666. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44667. /**
  44668. * Defines the camera the input is attached to.
  44669. */
  44670. camera: FlyCamera;
  44671. /**
  44672. * The list of keyboard keys used to control the forward move of the camera.
  44673. */
  44674. keysForward: number[];
  44675. /**
  44676. * The list of keyboard keys used to control the backward move of the camera.
  44677. */
  44678. keysBackward: number[];
  44679. /**
  44680. * The list of keyboard keys used to control the forward move of the camera.
  44681. */
  44682. keysUp: number[];
  44683. /**
  44684. * The list of keyboard keys used to control the backward move of the camera.
  44685. */
  44686. keysDown: number[];
  44687. /**
  44688. * The list of keyboard keys used to control the right strafe move of the camera.
  44689. */
  44690. keysRight: number[];
  44691. /**
  44692. * The list of keyboard keys used to control the left strafe move of the camera.
  44693. */
  44694. keysLeft: number[];
  44695. private _keys;
  44696. private _onCanvasBlurObserver;
  44697. private _onKeyboardObserver;
  44698. private _engine;
  44699. private _scene;
  44700. /**
  44701. * Attach the input controls to a specific dom element to get the input from.
  44702. * @param element Defines the element the controls should be listened from
  44703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44704. */
  44705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44706. /**
  44707. * Detach the current controls from the specified dom element.
  44708. * @param element Defines the element to stop listening the inputs from
  44709. */
  44710. detachControl(element: Nullable<HTMLElement>): void;
  44711. /**
  44712. * Gets the class name of the current intput.
  44713. * @returns the class name
  44714. */
  44715. getClassName(): string;
  44716. /** @hidden */
  44717. _onLostFocus(e: FocusEvent): void;
  44718. /**
  44719. * Get the friendly name associated with the input class.
  44720. * @returns the input friendly name
  44721. */
  44722. getSimpleName(): string;
  44723. /**
  44724. * Update the current camera state depending on the inputs that have been used this frame.
  44725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44726. */
  44727. checkInputs(): void;
  44728. }
  44729. }
  44730. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44731. import { Nullable } from "babylonjs/types";
  44732. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44733. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44734. /**
  44735. * Manage the mouse wheel inputs to control a follow camera.
  44736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44737. */
  44738. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44739. /**
  44740. * Defines the camera the input is attached to.
  44741. */
  44742. camera: FollowCamera;
  44743. /**
  44744. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44745. */
  44746. axisControlRadius: boolean;
  44747. /**
  44748. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44749. */
  44750. axisControlHeight: boolean;
  44751. /**
  44752. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44753. */
  44754. axisControlRotation: boolean;
  44755. /**
  44756. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44757. * relation to mouseWheel events.
  44758. */
  44759. wheelPrecision: number;
  44760. /**
  44761. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44762. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44763. */
  44764. wheelDeltaPercentage: number;
  44765. private _wheel;
  44766. private _observer;
  44767. /**
  44768. * Attach the input controls to a specific dom element to get the input from.
  44769. * @param element Defines the element the controls should be listened from
  44770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44771. */
  44772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44773. /**
  44774. * Detach the current controls from the specified dom element.
  44775. * @param element Defines the element to stop listening the inputs from
  44776. */
  44777. detachControl(element: Nullable<HTMLElement>): void;
  44778. /**
  44779. * Gets the class name of the current intput.
  44780. * @returns the class name
  44781. */
  44782. getClassName(): string;
  44783. /**
  44784. * Get the friendly name associated with the input class.
  44785. * @returns the input friendly name
  44786. */
  44787. getSimpleName(): string;
  44788. }
  44789. }
  44790. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44791. import { Nullable } from "babylonjs/types";
  44792. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44793. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44794. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44795. /**
  44796. * Manage the pointers inputs to control an follow camera.
  44797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44798. */
  44799. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44800. /**
  44801. * Defines the camera the input is attached to.
  44802. */
  44803. camera: FollowCamera;
  44804. /**
  44805. * Gets the class name of the current input.
  44806. * @returns the class name
  44807. */
  44808. getClassName(): string;
  44809. /**
  44810. * Defines the pointer angular sensibility along the X axis or how fast is
  44811. * the camera rotating.
  44812. * A negative number will reverse the axis direction.
  44813. */
  44814. angularSensibilityX: number;
  44815. /**
  44816. * Defines the pointer angular sensibility along the Y axis or how fast is
  44817. * the camera rotating.
  44818. * A negative number will reverse the axis direction.
  44819. */
  44820. angularSensibilityY: number;
  44821. /**
  44822. * Defines the pointer pinch precision or how fast is the camera zooming.
  44823. * A negative number will reverse the axis direction.
  44824. */
  44825. pinchPrecision: number;
  44826. /**
  44827. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44828. * from 0.
  44829. * It defines the percentage of current camera.radius to use as delta when
  44830. * pinch zoom is used.
  44831. */
  44832. pinchDeltaPercentage: number;
  44833. /**
  44834. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44835. */
  44836. axisXControlRadius: boolean;
  44837. /**
  44838. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44839. */
  44840. axisXControlHeight: boolean;
  44841. /**
  44842. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44843. */
  44844. axisXControlRotation: boolean;
  44845. /**
  44846. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44847. */
  44848. axisYControlRadius: boolean;
  44849. /**
  44850. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44851. */
  44852. axisYControlHeight: boolean;
  44853. /**
  44854. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44855. */
  44856. axisYControlRotation: boolean;
  44857. /**
  44858. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44859. */
  44860. axisPinchControlRadius: boolean;
  44861. /**
  44862. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44863. */
  44864. axisPinchControlHeight: boolean;
  44865. /**
  44866. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44867. */
  44868. axisPinchControlRotation: boolean;
  44869. /**
  44870. * Log error messages if basic misconfiguration has occurred.
  44871. */
  44872. warningEnable: boolean;
  44873. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44874. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44875. private _warningCounter;
  44876. private _warning;
  44877. }
  44878. }
  44879. declare module "babylonjs/Cameras/followCameraInputsManager" {
  44880. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44881. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44882. /**
  44883. * Default Inputs manager for the FollowCamera.
  44884. * It groups all the default supported inputs for ease of use.
  44885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44886. */
  44887. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44888. /**
  44889. * Instantiates a new FollowCameraInputsManager.
  44890. * @param camera Defines the camera the inputs belong to
  44891. */
  44892. constructor(camera: FollowCamera);
  44893. /**
  44894. * Add keyboard input support to the input manager.
  44895. * @returns the current input manager
  44896. */
  44897. addKeyboard(): FollowCameraInputsManager;
  44898. /**
  44899. * Add mouse wheel input support to the input manager.
  44900. * @returns the current input manager
  44901. */
  44902. addMouseWheel(): FollowCameraInputsManager;
  44903. /**
  44904. * Add pointers input support to the input manager.
  44905. * @returns the current input manager
  44906. */
  44907. addPointers(): FollowCameraInputsManager;
  44908. /**
  44909. * Add orientation input support to the input manager.
  44910. * @returns the current input manager
  44911. */
  44912. addVRDeviceOrientation(): FollowCameraInputsManager;
  44913. }
  44914. }
  44915. declare module "babylonjs/Cameras/followCamera" {
  44916. import { Nullable } from "babylonjs/types";
  44917. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44918. import { Scene } from "babylonjs/scene";
  44919. import { Vector3 } from "babylonjs/Maths/math.vector";
  44920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44921. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  44922. /**
  44923. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44924. * an arc rotate version arcFollowCamera are available.
  44925. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44926. */
  44927. export class FollowCamera extends TargetCamera {
  44928. /**
  44929. * Distance the follow camera should follow an object at
  44930. */
  44931. radius: number;
  44932. /**
  44933. * Minimum allowed distance of the camera to the axis of rotation
  44934. * (The camera can not get closer).
  44935. * This can help limiting how the Camera is able to move in the scene.
  44936. */
  44937. lowerRadiusLimit: Nullable<number>;
  44938. /**
  44939. * Maximum allowed distance of the camera to the axis of rotation
  44940. * (The camera can not get further).
  44941. * This can help limiting how the Camera is able to move in the scene.
  44942. */
  44943. upperRadiusLimit: Nullable<number>;
  44944. /**
  44945. * Define a rotation offset between the camera and the object it follows
  44946. */
  44947. rotationOffset: number;
  44948. /**
  44949. * Minimum allowed angle to camera position relative to target object.
  44950. * This can help limiting how the Camera is able to move in the scene.
  44951. */
  44952. lowerRotationOffsetLimit: Nullable<number>;
  44953. /**
  44954. * Maximum allowed angle to camera position relative to target object.
  44955. * This can help limiting how the Camera is able to move in the scene.
  44956. */
  44957. upperRotationOffsetLimit: Nullable<number>;
  44958. /**
  44959. * Define a height offset between the camera and the object it follows.
  44960. * It can help following an object from the top (like a car chaing a plane)
  44961. */
  44962. heightOffset: number;
  44963. /**
  44964. * Minimum allowed height of camera position relative to target object.
  44965. * This can help limiting how the Camera is able to move in the scene.
  44966. */
  44967. lowerHeightOffsetLimit: Nullable<number>;
  44968. /**
  44969. * Maximum allowed height of camera position relative to target object.
  44970. * This can help limiting how the Camera is able to move in the scene.
  44971. */
  44972. upperHeightOffsetLimit: Nullable<number>;
  44973. /**
  44974. * Define how fast the camera can accelerate to follow it s target.
  44975. */
  44976. cameraAcceleration: number;
  44977. /**
  44978. * Define the speed limit of the camera following an object.
  44979. */
  44980. maxCameraSpeed: number;
  44981. /**
  44982. * Define the target of the camera.
  44983. */
  44984. lockedTarget: Nullable<AbstractMesh>;
  44985. /**
  44986. * Defines the input associated with the camera.
  44987. */
  44988. inputs: FollowCameraInputsManager;
  44989. /**
  44990. * Instantiates the follow camera.
  44991. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44992. * @param name Define the name of the camera in the scene
  44993. * @param position Define the position of the camera
  44994. * @param scene Define the scene the camera belong to
  44995. * @param lockedTarget Define the target of the camera
  44996. */
  44997. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44998. private _follow;
  44999. /**
  45000. * Attached controls to the current camera.
  45001. * @param element Defines the element the controls should be listened from
  45002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45003. */
  45004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45005. /**
  45006. * Detach the current controls from the camera.
  45007. * The camera will stop reacting to inputs.
  45008. * @param element Defines the element to stop listening the inputs from
  45009. */
  45010. detachControl(element: HTMLElement): void;
  45011. /** @hidden */
  45012. _checkInputs(): void;
  45013. private _checkLimits;
  45014. /**
  45015. * Gets the camera class name.
  45016. * @returns the class name
  45017. */
  45018. getClassName(): string;
  45019. }
  45020. /**
  45021. * Arc Rotate version of the follow camera.
  45022. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45023. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45024. */
  45025. export class ArcFollowCamera extends TargetCamera {
  45026. /** The longitudinal angle of the camera */
  45027. alpha: number;
  45028. /** The latitudinal angle of the camera */
  45029. beta: number;
  45030. /** The radius of the camera from its target */
  45031. radius: number;
  45032. /** Define the camera target (the messh it should follow) */
  45033. target: Nullable<AbstractMesh>;
  45034. private _cartesianCoordinates;
  45035. /**
  45036. * Instantiates a new ArcFollowCamera
  45037. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45038. * @param name Define the name of the camera
  45039. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45040. * @param beta Define the rotation angle of the camera around the elevation axis
  45041. * @param radius Define the radius of the camera from its target point
  45042. * @param target Define the target of the camera
  45043. * @param scene Define the scene the camera belongs to
  45044. */
  45045. constructor(name: string,
  45046. /** The longitudinal angle of the camera */
  45047. alpha: number,
  45048. /** The latitudinal angle of the camera */
  45049. beta: number,
  45050. /** The radius of the camera from its target */
  45051. radius: number,
  45052. /** Define the camera target (the messh it should follow) */
  45053. target: Nullable<AbstractMesh>, scene: Scene);
  45054. private _follow;
  45055. /** @hidden */
  45056. _checkInputs(): void;
  45057. /**
  45058. * Returns the class name of the object.
  45059. * It is mostly used internally for serialization purposes.
  45060. */
  45061. getClassName(): string;
  45062. }
  45063. }
  45064. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45065. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45066. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45067. import { Nullable } from "babylonjs/types";
  45068. /**
  45069. * Manage the keyboard inputs to control the movement of a follow camera.
  45070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45071. */
  45072. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45073. /**
  45074. * Defines the camera the input is attached to.
  45075. */
  45076. camera: FollowCamera;
  45077. /**
  45078. * Defines the list of key codes associated with the up action (increase heightOffset)
  45079. */
  45080. keysHeightOffsetIncr: number[];
  45081. /**
  45082. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45083. */
  45084. keysHeightOffsetDecr: number[];
  45085. /**
  45086. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45087. */
  45088. keysHeightOffsetModifierAlt: boolean;
  45089. /**
  45090. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45091. */
  45092. keysHeightOffsetModifierCtrl: boolean;
  45093. /**
  45094. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45095. */
  45096. keysHeightOffsetModifierShift: boolean;
  45097. /**
  45098. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45099. */
  45100. keysRotationOffsetIncr: number[];
  45101. /**
  45102. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45103. */
  45104. keysRotationOffsetDecr: number[];
  45105. /**
  45106. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45107. */
  45108. keysRotationOffsetModifierAlt: boolean;
  45109. /**
  45110. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45111. */
  45112. keysRotationOffsetModifierCtrl: boolean;
  45113. /**
  45114. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45115. */
  45116. keysRotationOffsetModifierShift: boolean;
  45117. /**
  45118. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45119. */
  45120. keysRadiusIncr: number[];
  45121. /**
  45122. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45123. */
  45124. keysRadiusDecr: number[];
  45125. /**
  45126. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45127. */
  45128. keysRadiusModifierAlt: boolean;
  45129. /**
  45130. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45131. */
  45132. keysRadiusModifierCtrl: boolean;
  45133. /**
  45134. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45135. */
  45136. keysRadiusModifierShift: boolean;
  45137. /**
  45138. * Defines the rate of change of heightOffset.
  45139. */
  45140. heightSensibility: number;
  45141. /**
  45142. * Defines the rate of change of rotationOffset.
  45143. */
  45144. rotationSensibility: number;
  45145. /**
  45146. * Defines the rate of change of radius.
  45147. */
  45148. radiusSensibility: number;
  45149. private _keys;
  45150. private _ctrlPressed;
  45151. private _altPressed;
  45152. private _shiftPressed;
  45153. private _onCanvasBlurObserver;
  45154. private _onKeyboardObserver;
  45155. private _engine;
  45156. private _scene;
  45157. /**
  45158. * Attach the input controls to a specific dom element to get the input from.
  45159. * @param element Defines the element the controls should be listened from
  45160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45161. */
  45162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45163. /**
  45164. * Detach the current controls from the specified dom element.
  45165. * @param element Defines the element to stop listening the inputs from
  45166. */
  45167. detachControl(element: Nullable<HTMLElement>): void;
  45168. /**
  45169. * Update the current camera state depending on the inputs that have been used this frame.
  45170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45171. */
  45172. checkInputs(): void;
  45173. /**
  45174. * Gets the class name of the current input.
  45175. * @returns the class name
  45176. */
  45177. getClassName(): string;
  45178. /**
  45179. * Get the friendly name associated with the input class.
  45180. * @returns the input friendly name
  45181. */
  45182. getSimpleName(): string;
  45183. /**
  45184. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45185. * allow modification of the heightOffset value.
  45186. */
  45187. private _modifierHeightOffset;
  45188. /**
  45189. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45190. * allow modification of the rotationOffset value.
  45191. */
  45192. private _modifierRotationOffset;
  45193. /**
  45194. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45195. * allow modification of the radius value.
  45196. */
  45197. private _modifierRadius;
  45198. }
  45199. }
  45200. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45201. import { Nullable } from "babylonjs/types";
  45202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45203. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45204. import { Observable } from "babylonjs/Misc/observable";
  45205. module "babylonjs/Cameras/freeCameraInputsManager" {
  45206. interface FreeCameraInputsManager {
  45207. /**
  45208. * @hidden
  45209. */
  45210. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45211. /**
  45212. * Add orientation input support to the input manager.
  45213. * @returns the current input manager
  45214. */
  45215. addDeviceOrientation(): FreeCameraInputsManager;
  45216. }
  45217. }
  45218. /**
  45219. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45220. * Screen rotation is taken into account.
  45221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45222. */
  45223. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45224. private _camera;
  45225. private _screenOrientationAngle;
  45226. private _constantTranform;
  45227. private _screenQuaternion;
  45228. private _alpha;
  45229. private _beta;
  45230. private _gamma;
  45231. /**
  45232. * Can be used to detect if a device orientation sensor is available on a device
  45233. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45234. * @returns a promise that will resolve on orientation change
  45235. */
  45236. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45237. /**
  45238. * @hidden
  45239. */
  45240. _onDeviceOrientationChangedObservable: Observable<void>;
  45241. /**
  45242. * Instantiates a new input
  45243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45244. */
  45245. constructor();
  45246. /**
  45247. * Define the camera controlled by the input.
  45248. */
  45249. get camera(): FreeCamera;
  45250. set camera(camera: FreeCamera);
  45251. /**
  45252. * Attach the input controls to a specific dom element to get the input from.
  45253. * @param element Defines the element the controls should be listened from
  45254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45255. */
  45256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45257. private _orientationChanged;
  45258. private _deviceOrientation;
  45259. /**
  45260. * Detach the current controls from the specified dom element.
  45261. * @param element Defines the element to stop listening the inputs from
  45262. */
  45263. detachControl(element: Nullable<HTMLElement>): void;
  45264. /**
  45265. * Update the current camera state depending on the inputs that have been used this frame.
  45266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45267. */
  45268. checkInputs(): void;
  45269. /**
  45270. * Gets the class name of the current intput.
  45271. * @returns the class name
  45272. */
  45273. getClassName(): string;
  45274. /**
  45275. * Get the friendly name associated with the input class.
  45276. * @returns the input friendly name
  45277. */
  45278. getSimpleName(): string;
  45279. }
  45280. }
  45281. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45282. import { Nullable } from "babylonjs/types";
  45283. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45284. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45285. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45286. /**
  45287. * Manage the gamepad inputs to control a free camera.
  45288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45289. */
  45290. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45291. /**
  45292. * Define the camera the input is attached to.
  45293. */
  45294. camera: FreeCamera;
  45295. /**
  45296. * Define the Gamepad controlling the input
  45297. */
  45298. gamepad: Nullable<Gamepad>;
  45299. /**
  45300. * Defines the gamepad rotation sensiblity.
  45301. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45302. */
  45303. gamepadAngularSensibility: number;
  45304. /**
  45305. * Defines the gamepad move sensiblity.
  45306. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45307. */
  45308. gamepadMoveSensibility: number;
  45309. private _yAxisScale;
  45310. /**
  45311. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45312. */
  45313. get invertYAxis(): boolean;
  45314. set invertYAxis(value: boolean);
  45315. private _onGamepadConnectedObserver;
  45316. private _onGamepadDisconnectedObserver;
  45317. private _cameraTransform;
  45318. private _deltaTransform;
  45319. private _vector3;
  45320. private _vector2;
  45321. /**
  45322. * Attach the input controls to a specific dom element to get the input from.
  45323. * @param element Defines the element the controls should be listened from
  45324. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45325. */
  45326. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45327. /**
  45328. * Detach the current controls from the specified dom element.
  45329. * @param element Defines the element to stop listening the inputs from
  45330. */
  45331. detachControl(element: Nullable<HTMLElement>): void;
  45332. /**
  45333. * Update the current camera state depending on the inputs that have been used this frame.
  45334. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45335. */
  45336. checkInputs(): void;
  45337. /**
  45338. * Gets the class name of the current intput.
  45339. * @returns the class name
  45340. */
  45341. getClassName(): string;
  45342. /**
  45343. * Get the friendly name associated with the input class.
  45344. * @returns the input friendly name
  45345. */
  45346. getSimpleName(): string;
  45347. }
  45348. }
  45349. declare module "babylonjs/Misc/virtualJoystick" {
  45350. import { Nullable } from "babylonjs/types";
  45351. import { Vector3 } from "babylonjs/Maths/math.vector";
  45352. /**
  45353. * Defines the potential axis of a Joystick
  45354. */
  45355. export enum JoystickAxis {
  45356. /** X axis */
  45357. X = 0,
  45358. /** Y axis */
  45359. Y = 1,
  45360. /** Z axis */
  45361. Z = 2
  45362. }
  45363. /**
  45364. * Class used to define virtual joystick (used in touch mode)
  45365. */
  45366. export class VirtualJoystick {
  45367. /**
  45368. * Gets or sets a boolean indicating that left and right values must be inverted
  45369. */
  45370. reverseLeftRight: boolean;
  45371. /**
  45372. * Gets or sets a boolean indicating that up and down values must be inverted
  45373. */
  45374. reverseUpDown: boolean;
  45375. /**
  45376. * Gets the offset value for the position (ie. the change of the position value)
  45377. */
  45378. deltaPosition: Vector3;
  45379. /**
  45380. * Gets a boolean indicating if the virtual joystick was pressed
  45381. */
  45382. pressed: boolean;
  45383. /**
  45384. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45385. */
  45386. static Canvas: Nullable<HTMLCanvasElement>;
  45387. private static _globalJoystickIndex;
  45388. private static vjCanvasContext;
  45389. private static vjCanvasWidth;
  45390. private static vjCanvasHeight;
  45391. private static halfWidth;
  45392. private _action;
  45393. private _axisTargetedByLeftAndRight;
  45394. private _axisTargetedByUpAndDown;
  45395. private _joystickSensibility;
  45396. private _inversedSensibility;
  45397. private _joystickPointerID;
  45398. private _joystickColor;
  45399. private _joystickPointerPos;
  45400. private _joystickPreviousPointerPos;
  45401. private _joystickPointerStartPos;
  45402. private _deltaJoystickVector;
  45403. private _leftJoystick;
  45404. private _touches;
  45405. private _onPointerDownHandlerRef;
  45406. private _onPointerMoveHandlerRef;
  45407. private _onPointerUpHandlerRef;
  45408. private _onResize;
  45409. /**
  45410. * Creates a new virtual joystick
  45411. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45412. */
  45413. constructor(leftJoystick?: boolean);
  45414. /**
  45415. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45416. * @param newJoystickSensibility defines the new sensibility
  45417. */
  45418. setJoystickSensibility(newJoystickSensibility: number): void;
  45419. private _onPointerDown;
  45420. private _onPointerMove;
  45421. private _onPointerUp;
  45422. /**
  45423. * Change the color of the virtual joystick
  45424. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45425. */
  45426. setJoystickColor(newColor: string): void;
  45427. /**
  45428. * Defines a callback to call when the joystick is touched
  45429. * @param action defines the callback
  45430. */
  45431. setActionOnTouch(action: () => any): void;
  45432. /**
  45433. * Defines which axis you'd like to control for left & right
  45434. * @param axis defines the axis to use
  45435. */
  45436. setAxisForLeftRight(axis: JoystickAxis): void;
  45437. /**
  45438. * Defines which axis you'd like to control for up & down
  45439. * @param axis defines the axis to use
  45440. */
  45441. setAxisForUpDown(axis: JoystickAxis): void;
  45442. private _drawVirtualJoystick;
  45443. /**
  45444. * Release internal HTML canvas
  45445. */
  45446. releaseCanvas(): void;
  45447. }
  45448. }
  45449. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45450. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45451. import { Nullable } from "babylonjs/types";
  45452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45453. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45454. module "babylonjs/Cameras/freeCameraInputsManager" {
  45455. interface FreeCameraInputsManager {
  45456. /**
  45457. * Add virtual joystick input support to the input manager.
  45458. * @returns the current input manager
  45459. */
  45460. addVirtualJoystick(): FreeCameraInputsManager;
  45461. }
  45462. }
  45463. /**
  45464. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45466. */
  45467. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45468. /**
  45469. * Defines the camera the input is attached to.
  45470. */
  45471. camera: FreeCamera;
  45472. private _leftjoystick;
  45473. private _rightjoystick;
  45474. /**
  45475. * Gets the left stick of the virtual joystick.
  45476. * @returns The virtual Joystick
  45477. */
  45478. getLeftJoystick(): VirtualJoystick;
  45479. /**
  45480. * Gets the right stick of the virtual joystick.
  45481. * @returns The virtual Joystick
  45482. */
  45483. getRightJoystick(): VirtualJoystick;
  45484. /**
  45485. * Update the current camera state depending on the inputs that have been used this frame.
  45486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45487. */
  45488. checkInputs(): void;
  45489. /**
  45490. * Attach the input controls to a specific dom element to get the input from.
  45491. * @param element Defines the element the controls should be listened from
  45492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45493. */
  45494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45495. /**
  45496. * Detach the current controls from the specified dom element.
  45497. * @param element Defines the element to stop listening the inputs from
  45498. */
  45499. detachControl(element: Nullable<HTMLElement>): void;
  45500. /**
  45501. * Gets the class name of the current intput.
  45502. * @returns the class name
  45503. */
  45504. getClassName(): string;
  45505. /**
  45506. * Get the friendly name associated with the input class.
  45507. * @returns the input friendly name
  45508. */
  45509. getSimpleName(): string;
  45510. }
  45511. }
  45512. declare module "babylonjs/Cameras/Inputs/index" {
  45513. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45514. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45515. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45516. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45517. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45518. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45519. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45520. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45521. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45522. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45523. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45524. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45525. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45526. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45527. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45528. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45529. }
  45530. declare module "babylonjs/Cameras/touchCamera" {
  45531. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45532. import { Scene } from "babylonjs/scene";
  45533. import { Vector3 } from "babylonjs/Maths/math.vector";
  45534. /**
  45535. * This represents a FPS type of camera controlled by touch.
  45536. * This is like a universal camera minus the Gamepad controls.
  45537. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45538. */
  45539. export class TouchCamera extends FreeCamera {
  45540. /**
  45541. * Defines the touch sensibility for rotation.
  45542. * The higher the faster.
  45543. */
  45544. get touchAngularSensibility(): number;
  45545. set touchAngularSensibility(value: number);
  45546. /**
  45547. * Defines the touch sensibility for move.
  45548. * The higher the faster.
  45549. */
  45550. get touchMoveSensibility(): number;
  45551. set touchMoveSensibility(value: number);
  45552. /**
  45553. * Instantiates a new touch camera.
  45554. * This represents a FPS type of camera controlled by touch.
  45555. * This is like a universal camera minus the Gamepad controls.
  45556. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45557. * @param name Define the name of the camera in the scene
  45558. * @param position Define the start position of the camera in the scene
  45559. * @param scene Define the scene the camera belongs to
  45560. */
  45561. constructor(name: string, position: Vector3, scene: Scene);
  45562. /**
  45563. * Gets the current object class name.
  45564. * @return the class name
  45565. */
  45566. getClassName(): string;
  45567. /** @hidden */
  45568. _setupInputs(): void;
  45569. }
  45570. }
  45571. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45572. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45573. import { Scene } from "babylonjs/scene";
  45574. import { Vector3 } from "babylonjs/Maths/math.vector";
  45575. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45576. import { Axis } from "babylonjs/Maths/math.axis";
  45577. /**
  45578. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45579. * being tilted forward or back and left or right.
  45580. */
  45581. export class DeviceOrientationCamera extends FreeCamera {
  45582. private _initialQuaternion;
  45583. private _quaternionCache;
  45584. private _tmpDragQuaternion;
  45585. private _disablePointerInputWhenUsingDeviceOrientation;
  45586. /**
  45587. * Creates a new device orientation camera
  45588. * @param name The name of the camera
  45589. * @param position The start position camera
  45590. * @param scene The scene the camera belongs to
  45591. */
  45592. constructor(name: string, position: Vector3, scene: Scene);
  45593. /**
  45594. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45595. */
  45596. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45597. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45598. private _dragFactor;
  45599. /**
  45600. * Enabled turning on the y axis when the orientation sensor is active
  45601. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45602. */
  45603. enableHorizontalDragging(dragFactor?: number): void;
  45604. /**
  45605. * Gets the current instance class name ("DeviceOrientationCamera").
  45606. * This helps avoiding instanceof at run time.
  45607. * @returns the class name
  45608. */
  45609. getClassName(): string;
  45610. /**
  45611. * @hidden
  45612. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45613. */
  45614. _checkInputs(): void;
  45615. /**
  45616. * Reset the camera to its default orientation on the specified axis only.
  45617. * @param axis The axis to reset
  45618. */
  45619. resetToCurrentRotation(axis?: Axis): void;
  45620. }
  45621. }
  45622. declare module "babylonjs/Gamepads/xboxGamepad" {
  45623. import { Observable } from "babylonjs/Misc/observable";
  45624. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45625. /**
  45626. * Defines supported buttons for XBox360 compatible gamepads
  45627. */
  45628. export enum Xbox360Button {
  45629. /** A */
  45630. A = 0,
  45631. /** B */
  45632. B = 1,
  45633. /** X */
  45634. X = 2,
  45635. /** Y */
  45636. Y = 3,
  45637. /** Left button */
  45638. LB = 4,
  45639. /** Right button */
  45640. RB = 5,
  45641. /** Back */
  45642. Back = 8,
  45643. /** Start */
  45644. Start = 9,
  45645. /** Left stick */
  45646. LeftStick = 10,
  45647. /** Right stick */
  45648. RightStick = 11
  45649. }
  45650. /** Defines values for XBox360 DPad */
  45651. export enum Xbox360Dpad {
  45652. /** Up */
  45653. Up = 12,
  45654. /** Down */
  45655. Down = 13,
  45656. /** Left */
  45657. Left = 14,
  45658. /** Right */
  45659. Right = 15
  45660. }
  45661. /**
  45662. * Defines a XBox360 gamepad
  45663. */
  45664. export class Xbox360Pad extends Gamepad {
  45665. private _leftTrigger;
  45666. private _rightTrigger;
  45667. private _onlefttriggerchanged;
  45668. private _onrighttriggerchanged;
  45669. private _onbuttondown;
  45670. private _onbuttonup;
  45671. private _ondpaddown;
  45672. private _ondpadup;
  45673. /** Observable raised when a button is pressed */
  45674. onButtonDownObservable: Observable<Xbox360Button>;
  45675. /** Observable raised when a button is released */
  45676. onButtonUpObservable: Observable<Xbox360Button>;
  45677. /** Observable raised when a pad is pressed */
  45678. onPadDownObservable: Observable<Xbox360Dpad>;
  45679. /** Observable raised when a pad is released */
  45680. onPadUpObservable: Observable<Xbox360Dpad>;
  45681. private _buttonA;
  45682. private _buttonB;
  45683. private _buttonX;
  45684. private _buttonY;
  45685. private _buttonBack;
  45686. private _buttonStart;
  45687. private _buttonLB;
  45688. private _buttonRB;
  45689. private _buttonLeftStick;
  45690. private _buttonRightStick;
  45691. private _dPadUp;
  45692. private _dPadDown;
  45693. private _dPadLeft;
  45694. private _dPadRight;
  45695. private _isXboxOnePad;
  45696. /**
  45697. * Creates a new XBox360 gamepad object
  45698. * @param id defines the id of this gamepad
  45699. * @param index defines its index
  45700. * @param gamepad defines the internal HTML gamepad object
  45701. * @param xboxOne defines if it is a XBox One gamepad
  45702. */
  45703. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45704. /**
  45705. * Defines the callback to call when left trigger is pressed
  45706. * @param callback defines the callback to use
  45707. */
  45708. onlefttriggerchanged(callback: (value: number) => void): void;
  45709. /**
  45710. * Defines the callback to call when right trigger is pressed
  45711. * @param callback defines the callback to use
  45712. */
  45713. onrighttriggerchanged(callback: (value: number) => void): void;
  45714. /**
  45715. * Gets the left trigger value
  45716. */
  45717. get leftTrigger(): number;
  45718. /**
  45719. * Sets the left trigger value
  45720. */
  45721. set leftTrigger(newValue: number);
  45722. /**
  45723. * Gets the right trigger value
  45724. */
  45725. get rightTrigger(): number;
  45726. /**
  45727. * Sets the right trigger value
  45728. */
  45729. set rightTrigger(newValue: number);
  45730. /**
  45731. * Defines the callback to call when a button is pressed
  45732. * @param callback defines the callback to use
  45733. */
  45734. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45735. /**
  45736. * Defines the callback to call when a button is released
  45737. * @param callback defines the callback to use
  45738. */
  45739. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45740. /**
  45741. * Defines the callback to call when a pad is pressed
  45742. * @param callback defines the callback to use
  45743. */
  45744. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45745. /**
  45746. * Defines the callback to call when a pad is released
  45747. * @param callback defines the callback to use
  45748. */
  45749. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45750. private _setButtonValue;
  45751. private _setDPadValue;
  45752. /**
  45753. * Gets the value of the `A` button
  45754. */
  45755. get buttonA(): number;
  45756. /**
  45757. * Sets the value of the `A` button
  45758. */
  45759. set buttonA(value: number);
  45760. /**
  45761. * Gets the value of the `B` button
  45762. */
  45763. get buttonB(): number;
  45764. /**
  45765. * Sets the value of the `B` button
  45766. */
  45767. set buttonB(value: number);
  45768. /**
  45769. * Gets the value of the `X` button
  45770. */
  45771. get buttonX(): number;
  45772. /**
  45773. * Sets the value of the `X` button
  45774. */
  45775. set buttonX(value: number);
  45776. /**
  45777. * Gets the value of the `Y` button
  45778. */
  45779. get buttonY(): number;
  45780. /**
  45781. * Sets the value of the `Y` button
  45782. */
  45783. set buttonY(value: number);
  45784. /**
  45785. * Gets the value of the `Start` button
  45786. */
  45787. get buttonStart(): number;
  45788. /**
  45789. * Sets the value of the `Start` button
  45790. */
  45791. set buttonStart(value: number);
  45792. /**
  45793. * Gets the value of the `Back` button
  45794. */
  45795. get buttonBack(): number;
  45796. /**
  45797. * Sets the value of the `Back` button
  45798. */
  45799. set buttonBack(value: number);
  45800. /**
  45801. * Gets the value of the `Left` button
  45802. */
  45803. get buttonLB(): number;
  45804. /**
  45805. * Sets the value of the `Left` button
  45806. */
  45807. set buttonLB(value: number);
  45808. /**
  45809. * Gets the value of the `Right` button
  45810. */
  45811. get buttonRB(): number;
  45812. /**
  45813. * Sets the value of the `Right` button
  45814. */
  45815. set buttonRB(value: number);
  45816. /**
  45817. * Gets the value of the Left joystick
  45818. */
  45819. get buttonLeftStick(): number;
  45820. /**
  45821. * Sets the value of the Left joystick
  45822. */
  45823. set buttonLeftStick(value: number);
  45824. /**
  45825. * Gets the value of the Right joystick
  45826. */
  45827. get buttonRightStick(): number;
  45828. /**
  45829. * Sets the value of the Right joystick
  45830. */
  45831. set buttonRightStick(value: number);
  45832. /**
  45833. * Gets the value of D-pad up
  45834. */
  45835. get dPadUp(): number;
  45836. /**
  45837. * Sets the value of D-pad up
  45838. */
  45839. set dPadUp(value: number);
  45840. /**
  45841. * Gets the value of D-pad down
  45842. */
  45843. get dPadDown(): number;
  45844. /**
  45845. * Sets the value of D-pad down
  45846. */
  45847. set dPadDown(value: number);
  45848. /**
  45849. * Gets the value of D-pad left
  45850. */
  45851. get dPadLeft(): number;
  45852. /**
  45853. * Sets the value of D-pad left
  45854. */
  45855. set dPadLeft(value: number);
  45856. /**
  45857. * Gets the value of D-pad right
  45858. */
  45859. get dPadRight(): number;
  45860. /**
  45861. * Sets the value of D-pad right
  45862. */
  45863. set dPadRight(value: number);
  45864. /**
  45865. * Force the gamepad to synchronize with device values
  45866. */
  45867. update(): void;
  45868. /**
  45869. * Disposes the gamepad
  45870. */
  45871. dispose(): void;
  45872. }
  45873. }
  45874. declare module "babylonjs/Gamepads/dualShockGamepad" {
  45875. import { Observable } from "babylonjs/Misc/observable";
  45876. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45877. /**
  45878. * Defines supported buttons for DualShock compatible gamepads
  45879. */
  45880. export enum DualShockButton {
  45881. /** Cross */
  45882. Cross = 0,
  45883. /** Circle */
  45884. Circle = 1,
  45885. /** Square */
  45886. Square = 2,
  45887. /** Triangle */
  45888. Triangle = 3,
  45889. /** L1 */
  45890. L1 = 4,
  45891. /** R1 */
  45892. R1 = 5,
  45893. /** Share */
  45894. Share = 8,
  45895. /** Options */
  45896. Options = 9,
  45897. /** Left stick */
  45898. LeftStick = 10,
  45899. /** Right stick */
  45900. RightStick = 11
  45901. }
  45902. /** Defines values for DualShock DPad */
  45903. export enum DualShockDpad {
  45904. /** Up */
  45905. Up = 12,
  45906. /** Down */
  45907. Down = 13,
  45908. /** Left */
  45909. Left = 14,
  45910. /** Right */
  45911. Right = 15
  45912. }
  45913. /**
  45914. * Defines a DualShock gamepad
  45915. */
  45916. export class DualShockPad extends Gamepad {
  45917. private _leftTrigger;
  45918. private _rightTrigger;
  45919. private _onlefttriggerchanged;
  45920. private _onrighttriggerchanged;
  45921. private _onbuttondown;
  45922. private _onbuttonup;
  45923. private _ondpaddown;
  45924. private _ondpadup;
  45925. /** Observable raised when a button is pressed */
  45926. onButtonDownObservable: Observable<DualShockButton>;
  45927. /** Observable raised when a button is released */
  45928. onButtonUpObservable: Observable<DualShockButton>;
  45929. /** Observable raised when a pad is pressed */
  45930. onPadDownObservable: Observable<DualShockDpad>;
  45931. /** Observable raised when a pad is released */
  45932. onPadUpObservable: Observable<DualShockDpad>;
  45933. private _buttonCross;
  45934. private _buttonCircle;
  45935. private _buttonSquare;
  45936. private _buttonTriangle;
  45937. private _buttonShare;
  45938. private _buttonOptions;
  45939. private _buttonL1;
  45940. private _buttonR1;
  45941. private _buttonLeftStick;
  45942. private _buttonRightStick;
  45943. private _dPadUp;
  45944. private _dPadDown;
  45945. private _dPadLeft;
  45946. private _dPadRight;
  45947. /**
  45948. * Creates a new DualShock gamepad object
  45949. * @param id defines the id of this gamepad
  45950. * @param index defines its index
  45951. * @param gamepad defines the internal HTML gamepad object
  45952. */
  45953. constructor(id: string, index: number, gamepad: any);
  45954. /**
  45955. * Defines the callback to call when left trigger is pressed
  45956. * @param callback defines the callback to use
  45957. */
  45958. onlefttriggerchanged(callback: (value: number) => void): void;
  45959. /**
  45960. * Defines the callback to call when right trigger is pressed
  45961. * @param callback defines the callback to use
  45962. */
  45963. onrighttriggerchanged(callback: (value: number) => void): void;
  45964. /**
  45965. * Gets the left trigger value
  45966. */
  45967. get leftTrigger(): number;
  45968. /**
  45969. * Sets the left trigger value
  45970. */
  45971. set leftTrigger(newValue: number);
  45972. /**
  45973. * Gets the right trigger value
  45974. */
  45975. get rightTrigger(): number;
  45976. /**
  45977. * Sets the right trigger value
  45978. */
  45979. set rightTrigger(newValue: number);
  45980. /**
  45981. * Defines the callback to call when a button is pressed
  45982. * @param callback defines the callback to use
  45983. */
  45984. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45985. /**
  45986. * Defines the callback to call when a button is released
  45987. * @param callback defines the callback to use
  45988. */
  45989. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45990. /**
  45991. * Defines the callback to call when a pad is pressed
  45992. * @param callback defines the callback to use
  45993. */
  45994. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45995. /**
  45996. * Defines the callback to call when a pad is released
  45997. * @param callback defines the callback to use
  45998. */
  45999. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46000. private _setButtonValue;
  46001. private _setDPadValue;
  46002. /**
  46003. * Gets the value of the `Cross` button
  46004. */
  46005. get buttonCross(): number;
  46006. /**
  46007. * Sets the value of the `Cross` button
  46008. */
  46009. set buttonCross(value: number);
  46010. /**
  46011. * Gets the value of the `Circle` button
  46012. */
  46013. get buttonCircle(): number;
  46014. /**
  46015. * Sets the value of the `Circle` button
  46016. */
  46017. set buttonCircle(value: number);
  46018. /**
  46019. * Gets the value of the `Square` button
  46020. */
  46021. get buttonSquare(): number;
  46022. /**
  46023. * Sets the value of the `Square` button
  46024. */
  46025. set buttonSquare(value: number);
  46026. /**
  46027. * Gets the value of the `Triangle` button
  46028. */
  46029. get buttonTriangle(): number;
  46030. /**
  46031. * Sets the value of the `Triangle` button
  46032. */
  46033. set buttonTriangle(value: number);
  46034. /**
  46035. * Gets the value of the `Options` button
  46036. */
  46037. get buttonOptions(): number;
  46038. /**
  46039. * Sets the value of the `Options` button
  46040. */
  46041. set buttonOptions(value: number);
  46042. /**
  46043. * Gets the value of the `Share` button
  46044. */
  46045. get buttonShare(): number;
  46046. /**
  46047. * Sets the value of the `Share` button
  46048. */
  46049. set buttonShare(value: number);
  46050. /**
  46051. * Gets the value of the `L1` button
  46052. */
  46053. get buttonL1(): number;
  46054. /**
  46055. * Sets the value of the `L1` button
  46056. */
  46057. set buttonL1(value: number);
  46058. /**
  46059. * Gets the value of the `R1` button
  46060. */
  46061. get buttonR1(): number;
  46062. /**
  46063. * Sets the value of the `R1` button
  46064. */
  46065. set buttonR1(value: number);
  46066. /**
  46067. * Gets the value of the Left joystick
  46068. */
  46069. get buttonLeftStick(): number;
  46070. /**
  46071. * Sets the value of the Left joystick
  46072. */
  46073. set buttonLeftStick(value: number);
  46074. /**
  46075. * Gets the value of the Right joystick
  46076. */
  46077. get buttonRightStick(): number;
  46078. /**
  46079. * Sets the value of the Right joystick
  46080. */
  46081. set buttonRightStick(value: number);
  46082. /**
  46083. * Gets the value of D-pad up
  46084. */
  46085. get dPadUp(): number;
  46086. /**
  46087. * Sets the value of D-pad up
  46088. */
  46089. set dPadUp(value: number);
  46090. /**
  46091. * Gets the value of D-pad down
  46092. */
  46093. get dPadDown(): number;
  46094. /**
  46095. * Sets the value of D-pad down
  46096. */
  46097. set dPadDown(value: number);
  46098. /**
  46099. * Gets the value of D-pad left
  46100. */
  46101. get dPadLeft(): number;
  46102. /**
  46103. * Sets the value of D-pad left
  46104. */
  46105. set dPadLeft(value: number);
  46106. /**
  46107. * Gets the value of D-pad right
  46108. */
  46109. get dPadRight(): number;
  46110. /**
  46111. * Sets the value of D-pad right
  46112. */
  46113. set dPadRight(value: number);
  46114. /**
  46115. * Force the gamepad to synchronize with device values
  46116. */
  46117. update(): void;
  46118. /**
  46119. * Disposes the gamepad
  46120. */
  46121. dispose(): void;
  46122. }
  46123. }
  46124. declare module "babylonjs/Gamepads/gamepadManager" {
  46125. import { Observable } from "babylonjs/Misc/observable";
  46126. import { Nullable } from "babylonjs/types";
  46127. import { Scene } from "babylonjs/scene";
  46128. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46129. /**
  46130. * Manager for handling gamepads
  46131. */
  46132. export class GamepadManager {
  46133. private _scene?;
  46134. private _babylonGamepads;
  46135. private _oneGamepadConnected;
  46136. /** @hidden */
  46137. _isMonitoring: boolean;
  46138. private _gamepadEventSupported;
  46139. private _gamepadSupport?;
  46140. /**
  46141. * observable to be triggered when the gamepad controller has been connected
  46142. */
  46143. onGamepadConnectedObservable: Observable<Gamepad>;
  46144. /**
  46145. * observable to be triggered when the gamepad controller has been disconnected
  46146. */
  46147. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46148. private _onGamepadConnectedEvent;
  46149. private _onGamepadDisconnectedEvent;
  46150. /**
  46151. * Initializes the gamepad manager
  46152. * @param _scene BabylonJS scene
  46153. */
  46154. constructor(_scene?: Scene | undefined);
  46155. /**
  46156. * The gamepads in the game pad manager
  46157. */
  46158. get gamepads(): Gamepad[];
  46159. /**
  46160. * Get the gamepad controllers based on type
  46161. * @param type The type of gamepad controller
  46162. * @returns Nullable gamepad
  46163. */
  46164. getGamepadByType(type?: number): Nullable<Gamepad>;
  46165. /**
  46166. * Disposes the gamepad manager
  46167. */
  46168. dispose(): void;
  46169. private _addNewGamepad;
  46170. private _startMonitoringGamepads;
  46171. private _stopMonitoringGamepads;
  46172. /** @hidden */
  46173. _checkGamepadsStatus(): void;
  46174. private _updateGamepadObjects;
  46175. }
  46176. }
  46177. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46178. import { Nullable } from "babylonjs/types";
  46179. import { Scene } from "babylonjs/scene";
  46180. import { ISceneComponent } from "babylonjs/sceneComponent";
  46181. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46182. module "babylonjs/scene" {
  46183. interface Scene {
  46184. /** @hidden */
  46185. _gamepadManager: Nullable<GamepadManager>;
  46186. /**
  46187. * Gets the gamepad manager associated with the scene
  46188. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46189. */
  46190. gamepadManager: GamepadManager;
  46191. }
  46192. }
  46193. module "babylonjs/Cameras/freeCameraInputsManager" {
  46194. /**
  46195. * Interface representing a free camera inputs manager
  46196. */
  46197. interface FreeCameraInputsManager {
  46198. /**
  46199. * Adds gamepad input support to the FreeCameraInputsManager.
  46200. * @returns the FreeCameraInputsManager
  46201. */
  46202. addGamepad(): FreeCameraInputsManager;
  46203. }
  46204. }
  46205. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46206. /**
  46207. * Interface representing an arc rotate camera inputs manager
  46208. */
  46209. interface ArcRotateCameraInputsManager {
  46210. /**
  46211. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46212. * @returns the camera inputs manager
  46213. */
  46214. addGamepad(): ArcRotateCameraInputsManager;
  46215. }
  46216. }
  46217. /**
  46218. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46219. */
  46220. export class GamepadSystemSceneComponent implements ISceneComponent {
  46221. /**
  46222. * The component name helpfull to identify the component in the list of scene components.
  46223. */
  46224. readonly name: string;
  46225. /**
  46226. * The scene the component belongs to.
  46227. */
  46228. scene: Scene;
  46229. /**
  46230. * Creates a new instance of the component for the given scene
  46231. * @param scene Defines the scene to register the component in
  46232. */
  46233. constructor(scene: Scene);
  46234. /**
  46235. * Registers the component in a given scene
  46236. */
  46237. register(): void;
  46238. /**
  46239. * Rebuilds the elements related to this component in case of
  46240. * context lost for instance.
  46241. */
  46242. rebuild(): void;
  46243. /**
  46244. * Disposes the component and the associated ressources
  46245. */
  46246. dispose(): void;
  46247. private _beforeCameraUpdate;
  46248. }
  46249. }
  46250. declare module "babylonjs/Cameras/universalCamera" {
  46251. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46252. import { Scene } from "babylonjs/scene";
  46253. import { Vector3 } from "babylonjs/Maths/math.vector";
  46254. import "babylonjs/Gamepads/gamepadSceneComponent";
  46255. /**
  46256. * 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,
  46257. * which still works and will still be found in many Playgrounds.
  46258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46259. */
  46260. export class UniversalCamera extends TouchCamera {
  46261. /**
  46262. * Defines the gamepad rotation sensiblity.
  46263. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46264. */
  46265. get gamepadAngularSensibility(): number;
  46266. set gamepadAngularSensibility(value: number);
  46267. /**
  46268. * Defines the gamepad move sensiblity.
  46269. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46270. */
  46271. get gamepadMoveSensibility(): number;
  46272. set gamepadMoveSensibility(value: number);
  46273. /**
  46274. * 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,
  46275. * which still works and will still be found in many Playgrounds.
  46276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46277. * @param name Define the name of the camera in the scene
  46278. * @param position Define the start position of the camera in the scene
  46279. * @param scene Define the scene the camera belongs to
  46280. */
  46281. constructor(name: string, position: Vector3, scene: Scene);
  46282. /**
  46283. * Gets the current object class name.
  46284. * @return the class name
  46285. */
  46286. getClassName(): string;
  46287. }
  46288. }
  46289. declare module "babylonjs/Cameras/gamepadCamera" {
  46290. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46291. import { Scene } from "babylonjs/scene";
  46292. import { Vector3 } from "babylonjs/Maths/math.vector";
  46293. /**
  46294. * This represents a FPS type of camera. This is only here for back compat purpose.
  46295. * Please use the UniversalCamera instead as both are identical.
  46296. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46297. */
  46298. export class GamepadCamera extends UniversalCamera {
  46299. /**
  46300. * Instantiates a new Gamepad Camera
  46301. * This represents a FPS type of camera. This is only here for back compat purpose.
  46302. * Please use the UniversalCamera instead as both are identical.
  46303. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46304. * @param name Define the name of the camera in the scene
  46305. * @param position Define the start position of the camera in the scene
  46306. * @param scene Define the scene the camera belongs to
  46307. */
  46308. constructor(name: string, position: Vector3, scene: Scene);
  46309. /**
  46310. * Gets the current object class name.
  46311. * @return the class name
  46312. */
  46313. getClassName(): string;
  46314. }
  46315. }
  46316. declare module "babylonjs/Shaders/pass.fragment" {
  46317. /** @hidden */
  46318. export var passPixelShader: {
  46319. name: string;
  46320. shader: string;
  46321. };
  46322. }
  46323. declare module "babylonjs/Shaders/passCube.fragment" {
  46324. /** @hidden */
  46325. export var passCubePixelShader: {
  46326. name: string;
  46327. shader: string;
  46328. };
  46329. }
  46330. declare module "babylonjs/PostProcesses/passPostProcess" {
  46331. import { Nullable } from "babylonjs/types";
  46332. import { Camera } from "babylonjs/Cameras/camera";
  46333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46334. import { Engine } from "babylonjs/Engines/engine";
  46335. import "babylonjs/Shaders/pass.fragment";
  46336. import "babylonjs/Shaders/passCube.fragment";
  46337. /**
  46338. * PassPostProcess which produces an output the same as it's input
  46339. */
  46340. export class PassPostProcess extends PostProcess {
  46341. /**
  46342. * Creates the PassPostProcess
  46343. * @param name The name of the effect.
  46344. * @param options The required width/height ratio to downsize to before computing the render pass.
  46345. * @param camera The camera to apply the render pass to.
  46346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46347. * @param engine The engine which the post process will be applied. (default: current engine)
  46348. * @param reusable If the post process can be reused on the same frame. (default: false)
  46349. * @param textureType The type of texture to be used when performing the post processing.
  46350. * @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)
  46351. */
  46352. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46353. }
  46354. /**
  46355. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46356. */
  46357. export class PassCubePostProcess extends PostProcess {
  46358. private _face;
  46359. /**
  46360. * Gets or sets the cube face to display.
  46361. * * 0 is +X
  46362. * * 1 is -X
  46363. * * 2 is +Y
  46364. * * 3 is -Y
  46365. * * 4 is +Z
  46366. * * 5 is -Z
  46367. */
  46368. get face(): number;
  46369. set face(value: number);
  46370. /**
  46371. * Creates the PassCubePostProcess
  46372. * @param name The name of the effect.
  46373. * @param options The required width/height ratio to downsize to before computing the render pass.
  46374. * @param camera The camera to apply the render pass to.
  46375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46376. * @param engine The engine which the post process will be applied. (default: current engine)
  46377. * @param reusable If the post process can be reused on the same frame. (default: false)
  46378. * @param textureType The type of texture to be used when performing the post processing.
  46379. * @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)
  46380. */
  46381. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46382. }
  46383. }
  46384. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46385. /** @hidden */
  46386. export var anaglyphPixelShader: {
  46387. name: string;
  46388. shader: string;
  46389. };
  46390. }
  46391. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46392. import { Engine } from "babylonjs/Engines/engine";
  46393. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46394. import { Camera } from "babylonjs/Cameras/camera";
  46395. import "babylonjs/Shaders/anaglyph.fragment";
  46396. /**
  46397. * Postprocess used to generate anaglyphic rendering
  46398. */
  46399. export class AnaglyphPostProcess extends PostProcess {
  46400. private _passedProcess;
  46401. /**
  46402. * Creates a new AnaglyphPostProcess
  46403. * @param name defines postprocess name
  46404. * @param options defines creation options or target ratio scale
  46405. * @param rigCameras defines cameras using this postprocess
  46406. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46407. * @param engine defines hosting engine
  46408. * @param reusable defines if the postprocess will be reused multiple times per frame
  46409. */
  46410. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46411. }
  46412. }
  46413. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46414. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46415. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46416. import { Scene } from "babylonjs/scene";
  46417. import { Vector3 } from "babylonjs/Maths/math.vector";
  46418. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46419. /**
  46420. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46421. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46422. */
  46423. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46424. /**
  46425. * Creates a new AnaglyphArcRotateCamera
  46426. * @param name defines camera name
  46427. * @param alpha defines alpha angle (in radians)
  46428. * @param beta defines beta angle (in radians)
  46429. * @param radius defines radius
  46430. * @param target defines camera target
  46431. * @param interaxialDistance defines distance between each color axis
  46432. * @param scene defines the hosting scene
  46433. */
  46434. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46435. /**
  46436. * Gets camera class name
  46437. * @returns AnaglyphArcRotateCamera
  46438. */
  46439. getClassName(): string;
  46440. }
  46441. }
  46442. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46443. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46444. import { Scene } from "babylonjs/scene";
  46445. import { Vector3 } from "babylonjs/Maths/math.vector";
  46446. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46447. /**
  46448. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46449. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46450. */
  46451. export class AnaglyphFreeCamera extends FreeCamera {
  46452. /**
  46453. * Creates a new AnaglyphFreeCamera
  46454. * @param name defines camera name
  46455. * @param position defines initial position
  46456. * @param interaxialDistance defines distance between each color axis
  46457. * @param scene defines the hosting scene
  46458. */
  46459. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46460. /**
  46461. * Gets camera class name
  46462. * @returns AnaglyphFreeCamera
  46463. */
  46464. getClassName(): string;
  46465. }
  46466. }
  46467. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46468. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46469. import { Scene } from "babylonjs/scene";
  46470. import { Vector3 } from "babylonjs/Maths/math.vector";
  46471. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46472. /**
  46473. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46474. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46475. */
  46476. export class AnaglyphGamepadCamera extends GamepadCamera {
  46477. /**
  46478. * Creates a new AnaglyphGamepadCamera
  46479. * @param name defines camera name
  46480. * @param position defines initial position
  46481. * @param interaxialDistance defines distance between each color axis
  46482. * @param scene defines the hosting scene
  46483. */
  46484. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46485. /**
  46486. * Gets camera class name
  46487. * @returns AnaglyphGamepadCamera
  46488. */
  46489. getClassName(): string;
  46490. }
  46491. }
  46492. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46493. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46494. import { Scene } from "babylonjs/scene";
  46495. import { Vector3 } from "babylonjs/Maths/math.vector";
  46496. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46497. /**
  46498. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46499. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46500. */
  46501. export class AnaglyphUniversalCamera extends UniversalCamera {
  46502. /**
  46503. * Creates a new AnaglyphUniversalCamera
  46504. * @param name defines camera name
  46505. * @param position defines initial position
  46506. * @param interaxialDistance defines distance between each color axis
  46507. * @param scene defines the hosting scene
  46508. */
  46509. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46510. /**
  46511. * Gets camera class name
  46512. * @returns AnaglyphUniversalCamera
  46513. */
  46514. getClassName(): string;
  46515. }
  46516. }
  46517. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46518. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46520. import { Scene } from "babylonjs/scene";
  46521. import { Vector3 } from "babylonjs/Maths/math.vector";
  46522. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46523. /**
  46524. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46525. * @see http://doc.babylonjs.com/features/cameras
  46526. */
  46527. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46528. /**
  46529. * Creates a new StereoscopicArcRotateCamera
  46530. * @param name defines camera name
  46531. * @param alpha defines alpha angle (in radians)
  46532. * @param beta defines beta angle (in radians)
  46533. * @param radius defines radius
  46534. * @param target defines camera target
  46535. * @param interaxialDistance defines distance between each color axis
  46536. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46537. * @param scene defines the hosting scene
  46538. */
  46539. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46540. /**
  46541. * Gets camera class name
  46542. * @returns StereoscopicArcRotateCamera
  46543. */
  46544. getClassName(): string;
  46545. }
  46546. }
  46547. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46548. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46549. import { Scene } from "babylonjs/scene";
  46550. import { Vector3 } from "babylonjs/Maths/math.vector";
  46551. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46552. /**
  46553. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46554. * @see http://doc.babylonjs.com/features/cameras
  46555. */
  46556. export class StereoscopicFreeCamera extends FreeCamera {
  46557. /**
  46558. * Creates a new StereoscopicFreeCamera
  46559. * @param name defines camera name
  46560. * @param position defines initial position
  46561. * @param interaxialDistance defines distance between each color axis
  46562. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46563. * @param scene defines the hosting scene
  46564. */
  46565. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46566. /**
  46567. * Gets camera class name
  46568. * @returns StereoscopicFreeCamera
  46569. */
  46570. getClassName(): string;
  46571. }
  46572. }
  46573. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46574. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46575. import { Scene } from "babylonjs/scene";
  46576. import { Vector3 } from "babylonjs/Maths/math.vector";
  46577. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46578. /**
  46579. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46580. * @see http://doc.babylonjs.com/features/cameras
  46581. */
  46582. export class StereoscopicGamepadCamera extends GamepadCamera {
  46583. /**
  46584. * Creates a new StereoscopicGamepadCamera
  46585. * @param name defines camera name
  46586. * @param position defines initial position
  46587. * @param interaxialDistance defines distance between each color axis
  46588. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46589. * @param scene defines the hosting scene
  46590. */
  46591. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46592. /**
  46593. * Gets camera class name
  46594. * @returns StereoscopicGamepadCamera
  46595. */
  46596. getClassName(): string;
  46597. }
  46598. }
  46599. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46600. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46601. import { Scene } from "babylonjs/scene";
  46602. import { Vector3 } from "babylonjs/Maths/math.vector";
  46603. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46604. /**
  46605. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46606. * @see http://doc.babylonjs.com/features/cameras
  46607. */
  46608. export class StereoscopicUniversalCamera extends UniversalCamera {
  46609. /**
  46610. * Creates a new StereoscopicUniversalCamera
  46611. * @param name defines camera name
  46612. * @param position defines initial position
  46613. * @param interaxialDistance defines distance between each color axis
  46614. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46615. * @param scene defines the hosting scene
  46616. */
  46617. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46618. /**
  46619. * Gets camera class name
  46620. * @returns StereoscopicUniversalCamera
  46621. */
  46622. getClassName(): string;
  46623. }
  46624. }
  46625. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46626. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46627. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46628. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46629. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46630. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46631. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46632. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46633. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46634. }
  46635. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46636. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46637. import { Scene } from "babylonjs/scene";
  46638. import { Vector3 } from "babylonjs/Maths/math.vector";
  46639. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46640. /**
  46641. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46642. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46643. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46644. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46645. */
  46646. export class VirtualJoysticksCamera extends FreeCamera {
  46647. /**
  46648. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46649. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46650. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46651. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46652. * @param name Define the name of the camera in the scene
  46653. * @param position Define the start position of the camera in the scene
  46654. * @param scene Define the scene the camera belongs to
  46655. */
  46656. constructor(name: string, position: Vector3, scene: Scene);
  46657. /**
  46658. * Gets the current object class name.
  46659. * @return the class name
  46660. */
  46661. getClassName(): string;
  46662. }
  46663. }
  46664. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46665. import { Matrix } from "babylonjs/Maths/math.vector";
  46666. /**
  46667. * This represents all the required metrics to create a VR camera.
  46668. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46669. */
  46670. export class VRCameraMetrics {
  46671. /**
  46672. * Define the horizontal resolution off the screen.
  46673. */
  46674. hResolution: number;
  46675. /**
  46676. * Define the vertical resolution off the screen.
  46677. */
  46678. vResolution: number;
  46679. /**
  46680. * Define the horizontal screen size.
  46681. */
  46682. hScreenSize: number;
  46683. /**
  46684. * Define the vertical screen size.
  46685. */
  46686. vScreenSize: number;
  46687. /**
  46688. * Define the vertical screen center position.
  46689. */
  46690. vScreenCenter: number;
  46691. /**
  46692. * Define the distance of the eyes to the screen.
  46693. */
  46694. eyeToScreenDistance: number;
  46695. /**
  46696. * Define the distance between both lenses
  46697. */
  46698. lensSeparationDistance: number;
  46699. /**
  46700. * Define the distance between both viewer's eyes.
  46701. */
  46702. interpupillaryDistance: number;
  46703. /**
  46704. * Define the distortion factor of the VR postprocess.
  46705. * Please, touch with care.
  46706. */
  46707. distortionK: number[];
  46708. /**
  46709. * Define the chromatic aberration correction factors for the VR post process.
  46710. */
  46711. chromaAbCorrection: number[];
  46712. /**
  46713. * Define the scale factor of the post process.
  46714. * The smaller the better but the slower.
  46715. */
  46716. postProcessScaleFactor: number;
  46717. /**
  46718. * Define an offset for the lens center.
  46719. */
  46720. lensCenterOffset: number;
  46721. /**
  46722. * Define if the current vr camera should compensate the distortion of the lense or not.
  46723. */
  46724. compensateDistortion: boolean;
  46725. /**
  46726. * Defines if multiview should be enabled when rendering (Default: false)
  46727. */
  46728. multiviewEnabled: boolean;
  46729. /**
  46730. * Gets the rendering aspect ratio based on the provided resolutions.
  46731. */
  46732. get aspectRatio(): number;
  46733. /**
  46734. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46735. */
  46736. get aspectRatioFov(): number;
  46737. /**
  46738. * @hidden
  46739. */
  46740. get leftHMatrix(): Matrix;
  46741. /**
  46742. * @hidden
  46743. */
  46744. get rightHMatrix(): Matrix;
  46745. /**
  46746. * @hidden
  46747. */
  46748. get leftPreViewMatrix(): Matrix;
  46749. /**
  46750. * @hidden
  46751. */
  46752. get rightPreViewMatrix(): Matrix;
  46753. /**
  46754. * Get the default VRMetrics based on the most generic setup.
  46755. * @returns the default vr metrics
  46756. */
  46757. static GetDefault(): VRCameraMetrics;
  46758. }
  46759. }
  46760. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46761. /** @hidden */
  46762. export var vrDistortionCorrectionPixelShader: {
  46763. name: string;
  46764. shader: string;
  46765. };
  46766. }
  46767. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46768. import { Camera } from "babylonjs/Cameras/camera";
  46769. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46770. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46771. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46772. /**
  46773. * VRDistortionCorrectionPostProcess used for mobile VR
  46774. */
  46775. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46776. private _isRightEye;
  46777. private _distortionFactors;
  46778. private _postProcessScaleFactor;
  46779. private _lensCenterOffset;
  46780. private _scaleIn;
  46781. private _scaleFactor;
  46782. private _lensCenter;
  46783. /**
  46784. * Initializes the VRDistortionCorrectionPostProcess
  46785. * @param name The name of the effect.
  46786. * @param camera The camera to apply the render pass to.
  46787. * @param isRightEye If this is for the right eye distortion
  46788. * @param vrMetrics All the required metrics for the VR camera
  46789. */
  46790. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46791. }
  46792. }
  46793. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46794. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46795. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46796. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46797. import { Scene } from "babylonjs/scene";
  46798. import { Vector3 } from "babylonjs/Maths/math.vector";
  46799. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46800. import "babylonjs/Cameras/RigModes/vrRigMode";
  46801. /**
  46802. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46803. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46804. */
  46805. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46806. /**
  46807. * Creates a new VRDeviceOrientationArcRotateCamera
  46808. * @param name defines camera name
  46809. * @param alpha defines the camera rotation along the logitudinal axis
  46810. * @param beta defines the camera rotation along the latitudinal axis
  46811. * @param radius defines the camera distance from its target
  46812. * @param target defines the camera target
  46813. * @param scene defines the scene the camera belongs to
  46814. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46815. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46816. */
  46817. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46818. /**
  46819. * Gets camera class name
  46820. * @returns VRDeviceOrientationArcRotateCamera
  46821. */
  46822. getClassName(): string;
  46823. }
  46824. }
  46825. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46826. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46827. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46828. import { Scene } from "babylonjs/scene";
  46829. import { Vector3 } from "babylonjs/Maths/math.vector";
  46830. import "babylonjs/Cameras/RigModes/vrRigMode";
  46831. /**
  46832. * Camera used to simulate VR rendering (based on FreeCamera)
  46833. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46834. */
  46835. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46836. /**
  46837. * Creates a new VRDeviceOrientationFreeCamera
  46838. * @param name defines camera name
  46839. * @param position defines the start position of the camera
  46840. * @param scene defines the scene the camera belongs to
  46841. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46842. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46843. */
  46844. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46845. /**
  46846. * Gets camera class name
  46847. * @returns VRDeviceOrientationFreeCamera
  46848. */
  46849. getClassName(): string;
  46850. }
  46851. }
  46852. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  46853. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46854. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46855. import { Scene } from "babylonjs/scene";
  46856. import { Vector3 } from "babylonjs/Maths/math.vector";
  46857. import "babylonjs/Gamepads/gamepadSceneComponent";
  46858. /**
  46859. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46860. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46861. */
  46862. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46863. /**
  46864. * Creates a new VRDeviceOrientationGamepadCamera
  46865. * @param name defines camera name
  46866. * @param position defines the start position of the camera
  46867. * @param scene defines the scene the camera belongs to
  46868. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46869. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46870. */
  46871. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46872. /**
  46873. * Gets camera class name
  46874. * @returns VRDeviceOrientationGamepadCamera
  46875. */
  46876. getClassName(): string;
  46877. }
  46878. }
  46879. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  46880. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46882. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46883. /** @hidden */
  46884. export var imageProcessingPixelShader: {
  46885. name: string;
  46886. shader: string;
  46887. };
  46888. }
  46889. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  46890. import { Nullable } from "babylonjs/types";
  46891. import { Color4 } from "babylonjs/Maths/math.color";
  46892. import { Camera } from "babylonjs/Cameras/camera";
  46893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46894. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46895. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46897. import { Engine } from "babylonjs/Engines/engine";
  46898. import "babylonjs/Shaders/imageProcessing.fragment";
  46899. import "babylonjs/Shaders/postprocess.vertex";
  46900. /**
  46901. * ImageProcessingPostProcess
  46902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  46903. */
  46904. export class ImageProcessingPostProcess extends PostProcess {
  46905. /**
  46906. * Default configuration related to image processing available in the PBR Material.
  46907. */
  46908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46909. /**
  46910. * Gets the image processing configuration used either in this material.
  46911. */
  46912. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46913. /**
  46914. * Sets the Default image processing configuration used either in the this material.
  46915. *
  46916. * If sets to null, the scene one is in use.
  46917. */
  46918. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  46919. /**
  46920. * Keep track of the image processing observer to allow dispose and replace.
  46921. */
  46922. private _imageProcessingObserver;
  46923. /**
  46924. * Attaches a new image processing configuration to the PBR Material.
  46925. * @param configuration
  46926. */
  46927. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  46928. /**
  46929. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46930. */
  46931. get colorCurves(): Nullable<ColorCurves>;
  46932. /**
  46933. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46934. */
  46935. set colorCurves(value: Nullable<ColorCurves>);
  46936. /**
  46937. * Gets wether the color curves effect is enabled.
  46938. */
  46939. get colorCurvesEnabled(): boolean;
  46940. /**
  46941. * Sets wether the color curves effect is enabled.
  46942. */
  46943. set colorCurvesEnabled(value: boolean);
  46944. /**
  46945. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46946. */
  46947. get colorGradingTexture(): Nullable<BaseTexture>;
  46948. /**
  46949. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46950. */
  46951. set colorGradingTexture(value: Nullable<BaseTexture>);
  46952. /**
  46953. * Gets wether the color grading effect is enabled.
  46954. */
  46955. get colorGradingEnabled(): boolean;
  46956. /**
  46957. * Gets wether the color grading effect is enabled.
  46958. */
  46959. set colorGradingEnabled(value: boolean);
  46960. /**
  46961. * Gets exposure used in the effect.
  46962. */
  46963. get exposure(): number;
  46964. /**
  46965. * Sets exposure used in the effect.
  46966. */
  46967. set exposure(value: number);
  46968. /**
  46969. * Gets wether tonemapping is enabled or not.
  46970. */
  46971. get toneMappingEnabled(): boolean;
  46972. /**
  46973. * Sets wether tonemapping is enabled or not
  46974. */
  46975. set toneMappingEnabled(value: boolean);
  46976. /**
  46977. * Gets the type of tone mapping effect.
  46978. */
  46979. get toneMappingType(): number;
  46980. /**
  46981. * Sets the type of tone mapping effect.
  46982. */
  46983. set toneMappingType(value: number);
  46984. /**
  46985. * Gets contrast used in the effect.
  46986. */
  46987. get contrast(): number;
  46988. /**
  46989. * Sets contrast used in the effect.
  46990. */
  46991. set contrast(value: number);
  46992. /**
  46993. * Gets Vignette stretch size.
  46994. */
  46995. get vignetteStretch(): number;
  46996. /**
  46997. * Sets Vignette stretch size.
  46998. */
  46999. set vignetteStretch(value: number);
  47000. /**
  47001. * Gets Vignette centre X Offset.
  47002. */
  47003. get vignetteCentreX(): number;
  47004. /**
  47005. * Sets Vignette centre X Offset.
  47006. */
  47007. set vignetteCentreX(value: number);
  47008. /**
  47009. * Gets Vignette centre Y Offset.
  47010. */
  47011. get vignetteCentreY(): number;
  47012. /**
  47013. * Sets Vignette centre Y Offset.
  47014. */
  47015. set vignetteCentreY(value: number);
  47016. /**
  47017. * Gets Vignette weight or intensity of the vignette effect.
  47018. */
  47019. get vignetteWeight(): number;
  47020. /**
  47021. * Sets Vignette weight or intensity of the vignette effect.
  47022. */
  47023. set vignetteWeight(value: number);
  47024. /**
  47025. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47026. * if vignetteEnabled is set to true.
  47027. */
  47028. get vignetteColor(): Color4;
  47029. /**
  47030. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47031. * if vignetteEnabled is set to true.
  47032. */
  47033. set vignetteColor(value: Color4);
  47034. /**
  47035. * Gets Camera field of view used by the Vignette effect.
  47036. */
  47037. get vignetteCameraFov(): number;
  47038. /**
  47039. * Sets Camera field of view used by the Vignette effect.
  47040. */
  47041. set vignetteCameraFov(value: number);
  47042. /**
  47043. * Gets the vignette blend mode allowing different kind of effect.
  47044. */
  47045. get vignetteBlendMode(): number;
  47046. /**
  47047. * Sets the vignette blend mode allowing different kind of effect.
  47048. */
  47049. set vignetteBlendMode(value: number);
  47050. /**
  47051. * Gets wether the vignette effect is enabled.
  47052. */
  47053. get vignetteEnabled(): boolean;
  47054. /**
  47055. * Sets wether the vignette effect is enabled.
  47056. */
  47057. set vignetteEnabled(value: boolean);
  47058. private _fromLinearSpace;
  47059. /**
  47060. * Gets wether the input of the processing is in Gamma or Linear Space.
  47061. */
  47062. get fromLinearSpace(): boolean;
  47063. /**
  47064. * Sets wether the input of the processing is in Gamma or Linear Space.
  47065. */
  47066. set fromLinearSpace(value: boolean);
  47067. /**
  47068. * Defines cache preventing GC.
  47069. */
  47070. private _defines;
  47071. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47072. /**
  47073. * "ImageProcessingPostProcess"
  47074. * @returns "ImageProcessingPostProcess"
  47075. */
  47076. getClassName(): string;
  47077. protected _updateParameters(): void;
  47078. dispose(camera?: Camera): void;
  47079. }
  47080. }
  47081. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47082. import { Scene } from "babylonjs/scene";
  47083. import { Color3 } from "babylonjs/Maths/math.color";
  47084. import { Mesh } from "babylonjs/Meshes/mesh";
  47085. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47086. import { Nullable } from "babylonjs/types";
  47087. /**
  47088. * Class containing static functions to help procedurally build meshes
  47089. */
  47090. export class GroundBuilder {
  47091. /**
  47092. * Creates a ground mesh
  47093. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47094. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47096. * @param name defines the name of the mesh
  47097. * @param options defines the options used to create the mesh
  47098. * @param scene defines the hosting scene
  47099. * @returns the ground mesh
  47100. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47101. */
  47102. static CreateGround(name: string, options: {
  47103. width?: number;
  47104. height?: number;
  47105. subdivisions?: number;
  47106. subdivisionsX?: number;
  47107. subdivisionsY?: number;
  47108. updatable?: boolean;
  47109. }, scene: any): Mesh;
  47110. /**
  47111. * Creates a tiled ground mesh
  47112. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47113. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47114. * * 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
  47115. * * 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
  47116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47117. * @param name defines the name of the mesh
  47118. * @param options defines the options used to create the mesh
  47119. * @param scene defines the hosting scene
  47120. * @returns the tiled ground mesh
  47121. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47122. */
  47123. static CreateTiledGround(name: string, options: {
  47124. xmin: number;
  47125. zmin: number;
  47126. xmax: number;
  47127. zmax: number;
  47128. subdivisions?: {
  47129. w: number;
  47130. h: number;
  47131. };
  47132. precision?: {
  47133. w: number;
  47134. h: number;
  47135. };
  47136. updatable?: boolean;
  47137. }, scene?: Nullable<Scene>): Mesh;
  47138. /**
  47139. * Creates a ground mesh from a height map
  47140. * * The parameter `url` sets the URL of the height map image resource.
  47141. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47142. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47143. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47144. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47145. * * 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.
  47146. * * 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).
  47147. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47149. * @param name defines the name of the mesh
  47150. * @param url defines the url to the height map
  47151. * @param options defines the options used to create the mesh
  47152. * @param scene defines the hosting scene
  47153. * @returns the ground mesh
  47154. * @see https://doc.babylonjs.com/babylon101/height_map
  47155. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47156. */
  47157. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47158. width?: number;
  47159. height?: number;
  47160. subdivisions?: number;
  47161. minHeight?: number;
  47162. maxHeight?: number;
  47163. colorFilter?: Color3;
  47164. alphaFilter?: number;
  47165. updatable?: boolean;
  47166. onReady?: (mesh: GroundMesh) => void;
  47167. }, scene?: Nullable<Scene>): GroundMesh;
  47168. }
  47169. }
  47170. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47171. import { Vector4 } from "babylonjs/Maths/math.vector";
  47172. import { Mesh } from "babylonjs/Meshes/mesh";
  47173. /**
  47174. * Class containing static functions to help procedurally build meshes
  47175. */
  47176. export class TorusBuilder {
  47177. /**
  47178. * Creates a torus mesh
  47179. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47180. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47181. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47185. * @param name defines the name of the mesh
  47186. * @param options defines the options used to create the mesh
  47187. * @param scene defines the hosting scene
  47188. * @returns the torus mesh
  47189. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47190. */
  47191. static CreateTorus(name: string, options: {
  47192. diameter?: number;
  47193. thickness?: number;
  47194. tessellation?: number;
  47195. updatable?: boolean;
  47196. sideOrientation?: number;
  47197. frontUVs?: Vector4;
  47198. backUVs?: Vector4;
  47199. }, scene: any): Mesh;
  47200. }
  47201. }
  47202. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47203. import { Vector4 } from "babylonjs/Maths/math.vector";
  47204. import { Color4 } from "babylonjs/Maths/math.color";
  47205. import { Mesh } from "babylonjs/Meshes/mesh";
  47206. /**
  47207. * Class containing static functions to help procedurally build meshes
  47208. */
  47209. export class CylinderBuilder {
  47210. /**
  47211. * Creates a cylinder or a cone mesh
  47212. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47213. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47214. * * 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.
  47215. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47216. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47217. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47218. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47219. * * 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).
  47220. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47221. * * 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).
  47222. * * 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
  47223. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47224. * * 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
  47225. * * 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.
  47226. * * If `enclose` is false, a ring surface is one element.
  47227. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47228. * * 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
  47229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47232. * @param name defines the name of the mesh
  47233. * @param options defines the options used to create the mesh
  47234. * @param scene defines the hosting scene
  47235. * @returns the cylinder mesh
  47236. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47237. */
  47238. static CreateCylinder(name: string, options: {
  47239. height?: number;
  47240. diameterTop?: number;
  47241. diameterBottom?: number;
  47242. diameter?: number;
  47243. tessellation?: number;
  47244. subdivisions?: number;
  47245. arc?: number;
  47246. faceColors?: Color4[];
  47247. faceUV?: Vector4[];
  47248. updatable?: boolean;
  47249. hasRings?: boolean;
  47250. enclose?: boolean;
  47251. cap?: number;
  47252. sideOrientation?: number;
  47253. frontUVs?: Vector4;
  47254. backUVs?: Vector4;
  47255. }, scene: any): Mesh;
  47256. }
  47257. }
  47258. declare module "babylonjs/XR/webXRTypes" {
  47259. import { Nullable } from "babylonjs/types";
  47260. import { IDisposable } from "babylonjs/scene";
  47261. /**
  47262. * States of the webXR experience
  47263. */
  47264. export enum WebXRState {
  47265. /**
  47266. * Transitioning to being in XR mode
  47267. */
  47268. ENTERING_XR = 0,
  47269. /**
  47270. * Transitioning to non XR mode
  47271. */
  47272. EXITING_XR = 1,
  47273. /**
  47274. * In XR mode and presenting
  47275. */
  47276. IN_XR = 2,
  47277. /**
  47278. * Not entered XR mode
  47279. */
  47280. NOT_IN_XR = 3
  47281. }
  47282. /**
  47283. * Abstraction of the XR render target
  47284. */
  47285. export interface WebXRRenderTarget extends IDisposable {
  47286. /**
  47287. * xrpresent context of the canvas which can be used to display/mirror xr content
  47288. */
  47289. canvasContext: WebGLRenderingContext;
  47290. /**
  47291. * xr layer for the canvas
  47292. */
  47293. xrLayer: Nullable<XRWebGLLayer>;
  47294. /**
  47295. * Initializes the xr layer for the session
  47296. * @param xrSession xr session
  47297. * @returns a promise that will resolve once the XR Layer has been created
  47298. */
  47299. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47300. }
  47301. }
  47302. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47303. import { Nullable } from "babylonjs/types";
  47304. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47305. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47306. /**
  47307. * COnfiguration object for WebXR output canvas
  47308. */
  47309. export class WebXRManagedOutputCanvasOptions {
  47310. /**
  47311. * An optional canvas in case you wish to create it yourself and provide it here.
  47312. * If not provided, a new canvas will be created
  47313. */
  47314. canvasElement?: HTMLCanvasElement;
  47315. /**
  47316. * Options for this XR Layer output
  47317. */
  47318. canvasOptions?: XRWebGLLayerOptions;
  47319. /**
  47320. * CSS styling for a newly created canvas (if not provided)
  47321. */
  47322. newCanvasCssStyle?: string;
  47323. /**
  47324. * Get the default values of the configuration object
  47325. * @returns default values of this configuration object
  47326. */
  47327. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47328. }
  47329. /**
  47330. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47331. */
  47332. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47333. private _options;
  47334. private _canvas;
  47335. private _engine;
  47336. /**
  47337. * Rendering context of the canvas which can be used to display/mirror xr content
  47338. */
  47339. canvasContext: WebGLRenderingContext;
  47340. /**
  47341. * xr layer for the canvas
  47342. */
  47343. xrLayer: Nullable<XRWebGLLayer>;
  47344. /**
  47345. * Initializes the canvas to be added/removed upon entering/exiting xr
  47346. * @param _xrSessionManager The XR Session manager
  47347. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47348. */
  47349. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47350. /**
  47351. * Disposes of the object
  47352. */
  47353. dispose(): void;
  47354. /**
  47355. * Initializes the xr layer for the session
  47356. * @param xrSession xr session
  47357. * @returns a promise that will resolve once the XR Layer has been created
  47358. */
  47359. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47360. private _addCanvas;
  47361. private _removeCanvas;
  47362. private _setManagedOutputCanvas;
  47363. }
  47364. }
  47365. declare module "babylonjs/XR/webXRSessionManager" {
  47366. import { Observable } from "babylonjs/Misc/observable";
  47367. import { Nullable } from "babylonjs/types";
  47368. import { IDisposable, Scene } from "babylonjs/scene";
  47369. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47370. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47371. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47372. /**
  47373. * Manages an XRSession to work with Babylon's engine
  47374. * @see https://doc.babylonjs.com/how_to/webxr
  47375. */
  47376. export class WebXRSessionManager implements IDisposable {
  47377. /** The scene which the session should be created for */
  47378. scene: Scene;
  47379. private _referenceSpace;
  47380. private _rttProvider;
  47381. private _sessionEnded;
  47382. private _xrNavigator;
  47383. private baseLayer;
  47384. /**
  47385. * The base reference space from which the session started. good if you want to reset your
  47386. * reference space
  47387. */
  47388. baseReferenceSpace: XRReferenceSpace;
  47389. /**
  47390. * Current XR frame
  47391. */
  47392. currentFrame: Nullable<XRFrame>;
  47393. /** WebXR timestamp updated every frame */
  47394. currentTimestamp: number;
  47395. /**
  47396. * Used just in case of a failure to initialize an immersive session.
  47397. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47398. */
  47399. defaultHeightCompensation: number;
  47400. /**
  47401. * Fires every time a new xrFrame arrives which can be used to update the camera
  47402. */
  47403. onXRFrameObservable: Observable<XRFrame>;
  47404. /**
  47405. * Fires when the reference space changed
  47406. */
  47407. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47408. /**
  47409. * Fires when the xr session is ended either by the device or manually done
  47410. */
  47411. onXRSessionEnded: Observable<any>;
  47412. /**
  47413. * Fires when the xr session is ended either by the device or manually done
  47414. */
  47415. onXRSessionInit: Observable<XRSession>;
  47416. /**
  47417. * Underlying xr session
  47418. */
  47419. session: XRSession;
  47420. /**
  47421. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47422. * or get the offset the player is currently at.
  47423. */
  47424. viewerReferenceSpace: XRReferenceSpace;
  47425. /**
  47426. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47427. * @param scene The scene which the session should be created for
  47428. */
  47429. constructor(
  47430. /** The scene which the session should be created for */
  47431. scene: Scene);
  47432. /**
  47433. * The current reference space used in this session. This reference space can constantly change!
  47434. * It is mainly used to offset the camera's position.
  47435. */
  47436. get referenceSpace(): XRReferenceSpace;
  47437. /**
  47438. * Set a new reference space and triggers the observable
  47439. */
  47440. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47441. /**
  47442. * Disposes of the session manager
  47443. */
  47444. dispose(): void;
  47445. /**
  47446. * Stops the xrSession and restores the render loop
  47447. * @returns Promise which resolves after it exits XR
  47448. */
  47449. exitXRAsync(): Promise<void>;
  47450. /**
  47451. * Gets the correct render target texture to be rendered this frame for this eye
  47452. * @param eye the eye for which to get the render target
  47453. * @returns the render target for the specified eye
  47454. */
  47455. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47456. /**
  47457. * Creates a WebXRRenderTarget object for the XR session
  47458. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47459. * @param options optional options to provide when creating a new render target
  47460. * @returns a WebXR render target to which the session can render
  47461. */
  47462. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47463. /**
  47464. * Initializes the manager
  47465. * After initialization enterXR can be called to start an XR session
  47466. * @returns Promise which resolves after it is initialized
  47467. */
  47468. initializeAsync(): Promise<void>;
  47469. /**
  47470. * Initializes an xr session
  47471. * @param xrSessionMode mode to initialize
  47472. * @param xrSessionInit defines optional and required values to pass to the session builder
  47473. * @returns a promise which will resolve once the session has been initialized
  47474. */
  47475. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47476. /**
  47477. * Checks if a session would be supported for the creation options specified
  47478. * @param sessionMode session mode to check if supported eg. immersive-vr
  47479. * @returns A Promise that resolves to true if supported and false if not
  47480. */
  47481. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47482. /**
  47483. * Resets the reference space to the one started the session
  47484. */
  47485. resetReferenceSpace(): void;
  47486. /**
  47487. * Starts rendering to the xr layer
  47488. */
  47489. runXRRenderLoop(): void;
  47490. /**
  47491. * Sets the reference space on the xr session
  47492. * @param referenceSpaceType space to set
  47493. * @returns a promise that will resolve once the reference space has been set
  47494. */
  47495. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47496. /**
  47497. * Updates the render state of the session
  47498. * @param state state to set
  47499. * @returns a promise that resolves once the render state has been updated
  47500. */
  47501. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47502. /**
  47503. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47504. * @param sessionMode defines the session to test
  47505. * @returns a promise with boolean as final value
  47506. */
  47507. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47508. private _createRenderTargetTexture;
  47509. }
  47510. }
  47511. declare module "babylonjs/XR/webXRCamera" {
  47512. import { Matrix } from "babylonjs/Maths/math.vector";
  47513. import { Scene } from "babylonjs/scene";
  47514. import { Camera } from "babylonjs/Cameras/camera";
  47515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47516. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47517. /**
  47518. * WebXR Camera which holds the views for the xrSession
  47519. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47520. */
  47521. export class WebXRCamera extends FreeCamera {
  47522. private _xrSessionManager;
  47523. private _firstFrame;
  47524. private _referenceQuaternion;
  47525. private _referencedPosition;
  47526. private _xrInvPositionCache;
  47527. private _xrInvQuaternionCache;
  47528. /**
  47529. * Should position compensation execute on first frame.
  47530. * This is used when copying the position from a native (non XR) camera
  47531. */
  47532. compensateOnFirstFrame: boolean;
  47533. /**
  47534. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47535. * @param name the name of the camera
  47536. * @param scene the scene to add the camera to
  47537. * @param _xrSessionManager a constructed xr session manager
  47538. */
  47539. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47540. /**
  47541. * Return the user's height, unrelated to the current ground.
  47542. * This will be the y position of this camera, when ground level is 0.
  47543. */
  47544. get realWorldHeight(): number;
  47545. /** @hidden */
  47546. _updateForDualEyeDebugging(): void;
  47547. /**
  47548. * Sets this camera's transformation based on a non-vr camera
  47549. * @param otherCamera the non-vr camera to copy the transformation from
  47550. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47551. */
  47552. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47553. /**
  47554. * Gets the current instance class name ("WebXRCamera").
  47555. * @returns the class name
  47556. */
  47557. getClassName(): string;
  47558. /**
  47559. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47560. */
  47561. _getViewMatrix(): Matrix;
  47562. private _updateFromXRSession;
  47563. private _updateNumberOfRigCameras;
  47564. private _updateReferenceSpace;
  47565. private _updateReferenceSpaceOffset;
  47566. }
  47567. }
  47568. declare module "babylonjs/XR/webXRFeaturesManager" {
  47569. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47570. import { IDisposable } from "babylonjs/scene";
  47571. /**
  47572. * Defining the interface required for a (webxr) feature
  47573. */
  47574. export interface IWebXRFeature extends IDisposable {
  47575. /**
  47576. * Is this feature attached
  47577. */
  47578. attached: boolean;
  47579. /**
  47580. * Should auto-attach be disabled?
  47581. */
  47582. disableAutoAttach: boolean;
  47583. /**
  47584. * Attach the feature to the session
  47585. * Will usually be called by the features manager
  47586. *
  47587. * @param force should attachment be forced (even when already attached)
  47588. * @returns true if successful.
  47589. */
  47590. attach(force?: boolean): boolean;
  47591. /**
  47592. * Detach the feature from the session
  47593. * Will usually be called by the features manager
  47594. *
  47595. * @returns true if successful.
  47596. */
  47597. detach(): boolean;
  47598. }
  47599. /**
  47600. * A list of the currently available features without referencing them
  47601. */
  47602. export class WebXRFeatureName {
  47603. /**
  47604. * The name of the anchor system feature
  47605. */
  47606. static ANCHOR_SYSTEM: string;
  47607. /**
  47608. * The name of the background remover feature
  47609. */
  47610. static BACKGROUND_REMOVER: string;
  47611. /**
  47612. * The name of the hit test feature
  47613. */
  47614. static HIT_TEST: string;
  47615. /**
  47616. * physics impostors for xr controllers feature
  47617. */
  47618. static PHYSICS_CONTROLLERS: string;
  47619. /**
  47620. * The name of the plane detection feature
  47621. */
  47622. static PLANE_DETECTION: string;
  47623. /**
  47624. * The name of the pointer selection feature
  47625. */
  47626. static POINTER_SELECTION: string;
  47627. /**
  47628. * The name of the teleportation feature
  47629. */
  47630. static TELEPORTATION: string;
  47631. }
  47632. /**
  47633. * Defining the constructor of a feature. Used to register the modules.
  47634. */
  47635. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47636. /**
  47637. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47638. * It is mainly used in AR sessions.
  47639. *
  47640. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47641. */
  47642. export class WebXRFeaturesManager implements IDisposable {
  47643. private _xrSessionManager;
  47644. private static readonly _AvailableFeatures;
  47645. private _features;
  47646. /**
  47647. * constructs a new features manages.
  47648. *
  47649. * @param _xrSessionManager an instance of WebXRSessionManager
  47650. */
  47651. constructor(_xrSessionManager: WebXRSessionManager);
  47652. /**
  47653. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47654. * Mainly used internally.
  47655. *
  47656. * @param featureName the name of the feature to register
  47657. * @param constructorFunction the function used to construct the module
  47658. * @param version the (babylon) version of the module
  47659. * @param stable is that a stable version of this module
  47660. */
  47661. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47662. /**
  47663. * Returns a constructor of a specific feature.
  47664. *
  47665. * @param featureName the name of the feature to construct
  47666. * @param version the version of the feature to load
  47667. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47668. * @param options optional options provided to the module.
  47669. * @returns a function that, when called, will return a new instance of this feature
  47670. */
  47671. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47672. /**
  47673. * Can be used to return the list of features currently registered
  47674. *
  47675. * @returns an Array of available features
  47676. */
  47677. static GetAvailableFeatures(): string[];
  47678. /**
  47679. * Gets the versions available for a specific feature
  47680. * @param featureName the name of the feature
  47681. * @returns an array with the available versions
  47682. */
  47683. static GetAvailableVersions(featureName: string): string[];
  47684. /**
  47685. * Return the latest unstable version of this feature
  47686. * @param featureName the name of the feature to search
  47687. * @returns the version number. if not found will return -1
  47688. */
  47689. static GetLatestVersionOfFeature(featureName: string): number;
  47690. /**
  47691. * Return the latest stable version of this feature
  47692. * @param featureName the name of the feature to search
  47693. * @returns the version number. if not found will return -1
  47694. */
  47695. static GetStableVersionOfFeature(featureName: string): number;
  47696. /**
  47697. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47698. * Can be used during a session to start a feature
  47699. * @param featureName the name of feature to attach
  47700. */
  47701. attachFeature(featureName: string): void;
  47702. /**
  47703. * Can be used inside a session or when the session ends to detach a specific feature
  47704. * @param featureName the name of the feature to detach
  47705. */
  47706. detachFeature(featureName: string): void;
  47707. /**
  47708. * Used to disable an already-enabled feature
  47709. * The feature will be disposed and will be recreated once enabled.
  47710. * @param featureName the feature to disable
  47711. * @returns true if disable was successful
  47712. */
  47713. disableFeature(featureName: string | {
  47714. Name: string;
  47715. }): boolean;
  47716. /**
  47717. * dispose this features manager
  47718. */
  47719. dispose(): void;
  47720. /**
  47721. * 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.
  47722. * 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.
  47723. *
  47724. * @param featureName the name of the feature to load or the class of the feature
  47725. * @param version optional version to load. if not provided the latest version will be enabled
  47726. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47727. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47728. * @returns a new constructed feature or throws an error if feature not found.
  47729. */
  47730. enableFeature(featureName: string | {
  47731. Name: string;
  47732. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47733. /**
  47734. * get the implementation of an enabled feature.
  47735. * @param featureName the name of the feature to load
  47736. * @returns the feature class, if found
  47737. */
  47738. getEnabledFeature(featureName: string): IWebXRFeature;
  47739. /**
  47740. * Get the list of enabled features
  47741. * @returns an array of enabled features
  47742. */
  47743. getEnabledFeatures(): string[];
  47744. }
  47745. }
  47746. declare module "babylonjs/XR/webXRExperienceHelper" {
  47747. import { Observable } from "babylonjs/Misc/observable";
  47748. import { IDisposable, Scene } from "babylonjs/scene";
  47749. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47750. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47751. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47752. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  47753. /**
  47754. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47755. * @see https://doc.babylonjs.com/how_to/webxr
  47756. */
  47757. export class WebXRExperienceHelper implements IDisposable {
  47758. private scene;
  47759. private _nonVRCamera;
  47760. private _originalSceneAutoClear;
  47761. private _supported;
  47762. /**
  47763. * Camera used to render xr content
  47764. */
  47765. camera: WebXRCamera;
  47766. /** A features manager for this xr session */
  47767. featuresManager: WebXRFeaturesManager;
  47768. /**
  47769. * Observers registered here will be triggered after the camera's initial transformation is set
  47770. * This can be used to set a different ground level or an extra rotation.
  47771. *
  47772. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47773. * to the position set after this observable is done executing.
  47774. */
  47775. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47776. /**
  47777. * Fires when the state of the experience helper has changed
  47778. */
  47779. onStateChangedObservable: Observable<WebXRState>;
  47780. /** Session manager used to keep track of xr session */
  47781. sessionManager: WebXRSessionManager;
  47782. /**
  47783. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47784. */
  47785. state: WebXRState;
  47786. /**
  47787. * Creates a WebXRExperienceHelper
  47788. * @param scene The scene the helper should be created in
  47789. */
  47790. private constructor();
  47791. /**
  47792. * Creates the experience helper
  47793. * @param scene the scene to attach the experience helper to
  47794. * @returns a promise for the experience helper
  47795. */
  47796. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47797. /**
  47798. * Disposes of the experience helper
  47799. */
  47800. dispose(): void;
  47801. /**
  47802. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47803. * @param sessionMode options for the XR session
  47804. * @param referenceSpaceType frame of reference of the XR session
  47805. * @param renderTarget the output canvas that will be used to enter XR mode
  47806. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47807. * @returns promise that resolves after xr mode has entered
  47808. */
  47809. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47810. /**
  47811. * Exits XR mode and returns the scene to its original state
  47812. * @returns promise that resolves after xr mode has exited
  47813. */
  47814. exitXRAsync(): Promise<void>;
  47815. private _nonXRToXRCamera;
  47816. private _setState;
  47817. }
  47818. }
  47819. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  47820. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  47821. import { Observable } from "babylonjs/Misc/observable";
  47822. import { IDisposable } from "babylonjs/scene";
  47823. /**
  47824. * X-Y values for axes in WebXR
  47825. */
  47826. export interface IWebXRMotionControllerAxesValue {
  47827. /**
  47828. * The value of the x axis
  47829. */
  47830. x: number;
  47831. /**
  47832. * The value of the y-axis
  47833. */
  47834. y: number;
  47835. }
  47836. /**
  47837. * changed / previous values for the values of this component
  47838. */
  47839. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47840. /**
  47841. * current (this frame) value
  47842. */
  47843. current: T;
  47844. /**
  47845. * previous (last change) value
  47846. */
  47847. previous: T;
  47848. }
  47849. /**
  47850. * Represents changes in the component between current frame and last values recorded
  47851. */
  47852. export interface IWebXRMotionControllerComponentChanges {
  47853. /**
  47854. * will be populated with previous and current values if axes changed
  47855. */
  47856. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47857. /**
  47858. * will be populated with previous and current values if pressed changed
  47859. */
  47860. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47861. /**
  47862. * will be populated with previous and current values if touched changed
  47863. */
  47864. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47865. /**
  47866. * will be populated with previous and current values if value changed
  47867. */
  47868. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47869. }
  47870. /**
  47871. * This class represents a single component (for example button or thumbstick) of a motion controller
  47872. */
  47873. export class WebXRControllerComponent implements IDisposable {
  47874. /**
  47875. * the id of this component
  47876. */
  47877. id: string;
  47878. /**
  47879. * the type of the component
  47880. */
  47881. type: MotionControllerComponentType;
  47882. private _buttonIndex;
  47883. private _axesIndices;
  47884. private _axes;
  47885. private _changes;
  47886. private _currentValue;
  47887. private _hasChanges;
  47888. private _pressed;
  47889. private _touched;
  47890. /**
  47891. * button component type
  47892. */
  47893. static BUTTON_TYPE: MotionControllerComponentType;
  47894. /**
  47895. * squeeze component type
  47896. */
  47897. static SQUEEZE_TYPE: MotionControllerComponentType;
  47898. /**
  47899. * Thumbstick component type
  47900. */
  47901. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47902. /**
  47903. * Touchpad component type
  47904. */
  47905. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47906. /**
  47907. * trigger component type
  47908. */
  47909. static TRIGGER_TYPE: MotionControllerComponentType;
  47910. /**
  47911. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47912. * the axes data changes
  47913. */
  47914. onAxisValueChangedObservable: Observable<{
  47915. x: number;
  47916. y: number;
  47917. }>;
  47918. /**
  47919. * Observers registered here will be triggered when the state of a button changes
  47920. * State change is either pressed / touched / value
  47921. */
  47922. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47923. /**
  47924. * Creates a new component for a motion controller.
  47925. * It is created by the motion controller itself
  47926. *
  47927. * @param id the id of this component
  47928. * @param type the type of the component
  47929. * @param _buttonIndex index in the buttons array of the gamepad
  47930. * @param _axesIndices indices of the values in the axes array of the gamepad
  47931. */
  47932. constructor(
  47933. /**
  47934. * the id of this component
  47935. */
  47936. id: string,
  47937. /**
  47938. * the type of the component
  47939. */
  47940. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47941. /**
  47942. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47943. */
  47944. get axes(): IWebXRMotionControllerAxesValue;
  47945. /**
  47946. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47947. */
  47948. get changes(): IWebXRMotionControllerComponentChanges;
  47949. /**
  47950. * Return whether or not the component changed the last frame
  47951. */
  47952. get hasChanges(): boolean;
  47953. /**
  47954. * is the button currently pressed
  47955. */
  47956. get pressed(): boolean;
  47957. /**
  47958. * is the button currently touched
  47959. */
  47960. get touched(): boolean;
  47961. /**
  47962. * Get the current value of this component
  47963. */
  47964. get value(): number;
  47965. /**
  47966. * Dispose this component
  47967. */
  47968. dispose(): void;
  47969. /**
  47970. * Are there axes correlating to this component
  47971. * @return true is axes data is available
  47972. */
  47973. isAxes(): boolean;
  47974. /**
  47975. * Is this component a button (hence - pressable)
  47976. * @returns true if can be pressed
  47977. */
  47978. isButton(): boolean;
  47979. /**
  47980. * update this component using the gamepad object it is in. Called on every frame
  47981. * @param nativeController the native gamepad controller object
  47982. */
  47983. update(nativeController: IMinimalMotionControllerObject): void;
  47984. }
  47985. }
  47986. declare module "babylonjs/Loading/sceneLoader" {
  47987. import { Observable } from "babylonjs/Misc/observable";
  47988. import { Nullable } from "babylonjs/types";
  47989. import { Scene } from "babylonjs/scene";
  47990. import { Engine } from "babylonjs/Engines/engine";
  47991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47992. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47993. import { AssetContainer } from "babylonjs/assetContainer";
  47994. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47995. import { Skeleton } from "babylonjs/Bones/skeleton";
  47996. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47997. import { WebRequest } from "babylonjs/Misc/webRequest";
  47998. /**
  47999. * Class used to represent data loading progression
  48000. */
  48001. export class SceneLoaderProgressEvent {
  48002. /** defines if data length to load can be evaluated */
  48003. readonly lengthComputable: boolean;
  48004. /** defines the loaded data length */
  48005. readonly loaded: number;
  48006. /** defines the data length to load */
  48007. readonly total: number;
  48008. /**
  48009. * Create a new progress event
  48010. * @param lengthComputable defines if data length to load can be evaluated
  48011. * @param loaded defines the loaded data length
  48012. * @param total defines the data length to load
  48013. */
  48014. constructor(
  48015. /** defines if data length to load can be evaluated */
  48016. lengthComputable: boolean,
  48017. /** defines the loaded data length */
  48018. loaded: number,
  48019. /** defines the data length to load */
  48020. total: number);
  48021. /**
  48022. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48023. * @param event defines the source event
  48024. * @returns a new SceneLoaderProgressEvent
  48025. */
  48026. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48027. }
  48028. /**
  48029. * Interface used by SceneLoader plugins to define supported file extensions
  48030. */
  48031. export interface ISceneLoaderPluginExtensions {
  48032. /**
  48033. * Defines the list of supported extensions
  48034. */
  48035. [extension: string]: {
  48036. isBinary: boolean;
  48037. };
  48038. }
  48039. /**
  48040. * Interface used by SceneLoader plugin factory
  48041. */
  48042. export interface ISceneLoaderPluginFactory {
  48043. /**
  48044. * Defines the name of the factory
  48045. */
  48046. name: string;
  48047. /**
  48048. * Function called to create a new plugin
  48049. * @return the new plugin
  48050. */
  48051. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48052. /**
  48053. * The callback that returns true if the data can be directly loaded.
  48054. * @param data string containing the file data
  48055. * @returns if the data can be loaded directly
  48056. */
  48057. canDirectLoad?(data: string): boolean;
  48058. }
  48059. /**
  48060. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48061. */
  48062. export interface ISceneLoaderPluginBase {
  48063. /**
  48064. * The friendly name of this plugin.
  48065. */
  48066. name: string;
  48067. /**
  48068. * The file extensions supported by this plugin.
  48069. */
  48070. extensions: string | ISceneLoaderPluginExtensions;
  48071. /**
  48072. * The callback called when loading from a url.
  48073. * @param scene scene loading this url
  48074. * @param url url to load
  48075. * @param onSuccess callback called when the file successfully loads
  48076. * @param onProgress callback called while file is loading (if the server supports this mode)
  48077. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48078. * @param onError callback called when the file fails to load
  48079. * @returns a file request object
  48080. */
  48081. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48082. /**
  48083. * The callback called when loading from a file object.
  48084. * @param scene scene loading this file
  48085. * @param file defines the file to load
  48086. * @param onSuccess defines the callback to call when data is loaded
  48087. * @param onProgress defines the callback to call during loading process
  48088. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48089. * @param onError defines the callback to call when an error occurs
  48090. * @returns a file request object
  48091. */
  48092. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48093. /**
  48094. * The callback that returns true if the data can be directly loaded.
  48095. * @param data string containing the file data
  48096. * @returns if the data can be loaded directly
  48097. */
  48098. canDirectLoad?(data: string): boolean;
  48099. /**
  48100. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48101. * @param scene scene loading this data
  48102. * @param data string containing the data
  48103. * @returns data to pass to the plugin
  48104. */
  48105. directLoad?(scene: Scene, data: string): any;
  48106. /**
  48107. * The callback that allows custom handling of the root url based on the response url.
  48108. * @param rootUrl the original root url
  48109. * @param responseURL the response url if available
  48110. * @returns the new root url
  48111. */
  48112. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48113. }
  48114. /**
  48115. * Interface used to define a SceneLoader plugin
  48116. */
  48117. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48118. /**
  48119. * Import meshes into a scene.
  48120. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48121. * @param scene The scene to import into
  48122. * @param data The data to import
  48123. * @param rootUrl The root url for scene and resources
  48124. * @param meshes The meshes array to import into
  48125. * @param particleSystems The particle systems array to import into
  48126. * @param skeletons The skeletons array to import into
  48127. * @param onError The callback when import fails
  48128. * @returns True if successful or false otherwise
  48129. */
  48130. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48131. /**
  48132. * Load into a scene.
  48133. * @param scene The scene to load into
  48134. * @param data The data to import
  48135. * @param rootUrl The root url for scene and resources
  48136. * @param onError The callback when import fails
  48137. * @returns True if successful or false otherwise
  48138. */
  48139. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48140. /**
  48141. * Load into an asset container.
  48142. * @param scene The scene to load into
  48143. * @param data The data to import
  48144. * @param rootUrl The root url for scene and resources
  48145. * @param onError The callback when import fails
  48146. * @returns The loaded asset container
  48147. */
  48148. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48149. }
  48150. /**
  48151. * Interface used to define an async SceneLoader plugin
  48152. */
  48153. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48154. /**
  48155. * Import meshes into a scene.
  48156. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48157. * @param scene The scene to import into
  48158. * @param data The data to import
  48159. * @param rootUrl The root url for scene and resources
  48160. * @param onProgress The callback when the load progresses
  48161. * @param fileName Defines the name of the file to load
  48162. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48163. */
  48164. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48165. meshes: AbstractMesh[];
  48166. particleSystems: IParticleSystem[];
  48167. skeletons: Skeleton[];
  48168. animationGroups: AnimationGroup[];
  48169. }>;
  48170. /**
  48171. * Load into a scene.
  48172. * @param scene The scene to load into
  48173. * @param data The data to import
  48174. * @param rootUrl The root url for scene and resources
  48175. * @param onProgress The callback when the load progresses
  48176. * @param fileName Defines the name of the file to load
  48177. * @returns Nothing
  48178. */
  48179. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48180. /**
  48181. * Load into an asset container.
  48182. * @param scene The scene to load into
  48183. * @param data The data to import
  48184. * @param rootUrl The root url for scene and resources
  48185. * @param onProgress The callback when the load progresses
  48186. * @param fileName Defines the name of the file to load
  48187. * @returns The loaded asset container
  48188. */
  48189. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48190. }
  48191. /**
  48192. * Mode that determines how to handle old animation groups before loading new ones.
  48193. */
  48194. export enum SceneLoaderAnimationGroupLoadingMode {
  48195. /**
  48196. * Reset all old animations to initial state then dispose them.
  48197. */
  48198. Clean = 0,
  48199. /**
  48200. * Stop all old animations.
  48201. */
  48202. Stop = 1,
  48203. /**
  48204. * Restart old animations from first frame.
  48205. */
  48206. Sync = 2,
  48207. /**
  48208. * Old animations remains untouched.
  48209. */
  48210. NoSync = 3
  48211. }
  48212. /**
  48213. * Class used to load scene from various file formats using registered plugins
  48214. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48215. */
  48216. export class SceneLoader {
  48217. /**
  48218. * No logging while loading
  48219. */
  48220. static readonly NO_LOGGING: number;
  48221. /**
  48222. * Minimal logging while loading
  48223. */
  48224. static readonly MINIMAL_LOGGING: number;
  48225. /**
  48226. * Summary logging while loading
  48227. */
  48228. static readonly SUMMARY_LOGGING: number;
  48229. /**
  48230. * Detailled logging while loading
  48231. */
  48232. static readonly DETAILED_LOGGING: number;
  48233. /**
  48234. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48235. */
  48236. static get ForceFullSceneLoadingForIncremental(): boolean;
  48237. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48238. /**
  48239. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48240. */
  48241. static get ShowLoadingScreen(): boolean;
  48242. static set ShowLoadingScreen(value: boolean);
  48243. /**
  48244. * Defines the current logging level (while loading the scene)
  48245. * @ignorenaming
  48246. */
  48247. static get loggingLevel(): number;
  48248. static set loggingLevel(value: number);
  48249. /**
  48250. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48251. */
  48252. static get CleanBoneMatrixWeights(): boolean;
  48253. static set CleanBoneMatrixWeights(value: boolean);
  48254. /**
  48255. * Event raised when a plugin is used to load a scene
  48256. */
  48257. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48258. private static _registeredPlugins;
  48259. private static _getDefaultPlugin;
  48260. private static _getPluginForExtension;
  48261. private static _getPluginForDirectLoad;
  48262. private static _getPluginForFilename;
  48263. private static _getDirectLoad;
  48264. private static _loadData;
  48265. private static _getFileInfo;
  48266. /**
  48267. * Gets a plugin that can load the given extension
  48268. * @param extension defines the extension to load
  48269. * @returns a plugin or null if none works
  48270. */
  48271. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48272. /**
  48273. * Gets a boolean indicating that the given extension can be loaded
  48274. * @param extension defines the extension to load
  48275. * @returns true if the extension is supported
  48276. */
  48277. static IsPluginForExtensionAvailable(extension: string): boolean;
  48278. /**
  48279. * Adds a new plugin to the list of registered plugins
  48280. * @param plugin defines the plugin to add
  48281. */
  48282. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48283. /**
  48284. * Import meshes into a scene
  48285. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48286. * @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)
  48287. * @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)
  48288. * @param scene the instance of BABYLON.Scene to append to
  48289. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48290. * @param onProgress a callback with a progress event for each file being loaded
  48291. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48292. * @param pluginExtension the extension used to determine the plugin
  48293. * @returns The loaded plugin
  48294. */
  48295. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48296. /**
  48297. * Import meshes into a scene
  48298. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48299. * @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)
  48300. * @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)
  48301. * @param scene the instance of BABYLON.Scene to append to
  48302. * @param onProgress a callback with a progress event for each file being loaded
  48303. * @param pluginExtension the extension used to determine the plugin
  48304. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48305. */
  48306. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48307. meshes: AbstractMesh[];
  48308. particleSystems: IParticleSystem[];
  48309. skeletons: Skeleton[];
  48310. animationGroups: AnimationGroup[];
  48311. }>;
  48312. /**
  48313. * Load a scene
  48314. * @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)
  48315. * @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)
  48316. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48317. * @param onSuccess a callback with the scene when import succeeds
  48318. * @param onProgress a callback with a progress event for each file being loaded
  48319. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48320. * @param pluginExtension the extension used to determine the plugin
  48321. * @returns The loaded plugin
  48322. */
  48323. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48324. /**
  48325. * Load a scene
  48326. * @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)
  48327. * @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)
  48328. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48329. * @param onProgress a callback with a progress event for each file being loaded
  48330. * @param pluginExtension the extension used to determine the plugin
  48331. * @returns The loaded scene
  48332. */
  48333. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48334. /**
  48335. * Append a scene
  48336. * @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)
  48337. * @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)
  48338. * @param scene is the instance of BABYLON.Scene to append to
  48339. * @param onSuccess a callback with the scene when import succeeds
  48340. * @param onProgress a callback with a progress event for each file being loaded
  48341. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48342. * @param pluginExtension the extension used to determine the plugin
  48343. * @returns The loaded plugin
  48344. */
  48345. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48346. /**
  48347. * Append a scene
  48348. * @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)
  48349. * @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)
  48350. * @param scene is the instance of BABYLON.Scene to append to
  48351. * @param onProgress a callback with a progress event for each file being loaded
  48352. * @param pluginExtension the extension used to determine the plugin
  48353. * @returns The given scene
  48354. */
  48355. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48356. /**
  48357. * Load a scene into an asset container
  48358. * @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)
  48359. * @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)
  48360. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48361. * @param onSuccess a callback with the scene when import succeeds
  48362. * @param onProgress a callback with a progress event for each file being loaded
  48363. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48364. * @param pluginExtension the extension used to determine the plugin
  48365. * @returns The loaded plugin
  48366. */
  48367. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48368. /**
  48369. * Load a scene into an asset container
  48370. * @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)
  48371. * @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)
  48372. * @param scene is the instance of Scene to append to
  48373. * @param onProgress a callback with a progress event for each file being loaded
  48374. * @param pluginExtension the extension used to determine the plugin
  48375. * @returns The loaded asset container
  48376. */
  48377. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48378. /**
  48379. * Import animations from a file into a scene
  48380. * @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)
  48381. * @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)
  48382. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48383. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48384. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48385. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48386. * @param onSuccess a callback with the scene when import succeeds
  48387. * @param onProgress a callback with a progress event for each file being loaded
  48388. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48389. */
  48390. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  48391. /**
  48392. * Import animations from a file into a scene
  48393. * @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)
  48394. * @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)
  48395. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48396. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48397. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48398. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48399. * @param onSuccess a callback with the scene when import succeeds
  48400. * @param onProgress a callback with a progress event for each file being loaded
  48401. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48402. * @returns the updated scene with imported animations
  48403. */
  48404. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  48405. }
  48406. }
  48407. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48408. import { IDisposable, Scene } from "babylonjs/scene";
  48409. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48410. import { Observable } from "babylonjs/Misc/observable";
  48411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48412. import { Nullable } from "babylonjs/types";
  48413. /**
  48414. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48415. */
  48416. export type MotionControllerHandedness = "none" | "left" | "right";
  48417. /**
  48418. * The type of components available in motion controllers.
  48419. * This is not the name of the component.
  48420. */
  48421. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48422. /**
  48423. * The state of a controller component
  48424. */
  48425. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48426. /**
  48427. * The schema of motion controller layout.
  48428. * No object will be initialized using this interface
  48429. * This is used just to define the profile.
  48430. */
  48431. export interface IMotionControllerLayout {
  48432. /**
  48433. * Path to load the assets. Usually relative to the base path
  48434. */
  48435. assetPath: string;
  48436. /**
  48437. * Available components (unsorted)
  48438. */
  48439. components: {
  48440. /**
  48441. * A map of component Ids
  48442. */
  48443. [componentId: string]: {
  48444. /**
  48445. * The type of input the component outputs
  48446. */
  48447. type: MotionControllerComponentType;
  48448. /**
  48449. * The indices of this component in the gamepad object
  48450. */
  48451. gamepadIndices: {
  48452. /**
  48453. * Index of button
  48454. */
  48455. button?: number;
  48456. /**
  48457. * If available, index of x-axis
  48458. */
  48459. xAxis?: number;
  48460. /**
  48461. * If available, index of y-axis
  48462. */
  48463. yAxis?: number;
  48464. };
  48465. /**
  48466. * The mesh's root node name
  48467. */
  48468. rootNodeName: string;
  48469. /**
  48470. * Animation definitions for this model
  48471. */
  48472. visualResponses: {
  48473. [stateKey: string]: {
  48474. /**
  48475. * What property will be animated
  48476. */
  48477. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48478. /**
  48479. * What states influence this visual response
  48480. */
  48481. states: MotionControllerComponentStateType[];
  48482. /**
  48483. * Type of animation - movement or visibility
  48484. */
  48485. valueNodeProperty: "transform" | "visibility";
  48486. /**
  48487. * Base node name to move. Its position will be calculated according to the min and max nodes
  48488. */
  48489. valueNodeName?: string;
  48490. /**
  48491. * Minimum movement node
  48492. */
  48493. minNodeName?: string;
  48494. /**
  48495. * Max movement node
  48496. */
  48497. maxNodeName?: string;
  48498. };
  48499. };
  48500. /**
  48501. * If touch enabled, what is the name of node to display user feedback
  48502. */
  48503. touchPointNodeName?: string;
  48504. };
  48505. };
  48506. /**
  48507. * Is it xr standard mapping or not
  48508. */
  48509. gamepadMapping: "" | "xr-standard";
  48510. /**
  48511. * Base root node of this entire model
  48512. */
  48513. rootNodeName: string;
  48514. /**
  48515. * Defines the main button component id
  48516. */
  48517. selectComponentId: string;
  48518. }
  48519. /**
  48520. * A definition for the layout map in the input profile
  48521. */
  48522. export interface IMotionControllerLayoutMap {
  48523. /**
  48524. * Layouts with handedness type as a key
  48525. */
  48526. [handedness: string]: IMotionControllerLayout;
  48527. }
  48528. /**
  48529. * The XR Input profile schema
  48530. * Profiles can be found here:
  48531. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48532. */
  48533. export interface IMotionControllerProfile {
  48534. /**
  48535. * fallback profiles for this profileId
  48536. */
  48537. fallbackProfileIds: string[];
  48538. /**
  48539. * The layout map, with handedness as key
  48540. */
  48541. layouts: IMotionControllerLayoutMap;
  48542. /**
  48543. * The id of this profile
  48544. * correlates to the profile(s) in the xrInput.profiles array
  48545. */
  48546. profileId: string;
  48547. }
  48548. /**
  48549. * A helper-interface for the 3 meshes needed for controller button animation
  48550. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48551. */
  48552. export interface IMotionControllerButtonMeshMap {
  48553. /**
  48554. * the mesh that defines the pressed value mesh position.
  48555. * This is used to find the max-position of this button
  48556. */
  48557. pressedMesh: AbstractMesh;
  48558. /**
  48559. * the mesh that defines the unpressed value mesh position.
  48560. * This is used to find the min (or initial) position of this button
  48561. */
  48562. unpressedMesh: AbstractMesh;
  48563. /**
  48564. * The mesh that will be changed when value changes
  48565. */
  48566. valueMesh: AbstractMesh;
  48567. }
  48568. /**
  48569. * A helper-interface for the 3 meshes needed for controller axis animation.
  48570. * This will be expanded when touchpad animations are fully supported
  48571. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48572. */
  48573. export interface IMotionControllerMeshMap {
  48574. /**
  48575. * the mesh that defines the maximum value mesh position.
  48576. */
  48577. maxMesh?: AbstractMesh;
  48578. /**
  48579. * the mesh that defines the minimum value mesh position.
  48580. */
  48581. minMesh?: AbstractMesh;
  48582. /**
  48583. * The mesh that will be changed when axis value changes
  48584. */
  48585. valueMesh: AbstractMesh;
  48586. }
  48587. /**
  48588. * The elements needed for change-detection of the gamepad objects in motion controllers
  48589. */
  48590. export interface IMinimalMotionControllerObject {
  48591. /**
  48592. * Available axes of this controller
  48593. */
  48594. axes: number[];
  48595. /**
  48596. * An array of available buttons
  48597. */
  48598. buttons: Array<{
  48599. /**
  48600. * Value of the button/trigger
  48601. */
  48602. value: number;
  48603. /**
  48604. * If the button/trigger is currently touched
  48605. */
  48606. touched: boolean;
  48607. /**
  48608. * If the button/trigger is currently pressed
  48609. */
  48610. pressed: boolean;
  48611. }>;
  48612. /**
  48613. * EXPERIMENTAL haptic support.
  48614. */
  48615. hapticActuators?: Array<{
  48616. pulse: (value: number, duration: number) => Promise<boolean>;
  48617. }>;
  48618. }
  48619. /**
  48620. * An Abstract Motion controller
  48621. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48622. * Each component has an observable to check for changes in value and state
  48623. */
  48624. export abstract class WebXRAbstractMotionController implements IDisposable {
  48625. protected scene: Scene;
  48626. protected layout: IMotionControllerLayout;
  48627. /**
  48628. * The gamepad object correlating to this controller
  48629. */
  48630. gamepadObject: IMinimalMotionControllerObject;
  48631. /**
  48632. * handedness (left/right/none) of this controller
  48633. */
  48634. handedness: MotionControllerHandedness;
  48635. private _initComponent;
  48636. private _modelReady;
  48637. /**
  48638. * A map of components (WebXRControllerComponent) in this motion controller
  48639. * Components have a ComponentType and can also have both button and axis definitions
  48640. */
  48641. readonly components: {
  48642. [id: string]: WebXRControllerComponent;
  48643. };
  48644. /**
  48645. * Disable the model's animation. Can be set at any time.
  48646. */
  48647. disableAnimation: boolean;
  48648. /**
  48649. * Observers registered here will be triggered when the model of this controller is done loading
  48650. */
  48651. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48652. /**
  48653. * The profile id of this motion controller
  48654. */
  48655. abstract profileId: string;
  48656. /**
  48657. * The root mesh of the model. It is null if the model was not yet initialized
  48658. */
  48659. rootMesh: Nullable<AbstractMesh>;
  48660. /**
  48661. * constructs a new abstract motion controller
  48662. * @param scene the scene to which the model of the controller will be added
  48663. * @param layout The profile layout to load
  48664. * @param gamepadObject The gamepad object correlating to this controller
  48665. * @param handedness handedness (left/right/none) of this controller
  48666. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48667. */
  48668. constructor(scene: Scene, layout: IMotionControllerLayout,
  48669. /**
  48670. * The gamepad object correlating to this controller
  48671. */
  48672. gamepadObject: IMinimalMotionControllerObject,
  48673. /**
  48674. * handedness (left/right/none) of this controller
  48675. */
  48676. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48677. /**
  48678. * Dispose this controller, the model mesh and all its components
  48679. */
  48680. dispose(): void;
  48681. /**
  48682. * Returns all components of specific type
  48683. * @param type the type to search for
  48684. * @return an array of components with this type
  48685. */
  48686. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48687. /**
  48688. * get a component based an its component id as defined in layout.components
  48689. * @param id the id of the component
  48690. * @returns the component correlates to the id or undefined if not found
  48691. */
  48692. getComponent(id: string): WebXRControllerComponent;
  48693. /**
  48694. * Get the list of components available in this motion controller
  48695. * @returns an array of strings correlating to available components
  48696. */
  48697. getComponentIds(): string[];
  48698. /**
  48699. * Get the first component of specific type
  48700. * @param type type of component to find
  48701. * @return a controller component or null if not found
  48702. */
  48703. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48704. /**
  48705. * Get the main (Select) component of this controller as defined in the layout
  48706. * @returns the main component of this controller
  48707. */
  48708. getMainComponent(): WebXRControllerComponent;
  48709. /**
  48710. * Loads the model correlating to this controller
  48711. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48712. * @returns A promise fulfilled with the result of the model loading
  48713. */
  48714. loadModel(): Promise<boolean>;
  48715. /**
  48716. * Update this model using the current XRFrame
  48717. * @param xrFrame the current xr frame to use and update the model
  48718. */
  48719. updateFromXRFrame(xrFrame: XRFrame): void;
  48720. /**
  48721. * Backwards compatibility due to a deeply-integrated typo
  48722. */
  48723. get handness(): XREye;
  48724. /**
  48725. * Pulse (vibrate) this controller
  48726. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48727. * Consecutive calls to this function will cancel the last pulse call
  48728. *
  48729. * @param value the strength of the pulse in 0.0...1.0 range
  48730. * @param duration Duration of the pulse in milliseconds
  48731. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48732. * @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
  48733. */
  48734. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48735. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48736. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48737. /**
  48738. * Moves the axis on the controller mesh based on its current state
  48739. * @param axis the index of the axis
  48740. * @param axisValue the value of the axis which determines the meshes new position
  48741. * @hidden
  48742. */
  48743. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48744. /**
  48745. * Update the model itself with the current frame data
  48746. * @param xrFrame the frame to use for updating the model mesh
  48747. */
  48748. protected updateModel(xrFrame: XRFrame): void;
  48749. /**
  48750. * Get the filename and path for this controller's model
  48751. * @returns a map of filename and path
  48752. */
  48753. protected abstract _getFilenameAndPath(): {
  48754. filename: string;
  48755. path: string;
  48756. };
  48757. /**
  48758. * This function is called before the mesh is loaded. It checks for loading constraints.
  48759. * For example, this function can check if the GLB loader is available
  48760. * If this function returns false, the generic controller will be loaded instead
  48761. * @returns Is the client ready to load the mesh
  48762. */
  48763. protected abstract _getModelLoadingConstraints(): boolean;
  48764. /**
  48765. * This function will be called after the model was successfully loaded and can be used
  48766. * for mesh transformations before it is available for the user
  48767. * @param meshes the loaded meshes
  48768. */
  48769. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48770. /**
  48771. * Set the root mesh for this controller. Important for the WebXR controller class
  48772. * @param meshes the loaded meshes
  48773. */
  48774. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48775. /**
  48776. * A function executed each frame that updates the mesh (if needed)
  48777. * @param xrFrame the current xrFrame
  48778. */
  48779. protected abstract _updateModel(xrFrame: XRFrame): void;
  48780. private _getGenericFilenameAndPath;
  48781. private _getGenericParentMesh;
  48782. }
  48783. }
  48784. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  48785. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48787. import { Scene } from "babylonjs/scene";
  48788. /**
  48789. * A generic trigger-only motion controller for WebXR
  48790. */
  48791. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48792. /**
  48793. * Static version of the profile id of this controller
  48794. */
  48795. static ProfileId: string;
  48796. profileId: string;
  48797. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48798. protected _getFilenameAndPath(): {
  48799. filename: string;
  48800. path: string;
  48801. };
  48802. protected _getModelLoadingConstraints(): boolean;
  48803. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48804. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48805. protected _updateModel(): void;
  48806. }
  48807. }
  48808. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48809. import { Vector4 } from "babylonjs/Maths/math.vector";
  48810. import { Mesh } from "babylonjs/Meshes/mesh";
  48811. import { Scene } from "babylonjs/scene";
  48812. import { Nullable } from "babylonjs/types";
  48813. /**
  48814. * Class containing static functions to help procedurally build meshes
  48815. */
  48816. export class SphereBuilder {
  48817. /**
  48818. * Creates a sphere mesh
  48819. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48820. * * 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`)
  48821. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48822. * * 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
  48823. * * 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)
  48824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48827. * @param name defines the name of the mesh
  48828. * @param options defines the options used to create the mesh
  48829. * @param scene defines the hosting scene
  48830. * @returns the sphere mesh
  48831. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48832. */
  48833. static CreateSphere(name: string, options: {
  48834. segments?: number;
  48835. diameter?: number;
  48836. diameterX?: number;
  48837. diameterY?: number;
  48838. diameterZ?: number;
  48839. arc?: number;
  48840. slice?: number;
  48841. sideOrientation?: number;
  48842. frontUVs?: Vector4;
  48843. backUVs?: Vector4;
  48844. updatable?: boolean;
  48845. }, scene?: Nullable<Scene>): Mesh;
  48846. }
  48847. }
  48848. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  48849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48850. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48851. import { Scene } from "babylonjs/scene";
  48852. /**
  48853. * A profiled motion controller has its profile loaded from an online repository.
  48854. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48855. */
  48856. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48857. private _repositoryUrl;
  48858. private _buttonMeshMapping;
  48859. private _touchDots;
  48860. /**
  48861. * The profile ID of this controller. Will be populated when the controller initializes.
  48862. */
  48863. profileId: string;
  48864. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48865. dispose(): void;
  48866. protected _getFilenameAndPath(): {
  48867. filename: string;
  48868. path: string;
  48869. };
  48870. protected _getModelLoadingConstraints(): boolean;
  48871. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48872. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48873. protected _updateModel(_xrFrame: XRFrame): void;
  48874. }
  48875. }
  48876. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  48877. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48878. import { Scene } from "babylonjs/scene";
  48879. /**
  48880. * A construction function type to create a new controller based on an xrInput object
  48881. */
  48882. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48883. /**
  48884. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48885. *
  48886. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48887. * it should be replaced with auto-loaded controllers.
  48888. *
  48889. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48890. */
  48891. export class WebXRMotionControllerManager {
  48892. private static _AvailableControllers;
  48893. private static _Fallbacks;
  48894. private static _ProfileLoadingPromises;
  48895. private static _ProfilesList;
  48896. /**
  48897. * The base URL of the online controller repository. Can be changed at any time.
  48898. */
  48899. static BaseRepositoryUrl: string;
  48900. /**
  48901. * Which repository gets priority - local or online
  48902. */
  48903. static PrioritizeOnlineRepository: boolean;
  48904. /**
  48905. * Use the online repository, or use only locally-defined controllers
  48906. */
  48907. static UseOnlineRepository: boolean;
  48908. /**
  48909. * Clear the cache used for profile loading and reload when requested again
  48910. */
  48911. static ClearProfilesCache(): void;
  48912. /**
  48913. * Register the default fallbacks.
  48914. * This function is called automatically when this file is imported.
  48915. */
  48916. static DefaultFallbacks(): void;
  48917. /**
  48918. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48919. * @param profileId the profile to which a fallback needs to be found
  48920. * @return an array with corresponding fallback profiles
  48921. */
  48922. static FindFallbackWithProfileId(profileId: string): string[];
  48923. /**
  48924. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48925. * The order of search:
  48926. *
  48927. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48928. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48929. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48930. * 4) return the generic trigger controller if none were found
  48931. *
  48932. * @param xrInput the xrInput to which a new controller is initialized
  48933. * @param scene the scene to which the model will be added
  48934. * @param forceProfile force a certain profile for this controller
  48935. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48936. */
  48937. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48938. /**
  48939. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48940. *
  48941. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48942. *
  48943. * @param type the profile type to register
  48944. * @param constructFunction the function to be called when loading this profile
  48945. */
  48946. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48947. /**
  48948. * Register a fallback to a specific profile.
  48949. * @param profileId the profileId that will receive the fallbacks
  48950. * @param fallbacks A list of fallback profiles
  48951. */
  48952. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48953. /**
  48954. * Will update the list of profiles available in the repository
  48955. * @return a promise that resolves to a map of profiles available online
  48956. */
  48957. static UpdateProfilesList(): Promise<{
  48958. [profile: string]: string;
  48959. }>;
  48960. private static _LoadProfileFromRepository;
  48961. private static _LoadProfilesFromAvailableControllers;
  48962. }
  48963. }
  48964. declare module "babylonjs/XR/webXRInputSource" {
  48965. import { Observable } from "babylonjs/Misc/observable";
  48966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48967. import { Ray } from "babylonjs/Culling/ray";
  48968. import { Scene } from "babylonjs/scene";
  48969. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48970. /**
  48971. * Configuration options for the WebXR controller creation
  48972. */
  48973. export interface IWebXRControllerOptions {
  48974. /**
  48975. * Should the controller mesh be animated when a user interacts with it
  48976. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48977. */
  48978. disableMotionControllerAnimation?: boolean;
  48979. /**
  48980. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48981. */
  48982. doNotLoadControllerMesh?: boolean;
  48983. /**
  48984. * Force a specific controller type for this controller.
  48985. * This can be used when creating your own profile or when testing different controllers
  48986. */
  48987. forceControllerProfile?: string;
  48988. /**
  48989. * Defines a rendering group ID for meshes that will be loaded.
  48990. * This is for the default controllers only.
  48991. */
  48992. renderingGroupId?: number;
  48993. }
  48994. /**
  48995. * Represents an XR controller
  48996. */
  48997. export class WebXRInputSource {
  48998. private _scene;
  48999. /** The underlying input source for the controller */
  49000. inputSource: XRInputSource;
  49001. private _options;
  49002. private _tmpVector;
  49003. private _uniqueId;
  49004. /**
  49005. * 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
  49006. */
  49007. grip?: AbstractMesh;
  49008. /**
  49009. * If available, this is the gamepad object related to this controller.
  49010. * Using this object it is possible to get click events and trackpad changes of the
  49011. * webxr controller that is currently being used.
  49012. */
  49013. motionController?: WebXRAbstractMotionController;
  49014. /**
  49015. * Event that fires when the controller is removed/disposed.
  49016. * The object provided as event data is this controller, after associated assets were disposed.
  49017. * uniqueId is still available.
  49018. */
  49019. onDisposeObservable: Observable<WebXRInputSource>;
  49020. /**
  49021. * Will be triggered when the mesh associated with the motion controller is done loading.
  49022. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49023. * A shortened version of controller -> motion controller -> on mesh loaded.
  49024. */
  49025. onMeshLoadedObservable: Observable<AbstractMesh>;
  49026. /**
  49027. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49028. */
  49029. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49030. /**
  49031. * Pointer which can be used to select objects or attach a visible laser to
  49032. */
  49033. pointer: AbstractMesh;
  49034. /**
  49035. * Creates the controller
  49036. * @see https://doc.babylonjs.com/how_to/webxr
  49037. * @param _scene the scene which the controller should be associated to
  49038. * @param inputSource the underlying input source for the controller
  49039. * @param _options options for this controller creation
  49040. */
  49041. constructor(_scene: Scene,
  49042. /** The underlying input source for the controller */
  49043. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49044. /**
  49045. * Get this controllers unique id
  49046. */
  49047. get uniqueId(): string;
  49048. /**
  49049. * Disposes of the object
  49050. */
  49051. dispose(): void;
  49052. /**
  49053. * Gets a world space ray coming from the pointer or grip
  49054. * @param result the resulting ray
  49055. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49056. */
  49057. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49058. /**
  49059. * Updates the controller pose based on the given XRFrame
  49060. * @param xrFrame xr frame to update the pose with
  49061. * @param referenceSpace reference space to use
  49062. */
  49063. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49064. }
  49065. }
  49066. declare module "babylonjs/XR/webXRInput" {
  49067. import { Observable } from "babylonjs/Misc/observable";
  49068. import { IDisposable } from "babylonjs/scene";
  49069. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49070. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49071. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49072. /**
  49073. * The schema for initialization options of the XR Input class
  49074. */
  49075. export interface IWebXRInputOptions {
  49076. /**
  49077. * If set to true no model will be automatically loaded
  49078. */
  49079. doNotLoadControllerMeshes?: boolean;
  49080. /**
  49081. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49082. * If not found, the xr input profile data will be used.
  49083. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49084. */
  49085. forceInputProfile?: string;
  49086. /**
  49087. * Do not send a request to the controller repository to load the profile.
  49088. *
  49089. * Instead, use the controllers available in babylon itself.
  49090. */
  49091. disableOnlineControllerRepository?: boolean;
  49092. /**
  49093. * A custom URL for the controllers repository
  49094. */
  49095. customControllersRepositoryURL?: string;
  49096. /**
  49097. * Should the controller model's components not move according to the user input
  49098. */
  49099. disableControllerAnimation?: boolean;
  49100. /**
  49101. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49102. */
  49103. controllerOptions?: IWebXRControllerOptions;
  49104. }
  49105. /**
  49106. * XR input used to track XR inputs such as controllers/rays
  49107. */
  49108. export class WebXRInput implements IDisposable {
  49109. /**
  49110. * the xr session manager for this session
  49111. */
  49112. xrSessionManager: WebXRSessionManager;
  49113. /**
  49114. * the WebXR camera for this session. Mainly used for teleportation
  49115. */
  49116. xrCamera: WebXRCamera;
  49117. private readonly options;
  49118. /**
  49119. * XR controllers being tracked
  49120. */
  49121. controllers: Array<WebXRInputSource>;
  49122. private _frameObserver;
  49123. private _sessionEndedObserver;
  49124. private _sessionInitObserver;
  49125. /**
  49126. * Event when a controller has been connected/added
  49127. */
  49128. onControllerAddedObservable: Observable<WebXRInputSource>;
  49129. /**
  49130. * Event when a controller has been removed/disconnected
  49131. */
  49132. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49133. /**
  49134. * Initializes the WebXRInput
  49135. * @param xrSessionManager the xr session manager for this session
  49136. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49137. * @param options = initialization options for this xr input
  49138. */
  49139. constructor(
  49140. /**
  49141. * the xr session manager for this session
  49142. */
  49143. xrSessionManager: WebXRSessionManager,
  49144. /**
  49145. * the WebXR camera for this session. Mainly used for teleportation
  49146. */
  49147. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49148. private _onInputSourcesChange;
  49149. private _addAndRemoveControllers;
  49150. /**
  49151. * Disposes of the object
  49152. */
  49153. dispose(): void;
  49154. }
  49155. }
  49156. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49157. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49158. import { Observable, EventState } from "babylonjs/Misc/observable";
  49159. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49160. /**
  49161. * This is the base class for all WebXR features.
  49162. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49163. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49164. */
  49165. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49166. protected _xrSessionManager: WebXRSessionManager;
  49167. private _attached;
  49168. private _removeOnDetach;
  49169. /**
  49170. * Should auto-attach be disabled?
  49171. */
  49172. disableAutoAttach: boolean;
  49173. /**
  49174. * Construct a new (abstract) WebXR feature
  49175. * @param _xrSessionManager the xr session manager for this feature
  49176. */
  49177. constructor(_xrSessionManager: WebXRSessionManager);
  49178. /**
  49179. * Is this feature attached
  49180. */
  49181. get attached(): boolean;
  49182. /**
  49183. * attach this feature
  49184. *
  49185. * @param force should attachment be forced (even when already attached)
  49186. * @returns true if successful, false is failed or already attached
  49187. */
  49188. attach(force?: boolean): boolean;
  49189. /**
  49190. * detach this feature.
  49191. *
  49192. * @returns true if successful, false if failed or already detached
  49193. */
  49194. detach(): boolean;
  49195. /**
  49196. * Dispose this feature and all of the resources attached
  49197. */
  49198. dispose(): void;
  49199. /**
  49200. * This is used to register callbacks that will automatically be removed when detach is called.
  49201. * @param observable the observable to which the observer will be attached
  49202. * @param callback the callback to register
  49203. */
  49204. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49205. /**
  49206. * Code in this function will be executed on each xrFrame received from the browser.
  49207. * This function will not execute after the feature is detached.
  49208. * @param _xrFrame the current frame
  49209. */
  49210. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49211. }
  49212. }
  49213. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49214. import { IDisposable, Scene } from "babylonjs/scene";
  49215. import { Nullable } from "babylonjs/types";
  49216. import { Observable } from "babylonjs/Misc/observable";
  49217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49218. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49219. import { Camera } from "babylonjs/Cameras/camera";
  49220. /**
  49221. * Renders a layer on top of an existing scene
  49222. */
  49223. export class UtilityLayerRenderer implements IDisposable {
  49224. /** the original scene that will be rendered on top of */
  49225. originalScene: Scene;
  49226. private _pointerCaptures;
  49227. private _lastPointerEvents;
  49228. private static _DefaultUtilityLayer;
  49229. private static _DefaultKeepDepthUtilityLayer;
  49230. private _sharedGizmoLight;
  49231. private _renderCamera;
  49232. /**
  49233. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49234. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49235. * @returns the camera that is used when rendering the utility layer
  49236. */
  49237. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49238. /**
  49239. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49240. * @param cam the camera that should be used when rendering the utility layer
  49241. */
  49242. setRenderCamera(cam: Nullable<Camera>): void;
  49243. /**
  49244. * @hidden
  49245. * Light which used by gizmos to get light shading
  49246. */
  49247. _getSharedGizmoLight(): HemisphericLight;
  49248. /**
  49249. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49250. */
  49251. pickUtilitySceneFirst: boolean;
  49252. /**
  49253. * 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)
  49254. */
  49255. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49256. /**
  49257. * 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)
  49258. */
  49259. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49260. /**
  49261. * The scene that is rendered on top of the original scene
  49262. */
  49263. utilityLayerScene: Scene;
  49264. /**
  49265. * If the utility layer should automatically be rendered on top of existing scene
  49266. */
  49267. shouldRender: boolean;
  49268. /**
  49269. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49270. */
  49271. onlyCheckPointerDownEvents: boolean;
  49272. /**
  49273. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49274. */
  49275. processAllEvents: boolean;
  49276. /**
  49277. * Observable raised when the pointer move from the utility layer scene to the main scene
  49278. */
  49279. onPointerOutObservable: Observable<number>;
  49280. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49281. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49282. private _afterRenderObserver;
  49283. private _sceneDisposeObserver;
  49284. private _originalPointerObserver;
  49285. /**
  49286. * Instantiates a UtilityLayerRenderer
  49287. * @param originalScene the original scene that will be rendered on top of
  49288. * @param handleEvents boolean indicating if the utility layer should handle events
  49289. */
  49290. constructor(
  49291. /** the original scene that will be rendered on top of */
  49292. originalScene: Scene, handleEvents?: boolean);
  49293. private _notifyObservers;
  49294. /**
  49295. * Renders the utility layers scene on top of the original scene
  49296. */
  49297. render(): void;
  49298. /**
  49299. * Disposes of the renderer
  49300. */
  49301. dispose(): void;
  49302. private _updateCamera;
  49303. }
  49304. }
  49305. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49306. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49308. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49309. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49310. import { Scene } from "babylonjs/scene";
  49311. import { Nullable } from "babylonjs/types";
  49312. import { Color3 } from "babylonjs/Maths/math.color";
  49313. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49314. /**
  49315. * Options interface for the pointer selection module
  49316. */
  49317. export interface IWebXRControllerPointerSelectionOptions {
  49318. /**
  49319. * if provided, this scene will be used to render meshes.
  49320. */
  49321. customUtilityLayerScene?: Scene;
  49322. /**
  49323. * 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)
  49324. * If not disabled, the last picked point will be used to execute a pointer up event
  49325. * If disabled, pointer up event will be triggered right after the pointer down event.
  49326. * Used in screen and gaze target ray mode only
  49327. */
  49328. disablePointerUpOnTouchOut: boolean;
  49329. /**
  49330. * For gaze mode (time to select instead of press)
  49331. */
  49332. forceGazeMode: boolean;
  49333. /**
  49334. * 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
  49335. * to start a new countdown to the pointer down event.
  49336. * Defaults to 1.
  49337. */
  49338. gazeModePointerMovedFactor?: number;
  49339. /**
  49340. * Different button type to use instead of the main component
  49341. */
  49342. overrideButtonId?: string;
  49343. /**
  49344. * use this rendering group id for the meshes (optional)
  49345. */
  49346. renderingGroupId?: number;
  49347. /**
  49348. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49349. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49350. * 3000 means 3 seconds between pointing at something and selecting it
  49351. */
  49352. timeToSelect?: number;
  49353. /**
  49354. * Should meshes created here be added to a utility layer or the main scene
  49355. */
  49356. useUtilityLayer?: boolean;
  49357. /**
  49358. * the xr input to use with this pointer selection
  49359. */
  49360. xrInput: WebXRInput;
  49361. }
  49362. /**
  49363. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49364. */
  49365. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49366. private readonly _options;
  49367. private static _idCounter;
  49368. private _attachController;
  49369. private _controllers;
  49370. private _scene;
  49371. private _tmpVectorForPickCompare;
  49372. /**
  49373. * The module's name
  49374. */
  49375. static readonly Name: string;
  49376. /**
  49377. * The (Babylon) version of this module.
  49378. * This is an integer representing the implementation version.
  49379. * This number does not correspond to the WebXR specs version
  49380. */
  49381. static readonly Version: number;
  49382. /**
  49383. * Disable lighting on the laser pointer (so it will always be visible)
  49384. */
  49385. disablePointerLighting: boolean;
  49386. /**
  49387. * Disable lighting on the selection mesh (so it will always be visible)
  49388. */
  49389. disableSelectionMeshLighting: boolean;
  49390. /**
  49391. * Should the laser pointer be displayed
  49392. */
  49393. displayLaserPointer: boolean;
  49394. /**
  49395. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49396. */
  49397. displaySelectionMesh: boolean;
  49398. /**
  49399. * This color will be set to the laser pointer when selection is triggered
  49400. */
  49401. laserPointerPickedColor: Color3;
  49402. /**
  49403. * Default color of the laser pointer
  49404. */
  49405. lasterPointerDefaultColor: Color3;
  49406. /**
  49407. * default color of the selection ring
  49408. */
  49409. selectionMeshDefaultColor: Color3;
  49410. /**
  49411. * This color will be applied to the selection ring when selection is triggered
  49412. */
  49413. selectionMeshPickedColor: Color3;
  49414. /**
  49415. * Optional filter to be used for ray selection. This predicate shares behavior with
  49416. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49417. */
  49418. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49419. /**
  49420. * constructs a new background remover module
  49421. * @param _xrSessionManager the session manager for this module
  49422. * @param _options read-only options to be used in this module
  49423. */
  49424. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49425. /**
  49426. * attach this feature
  49427. * Will usually be called by the features manager
  49428. *
  49429. * @returns true if successful.
  49430. */
  49431. attach(): boolean;
  49432. /**
  49433. * detach this feature.
  49434. * Will usually be called by the features manager
  49435. *
  49436. * @returns true if successful.
  49437. */
  49438. detach(): boolean;
  49439. /**
  49440. * Will get the mesh under a specific pointer.
  49441. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49442. * @param controllerId the controllerId to check
  49443. * @returns The mesh under pointer or null if no mesh is under the pointer
  49444. */
  49445. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49446. /**
  49447. * Get the xr controller that correlates to the pointer id in the pointer event
  49448. *
  49449. * @param id the pointer id to search for
  49450. * @returns the controller that correlates to this id or null if not found
  49451. */
  49452. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49453. protected _onXRFrame(_xrFrame: XRFrame): void;
  49454. private _attachGazeMode;
  49455. private _attachScreenRayMode;
  49456. private _attachTrackedPointerRayMode;
  49457. private _convertNormalToDirectionOfRay;
  49458. private _detachController;
  49459. private _generateNewMeshPair;
  49460. private _pickingMoved;
  49461. private _updatePointerDistance;
  49462. }
  49463. }
  49464. declare module "babylonjs/XR/webXREnterExitUI" {
  49465. import { Nullable } from "babylonjs/types";
  49466. import { Observable } from "babylonjs/Misc/observable";
  49467. import { IDisposable, Scene } from "babylonjs/scene";
  49468. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49469. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49470. /**
  49471. * Button which can be used to enter a different mode of XR
  49472. */
  49473. export class WebXREnterExitUIButton {
  49474. /** button element */
  49475. element: HTMLElement;
  49476. /** XR initialization options for the button */
  49477. sessionMode: XRSessionMode;
  49478. /** Reference space type */
  49479. referenceSpaceType: XRReferenceSpaceType;
  49480. /**
  49481. * Creates a WebXREnterExitUIButton
  49482. * @param element button element
  49483. * @param sessionMode XR initialization session mode
  49484. * @param referenceSpaceType the type of reference space to be used
  49485. */
  49486. constructor(
  49487. /** button element */
  49488. element: HTMLElement,
  49489. /** XR initialization options for the button */
  49490. sessionMode: XRSessionMode,
  49491. /** Reference space type */
  49492. referenceSpaceType: XRReferenceSpaceType);
  49493. /**
  49494. * Extendable function which can be used to update the button's visuals when the state changes
  49495. * @param activeButton the current active button in the UI
  49496. */
  49497. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49498. }
  49499. /**
  49500. * Options to create the webXR UI
  49501. */
  49502. export class WebXREnterExitUIOptions {
  49503. /**
  49504. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49505. */
  49506. customButtons?: Array<WebXREnterExitUIButton>;
  49507. /**
  49508. * A reference space type to use when creating the default button.
  49509. * Default is local-floor
  49510. */
  49511. referenceSpaceType?: XRReferenceSpaceType;
  49512. /**
  49513. * Context to enter xr with
  49514. */
  49515. renderTarget?: Nullable<WebXRRenderTarget>;
  49516. /**
  49517. * A session mode to use when creating the default button.
  49518. * Default is immersive-vr
  49519. */
  49520. sessionMode?: XRSessionMode;
  49521. /**
  49522. * A list of optional features to init the session with
  49523. */
  49524. optionalFeatures?: string[];
  49525. }
  49526. /**
  49527. * UI to allow the user to enter/exit XR mode
  49528. */
  49529. export class WebXREnterExitUI implements IDisposable {
  49530. private scene;
  49531. /** version of the options passed to this UI */
  49532. options: WebXREnterExitUIOptions;
  49533. private _activeButton;
  49534. private _buttons;
  49535. private _overlay;
  49536. /**
  49537. * Fired every time the active button is changed.
  49538. *
  49539. * When xr is entered via a button that launches xr that button will be the callback parameter
  49540. *
  49541. * When exiting xr the callback parameter will be null)
  49542. */
  49543. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49544. /**
  49545. *
  49546. * @param scene babylon scene object to use
  49547. * @param options (read-only) version of the options passed to this UI
  49548. */
  49549. private constructor();
  49550. /**
  49551. * Creates UI to allow the user to enter/exit XR mode
  49552. * @param scene the scene to add the ui to
  49553. * @param helper the xr experience helper to enter/exit xr with
  49554. * @param options options to configure the UI
  49555. * @returns the created ui
  49556. */
  49557. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49558. /**
  49559. * Disposes of the XR UI component
  49560. */
  49561. dispose(): void;
  49562. private _updateButtons;
  49563. }
  49564. }
  49565. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49566. import { Vector3 } from "babylonjs/Maths/math.vector";
  49567. import { Color4 } from "babylonjs/Maths/math.color";
  49568. import { Nullable } from "babylonjs/types";
  49569. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49570. import { Scene } from "babylonjs/scene";
  49571. /**
  49572. * Class containing static functions to help procedurally build meshes
  49573. */
  49574. export class LinesBuilder {
  49575. /**
  49576. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49577. * * 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
  49578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49579. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49580. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49581. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49582. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49583. * * 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
  49584. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49587. * @param name defines the name of the new line system
  49588. * @param options defines the options used to create the line system
  49589. * @param scene defines the hosting scene
  49590. * @returns a new line system mesh
  49591. */
  49592. static CreateLineSystem(name: string, options: {
  49593. lines: Vector3[][];
  49594. updatable?: boolean;
  49595. instance?: Nullable<LinesMesh>;
  49596. colors?: Nullable<Color4[][]>;
  49597. useVertexAlpha?: boolean;
  49598. }, scene: Nullable<Scene>): LinesMesh;
  49599. /**
  49600. * Creates a line mesh
  49601. * 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
  49602. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49603. * * The parameter `points` is an array successive Vector3
  49604. * * 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
  49605. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49606. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49607. * * When updating an instance, remember that only point positions can change, not the number of points
  49608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49610. * @param name defines the name of the new line system
  49611. * @param options defines the options used to create the line system
  49612. * @param scene defines the hosting scene
  49613. * @returns a new line mesh
  49614. */
  49615. static CreateLines(name: string, options: {
  49616. points: Vector3[];
  49617. updatable?: boolean;
  49618. instance?: Nullable<LinesMesh>;
  49619. colors?: Color4[];
  49620. useVertexAlpha?: boolean;
  49621. }, scene?: Nullable<Scene>): LinesMesh;
  49622. /**
  49623. * Creates a dashed line mesh
  49624. * * 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
  49625. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49626. * * The parameter `points` is an array successive Vector3
  49627. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49628. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49629. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49630. * * 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
  49631. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49632. * * When updating an instance, remember that only point positions can change, not the number of points
  49633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49634. * @param name defines the name of the mesh
  49635. * @param options defines the options used to create the mesh
  49636. * @param scene defines the hosting scene
  49637. * @returns the dashed line mesh
  49638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49639. */
  49640. static CreateDashedLines(name: string, options: {
  49641. points: Vector3[];
  49642. dashSize?: number;
  49643. gapSize?: number;
  49644. dashNb?: number;
  49645. updatable?: boolean;
  49646. instance?: LinesMesh;
  49647. useVertexAlpha?: boolean;
  49648. }, scene?: Nullable<Scene>): LinesMesh;
  49649. }
  49650. }
  49651. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  49652. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49653. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49654. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49656. import { Vector3 } from "babylonjs/Maths/math.vector";
  49657. import { Material } from "babylonjs/Materials/material";
  49658. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49659. import { Scene } from "babylonjs/scene";
  49660. /**
  49661. * The options container for the teleportation module
  49662. */
  49663. export interface IWebXRTeleportationOptions {
  49664. /**
  49665. * if provided, this scene will be used to render meshes.
  49666. */
  49667. customUtilityLayerScene?: Scene;
  49668. /**
  49669. * Values to configure the default target mesh
  49670. */
  49671. defaultTargetMeshOptions?: {
  49672. /**
  49673. * Fill color of the teleportation area
  49674. */
  49675. teleportationFillColor?: string;
  49676. /**
  49677. * Border color for the teleportation area
  49678. */
  49679. teleportationBorderColor?: string;
  49680. /**
  49681. * Disable the mesh's animation sequence
  49682. */
  49683. disableAnimation?: boolean;
  49684. /**
  49685. * Disable lighting on the material or the ring and arrow
  49686. */
  49687. disableLighting?: boolean;
  49688. /**
  49689. * Override the default material of the torus and arrow
  49690. */
  49691. torusArrowMaterial?: Material;
  49692. };
  49693. /**
  49694. * A list of meshes to use as floor meshes.
  49695. * Meshes can be added and removed after initializing the feature using the
  49696. * addFloorMesh and removeFloorMesh functions
  49697. * If empty, rotation will still work
  49698. */
  49699. floorMeshes?: AbstractMesh[];
  49700. /**
  49701. * use this rendering group id for the meshes (optional)
  49702. */
  49703. renderingGroupId?: number;
  49704. /**
  49705. * Should teleportation move only to snap points
  49706. */
  49707. snapPointsOnly?: boolean;
  49708. /**
  49709. * An array of points to which the teleportation will snap to.
  49710. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49711. */
  49712. snapPositions?: Vector3[];
  49713. /**
  49714. * How close should the teleportation ray be in order to snap to position.
  49715. * Default to 0.8 units (meters)
  49716. */
  49717. snapToPositionRadius?: number;
  49718. /**
  49719. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49720. * If you want to support rotation, make sure your mesh has a direction indicator.
  49721. *
  49722. * When left untouched, the default mesh will be initialized.
  49723. */
  49724. teleportationTargetMesh?: AbstractMesh;
  49725. /**
  49726. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49727. */
  49728. timeToTeleport?: number;
  49729. /**
  49730. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49731. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49732. */
  49733. useMainComponentOnly?: boolean;
  49734. /**
  49735. * Should meshes created here be added to a utility layer or the main scene
  49736. */
  49737. useUtilityLayer?: boolean;
  49738. /**
  49739. * Babylon XR Input class for controller
  49740. */
  49741. xrInput: WebXRInput;
  49742. }
  49743. /**
  49744. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49745. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49746. * the input of the attached controllers.
  49747. */
  49748. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49749. private _options;
  49750. private _controllers;
  49751. private _currentTeleportationControllerId;
  49752. private _floorMeshes;
  49753. private _quadraticBezierCurve;
  49754. private _selectionFeature;
  49755. private _snapToPositions;
  49756. private _snappedToPoint;
  49757. private _teleportationRingMaterial?;
  49758. private _tmpRay;
  49759. private _tmpVector;
  49760. /**
  49761. * The module's name
  49762. */
  49763. static readonly Name: string;
  49764. /**
  49765. * The (Babylon) version of this module.
  49766. * This is an integer representing the implementation version.
  49767. * This number does not correspond to the webxr specs version
  49768. */
  49769. static readonly Version: number;
  49770. /**
  49771. * Is movement backwards enabled
  49772. */
  49773. backwardsMovementEnabled: boolean;
  49774. /**
  49775. * Distance to travel when moving backwards
  49776. */
  49777. backwardsTeleportationDistance: number;
  49778. /**
  49779. * The distance from the user to the inspection point in the direction of the controller
  49780. * A higher number will allow the user to move further
  49781. * defaults to 5 (meters, in xr units)
  49782. */
  49783. parabolicCheckRadius: number;
  49784. /**
  49785. * Should the module support parabolic ray on top of direct ray
  49786. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49787. * Very helpful when moving between floors / different heights
  49788. */
  49789. parabolicRayEnabled: boolean;
  49790. /**
  49791. * How much rotation should be applied when rotating right and left
  49792. */
  49793. rotationAngle: number;
  49794. /**
  49795. * Is rotation enabled when moving forward?
  49796. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49797. */
  49798. rotationEnabled: boolean;
  49799. /**
  49800. * constructs a new anchor system
  49801. * @param _xrSessionManager an instance of WebXRSessionManager
  49802. * @param _options configuration object for this feature
  49803. */
  49804. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49805. /**
  49806. * Get the snapPointsOnly flag
  49807. */
  49808. get snapPointsOnly(): boolean;
  49809. /**
  49810. * Sets the snapPointsOnly flag
  49811. * @param snapToPoints should teleportation be exclusively to snap points
  49812. */
  49813. set snapPointsOnly(snapToPoints: boolean);
  49814. /**
  49815. * Add a new mesh to the floor meshes array
  49816. * @param mesh the mesh to use as floor mesh
  49817. */
  49818. addFloorMesh(mesh: AbstractMesh): void;
  49819. /**
  49820. * Add a new snap-to point to fix teleportation to this position
  49821. * @param newSnapPoint The new Snap-To point
  49822. */
  49823. addSnapPoint(newSnapPoint: Vector3): void;
  49824. attach(): boolean;
  49825. detach(): boolean;
  49826. dispose(): void;
  49827. /**
  49828. * Remove a mesh from the floor meshes array
  49829. * @param mesh the mesh to remove
  49830. */
  49831. removeFloorMesh(mesh: AbstractMesh): void;
  49832. /**
  49833. * Remove a mesh from the floor meshes array using its name
  49834. * @param name the mesh name to remove
  49835. */
  49836. removeFloorMeshByName(name: string): void;
  49837. /**
  49838. * 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
  49839. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49840. * @returns was the point found and removed or not
  49841. */
  49842. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49843. /**
  49844. * This function sets a selection feature that will be disabled when
  49845. * the forward ray is shown and will be reattached when hidden.
  49846. * This is used to remove the selection rays when moving.
  49847. * @param selectionFeature the feature to disable when forward movement is enabled
  49848. */
  49849. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49850. protected _onXRFrame(_xrFrame: XRFrame): void;
  49851. private _attachController;
  49852. private _createDefaultTargetMesh;
  49853. private _detachController;
  49854. private _findClosestSnapPointWithRadius;
  49855. private _setTargetMeshPosition;
  49856. private _setTargetMeshVisibility;
  49857. private _showParabolicPath;
  49858. private _teleportForward;
  49859. }
  49860. }
  49861. declare module "babylonjs/XR/webXRDefaultExperience" {
  49862. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49863. import { Scene } from "babylonjs/scene";
  49864. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  49865. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  49866. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49867. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  49868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49869. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  49870. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  49871. /**
  49872. * Options for the default xr helper
  49873. */
  49874. export class WebXRDefaultExperienceOptions {
  49875. /**
  49876. * Enable or disable default UI to enter XR
  49877. */
  49878. disableDefaultUI?: boolean;
  49879. /**
  49880. * Should teleportation not initialize. defaults to false.
  49881. */
  49882. disableTeleportation?: boolean;
  49883. /**
  49884. * Floor meshes that will be used for teleport
  49885. */
  49886. floorMeshes?: Array<AbstractMesh>;
  49887. /**
  49888. * If set to true, the first frame will not be used to reset position
  49889. * The first frame is mainly used when copying transformation from the old camera
  49890. * Mainly used in AR
  49891. */
  49892. ignoreNativeCameraTransformation?: boolean;
  49893. /**
  49894. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49895. */
  49896. inputOptions?: IWebXRInputOptions;
  49897. /**
  49898. * optional configuration for the output canvas
  49899. */
  49900. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49901. /**
  49902. * optional UI options. This can be used among other to change session mode and reference space type
  49903. */
  49904. uiOptions?: WebXREnterExitUIOptions;
  49905. /**
  49906. * When loading teleportation and pointer select, use stable versions instead of latest.
  49907. */
  49908. useStablePlugins?: boolean;
  49909. /**
  49910. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49911. */
  49912. renderingGroupId?: number;
  49913. /**
  49914. * A list of optional features to init the session with
  49915. * If set to true, all features we support will be added
  49916. */
  49917. optionalFeatures?: boolean | string[];
  49918. }
  49919. /**
  49920. * Default experience which provides a similar setup to the previous webVRExperience
  49921. */
  49922. export class WebXRDefaultExperience {
  49923. /**
  49924. * Base experience
  49925. */
  49926. baseExperience: WebXRExperienceHelper;
  49927. /**
  49928. * Enables ui for entering/exiting xr
  49929. */
  49930. enterExitUI: WebXREnterExitUI;
  49931. /**
  49932. * Input experience extension
  49933. */
  49934. input: WebXRInput;
  49935. /**
  49936. * Enables laser pointer and selection
  49937. */
  49938. pointerSelection: WebXRControllerPointerSelection;
  49939. /**
  49940. * Default target xr should render to
  49941. */
  49942. renderTarget: WebXRRenderTarget;
  49943. /**
  49944. * Enables teleportation
  49945. */
  49946. teleportation: WebXRMotionControllerTeleportation;
  49947. private constructor();
  49948. /**
  49949. * Creates the default xr experience
  49950. * @param scene scene
  49951. * @param options options for basic configuration
  49952. * @returns resulting WebXRDefaultExperience
  49953. */
  49954. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49955. /**
  49956. * DIsposes of the experience helper
  49957. */
  49958. dispose(): void;
  49959. }
  49960. }
  49961. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  49962. import { Observable } from "babylonjs/Misc/observable";
  49963. import { Nullable } from "babylonjs/types";
  49964. import { Camera } from "babylonjs/Cameras/camera";
  49965. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  49966. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  49967. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  49968. import { Scene } from "babylonjs/scene";
  49969. import { Vector3 } from "babylonjs/Maths/math.vector";
  49970. import { Color3 } from "babylonjs/Maths/math.color";
  49971. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49973. import { Mesh } from "babylonjs/Meshes/mesh";
  49974. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  49975. import { EasingFunction } from "babylonjs/Animations/easing";
  49976. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  49977. import "babylonjs/Meshes/Builders/groundBuilder";
  49978. import "babylonjs/Meshes/Builders/torusBuilder";
  49979. import "babylonjs/Meshes/Builders/cylinderBuilder";
  49980. import "babylonjs/Gamepads/gamepadSceneComponent";
  49981. import "babylonjs/Animations/animatable";
  49982. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  49983. /**
  49984. * Options to modify the vr teleportation behavior.
  49985. */
  49986. export interface VRTeleportationOptions {
  49987. /**
  49988. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49989. */
  49990. floorMeshName?: string;
  49991. /**
  49992. * A list of meshes to be used as the teleportation floor. (default: empty)
  49993. */
  49994. floorMeshes?: Mesh[];
  49995. /**
  49996. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49997. */
  49998. teleportationMode?: number;
  49999. /**
  50000. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50001. */
  50002. teleportationTime?: number;
  50003. /**
  50004. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50005. */
  50006. teleportationSpeed?: number;
  50007. /**
  50008. * The easing function used in the animation or null for Linear. (default CircleEase)
  50009. */
  50010. easingFunction?: EasingFunction;
  50011. }
  50012. /**
  50013. * Options to modify the vr experience helper's behavior.
  50014. */
  50015. export interface VRExperienceHelperOptions extends WebVROptions {
  50016. /**
  50017. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50018. */
  50019. createDeviceOrientationCamera?: boolean;
  50020. /**
  50021. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50022. */
  50023. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50024. /**
  50025. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50026. */
  50027. laserToggle?: boolean;
  50028. /**
  50029. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50030. */
  50031. floorMeshes?: Mesh[];
  50032. /**
  50033. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50034. */
  50035. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50036. /**
  50037. * Defines if WebXR should be used instead of WebVR (if available)
  50038. */
  50039. useXR?: boolean;
  50040. }
  50041. /**
  50042. * Event containing information after VR has been entered
  50043. */
  50044. export class OnAfterEnteringVRObservableEvent {
  50045. /**
  50046. * If entering vr was successful
  50047. */
  50048. success: boolean;
  50049. }
  50050. /**
  50051. * Helps to quickly add VR support to an existing scene.
  50052. * See http://doc.babylonjs.com/how_to/webvr_helper
  50053. */
  50054. export class VRExperienceHelper {
  50055. /** Options to modify the vr experience helper's behavior. */
  50056. webVROptions: VRExperienceHelperOptions;
  50057. private _scene;
  50058. private _position;
  50059. private _btnVR;
  50060. private _btnVRDisplayed;
  50061. private _webVRsupported;
  50062. private _webVRready;
  50063. private _webVRrequesting;
  50064. private _webVRpresenting;
  50065. private _hasEnteredVR;
  50066. private _fullscreenVRpresenting;
  50067. private _inputElement;
  50068. private _webVRCamera;
  50069. private _vrDeviceOrientationCamera;
  50070. private _deviceOrientationCamera;
  50071. private _existingCamera;
  50072. private _onKeyDown;
  50073. private _onVrDisplayPresentChange;
  50074. private _onVRDisplayChanged;
  50075. private _onVRRequestPresentStart;
  50076. private _onVRRequestPresentComplete;
  50077. /**
  50078. * 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)
  50079. */
  50080. enableGazeEvenWhenNoPointerLock: boolean;
  50081. /**
  50082. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50083. */
  50084. exitVROnDoubleTap: boolean;
  50085. /**
  50086. * Observable raised right before entering VR.
  50087. */
  50088. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50089. /**
  50090. * Observable raised when entering VR has completed.
  50091. */
  50092. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50093. /**
  50094. * Observable raised when exiting VR.
  50095. */
  50096. onExitingVRObservable: Observable<VRExperienceHelper>;
  50097. /**
  50098. * Observable raised when controller mesh is loaded.
  50099. */
  50100. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50101. /** Return this.onEnteringVRObservable
  50102. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50103. */
  50104. get onEnteringVR(): Observable<VRExperienceHelper>;
  50105. /** Return this.onExitingVRObservable
  50106. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50107. */
  50108. get onExitingVR(): Observable<VRExperienceHelper>;
  50109. /** Return this.onControllerMeshLoadedObservable
  50110. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50111. */
  50112. get onControllerMeshLoaded(): Observable<WebVRController>;
  50113. private _rayLength;
  50114. private _useCustomVRButton;
  50115. private _teleportationRequested;
  50116. private _teleportActive;
  50117. private _floorMeshName;
  50118. private _floorMeshesCollection;
  50119. private _teleportationMode;
  50120. private _teleportationTime;
  50121. private _teleportationSpeed;
  50122. private _teleportationEasing;
  50123. private _rotationAllowed;
  50124. private _teleportBackwardsVector;
  50125. private _teleportationTarget;
  50126. private _isDefaultTeleportationTarget;
  50127. private _postProcessMove;
  50128. private _teleportationFillColor;
  50129. private _teleportationBorderColor;
  50130. private _rotationAngle;
  50131. private _haloCenter;
  50132. private _cameraGazer;
  50133. private _padSensibilityUp;
  50134. private _padSensibilityDown;
  50135. private _leftController;
  50136. private _rightController;
  50137. private _gazeColor;
  50138. private _laserColor;
  50139. private _pickedLaserColor;
  50140. private _pickedGazeColor;
  50141. /**
  50142. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50143. */
  50144. onNewMeshSelected: Observable<AbstractMesh>;
  50145. /**
  50146. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50147. * This observable will provide the mesh and the controller used to select the mesh
  50148. */
  50149. onMeshSelectedWithController: Observable<{
  50150. mesh: AbstractMesh;
  50151. controller: WebVRController;
  50152. }>;
  50153. /**
  50154. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50155. */
  50156. onNewMeshPicked: Observable<PickingInfo>;
  50157. private _circleEase;
  50158. /**
  50159. * Observable raised before camera teleportation
  50160. */
  50161. onBeforeCameraTeleport: Observable<Vector3>;
  50162. /**
  50163. * Observable raised after camera teleportation
  50164. */
  50165. onAfterCameraTeleport: Observable<Vector3>;
  50166. /**
  50167. * Observable raised when current selected mesh gets unselected
  50168. */
  50169. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50170. private _raySelectionPredicate;
  50171. /**
  50172. * To be optionaly changed by user to define custom ray selection
  50173. */
  50174. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50175. /**
  50176. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50177. */
  50178. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50179. /**
  50180. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50181. */
  50182. teleportationEnabled: boolean;
  50183. private _defaultHeight;
  50184. private _teleportationInitialized;
  50185. private _interactionsEnabled;
  50186. private _interactionsRequested;
  50187. private _displayGaze;
  50188. private _displayLaserPointer;
  50189. /**
  50190. * The mesh used to display where the user is going to teleport.
  50191. */
  50192. get teleportationTarget(): Mesh;
  50193. /**
  50194. * Sets the mesh to be used to display where the user is going to teleport.
  50195. */
  50196. set teleportationTarget(value: Mesh);
  50197. /**
  50198. * 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
  50199. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50200. * See http://doc.babylonjs.com/resources/baking_transformations
  50201. */
  50202. get gazeTrackerMesh(): Mesh;
  50203. set gazeTrackerMesh(value: Mesh);
  50204. /**
  50205. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50206. */
  50207. updateGazeTrackerScale: boolean;
  50208. /**
  50209. * If the gaze trackers color should be updated when selecting meshes
  50210. */
  50211. updateGazeTrackerColor: boolean;
  50212. /**
  50213. * If the controller laser color should be updated when selecting meshes
  50214. */
  50215. updateControllerLaserColor: boolean;
  50216. /**
  50217. * The gaze tracking mesh corresponding to the left controller
  50218. */
  50219. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50220. /**
  50221. * The gaze tracking mesh corresponding to the right controller
  50222. */
  50223. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50224. /**
  50225. * If the ray of the gaze should be displayed.
  50226. */
  50227. get displayGaze(): boolean;
  50228. /**
  50229. * Sets if the ray of the gaze should be displayed.
  50230. */
  50231. set displayGaze(value: boolean);
  50232. /**
  50233. * If the ray of the LaserPointer should be displayed.
  50234. */
  50235. get displayLaserPointer(): boolean;
  50236. /**
  50237. * Sets if the ray of the LaserPointer should be displayed.
  50238. */
  50239. set displayLaserPointer(value: boolean);
  50240. /**
  50241. * The deviceOrientationCamera used as the camera when not in VR.
  50242. */
  50243. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50244. /**
  50245. * Based on the current WebVR support, returns the current VR camera used.
  50246. */
  50247. get currentVRCamera(): Nullable<Camera>;
  50248. /**
  50249. * The webVRCamera which is used when in VR.
  50250. */
  50251. get webVRCamera(): WebVRFreeCamera;
  50252. /**
  50253. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50254. */
  50255. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50256. /**
  50257. * The html button that is used to trigger entering into VR.
  50258. */
  50259. get vrButton(): Nullable<HTMLButtonElement>;
  50260. private get _teleportationRequestInitiated();
  50261. /**
  50262. * Defines whether or not Pointer lock should be requested when switching to
  50263. * full screen.
  50264. */
  50265. requestPointerLockOnFullScreen: boolean;
  50266. /**
  50267. * If asking to force XR, this will be populated with the default xr experience
  50268. */
  50269. xr: WebXRDefaultExperience;
  50270. /**
  50271. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50272. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50273. */
  50274. xrTestDone: boolean;
  50275. /**
  50276. * Instantiates a VRExperienceHelper.
  50277. * Helps to quickly add VR support to an existing scene.
  50278. * @param scene The scene the VRExperienceHelper belongs to.
  50279. * @param webVROptions Options to modify the vr experience helper's behavior.
  50280. */
  50281. constructor(scene: Scene,
  50282. /** Options to modify the vr experience helper's behavior. */
  50283. webVROptions?: VRExperienceHelperOptions);
  50284. private completeVRInit;
  50285. private _onDefaultMeshLoaded;
  50286. private _onResize;
  50287. private _onFullscreenChange;
  50288. /**
  50289. * Gets a value indicating if we are currently in VR mode.
  50290. */
  50291. get isInVRMode(): boolean;
  50292. private onVrDisplayPresentChange;
  50293. private onVRDisplayChanged;
  50294. private moveButtonToBottomRight;
  50295. private displayVRButton;
  50296. private updateButtonVisibility;
  50297. private _cachedAngularSensibility;
  50298. /**
  50299. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50300. * Otherwise, will use the fullscreen API.
  50301. */
  50302. enterVR(): void;
  50303. /**
  50304. * Attempt to exit VR, or fullscreen.
  50305. */
  50306. exitVR(): void;
  50307. /**
  50308. * The position of the vr experience helper.
  50309. */
  50310. get position(): Vector3;
  50311. /**
  50312. * Sets the position of the vr experience helper.
  50313. */
  50314. set position(value: Vector3);
  50315. /**
  50316. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50317. */
  50318. enableInteractions(): void;
  50319. private get _noControllerIsActive();
  50320. private beforeRender;
  50321. private _isTeleportationFloor;
  50322. /**
  50323. * Adds a floor mesh to be used for teleportation.
  50324. * @param floorMesh the mesh to be used for teleportation.
  50325. */
  50326. addFloorMesh(floorMesh: Mesh): void;
  50327. /**
  50328. * Removes a floor mesh from being used for teleportation.
  50329. * @param floorMesh the mesh to be removed.
  50330. */
  50331. removeFloorMesh(floorMesh: Mesh): void;
  50332. /**
  50333. * Enables interactions and teleportation using the VR controllers and gaze.
  50334. * @param vrTeleportationOptions options to modify teleportation behavior.
  50335. */
  50336. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50337. private _onNewGamepadConnected;
  50338. private _tryEnableInteractionOnController;
  50339. private _onNewGamepadDisconnected;
  50340. private _enableInteractionOnController;
  50341. private _checkTeleportWithRay;
  50342. private _checkRotate;
  50343. private _checkTeleportBackwards;
  50344. private _enableTeleportationOnController;
  50345. private _createTeleportationCircles;
  50346. private _displayTeleportationTarget;
  50347. private _hideTeleportationTarget;
  50348. private _rotateCamera;
  50349. private _moveTeleportationSelectorTo;
  50350. private _workingVector;
  50351. private _workingQuaternion;
  50352. private _workingMatrix;
  50353. /**
  50354. * Time Constant Teleportation Mode
  50355. */
  50356. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50357. /**
  50358. * Speed Constant Teleportation Mode
  50359. */
  50360. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50361. /**
  50362. * Teleports the users feet to the desired location
  50363. * @param location The location where the user's feet should be placed
  50364. */
  50365. teleportCamera(location: Vector3): void;
  50366. private _convertNormalToDirectionOfRay;
  50367. private _castRayAndSelectObject;
  50368. private _notifySelectedMeshUnselected;
  50369. /**
  50370. * Permanently set new colors for the laser pointer
  50371. * @param color the new laser color
  50372. * @param pickedColor the new laser color when picked mesh detected
  50373. */
  50374. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50375. /**
  50376. * Set lighting enabled / disabled on the laser pointer of both controllers
  50377. * @param enabled should the lighting be enabled on the laser pointer
  50378. */
  50379. setLaserLightingState(enabled?: boolean): void;
  50380. /**
  50381. * Permanently set new colors for the gaze pointer
  50382. * @param color the new gaze color
  50383. * @param pickedColor the new gaze color when picked mesh detected
  50384. */
  50385. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50386. /**
  50387. * Sets the color of the laser ray from the vr controllers.
  50388. * @param color new color for the ray.
  50389. */
  50390. changeLaserColor(color: Color3): void;
  50391. /**
  50392. * Sets the color of the ray from the vr headsets gaze.
  50393. * @param color new color for the ray.
  50394. */
  50395. changeGazeColor(color: Color3): void;
  50396. /**
  50397. * Exits VR and disposes of the vr experience helper
  50398. */
  50399. dispose(): void;
  50400. /**
  50401. * Gets the name of the VRExperienceHelper class
  50402. * @returns "VRExperienceHelper"
  50403. */
  50404. getClassName(): string;
  50405. }
  50406. }
  50407. declare module "babylonjs/Cameras/VR/index" {
  50408. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50409. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50410. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50411. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50412. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50413. export * from "babylonjs/Cameras/VR/webVRCamera";
  50414. }
  50415. declare module "babylonjs/Cameras/RigModes/index" {
  50416. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50417. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50418. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50419. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50420. }
  50421. declare module "babylonjs/Cameras/index" {
  50422. export * from "babylonjs/Cameras/Inputs/index";
  50423. export * from "babylonjs/Cameras/cameraInputsManager";
  50424. export * from "babylonjs/Cameras/camera";
  50425. export * from "babylonjs/Cameras/targetCamera";
  50426. export * from "babylonjs/Cameras/freeCamera";
  50427. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50428. export * from "babylonjs/Cameras/touchCamera";
  50429. export * from "babylonjs/Cameras/arcRotateCamera";
  50430. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50431. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50432. export * from "babylonjs/Cameras/flyCamera";
  50433. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50434. export * from "babylonjs/Cameras/followCamera";
  50435. export * from "babylonjs/Cameras/followCameraInputsManager";
  50436. export * from "babylonjs/Cameras/gamepadCamera";
  50437. export * from "babylonjs/Cameras/Stereoscopic/index";
  50438. export * from "babylonjs/Cameras/universalCamera";
  50439. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50440. export * from "babylonjs/Cameras/VR/index";
  50441. export * from "babylonjs/Cameras/RigModes/index";
  50442. }
  50443. declare module "babylonjs/Collisions/index" {
  50444. export * from "babylonjs/Collisions/collider";
  50445. export * from "babylonjs/Collisions/collisionCoordinator";
  50446. export * from "babylonjs/Collisions/pickingInfo";
  50447. export * from "babylonjs/Collisions/intersectionInfo";
  50448. export * from "babylonjs/Collisions/meshCollisionData";
  50449. }
  50450. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50451. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50452. import { Vector3 } from "babylonjs/Maths/math.vector";
  50453. import { Ray } from "babylonjs/Culling/ray";
  50454. import { Plane } from "babylonjs/Maths/math.plane";
  50455. /**
  50456. * Contains an array of blocks representing the octree
  50457. */
  50458. export interface IOctreeContainer<T> {
  50459. /**
  50460. * Blocks within the octree
  50461. */
  50462. blocks: Array<OctreeBlock<T>>;
  50463. }
  50464. /**
  50465. * Class used to store a cell in an octree
  50466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50467. */
  50468. export class OctreeBlock<T> {
  50469. /**
  50470. * Gets the content of the current block
  50471. */
  50472. entries: T[];
  50473. /**
  50474. * Gets the list of block children
  50475. */
  50476. blocks: Array<OctreeBlock<T>>;
  50477. private _depth;
  50478. private _maxDepth;
  50479. private _capacity;
  50480. private _minPoint;
  50481. private _maxPoint;
  50482. private _boundingVectors;
  50483. private _creationFunc;
  50484. /**
  50485. * Creates a new block
  50486. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50487. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50488. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50489. * @param depth defines the current depth of this block in the octree
  50490. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50491. * @param creationFunc defines a callback to call when an element is added to the block
  50492. */
  50493. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50494. /**
  50495. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50496. */
  50497. get capacity(): number;
  50498. /**
  50499. * Gets the minimum vector (in world space) of the block's bounding box
  50500. */
  50501. get minPoint(): Vector3;
  50502. /**
  50503. * Gets the maximum vector (in world space) of the block's bounding box
  50504. */
  50505. get maxPoint(): Vector3;
  50506. /**
  50507. * Add a new element to this block
  50508. * @param entry defines the element to add
  50509. */
  50510. addEntry(entry: T): void;
  50511. /**
  50512. * Remove an element from this block
  50513. * @param entry defines the element to remove
  50514. */
  50515. removeEntry(entry: T): void;
  50516. /**
  50517. * Add an array of elements to this block
  50518. * @param entries defines the array of elements to add
  50519. */
  50520. addEntries(entries: T[]): void;
  50521. /**
  50522. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50523. * @param frustumPlanes defines the frustum planes to test
  50524. * @param selection defines the array to store current content if selection is positive
  50525. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50526. */
  50527. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50528. /**
  50529. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50530. * @param sphereCenter defines the bounding sphere center
  50531. * @param sphereRadius defines the bounding sphere radius
  50532. * @param selection defines the array to store current content if selection is positive
  50533. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50534. */
  50535. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50536. /**
  50537. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50538. * @param ray defines the ray to test with
  50539. * @param selection defines the array to store current content if selection is positive
  50540. */
  50541. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50542. /**
  50543. * Subdivide the content into child blocks (this block will then be empty)
  50544. */
  50545. createInnerBlocks(): void;
  50546. /**
  50547. * @hidden
  50548. */
  50549. 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;
  50550. }
  50551. }
  50552. declare module "babylonjs/Culling/Octrees/octree" {
  50553. import { SmartArray } from "babylonjs/Misc/smartArray";
  50554. import { Vector3 } from "babylonjs/Maths/math.vector";
  50555. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50557. import { Ray } from "babylonjs/Culling/ray";
  50558. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50559. import { Plane } from "babylonjs/Maths/math.plane";
  50560. /**
  50561. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50563. */
  50564. export class Octree<T> {
  50565. /** 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.) */
  50566. maxDepth: number;
  50567. /**
  50568. * Blocks within the octree containing objects
  50569. */
  50570. blocks: Array<OctreeBlock<T>>;
  50571. /**
  50572. * Content stored in the octree
  50573. */
  50574. dynamicContent: T[];
  50575. private _maxBlockCapacity;
  50576. private _selectionContent;
  50577. private _creationFunc;
  50578. /**
  50579. * Creates a octree
  50580. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50581. * @param creationFunc function to be used to instatiate the octree
  50582. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50583. * @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.)
  50584. */
  50585. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50586. /** 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.) */
  50587. maxDepth?: number);
  50588. /**
  50589. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50590. * @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);
  50591. * @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);
  50592. * @param entries meshes to be added to the octree blocks
  50593. */
  50594. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50595. /**
  50596. * Adds a mesh to the octree
  50597. * @param entry Mesh to add to the octree
  50598. */
  50599. addMesh(entry: T): void;
  50600. /**
  50601. * Remove an element from the octree
  50602. * @param entry defines the element to remove
  50603. */
  50604. removeMesh(entry: T): void;
  50605. /**
  50606. * Selects an array of meshes within the frustum
  50607. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50608. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50609. * @returns array of meshes within the frustum
  50610. */
  50611. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50612. /**
  50613. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50614. * @param sphereCenter defines the bounding sphere center
  50615. * @param sphereRadius defines the bounding sphere radius
  50616. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50617. * @returns an array of objects that intersect the sphere
  50618. */
  50619. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50620. /**
  50621. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50622. * @param ray defines the ray to test with
  50623. * @returns array of intersected objects
  50624. */
  50625. intersectsRay(ray: Ray): SmartArray<T>;
  50626. /**
  50627. * Adds a mesh into the octree block if it intersects the block
  50628. */
  50629. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50630. /**
  50631. * Adds a submesh into the octree block if it intersects the block
  50632. */
  50633. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50634. }
  50635. }
  50636. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  50637. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  50638. import { Scene } from "babylonjs/scene";
  50639. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50641. import { Ray } from "babylonjs/Culling/ray";
  50642. import { Octree } from "babylonjs/Culling/Octrees/octree";
  50643. import { Collider } from "babylonjs/Collisions/collider";
  50644. module "babylonjs/scene" {
  50645. interface Scene {
  50646. /**
  50647. * @hidden
  50648. * Backing Filed
  50649. */
  50650. _selectionOctree: Octree<AbstractMesh>;
  50651. /**
  50652. * Gets the octree used to boost mesh selection (picking)
  50653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50654. */
  50655. selectionOctree: Octree<AbstractMesh>;
  50656. /**
  50657. * Creates or updates the octree used to boost selection (picking)
  50658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50659. * @param maxCapacity defines the maximum capacity per leaf
  50660. * @param maxDepth defines the maximum depth of the octree
  50661. * @returns an octree of AbstractMesh
  50662. */
  50663. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50664. }
  50665. }
  50666. module "babylonjs/Meshes/abstractMesh" {
  50667. interface AbstractMesh {
  50668. /**
  50669. * @hidden
  50670. * Backing Field
  50671. */
  50672. _submeshesOctree: Octree<SubMesh>;
  50673. /**
  50674. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50675. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50676. * @param maxCapacity defines the maximum size of each block (64 by default)
  50677. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50678. * @returns the new octree
  50679. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50681. */
  50682. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50683. }
  50684. }
  50685. /**
  50686. * Defines the octree scene component responsible to manage any octrees
  50687. * in a given scene.
  50688. */
  50689. export class OctreeSceneComponent {
  50690. /**
  50691. * The component name help to identify the component in the list of scene components.
  50692. */
  50693. readonly name: string;
  50694. /**
  50695. * The scene the component belongs to.
  50696. */
  50697. scene: Scene;
  50698. /**
  50699. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50700. */
  50701. readonly checksIsEnabled: boolean;
  50702. /**
  50703. * Creates a new instance of the component for the given scene
  50704. * @param scene Defines the scene to register the component in
  50705. */
  50706. constructor(scene: Scene);
  50707. /**
  50708. * Registers the component in a given scene
  50709. */
  50710. register(): void;
  50711. /**
  50712. * Return the list of active meshes
  50713. * @returns the list of active meshes
  50714. */
  50715. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50716. /**
  50717. * Return the list of active sub meshes
  50718. * @param mesh The mesh to get the candidates sub meshes from
  50719. * @returns the list of active sub meshes
  50720. */
  50721. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50722. private _tempRay;
  50723. /**
  50724. * Return the list of sub meshes intersecting with a given local ray
  50725. * @param mesh defines the mesh to find the submesh for
  50726. * @param localRay defines the ray in local space
  50727. * @returns the list of intersecting sub meshes
  50728. */
  50729. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50730. /**
  50731. * Return the list of sub meshes colliding with a collider
  50732. * @param mesh defines the mesh to find the submesh for
  50733. * @param collider defines the collider to evaluate the collision against
  50734. * @returns the list of colliding sub meshes
  50735. */
  50736. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50737. /**
  50738. * Rebuilds the elements related to this component in case of
  50739. * context lost for instance.
  50740. */
  50741. rebuild(): void;
  50742. /**
  50743. * Disposes the component and the associated ressources.
  50744. */
  50745. dispose(): void;
  50746. }
  50747. }
  50748. declare module "babylonjs/Culling/Octrees/index" {
  50749. export * from "babylonjs/Culling/Octrees/octree";
  50750. export * from "babylonjs/Culling/Octrees/octreeBlock";
  50751. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  50752. }
  50753. declare module "babylonjs/Culling/index" {
  50754. export * from "babylonjs/Culling/boundingBox";
  50755. export * from "babylonjs/Culling/boundingInfo";
  50756. export * from "babylonjs/Culling/boundingSphere";
  50757. export * from "babylonjs/Culling/Octrees/index";
  50758. export * from "babylonjs/Culling/ray";
  50759. }
  50760. declare module "babylonjs/Gizmos/gizmo" {
  50761. import { Nullable } from "babylonjs/types";
  50762. import { IDisposable } from "babylonjs/scene";
  50763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50764. import { Mesh } from "babylonjs/Meshes/mesh";
  50765. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50766. /**
  50767. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50768. */
  50769. export class Gizmo implements IDisposable {
  50770. /** The utility layer the gizmo will be added to */
  50771. gizmoLayer: UtilityLayerRenderer;
  50772. /**
  50773. * The root mesh of the gizmo
  50774. */
  50775. _rootMesh: Mesh;
  50776. private _attachedMesh;
  50777. /**
  50778. * Ratio for the scale of the gizmo (Default: 1)
  50779. */
  50780. scaleRatio: number;
  50781. /**
  50782. * If a custom mesh has been set (Default: false)
  50783. */
  50784. protected _customMeshSet: boolean;
  50785. /**
  50786. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50787. * * When set, interactions will be enabled
  50788. */
  50789. get attachedMesh(): Nullable<AbstractMesh>;
  50790. set attachedMesh(value: Nullable<AbstractMesh>);
  50791. /**
  50792. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50793. * @param mesh The mesh to replace the default mesh of the gizmo
  50794. */
  50795. setCustomMesh(mesh: Mesh): void;
  50796. /**
  50797. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50798. */
  50799. updateGizmoRotationToMatchAttachedMesh: boolean;
  50800. /**
  50801. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50802. */
  50803. updateGizmoPositionToMatchAttachedMesh: boolean;
  50804. /**
  50805. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50806. */
  50807. updateScale: boolean;
  50808. protected _interactionsEnabled: boolean;
  50809. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50810. private _beforeRenderObserver;
  50811. private _tempVector;
  50812. /**
  50813. * Creates a gizmo
  50814. * @param gizmoLayer The utility layer the gizmo will be added to
  50815. */
  50816. constructor(
  50817. /** The utility layer the gizmo will be added to */
  50818. gizmoLayer?: UtilityLayerRenderer);
  50819. /**
  50820. * Updates the gizmo to match the attached mesh's position/rotation
  50821. */
  50822. protected _update(): void;
  50823. /**
  50824. * Disposes of the gizmo
  50825. */
  50826. dispose(): void;
  50827. }
  50828. }
  50829. declare module "babylonjs/Gizmos/planeDragGizmo" {
  50830. import { Observable } from "babylonjs/Misc/observable";
  50831. import { Nullable } from "babylonjs/types";
  50832. import { Vector3 } from "babylonjs/Maths/math.vector";
  50833. import { Color3 } from "babylonjs/Maths/math.color";
  50834. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50836. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50837. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50838. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50839. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50840. import { Scene } from "babylonjs/scene";
  50841. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50842. /**
  50843. * Single plane drag gizmo
  50844. */
  50845. export class PlaneDragGizmo extends Gizmo {
  50846. /**
  50847. * Drag behavior responsible for the gizmos dragging interactions
  50848. */
  50849. dragBehavior: PointerDragBehavior;
  50850. private _pointerObserver;
  50851. /**
  50852. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50853. */
  50854. snapDistance: number;
  50855. /**
  50856. * Event that fires each time the gizmo snaps to a new location.
  50857. * * snapDistance is the the change in distance
  50858. */
  50859. onSnapObservable: Observable<{
  50860. snapDistance: number;
  50861. }>;
  50862. private _plane;
  50863. private _coloredMaterial;
  50864. private _hoverMaterial;
  50865. private _isEnabled;
  50866. private _parent;
  50867. /** @hidden */
  50868. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50869. /** @hidden */
  50870. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50871. /**
  50872. * Creates a PlaneDragGizmo
  50873. * @param gizmoLayer The utility layer the gizmo will be added to
  50874. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50875. * @param color The color of the gizmo
  50876. */
  50877. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50878. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50879. /**
  50880. * If the gizmo is enabled
  50881. */
  50882. set isEnabled(value: boolean);
  50883. get isEnabled(): boolean;
  50884. /**
  50885. * Disposes of the gizmo
  50886. */
  50887. dispose(): void;
  50888. }
  50889. }
  50890. declare module "babylonjs/Gizmos/positionGizmo" {
  50891. import { Observable } from "babylonjs/Misc/observable";
  50892. import { Nullable } from "babylonjs/types";
  50893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50894. import { Mesh } from "babylonjs/Meshes/mesh";
  50895. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50896. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  50897. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  50898. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50899. /**
  50900. * Gizmo that enables dragging a mesh along 3 axis
  50901. */
  50902. export class PositionGizmo extends Gizmo {
  50903. /**
  50904. * Internal gizmo used for interactions on the x axis
  50905. */
  50906. xGizmo: AxisDragGizmo;
  50907. /**
  50908. * Internal gizmo used for interactions on the y axis
  50909. */
  50910. yGizmo: AxisDragGizmo;
  50911. /**
  50912. * Internal gizmo used for interactions on the z axis
  50913. */
  50914. zGizmo: AxisDragGizmo;
  50915. /**
  50916. * Internal gizmo used for interactions on the yz plane
  50917. */
  50918. xPlaneGizmo: PlaneDragGizmo;
  50919. /**
  50920. * Internal gizmo used for interactions on the xz plane
  50921. */
  50922. yPlaneGizmo: PlaneDragGizmo;
  50923. /**
  50924. * Internal gizmo used for interactions on the xy plane
  50925. */
  50926. zPlaneGizmo: PlaneDragGizmo;
  50927. /**
  50928. * private variables
  50929. */
  50930. private _meshAttached;
  50931. private _updateGizmoRotationToMatchAttachedMesh;
  50932. private _snapDistance;
  50933. private _scaleRatio;
  50934. /** Fires an event when any of it's sub gizmos are dragged */
  50935. onDragStartObservable: Observable<unknown>;
  50936. /** Fires an event when any of it's sub gizmos are released from dragging */
  50937. onDragEndObservable: Observable<unknown>;
  50938. /**
  50939. * If set to true, planar drag is enabled
  50940. */
  50941. private _planarGizmoEnabled;
  50942. get attachedMesh(): Nullable<AbstractMesh>;
  50943. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50944. /**
  50945. * Creates a PositionGizmo
  50946. * @param gizmoLayer The utility layer the gizmo will be added to
  50947. */
  50948. constructor(gizmoLayer?: UtilityLayerRenderer);
  50949. /**
  50950. * If the planar drag gizmo is enabled
  50951. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50952. */
  50953. set planarGizmoEnabled(value: boolean);
  50954. get planarGizmoEnabled(): boolean;
  50955. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50956. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50957. /**
  50958. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50959. */
  50960. set snapDistance(value: number);
  50961. get snapDistance(): number;
  50962. /**
  50963. * Ratio for the scale of the gizmo (Default: 1)
  50964. */
  50965. set scaleRatio(value: number);
  50966. get scaleRatio(): number;
  50967. /**
  50968. * Disposes of the gizmo
  50969. */
  50970. dispose(): void;
  50971. /**
  50972. * CustomMeshes are not supported by this gizmo
  50973. * @param mesh The mesh to replace the default mesh of the gizmo
  50974. */
  50975. setCustomMesh(mesh: Mesh): void;
  50976. }
  50977. }
  50978. declare module "babylonjs/Gizmos/axisDragGizmo" {
  50979. import { Observable } from "babylonjs/Misc/observable";
  50980. import { Nullable } from "babylonjs/types";
  50981. import { Vector3 } from "babylonjs/Maths/math.vector";
  50982. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50984. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50985. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50986. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50987. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50988. import { Scene } from "babylonjs/scene";
  50989. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50990. import { Color3 } from "babylonjs/Maths/math.color";
  50991. /**
  50992. * Single axis drag gizmo
  50993. */
  50994. export class AxisDragGizmo extends Gizmo {
  50995. /**
  50996. * Drag behavior responsible for the gizmos dragging interactions
  50997. */
  50998. dragBehavior: PointerDragBehavior;
  50999. private _pointerObserver;
  51000. /**
  51001. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51002. */
  51003. snapDistance: number;
  51004. /**
  51005. * Event that fires each time the gizmo snaps to a new location.
  51006. * * snapDistance is the the change in distance
  51007. */
  51008. onSnapObservable: Observable<{
  51009. snapDistance: number;
  51010. }>;
  51011. private _isEnabled;
  51012. private _parent;
  51013. private _arrow;
  51014. private _coloredMaterial;
  51015. private _hoverMaterial;
  51016. /** @hidden */
  51017. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51018. /** @hidden */
  51019. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51020. /**
  51021. * Creates an AxisDragGizmo
  51022. * @param gizmoLayer The utility layer the gizmo will be added to
  51023. * @param dragAxis The axis which the gizmo will be able to drag on
  51024. * @param color The color of the gizmo
  51025. */
  51026. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51027. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51028. /**
  51029. * If the gizmo is enabled
  51030. */
  51031. set isEnabled(value: boolean);
  51032. get isEnabled(): boolean;
  51033. /**
  51034. * Disposes of the gizmo
  51035. */
  51036. dispose(): void;
  51037. }
  51038. }
  51039. declare module "babylonjs/Debug/axesViewer" {
  51040. import { Vector3 } from "babylonjs/Maths/math.vector";
  51041. import { Nullable } from "babylonjs/types";
  51042. import { Scene } from "babylonjs/scene";
  51043. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51044. /**
  51045. * The Axes viewer will show 3 axes in a specific point in space
  51046. */
  51047. export class AxesViewer {
  51048. private _xAxis;
  51049. private _yAxis;
  51050. private _zAxis;
  51051. private _scaleLinesFactor;
  51052. private _instanced;
  51053. /**
  51054. * Gets the hosting scene
  51055. */
  51056. scene: Scene;
  51057. /**
  51058. * Gets or sets a number used to scale line length
  51059. */
  51060. scaleLines: number;
  51061. /** Gets the node hierarchy used to render x-axis */
  51062. get xAxis(): TransformNode;
  51063. /** Gets the node hierarchy used to render y-axis */
  51064. get yAxis(): TransformNode;
  51065. /** Gets the node hierarchy used to render z-axis */
  51066. get zAxis(): TransformNode;
  51067. /**
  51068. * Creates a new AxesViewer
  51069. * @param scene defines the hosting scene
  51070. * @param scaleLines defines a number used to scale line length (1 by default)
  51071. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51072. * @param xAxis defines the node hierarchy used to render the x-axis
  51073. * @param yAxis defines the node hierarchy used to render the y-axis
  51074. * @param zAxis defines the node hierarchy used to render the z-axis
  51075. */
  51076. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51077. /**
  51078. * Force the viewer to update
  51079. * @param position defines the position of the viewer
  51080. * @param xaxis defines the x axis of the viewer
  51081. * @param yaxis defines the y axis of the viewer
  51082. * @param zaxis defines the z axis of the viewer
  51083. */
  51084. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51085. /**
  51086. * Creates an instance of this axes viewer.
  51087. * @returns a new axes viewer with instanced meshes
  51088. */
  51089. createInstance(): AxesViewer;
  51090. /** Releases resources */
  51091. dispose(): void;
  51092. private static _SetRenderingGroupId;
  51093. }
  51094. }
  51095. declare module "babylonjs/Debug/boneAxesViewer" {
  51096. import { Nullable } from "babylonjs/types";
  51097. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51098. import { Vector3 } from "babylonjs/Maths/math.vector";
  51099. import { Mesh } from "babylonjs/Meshes/mesh";
  51100. import { Bone } from "babylonjs/Bones/bone";
  51101. import { Scene } from "babylonjs/scene";
  51102. /**
  51103. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51104. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51105. */
  51106. export class BoneAxesViewer extends AxesViewer {
  51107. /**
  51108. * Gets or sets the target mesh where to display the axes viewer
  51109. */
  51110. mesh: Nullable<Mesh>;
  51111. /**
  51112. * Gets or sets the target bone where to display the axes viewer
  51113. */
  51114. bone: Nullable<Bone>;
  51115. /** Gets current position */
  51116. pos: Vector3;
  51117. /** Gets direction of X axis */
  51118. xaxis: Vector3;
  51119. /** Gets direction of Y axis */
  51120. yaxis: Vector3;
  51121. /** Gets direction of Z axis */
  51122. zaxis: Vector3;
  51123. /**
  51124. * Creates a new BoneAxesViewer
  51125. * @param scene defines the hosting scene
  51126. * @param bone defines the target bone
  51127. * @param mesh defines the target mesh
  51128. * @param scaleLines defines a scaling factor for line length (1 by default)
  51129. */
  51130. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51131. /**
  51132. * Force the viewer to update
  51133. */
  51134. update(): void;
  51135. /** Releases resources */
  51136. dispose(): void;
  51137. }
  51138. }
  51139. declare module "babylonjs/Debug/debugLayer" {
  51140. import { Scene } from "babylonjs/scene";
  51141. /**
  51142. * Interface used to define scene explorer extensibility option
  51143. */
  51144. export interface IExplorerExtensibilityOption {
  51145. /**
  51146. * Define the option label
  51147. */
  51148. label: string;
  51149. /**
  51150. * Defines the action to execute on click
  51151. */
  51152. action: (entity: any) => void;
  51153. }
  51154. /**
  51155. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51156. */
  51157. export interface IExplorerExtensibilityGroup {
  51158. /**
  51159. * Defines a predicate to test if a given type mut be extended
  51160. */
  51161. predicate: (entity: any) => boolean;
  51162. /**
  51163. * Gets the list of options added to a type
  51164. */
  51165. entries: IExplorerExtensibilityOption[];
  51166. }
  51167. /**
  51168. * Interface used to define the options to use to create the Inspector
  51169. */
  51170. export interface IInspectorOptions {
  51171. /**
  51172. * Display in overlay mode (default: false)
  51173. */
  51174. overlay?: boolean;
  51175. /**
  51176. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51177. */
  51178. globalRoot?: HTMLElement;
  51179. /**
  51180. * Display the Scene explorer
  51181. */
  51182. showExplorer?: boolean;
  51183. /**
  51184. * Display the property inspector
  51185. */
  51186. showInspector?: boolean;
  51187. /**
  51188. * Display in embed mode (both panes on the right)
  51189. */
  51190. embedMode?: boolean;
  51191. /**
  51192. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51193. */
  51194. handleResize?: boolean;
  51195. /**
  51196. * Allow the panes to popup (default: true)
  51197. */
  51198. enablePopup?: boolean;
  51199. /**
  51200. * Allow the panes to be closed by users (default: true)
  51201. */
  51202. enableClose?: boolean;
  51203. /**
  51204. * Optional list of extensibility entries
  51205. */
  51206. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51207. /**
  51208. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51209. */
  51210. inspectorURL?: string;
  51211. /**
  51212. * Optional initial tab (default to DebugLayerTab.Properties)
  51213. */
  51214. initialTab?: DebugLayerTab;
  51215. }
  51216. module "babylonjs/scene" {
  51217. interface Scene {
  51218. /**
  51219. * @hidden
  51220. * Backing field
  51221. */
  51222. _debugLayer: DebugLayer;
  51223. /**
  51224. * Gets the debug layer (aka Inspector) associated with the scene
  51225. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51226. */
  51227. debugLayer: DebugLayer;
  51228. }
  51229. }
  51230. /**
  51231. * Enum of inspector action tab
  51232. */
  51233. export enum DebugLayerTab {
  51234. /**
  51235. * Properties tag (default)
  51236. */
  51237. Properties = 0,
  51238. /**
  51239. * Debug tab
  51240. */
  51241. Debug = 1,
  51242. /**
  51243. * Statistics tab
  51244. */
  51245. Statistics = 2,
  51246. /**
  51247. * Tools tab
  51248. */
  51249. Tools = 3,
  51250. /**
  51251. * Settings tab
  51252. */
  51253. Settings = 4
  51254. }
  51255. /**
  51256. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51257. * what is happening in your scene
  51258. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51259. */
  51260. export class DebugLayer {
  51261. /**
  51262. * Define the url to get the inspector script from.
  51263. * By default it uses the babylonjs CDN.
  51264. * @ignoreNaming
  51265. */
  51266. static InspectorURL: string;
  51267. private _scene;
  51268. private BJSINSPECTOR;
  51269. private _onPropertyChangedObservable?;
  51270. /**
  51271. * Observable triggered when a property is changed through the inspector.
  51272. */
  51273. get onPropertyChangedObservable(): any;
  51274. /**
  51275. * Instantiates a new debug layer.
  51276. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51277. * what is happening in your scene
  51278. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51279. * @param scene Defines the scene to inspect
  51280. */
  51281. constructor(scene: Scene);
  51282. /** Creates the inspector window. */
  51283. private _createInspector;
  51284. /**
  51285. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51286. * @param entity defines the entity to select
  51287. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51288. */
  51289. select(entity: any, lineContainerTitles?: string | string[]): void;
  51290. /** Get the inspector from bundle or global */
  51291. private _getGlobalInspector;
  51292. /**
  51293. * Get if the inspector is visible or not.
  51294. * @returns true if visible otherwise, false
  51295. */
  51296. isVisible(): boolean;
  51297. /**
  51298. * Hide the inspector and close its window.
  51299. */
  51300. hide(): void;
  51301. /**
  51302. * Update the scene in the inspector
  51303. */
  51304. setAsActiveScene(): void;
  51305. /**
  51306. * Launch the debugLayer.
  51307. * @param config Define the configuration of the inspector
  51308. * @return a promise fulfilled when the debug layer is visible
  51309. */
  51310. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51311. }
  51312. }
  51313. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51314. import { Nullable } from "babylonjs/types";
  51315. import { Scene } from "babylonjs/scene";
  51316. import { Vector4 } from "babylonjs/Maths/math.vector";
  51317. import { Color4 } from "babylonjs/Maths/math.color";
  51318. import { Mesh } from "babylonjs/Meshes/mesh";
  51319. /**
  51320. * Class containing static functions to help procedurally build meshes
  51321. */
  51322. export class BoxBuilder {
  51323. /**
  51324. * Creates a box mesh
  51325. * * The parameter `size` sets the size (float) of each box side (default 1)
  51326. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51327. * * 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)
  51328. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51332. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51333. * @param name defines the name of the mesh
  51334. * @param options defines the options used to create the mesh
  51335. * @param scene defines the hosting scene
  51336. * @returns the box mesh
  51337. */
  51338. static CreateBox(name: string, options: {
  51339. size?: number;
  51340. width?: number;
  51341. height?: number;
  51342. depth?: number;
  51343. faceUV?: Vector4[];
  51344. faceColors?: Color4[];
  51345. sideOrientation?: number;
  51346. frontUVs?: Vector4;
  51347. backUVs?: Vector4;
  51348. wrap?: boolean;
  51349. topBaseAt?: number;
  51350. bottomBaseAt?: number;
  51351. updatable?: boolean;
  51352. }, scene?: Nullable<Scene>): Mesh;
  51353. }
  51354. }
  51355. declare module "babylonjs/Debug/physicsViewer" {
  51356. import { Nullable } from "babylonjs/types";
  51357. import { Scene } from "babylonjs/scene";
  51358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51359. import { Mesh } from "babylonjs/Meshes/mesh";
  51360. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51361. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51362. /**
  51363. * Used to show the physics impostor around the specific mesh
  51364. */
  51365. export class PhysicsViewer {
  51366. /** @hidden */
  51367. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51368. /** @hidden */
  51369. protected _meshes: Array<Nullable<AbstractMesh>>;
  51370. /** @hidden */
  51371. protected _scene: Nullable<Scene>;
  51372. /** @hidden */
  51373. protected _numMeshes: number;
  51374. /** @hidden */
  51375. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51376. private _renderFunction;
  51377. private _utilityLayer;
  51378. private _debugBoxMesh;
  51379. private _debugSphereMesh;
  51380. private _debugCylinderMesh;
  51381. private _debugMaterial;
  51382. private _debugMeshMeshes;
  51383. /**
  51384. * Creates a new PhysicsViewer
  51385. * @param scene defines the hosting scene
  51386. */
  51387. constructor(scene: Scene);
  51388. /** @hidden */
  51389. protected _updateDebugMeshes(): void;
  51390. /**
  51391. * Renders a specified physic impostor
  51392. * @param impostor defines the impostor to render
  51393. * @param targetMesh defines the mesh represented by the impostor
  51394. * @returns the new debug mesh used to render the impostor
  51395. */
  51396. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51397. /**
  51398. * Hides a specified physic impostor
  51399. * @param impostor defines the impostor to hide
  51400. */
  51401. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51402. private _getDebugMaterial;
  51403. private _getDebugBoxMesh;
  51404. private _getDebugSphereMesh;
  51405. private _getDebugCylinderMesh;
  51406. private _getDebugMeshMesh;
  51407. private _getDebugMesh;
  51408. /** Releases all resources */
  51409. dispose(): void;
  51410. }
  51411. }
  51412. declare module "babylonjs/Debug/rayHelper" {
  51413. import { Nullable } from "babylonjs/types";
  51414. import { Ray } from "babylonjs/Culling/ray";
  51415. import { Vector3 } from "babylonjs/Maths/math.vector";
  51416. import { Color3 } from "babylonjs/Maths/math.color";
  51417. import { Scene } from "babylonjs/scene";
  51418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51419. import "babylonjs/Meshes/Builders/linesBuilder";
  51420. /**
  51421. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51422. * in order to better appreciate the issue one might have.
  51423. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51424. */
  51425. export class RayHelper {
  51426. /**
  51427. * Defines the ray we are currently tryin to visualize.
  51428. */
  51429. ray: Nullable<Ray>;
  51430. private _renderPoints;
  51431. private _renderLine;
  51432. private _renderFunction;
  51433. private _scene;
  51434. private _updateToMeshFunction;
  51435. private _attachedToMesh;
  51436. private _meshSpaceDirection;
  51437. private _meshSpaceOrigin;
  51438. /**
  51439. * Helper function to create a colored helper in a scene in one line.
  51440. * @param ray Defines the ray we are currently tryin to visualize
  51441. * @param scene Defines the scene the ray is used in
  51442. * @param color Defines the color we want to see the ray in
  51443. * @returns The newly created ray helper.
  51444. */
  51445. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51446. /**
  51447. * Instantiate a new ray helper.
  51448. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51449. * in order to better appreciate the issue one might have.
  51450. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51451. * @param ray Defines the ray we are currently tryin to visualize
  51452. */
  51453. constructor(ray: Ray);
  51454. /**
  51455. * Shows the ray we are willing to debug.
  51456. * @param scene Defines the scene the ray needs to be rendered in
  51457. * @param color Defines the color the ray needs to be rendered in
  51458. */
  51459. show(scene: Scene, color?: Color3): void;
  51460. /**
  51461. * Hides the ray we are debugging.
  51462. */
  51463. hide(): void;
  51464. private _render;
  51465. /**
  51466. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51467. * @param mesh Defines the mesh we want the helper attached to
  51468. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51469. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51470. * @param length Defines the length of the ray
  51471. */
  51472. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51473. /**
  51474. * Detach the ray helper from the mesh it has previously been attached to.
  51475. */
  51476. detachFromMesh(): void;
  51477. private _updateToMesh;
  51478. /**
  51479. * Dispose the helper and release its associated resources.
  51480. */
  51481. dispose(): void;
  51482. }
  51483. }
  51484. declare module "babylonjs/Debug/skeletonViewer" {
  51485. import { Color3 } from "babylonjs/Maths/math.color";
  51486. import { Scene } from "babylonjs/scene";
  51487. import { Nullable } from "babylonjs/types";
  51488. import { Skeleton } from "babylonjs/Bones/skeleton";
  51489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51490. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51491. /**
  51492. * Class used to render a debug view of a given skeleton
  51493. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51494. */
  51495. export class SkeletonViewer {
  51496. /** defines the skeleton to render */
  51497. skeleton: Skeleton;
  51498. /** defines the mesh attached to the skeleton */
  51499. mesh: AbstractMesh;
  51500. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51501. autoUpdateBonesMatrices: boolean;
  51502. /** defines the rendering group id to use with the viewer */
  51503. renderingGroupId: number;
  51504. /** Gets or sets the color used to render the skeleton */
  51505. color: Color3;
  51506. private _scene;
  51507. private _debugLines;
  51508. private _debugMesh;
  51509. private _isEnabled;
  51510. private _renderFunction;
  51511. private _utilityLayer;
  51512. /**
  51513. * Returns the mesh used to render the bones
  51514. */
  51515. get debugMesh(): Nullable<LinesMesh>;
  51516. /**
  51517. * Creates a new SkeletonViewer
  51518. * @param skeleton defines the skeleton to render
  51519. * @param mesh defines the mesh attached to the skeleton
  51520. * @param scene defines the hosting scene
  51521. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51522. * @param renderingGroupId defines the rendering group id to use with the viewer
  51523. */
  51524. constructor(
  51525. /** defines the skeleton to render */
  51526. skeleton: Skeleton,
  51527. /** defines the mesh attached to the skeleton */
  51528. mesh: AbstractMesh, scene: Scene,
  51529. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51530. autoUpdateBonesMatrices?: boolean,
  51531. /** defines the rendering group id to use with the viewer */
  51532. renderingGroupId?: number);
  51533. /** Gets or sets a boolean indicating if the viewer is enabled */
  51534. set isEnabled(value: boolean);
  51535. get isEnabled(): boolean;
  51536. private _getBonePosition;
  51537. private _getLinesForBonesWithLength;
  51538. private _getLinesForBonesNoLength;
  51539. /** Update the viewer to sync with current skeleton state */
  51540. update(): void;
  51541. /** Release associated resources */
  51542. dispose(): void;
  51543. }
  51544. }
  51545. declare module "babylonjs/Debug/index" {
  51546. export * from "babylonjs/Debug/axesViewer";
  51547. export * from "babylonjs/Debug/boneAxesViewer";
  51548. export * from "babylonjs/Debug/debugLayer";
  51549. export * from "babylonjs/Debug/physicsViewer";
  51550. export * from "babylonjs/Debug/rayHelper";
  51551. export * from "babylonjs/Debug/skeletonViewer";
  51552. }
  51553. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51554. /**
  51555. * Enum for Device Types
  51556. */
  51557. export enum DeviceType {
  51558. /** Generic */
  51559. Generic = 0,
  51560. /** Keyboard */
  51561. Keyboard = 1,
  51562. /** Mouse */
  51563. Mouse = 2,
  51564. /** Touch Pointers */
  51565. Touch = 3,
  51566. /** PS4 Dual Shock */
  51567. DualShock = 4,
  51568. /** Xbox */
  51569. Xbox = 5,
  51570. /** Switch Controller */
  51571. Switch = 6
  51572. }
  51573. /**
  51574. * Enum for All Pointers (Touch/Mouse)
  51575. */
  51576. export enum PointerInput {
  51577. /** Horizontal Axis */
  51578. Horizontal = 0,
  51579. /** Vertical Axis */
  51580. Vertical = 1,
  51581. /** Left Click or Touch */
  51582. LeftClick = 2,
  51583. /** Middle Click */
  51584. MiddleClick = 3,
  51585. /** Right Click */
  51586. RightClick = 4,
  51587. /** Browser Back */
  51588. BrowserBack = 5,
  51589. /** Browser Forward */
  51590. BrowserForward = 6
  51591. }
  51592. /**
  51593. * Enum for Dual Shock Gamepad
  51594. */
  51595. export enum DualShockInput {
  51596. /** Cross */
  51597. Cross = 0,
  51598. /** Circle */
  51599. Circle = 1,
  51600. /** Square */
  51601. Square = 2,
  51602. /** Triangle */
  51603. Triangle = 3,
  51604. /** L1 */
  51605. L1 = 4,
  51606. /** R1 */
  51607. R1 = 5,
  51608. /** L2 */
  51609. L2 = 6,
  51610. /** R2 */
  51611. R2 = 7,
  51612. /** Share */
  51613. Share = 8,
  51614. /** Options */
  51615. Options = 9,
  51616. /** L3 */
  51617. L3 = 10,
  51618. /** R3 */
  51619. R3 = 11,
  51620. /** DPadUp */
  51621. DPadUp = 12,
  51622. /** DPadDown */
  51623. DPadDown = 13,
  51624. /** DPadLeft */
  51625. DPadLeft = 14,
  51626. /** DRight */
  51627. DPadRight = 15,
  51628. /** Home */
  51629. Home = 16,
  51630. /** TouchPad */
  51631. TouchPad = 17,
  51632. /** LStickXAxis */
  51633. LStickXAxis = 18,
  51634. /** LStickYAxis */
  51635. LStickYAxis = 19,
  51636. /** RStickXAxis */
  51637. RStickXAxis = 20,
  51638. /** RStickYAxis */
  51639. RStickYAxis = 21
  51640. }
  51641. /**
  51642. * Enum for Xbox Gamepad
  51643. */
  51644. export enum XboxInput {
  51645. /** A */
  51646. A = 0,
  51647. /** B */
  51648. B = 1,
  51649. /** X */
  51650. X = 2,
  51651. /** Y */
  51652. Y = 3,
  51653. /** LB */
  51654. LB = 4,
  51655. /** RB */
  51656. RB = 5,
  51657. /** LT */
  51658. LT = 6,
  51659. /** RT */
  51660. RT = 7,
  51661. /** Back */
  51662. Back = 8,
  51663. /** Start */
  51664. Start = 9,
  51665. /** LS */
  51666. LS = 10,
  51667. /** RS */
  51668. RS = 11,
  51669. /** DPadUp */
  51670. DPadUp = 12,
  51671. /** DPadDown */
  51672. DPadDown = 13,
  51673. /** DPadLeft */
  51674. DPadLeft = 14,
  51675. /** DRight */
  51676. DPadRight = 15,
  51677. /** Home */
  51678. Home = 16,
  51679. /** LStickXAxis */
  51680. LStickXAxis = 17,
  51681. /** LStickYAxis */
  51682. LStickYAxis = 18,
  51683. /** RStickXAxis */
  51684. RStickXAxis = 19,
  51685. /** RStickYAxis */
  51686. RStickYAxis = 20
  51687. }
  51688. /**
  51689. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51690. */
  51691. export enum SwitchInput {
  51692. /** B */
  51693. B = 0,
  51694. /** A */
  51695. A = 1,
  51696. /** Y */
  51697. Y = 2,
  51698. /** X */
  51699. X = 3,
  51700. /** L */
  51701. L = 4,
  51702. /** R */
  51703. R = 5,
  51704. /** ZL */
  51705. ZL = 6,
  51706. /** ZR */
  51707. ZR = 7,
  51708. /** Minus */
  51709. Minus = 8,
  51710. /** Plus */
  51711. Plus = 9,
  51712. /** LS */
  51713. LS = 10,
  51714. /** RS */
  51715. RS = 11,
  51716. /** DPadUp */
  51717. DPadUp = 12,
  51718. /** DPadDown */
  51719. DPadDown = 13,
  51720. /** DPadLeft */
  51721. DPadLeft = 14,
  51722. /** DRight */
  51723. DPadRight = 15,
  51724. /** Home */
  51725. Home = 16,
  51726. /** Capture */
  51727. Capture = 17,
  51728. /** LStickXAxis */
  51729. LStickXAxis = 18,
  51730. /** LStickYAxis */
  51731. LStickYAxis = 19,
  51732. /** RStickXAxis */
  51733. RStickXAxis = 20,
  51734. /** RStickYAxis */
  51735. RStickYAxis = 21
  51736. }
  51737. }
  51738. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  51739. import { Engine } from "babylonjs/Engines/engine";
  51740. import { IDisposable } from "babylonjs/scene";
  51741. import { Nullable } from "babylonjs/types";
  51742. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51743. /**
  51744. * This class will take all inputs from Keyboard, Pointer, and
  51745. * any Gamepads and provide a polling system that all devices
  51746. * will use. This class assumes that there will only be one
  51747. * pointer device and one keyboard.
  51748. */
  51749. export class DeviceInputSystem implements IDisposable {
  51750. /**
  51751. * Callback to be triggered when a device is connected
  51752. */
  51753. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51754. /**
  51755. * Callback to be triggered when a device is disconnected
  51756. */
  51757. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51758. /**
  51759. * Callback to be triggered when event driven input is updated
  51760. */
  51761. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51762. private _inputs;
  51763. private _gamepads;
  51764. private _keyboardActive;
  51765. private _pointerActive;
  51766. private _elementToAttachTo;
  51767. private _keyboardDownEvent;
  51768. private _keyboardUpEvent;
  51769. private _pointerMoveEvent;
  51770. private _pointerDownEvent;
  51771. private _pointerUpEvent;
  51772. private _gamepadConnectedEvent;
  51773. private _gamepadDisconnectedEvent;
  51774. private static _MAX_KEYCODES;
  51775. private static _MAX_POINTER_INPUTS;
  51776. private constructor();
  51777. /**
  51778. * Creates a new DeviceInputSystem instance
  51779. * @param engine Engine to pull input element from
  51780. * @returns The new instance
  51781. */
  51782. static Create(engine: Engine): DeviceInputSystem;
  51783. /**
  51784. * Checks for current device input value, given an id and input index
  51785. * @param deviceName Id of connected device
  51786. * @param inputIndex Index of device input
  51787. * @returns Current value of input
  51788. */
  51789. /**
  51790. * Checks for current device input value, given an id and input index
  51791. * @param deviceType Enum specifiying device type
  51792. * @param deviceSlot "Slot" or index that device is referenced in
  51793. * @param inputIndex Id of input to be checked
  51794. * @returns Current value of input
  51795. */
  51796. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51797. /**
  51798. * Dispose of all the eventlisteners
  51799. */
  51800. dispose(): void;
  51801. /**
  51802. * Add device and inputs to device array
  51803. * @param deviceType Enum specifiying device type
  51804. * @param deviceSlot "Slot" or index that device is referenced in
  51805. * @param numberOfInputs Number of input entries to create for given device
  51806. */
  51807. private _registerDevice;
  51808. /**
  51809. * Given a specific device name, remove that device from the device map
  51810. * @param deviceType Enum specifiying device type
  51811. * @param deviceSlot "Slot" or index that device is referenced in
  51812. */
  51813. private _unregisterDevice;
  51814. /**
  51815. * Handle all actions that come from keyboard interaction
  51816. */
  51817. private _handleKeyActions;
  51818. /**
  51819. * Handle all actions that come from pointer interaction
  51820. */
  51821. private _handlePointerActions;
  51822. /**
  51823. * Handle all actions that come from gamepad interaction
  51824. */
  51825. private _handleGamepadActions;
  51826. /**
  51827. * Update all non-event based devices with each frame
  51828. * @param deviceType Enum specifiying device type
  51829. * @param deviceSlot "Slot" or index that device is referenced in
  51830. * @param inputIndex Id of input to be checked
  51831. */
  51832. private _updateDevice;
  51833. /**
  51834. * Gets DeviceType from the device name
  51835. * @param deviceName Name of Device from DeviceInputSystem
  51836. * @returns DeviceType enum value
  51837. */
  51838. private _getGamepadDeviceType;
  51839. }
  51840. }
  51841. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  51842. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51843. /**
  51844. * Type to handle enforcement of inputs
  51845. */
  51846. 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;
  51847. }
  51848. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  51849. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  51850. import { Engine } from "babylonjs/Engines/engine";
  51851. import { IDisposable } from "babylonjs/scene";
  51852. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51853. import { Nullable } from "babylonjs/types";
  51854. import { Observable } from "babylonjs/Misc/observable";
  51855. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51856. /**
  51857. * Class that handles all input for a specific device
  51858. */
  51859. export class DeviceSource<T extends DeviceType> {
  51860. /** Type of device */
  51861. readonly deviceType: DeviceType;
  51862. /** "Slot" or index that device is referenced in */
  51863. readonly deviceSlot: number;
  51864. /**
  51865. * Observable to handle device input changes per device
  51866. */
  51867. readonly onInputChangedObservable: Observable<{
  51868. inputIndex: DeviceInput<T>;
  51869. previousState: Nullable<number>;
  51870. currentState: Nullable<number>;
  51871. }>;
  51872. private readonly _deviceInputSystem;
  51873. /**
  51874. * Default Constructor
  51875. * @param deviceInputSystem Reference to DeviceInputSystem
  51876. * @param deviceType Type of device
  51877. * @param deviceSlot "Slot" or index that device is referenced in
  51878. */
  51879. constructor(deviceInputSystem: DeviceInputSystem,
  51880. /** Type of device */
  51881. deviceType: DeviceType,
  51882. /** "Slot" or index that device is referenced in */
  51883. deviceSlot?: number);
  51884. /**
  51885. * Get input for specific input
  51886. * @param inputIndex index of specific input on device
  51887. * @returns Input value from DeviceInputSystem
  51888. */
  51889. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51890. }
  51891. /**
  51892. * Class to keep track of devices
  51893. */
  51894. export class DeviceSourceManager implements IDisposable {
  51895. /**
  51896. * Observable to be triggered when before a device is connected
  51897. */
  51898. readonly onBeforeDeviceConnectedObservable: Observable<{
  51899. deviceType: DeviceType;
  51900. deviceSlot: number;
  51901. }>;
  51902. /**
  51903. * Observable to be triggered when before a device is disconnected
  51904. */
  51905. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51906. deviceType: DeviceType;
  51907. deviceSlot: number;
  51908. }>;
  51909. /**
  51910. * Observable to be triggered when after a device is connected
  51911. */
  51912. readonly onAfterDeviceConnectedObservable: Observable<{
  51913. deviceType: DeviceType;
  51914. deviceSlot: number;
  51915. }>;
  51916. /**
  51917. * Observable to be triggered when after a device is disconnected
  51918. */
  51919. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51920. deviceType: DeviceType;
  51921. deviceSlot: number;
  51922. }>;
  51923. private readonly _devices;
  51924. private readonly _firstDevice;
  51925. private readonly _deviceInputSystem;
  51926. /**
  51927. * Default Constructor
  51928. * @param engine engine to pull input element from
  51929. */
  51930. constructor(engine: Engine);
  51931. /**
  51932. * Gets a DeviceSource, given a type and slot
  51933. * @param deviceType Enum specifying device type
  51934. * @param deviceSlot "Slot" or index that device is referenced in
  51935. * @returns DeviceSource object
  51936. */
  51937. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51938. /**
  51939. * Gets an array of DeviceSource objects for a given device type
  51940. * @param deviceType Enum specifying device type
  51941. * @returns Array of DeviceSource objects
  51942. */
  51943. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51944. /**
  51945. * Dispose of DeviceInputSystem and other parts
  51946. */
  51947. dispose(): void;
  51948. /**
  51949. * Function to add device name to device list
  51950. * @param deviceType Enum specifying device type
  51951. * @param deviceSlot "Slot" or index that device is referenced in
  51952. */
  51953. private _addDevice;
  51954. /**
  51955. * Function to remove device name to device list
  51956. * @param deviceType Enum specifying device type
  51957. * @param deviceSlot "Slot" or index that device is referenced in
  51958. */
  51959. private _removeDevice;
  51960. /**
  51961. * Updates array storing first connected device of each type
  51962. * @param type Type of Device
  51963. */
  51964. private _updateFirstDevices;
  51965. }
  51966. }
  51967. declare module "babylonjs/DeviceInput/index" {
  51968. export * from "babylonjs/DeviceInput/deviceInputSystem";
  51969. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51970. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51971. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51972. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51973. }
  51974. declare module "babylonjs/Engines/nullEngine" {
  51975. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  51976. import { Engine } from "babylonjs/Engines/engine";
  51977. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  51978. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  51979. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51980. import { Effect } from "babylonjs/Materials/effect";
  51981. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  51982. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  51983. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  51984. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  51985. /**
  51986. * Options to create the null engine
  51987. */
  51988. export class NullEngineOptions {
  51989. /**
  51990. * Render width (Default: 512)
  51991. */
  51992. renderWidth: number;
  51993. /**
  51994. * Render height (Default: 256)
  51995. */
  51996. renderHeight: number;
  51997. /**
  51998. * Texture size (Default: 512)
  51999. */
  52000. textureSize: number;
  52001. /**
  52002. * If delta time between frames should be constant
  52003. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52004. */
  52005. deterministicLockstep: boolean;
  52006. /**
  52007. * Maximum about of steps between frames (Default: 4)
  52008. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52009. */
  52010. lockstepMaxSteps: number;
  52011. }
  52012. /**
  52013. * The null engine class provides support for headless version of babylon.js.
  52014. * This can be used in server side scenario or for testing purposes
  52015. */
  52016. export class NullEngine extends Engine {
  52017. private _options;
  52018. /**
  52019. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52021. * @returns true if engine is in deterministic lock step mode
  52022. */
  52023. isDeterministicLockStep(): boolean;
  52024. /**
  52025. * Gets the max steps when engine is running in deterministic lock step
  52026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52027. * @returns the max steps
  52028. */
  52029. getLockstepMaxSteps(): number;
  52030. /**
  52031. * Gets the current hardware scaling level.
  52032. * By default the hardware scaling level is computed from the window device ratio.
  52033. * 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.
  52034. * @returns a number indicating the current hardware scaling level
  52035. */
  52036. getHardwareScalingLevel(): number;
  52037. constructor(options?: NullEngineOptions);
  52038. /**
  52039. * Creates a vertex buffer
  52040. * @param vertices the data for the vertex buffer
  52041. * @returns the new WebGL static buffer
  52042. */
  52043. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52044. /**
  52045. * Creates a new index buffer
  52046. * @param indices defines the content of the index buffer
  52047. * @param updatable defines if the index buffer must be updatable
  52048. * @returns a new webGL buffer
  52049. */
  52050. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52051. /**
  52052. * Clear the current render buffer or the current render target (if any is set up)
  52053. * @param color defines the color to use
  52054. * @param backBuffer defines if the back buffer must be cleared
  52055. * @param depth defines if the depth buffer must be cleared
  52056. * @param stencil defines if the stencil buffer must be cleared
  52057. */
  52058. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52059. /**
  52060. * Gets the current render width
  52061. * @param useScreen defines if screen size must be used (or the current render target if any)
  52062. * @returns a number defining the current render width
  52063. */
  52064. getRenderWidth(useScreen?: boolean): number;
  52065. /**
  52066. * Gets the current render height
  52067. * @param useScreen defines if screen size must be used (or the current render target if any)
  52068. * @returns a number defining the current render height
  52069. */
  52070. getRenderHeight(useScreen?: boolean): number;
  52071. /**
  52072. * Set the WebGL's viewport
  52073. * @param viewport defines the viewport element to be used
  52074. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52075. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52076. */
  52077. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52078. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52079. /**
  52080. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52081. * @param pipelineContext defines the pipeline context to use
  52082. * @param uniformsNames defines the list of uniform names
  52083. * @returns an array of webGL uniform locations
  52084. */
  52085. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52086. /**
  52087. * Gets the lsit of active attributes for a given webGL program
  52088. * @param pipelineContext defines the pipeline context to use
  52089. * @param attributesNames defines the list of attribute names to get
  52090. * @returns an array of indices indicating the offset of each attribute
  52091. */
  52092. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52093. /**
  52094. * Binds an effect to the webGL context
  52095. * @param effect defines the effect to bind
  52096. */
  52097. bindSamplers(effect: Effect): void;
  52098. /**
  52099. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52100. * @param effect defines the effect to activate
  52101. */
  52102. enableEffect(effect: Effect): void;
  52103. /**
  52104. * Set various states to the webGL context
  52105. * @param culling defines backface culling state
  52106. * @param zOffset defines the value to apply to zOffset (0 by default)
  52107. * @param force defines if states must be applied even if cache is up to date
  52108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52109. */
  52110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52111. /**
  52112. * Set the value of an uniform to an array of int32
  52113. * @param uniform defines the webGL uniform location where to store the value
  52114. * @param array defines the array of int32 to store
  52115. */
  52116. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52117. /**
  52118. * Set the value of an uniform to an array of int32 (stored as vec2)
  52119. * @param uniform defines the webGL uniform location where to store the value
  52120. * @param array defines the array of int32 to store
  52121. */
  52122. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52123. /**
  52124. * Set the value of an uniform to an array of int32 (stored as vec3)
  52125. * @param uniform defines the webGL uniform location where to store the value
  52126. * @param array defines the array of int32 to store
  52127. */
  52128. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52129. /**
  52130. * Set the value of an uniform to an array of int32 (stored as vec4)
  52131. * @param uniform defines the webGL uniform location where to store the value
  52132. * @param array defines the array of int32 to store
  52133. */
  52134. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52135. /**
  52136. * Set the value of an uniform to an array of float32
  52137. * @param uniform defines the webGL uniform location where to store the value
  52138. * @param array defines the array of float32 to store
  52139. */
  52140. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52141. /**
  52142. * Set the value of an uniform to an array of float32 (stored as vec2)
  52143. * @param uniform defines the webGL uniform location where to store the value
  52144. * @param array defines the array of float32 to store
  52145. */
  52146. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52147. /**
  52148. * Set the value of an uniform to an array of float32 (stored as vec3)
  52149. * @param uniform defines the webGL uniform location where to store the value
  52150. * @param array defines the array of float32 to store
  52151. */
  52152. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52153. /**
  52154. * Set the value of an uniform to an array of float32 (stored as vec4)
  52155. * @param uniform defines the webGL uniform location where to store the value
  52156. * @param array defines the array of float32 to store
  52157. */
  52158. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52159. /**
  52160. * Set the value of an uniform to an array of number
  52161. * @param uniform defines the webGL uniform location where to store the value
  52162. * @param array defines the array of number to store
  52163. */
  52164. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52165. /**
  52166. * Set the value of an uniform to an array of number (stored as vec2)
  52167. * @param uniform defines the webGL uniform location where to store the value
  52168. * @param array defines the array of number to store
  52169. */
  52170. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52171. /**
  52172. * Set the value of an uniform to an array of number (stored as vec3)
  52173. * @param uniform defines the webGL uniform location where to store the value
  52174. * @param array defines the array of number to store
  52175. */
  52176. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52177. /**
  52178. * Set the value of an uniform to an array of number (stored as vec4)
  52179. * @param uniform defines the webGL uniform location where to store the value
  52180. * @param array defines the array of number to store
  52181. */
  52182. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52183. /**
  52184. * Set the value of an uniform to an array of float32 (stored as matrices)
  52185. * @param uniform defines the webGL uniform location where to store the value
  52186. * @param matrices defines the array of float32 to store
  52187. */
  52188. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52189. /**
  52190. * Set the value of an uniform to a matrix (3x3)
  52191. * @param uniform defines the webGL uniform location where to store the value
  52192. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52193. */
  52194. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52195. /**
  52196. * Set the value of an uniform to a matrix (2x2)
  52197. * @param uniform defines the webGL uniform location where to store the value
  52198. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52199. */
  52200. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52201. /**
  52202. * Set the value of an uniform to a number (float)
  52203. * @param uniform defines the webGL uniform location where to store the value
  52204. * @param value defines the float number to store
  52205. */
  52206. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52207. /**
  52208. * Set the value of an uniform to a vec2
  52209. * @param uniform defines the webGL uniform location where to store the value
  52210. * @param x defines the 1st component of the value
  52211. * @param y defines the 2nd component of the value
  52212. */
  52213. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52214. /**
  52215. * Set the value of an uniform to a vec3
  52216. * @param uniform defines the webGL uniform location where to store the value
  52217. * @param x defines the 1st component of the value
  52218. * @param y defines the 2nd component of the value
  52219. * @param z defines the 3rd component of the value
  52220. */
  52221. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52222. /**
  52223. * Set the value of an uniform to a boolean
  52224. * @param uniform defines the webGL uniform location where to store the value
  52225. * @param bool defines the boolean to store
  52226. */
  52227. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52228. /**
  52229. * Set the value of an uniform to a vec4
  52230. * @param uniform defines the webGL uniform location where to store the value
  52231. * @param x defines the 1st component of the value
  52232. * @param y defines the 2nd component of the value
  52233. * @param z defines the 3rd component of the value
  52234. * @param w defines the 4th component of the value
  52235. */
  52236. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52237. /**
  52238. * Sets the current alpha mode
  52239. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52240. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52241. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52242. */
  52243. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52244. /**
  52245. * Bind webGl buffers directly to the webGL context
  52246. * @param vertexBuffers defines the vertex buffer to bind
  52247. * @param indexBuffer defines the index buffer to bind
  52248. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52249. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52250. * @param effect defines the effect associated with the vertex buffer
  52251. */
  52252. bindBuffers(vertexBuffers: {
  52253. [key: string]: VertexBuffer;
  52254. }, indexBuffer: DataBuffer, effect: Effect): void;
  52255. /**
  52256. * Force the entire cache to be cleared
  52257. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52258. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52259. */
  52260. wipeCaches(bruteForce?: boolean): void;
  52261. /**
  52262. * Send a draw order
  52263. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52264. * @param indexStart defines the starting index
  52265. * @param indexCount defines the number of index to draw
  52266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52267. */
  52268. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52269. /**
  52270. * Draw a list of indexed primitives
  52271. * @param fillMode defines the primitive to use
  52272. * @param indexStart defines the starting index
  52273. * @param indexCount defines the number of index to draw
  52274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52275. */
  52276. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52277. /**
  52278. * Draw a list of unindexed primitives
  52279. * @param fillMode defines the primitive to use
  52280. * @param verticesStart defines the index of first vertex to draw
  52281. * @param verticesCount defines the count of vertices to draw
  52282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52283. */
  52284. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52285. /** @hidden */
  52286. _createTexture(): WebGLTexture;
  52287. /** @hidden */
  52288. _releaseTexture(texture: InternalTexture): void;
  52289. /**
  52290. * Usually called from Texture.ts.
  52291. * Passed information to create a WebGLTexture
  52292. * @param urlArg defines a value which contains one of the following:
  52293. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52294. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52295. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52296. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52297. * @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)
  52298. * @param scene needed for loading to the correct scene
  52299. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52300. * @param onLoad optional callback to be called upon successful completion
  52301. * @param onError optional callback to be called upon failure
  52302. * @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
  52303. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52304. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52305. * @param forcedExtension defines the extension to use to pick the right loader
  52306. * @param mimeType defines an optional mime type
  52307. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52308. */
  52309. 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;
  52310. /**
  52311. * Creates a new render target texture
  52312. * @param size defines the size of the texture
  52313. * @param options defines the options used to create the texture
  52314. * @returns a new render target texture stored in an InternalTexture
  52315. */
  52316. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52317. /**
  52318. * Update the sampling mode of a given texture
  52319. * @param samplingMode defines the required sampling mode
  52320. * @param texture defines the texture to update
  52321. */
  52322. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52323. /**
  52324. * Binds the frame buffer to the specified texture.
  52325. * @param texture The texture to render to or null for the default canvas
  52326. * @param faceIndex The face of the texture to render to in case of cube texture
  52327. * @param requiredWidth The width of the target to render to
  52328. * @param requiredHeight The height of the target to render to
  52329. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52330. * @param lodLevel defines le lod level to bind to the frame buffer
  52331. */
  52332. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52333. /**
  52334. * Unbind the current render target texture from the webGL context
  52335. * @param texture defines the render target texture to unbind
  52336. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52337. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52338. */
  52339. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52340. /**
  52341. * Creates a dynamic vertex buffer
  52342. * @param vertices the data for the dynamic vertex buffer
  52343. * @returns the new WebGL dynamic buffer
  52344. */
  52345. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52346. /**
  52347. * Update the content of a dynamic texture
  52348. * @param texture defines the texture to update
  52349. * @param canvas defines the canvas containing the source
  52350. * @param invertY defines if data must be stored with Y axis inverted
  52351. * @param premulAlpha defines if alpha is stored as premultiplied
  52352. * @param format defines the format of the data
  52353. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52354. */
  52355. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52356. /**
  52357. * Gets a boolean indicating if all created effects are ready
  52358. * @returns true if all effects are ready
  52359. */
  52360. areAllEffectsReady(): boolean;
  52361. /**
  52362. * @hidden
  52363. * Get the current error code of the webGL context
  52364. * @returns the error code
  52365. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52366. */
  52367. getError(): number;
  52368. /** @hidden */
  52369. _getUnpackAlignement(): number;
  52370. /** @hidden */
  52371. _unpackFlipY(value: boolean): void;
  52372. /**
  52373. * Update a dynamic index buffer
  52374. * @param indexBuffer defines the target index buffer
  52375. * @param indices defines the data to update
  52376. * @param offset defines the offset in the target index buffer where update should start
  52377. */
  52378. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52379. /**
  52380. * Updates a dynamic vertex buffer.
  52381. * @param vertexBuffer the vertex buffer to update
  52382. * @param vertices the data used to update the vertex buffer
  52383. * @param byteOffset the byte offset of the data (optional)
  52384. * @param byteLength the byte length of the data (optional)
  52385. */
  52386. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52387. /** @hidden */
  52388. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52389. /** @hidden */
  52390. _bindTexture(channel: number, texture: InternalTexture): void;
  52391. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52392. /**
  52393. * 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
  52394. */
  52395. releaseEffects(): void;
  52396. displayLoadingUI(): void;
  52397. hideLoadingUI(): void;
  52398. /** @hidden */
  52399. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52400. /** @hidden */
  52401. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52402. /** @hidden */
  52403. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52404. /** @hidden */
  52405. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52406. }
  52407. }
  52408. declare module "babylonjs/Instrumentation/timeToken" {
  52409. import { Nullable } from "babylonjs/types";
  52410. /**
  52411. * @hidden
  52412. **/
  52413. export class _TimeToken {
  52414. _startTimeQuery: Nullable<WebGLQuery>;
  52415. _endTimeQuery: Nullable<WebGLQuery>;
  52416. _timeElapsedQuery: Nullable<WebGLQuery>;
  52417. _timeElapsedQueryEnded: boolean;
  52418. }
  52419. }
  52420. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52421. import { Nullable, int } from "babylonjs/types";
  52422. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52423. /** @hidden */
  52424. export class _OcclusionDataStorage {
  52425. /** @hidden */
  52426. occlusionInternalRetryCounter: number;
  52427. /** @hidden */
  52428. isOcclusionQueryInProgress: boolean;
  52429. /** @hidden */
  52430. isOccluded: boolean;
  52431. /** @hidden */
  52432. occlusionRetryCount: number;
  52433. /** @hidden */
  52434. occlusionType: number;
  52435. /** @hidden */
  52436. occlusionQueryAlgorithmType: number;
  52437. }
  52438. module "babylonjs/Engines/engine" {
  52439. interface Engine {
  52440. /**
  52441. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52442. * @return the new query
  52443. */
  52444. createQuery(): WebGLQuery;
  52445. /**
  52446. * Delete and release a webGL query
  52447. * @param query defines the query to delete
  52448. * @return the current engine
  52449. */
  52450. deleteQuery(query: WebGLQuery): Engine;
  52451. /**
  52452. * Check if a given query has resolved and got its value
  52453. * @param query defines the query to check
  52454. * @returns true if the query got its value
  52455. */
  52456. isQueryResultAvailable(query: WebGLQuery): boolean;
  52457. /**
  52458. * Gets the value of a given query
  52459. * @param query defines the query to check
  52460. * @returns the value of the query
  52461. */
  52462. getQueryResult(query: WebGLQuery): number;
  52463. /**
  52464. * Initiates an occlusion query
  52465. * @param algorithmType defines the algorithm to use
  52466. * @param query defines the query to use
  52467. * @returns the current engine
  52468. * @see http://doc.babylonjs.com/features/occlusionquery
  52469. */
  52470. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52471. /**
  52472. * Ends an occlusion query
  52473. * @see http://doc.babylonjs.com/features/occlusionquery
  52474. * @param algorithmType defines the algorithm to use
  52475. * @returns the current engine
  52476. */
  52477. endOcclusionQuery(algorithmType: number): Engine;
  52478. /**
  52479. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52480. * Please note that only one query can be issued at a time
  52481. * @returns a time token used to track the time span
  52482. */
  52483. startTimeQuery(): Nullable<_TimeToken>;
  52484. /**
  52485. * Ends a time query
  52486. * @param token defines the token used to measure the time span
  52487. * @returns the time spent (in ns)
  52488. */
  52489. endTimeQuery(token: _TimeToken): int;
  52490. /** @hidden */
  52491. _currentNonTimestampToken: Nullable<_TimeToken>;
  52492. /** @hidden */
  52493. _createTimeQuery(): WebGLQuery;
  52494. /** @hidden */
  52495. _deleteTimeQuery(query: WebGLQuery): void;
  52496. /** @hidden */
  52497. _getGlAlgorithmType(algorithmType: number): number;
  52498. /** @hidden */
  52499. _getTimeQueryResult(query: WebGLQuery): any;
  52500. /** @hidden */
  52501. _getTimeQueryAvailability(query: WebGLQuery): any;
  52502. }
  52503. }
  52504. module "babylonjs/Meshes/abstractMesh" {
  52505. interface AbstractMesh {
  52506. /**
  52507. * Backing filed
  52508. * @hidden
  52509. */
  52510. __occlusionDataStorage: _OcclusionDataStorage;
  52511. /**
  52512. * Access property
  52513. * @hidden
  52514. */
  52515. _occlusionDataStorage: _OcclusionDataStorage;
  52516. /**
  52517. * 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.
  52518. * The default value is -1 which means don't break the query and wait till the result
  52519. * @see http://doc.babylonjs.com/features/occlusionquery
  52520. */
  52521. occlusionRetryCount: number;
  52522. /**
  52523. * 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:
  52524. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52525. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52526. * * 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.
  52527. * @see http://doc.babylonjs.com/features/occlusionquery
  52528. */
  52529. occlusionType: number;
  52530. /**
  52531. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52532. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52533. * * 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.
  52534. * @see http://doc.babylonjs.com/features/occlusionquery
  52535. */
  52536. occlusionQueryAlgorithmType: number;
  52537. /**
  52538. * 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
  52539. * @see http://doc.babylonjs.com/features/occlusionquery
  52540. */
  52541. isOccluded: boolean;
  52542. /**
  52543. * Flag to check the progress status of the query
  52544. * @see http://doc.babylonjs.com/features/occlusionquery
  52545. */
  52546. isOcclusionQueryInProgress: boolean;
  52547. }
  52548. }
  52549. }
  52550. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52551. import { Nullable } from "babylonjs/types";
  52552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52553. /** @hidden */
  52554. export var _forceTransformFeedbackToBundle: boolean;
  52555. module "babylonjs/Engines/engine" {
  52556. interface Engine {
  52557. /**
  52558. * Creates a webGL transform feedback object
  52559. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52560. * @returns the webGL transform feedback object
  52561. */
  52562. createTransformFeedback(): WebGLTransformFeedback;
  52563. /**
  52564. * Delete a webGL transform feedback object
  52565. * @param value defines the webGL transform feedback object to delete
  52566. */
  52567. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52568. /**
  52569. * Bind a webGL transform feedback object to the webgl context
  52570. * @param value defines the webGL transform feedback object to bind
  52571. */
  52572. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52573. /**
  52574. * Begins a transform feedback operation
  52575. * @param usePoints defines if points or triangles must be used
  52576. */
  52577. beginTransformFeedback(usePoints: boolean): void;
  52578. /**
  52579. * Ends a transform feedback operation
  52580. */
  52581. endTransformFeedback(): void;
  52582. /**
  52583. * Specify the varyings to use with transform feedback
  52584. * @param program defines the associated webGL program
  52585. * @param value defines the list of strings representing the varying names
  52586. */
  52587. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52588. /**
  52589. * Bind a webGL buffer for a transform feedback operation
  52590. * @param value defines the webGL buffer to bind
  52591. */
  52592. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52593. }
  52594. }
  52595. }
  52596. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52597. import { Scene } from "babylonjs/scene";
  52598. import { Engine } from "babylonjs/Engines/engine";
  52599. import { Texture } from "babylonjs/Materials/Textures/texture";
  52600. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52601. import "babylonjs/Engines/Extensions/engine.multiRender";
  52602. /**
  52603. * Creation options of the multi render target texture.
  52604. */
  52605. export interface IMultiRenderTargetOptions {
  52606. /**
  52607. * Define if the texture needs to create mip maps after render.
  52608. */
  52609. generateMipMaps?: boolean;
  52610. /**
  52611. * Define the types of all the draw buffers we want to create
  52612. */
  52613. types?: number[];
  52614. /**
  52615. * Define the sampling modes of all the draw buffers we want to create
  52616. */
  52617. samplingModes?: number[];
  52618. /**
  52619. * Define if a depth buffer is required
  52620. */
  52621. generateDepthBuffer?: boolean;
  52622. /**
  52623. * Define if a stencil buffer is required
  52624. */
  52625. generateStencilBuffer?: boolean;
  52626. /**
  52627. * Define if a depth texture is required instead of a depth buffer
  52628. */
  52629. generateDepthTexture?: boolean;
  52630. /**
  52631. * Define the number of desired draw buffers
  52632. */
  52633. textureCount?: number;
  52634. /**
  52635. * Define if aspect ratio should be adapted to the texture or stay the scene one
  52636. */
  52637. doNotChangeAspectRatio?: boolean;
  52638. /**
  52639. * Define the default type of the buffers we are creating
  52640. */
  52641. defaultType?: number;
  52642. }
  52643. /**
  52644. * A multi render target, like a render target provides the ability to render to a texture.
  52645. * Unlike the render target, it can render to several draw buffers in one draw.
  52646. * This is specially interesting in deferred rendering or for any effects requiring more than
  52647. * just one color from a single pass.
  52648. */
  52649. export class MultiRenderTarget extends RenderTargetTexture {
  52650. private _internalTextures;
  52651. private _textures;
  52652. private _multiRenderTargetOptions;
  52653. /**
  52654. * Get if draw buffers are currently supported by the used hardware and browser.
  52655. */
  52656. get isSupported(): boolean;
  52657. /**
  52658. * Get the list of textures generated by the multi render target.
  52659. */
  52660. get textures(): Texture[];
  52661. /**
  52662. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  52663. */
  52664. get depthTexture(): Texture;
  52665. /**
  52666. * Set the wrapping mode on U of all the textures we are rendering to.
  52667. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52668. */
  52669. set wrapU(wrap: number);
  52670. /**
  52671. * Set the wrapping mode on V of all the textures we are rendering to.
  52672. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52673. */
  52674. set wrapV(wrap: number);
  52675. /**
  52676. * Instantiate a new multi render target texture.
  52677. * A multi render target, like a render target provides the ability to render to a texture.
  52678. * Unlike the render target, it can render to several draw buffers in one draw.
  52679. * This is specially interesting in deferred rendering or for any effects requiring more than
  52680. * just one color from a single pass.
  52681. * @param name Define the name of the texture
  52682. * @param size Define the size of the buffers to render to
  52683. * @param count Define the number of target we are rendering into
  52684. * @param scene Define the scene the texture belongs to
  52685. * @param options Define the options used to create the multi render target
  52686. */
  52687. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  52688. /** @hidden */
  52689. _rebuild(): void;
  52690. private _createInternalTextures;
  52691. private _createTextures;
  52692. /**
  52693. * Define the number of samples used if MSAA is enabled.
  52694. */
  52695. get samples(): number;
  52696. set samples(value: number);
  52697. /**
  52698. * Resize all the textures in the multi render target.
  52699. * Be carrefull as it will recreate all the data in the new texture.
  52700. * @param size Define the new size
  52701. */
  52702. resize(size: any): void;
  52703. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  52704. /**
  52705. * Dispose the render targets and their associated resources
  52706. */
  52707. dispose(): void;
  52708. /**
  52709. * Release all the underlying texture used as draw buffers.
  52710. */
  52711. releaseInternalTextures(): void;
  52712. }
  52713. }
  52714. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  52715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52716. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  52717. import { Nullable } from "babylonjs/types";
  52718. module "babylonjs/Engines/thinEngine" {
  52719. interface ThinEngine {
  52720. /**
  52721. * Unbind a list of render target textures from the webGL context
  52722. * This is used only when drawBuffer extension or webGL2 are active
  52723. * @param textures defines the render target textures to unbind
  52724. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52725. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52726. */
  52727. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  52728. /**
  52729. * Create a multi render target texture
  52730. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  52731. * @param size defines the size of the texture
  52732. * @param options defines the creation options
  52733. * @returns the cube texture as an InternalTexture
  52734. */
  52735. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  52736. /**
  52737. * Update the sample count for a given multiple render target texture
  52738. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  52739. * @param textures defines the textures to update
  52740. * @param samples defines the sample count to set
  52741. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  52742. */
  52743. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  52744. }
  52745. }
  52746. }
  52747. declare module "babylonjs/Engines/Extensions/engine.views" {
  52748. import { Camera } from "babylonjs/Cameras/camera";
  52749. import { Nullable } from "babylonjs/types";
  52750. /**
  52751. * Class used to define an additional view for the engine
  52752. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52753. */
  52754. export class EngineView {
  52755. /** Defines the canvas where to render the view */
  52756. target: HTMLCanvasElement;
  52757. /** Defines an optional camera used to render the view (will use active camera else) */
  52758. camera?: Camera;
  52759. }
  52760. module "babylonjs/Engines/engine" {
  52761. interface Engine {
  52762. /**
  52763. * Gets or sets the HTML element to use for attaching events
  52764. */
  52765. inputElement: Nullable<HTMLElement>;
  52766. /**
  52767. * Gets the current engine view
  52768. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52769. */
  52770. activeView: Nullable<EngineView>;
  52771. /** Gets or sets the list of views */
  52772. views: EngineView[];
  52773. /**
  52774. * Register a new child canvas
  52775. * @param canvas defines the canvas to register
  52776. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52777. * @returns the associated view
  52778. */
  52779. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52780. /**
  52781. * Remove a registered child canvas
  52782. * @param canvas defines the canvas to remove
  52783. * @returns the current engine
  52784. */
  52785. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52786. }
  52787. }
  52788. }
  52789. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  52790. import { Nullable } from "babylonjs/types";
  52791. module "babylonjs/Engines/engine" {
  52792. interface Engine {
  52793. /** @hidden */
  52794. _excludedCompressedTextures: string[];
  52795. /** @hidden */
  52796. _textureFormatInUse: string;
  52797. /**
  52798. * Gets the list of texture formats supported
  52799. */
  52800. readonly texturesSupported: Array<string>;
  52801. /**
  52802. * Gets the texture format in use
  52803. */
  52804. readonly textureFormatInUse: Nullable<string>;
  52805. /**
  52806. * Set the compressed texture extensions or file names to skip.
  52807. *
  52808. * @param skippedFiles defines the list of those texture files you want to skip
  52809. * Example: [".dds", ".env", "myfile.png"]
  52810. */
  52811. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52812. /**
  52813. * Set the compressed texture format to use, based on the formats you have, and the formats
  52814. * supported by the hardware / browser.
  52815. *
  52816. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52817. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52818. * to API arguments needed to compressed textures. This puts the burden on the container
  52819. * generator to house the arcane code for determining these for current & future formats.
  52820. *
  52821. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52822. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52823. *
  52824. * Note: The result of this call is not taken into account when a texture is base64.
  52825. *
  52826. * @param formatsAvailable defines the list of those format families you have created
  52827. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52828. *
  52829. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52830. * @returns The extension selected.
  52831. */
  52832. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52833. }
  52834. }
  52835. }
  52836. declare module "babylonjs/Engines/Extensions/index" {
  52837. export * from "babylonjs/Engines/Extensions/engine.alpha";
  52838. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  52839. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  52840. export * from "babylonjs/Engines/Extensions/engine.multiview";
  52841. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  52842. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52843. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  52844. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  52845. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  52846. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  52847. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52848. export * from "babylonjs/Engines/Extensions/engine.webVR";
  52849. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  52850. export * from "babylonjs/Engines/Extensions/engine.views";
  52851. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  52852. import "babylonjs/Engines/Extensions/engine.textureSelector";
  52853. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  52854. }
  52855. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  52856. import { Nullable } from "babylonjs/types";
  52857. /**
  52858. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52859. */
  52860. export interface CubeMapInfo {
  52861. /**
  52862. * The pixel array for the front face.
  52863. * This is stored in format, left to right, up to down format.
  52864. */
  52865. front: Nullable<ArrayBufferView>;
  52866. /**
  52867. * The pixel array for the back face.
  52868. * This is stored in format, left to right, up to down format.
  52869. */
  52870. back: Nullable<ArrayBufferView>;
  52871. /**
  52872. * The pixel array for the left face.
  52873. * This is stored in format, left to right, up to down format.
  52874. */
  52875. left: Nullable<ArrayBufferView>;
  52876. /**
  52877. * The pixel array for the right face.
  52878. * This is stored in format, left to right, up to down format.
  52879. */
  52880. right: Nullable<ArrayBufferView>;
  52881. /**
  52882. * The pixel array for the up face.
  52883. * This is stored in format, left to right, up to down format.
  52884. */
  52885. up: Nullable<ArrayBufferView>;
  52886. /**
  52887. * The pixel array for the down face.
  52888. * This is stored in format, left to right, up to down format.
  52889. */
  52890. down: Nullable<ArrayBufferView>;
  52891. /**
  52892. * The size of the cubemap stored.
  52893. *
  52894. * Each faces will be size * size pixels.
  52895. */
  52896. size: number;
  52897. /**
  52898. * The format of the texture.
  52899. *
  52900. * RGBA, RGB.
  52901. */
  52902. format: number;
  52903. /**
  52904. * The type of the texture data.
  52905. *
  52906. * UNSIGNED_INT, FLOAT.
  52907. */
  52908. type: number;
  52909. /**
  52910. * Specifies whether the texture is in gamma space.
  52911. */
  52912. gammaSpace: boolean;
  52913. }
  52914. /**
  52915. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52916. */
  52917. export class PanoramaToCubeMapTools {
  52918. private static FACE_LEFT;
  52919. private static FACE_RIGHT;
  52920. private static FACE_FRONT;
  52921. private static FACE_BACK;
  52922. private static FACE_DOWN;
  52923. private static FACE_UP;
  52924. /**
  52925. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52926. *
  52927. * @param float32Array The source data.
  52928. * @param inputWidth The width of the input panorama.
  52929. * @param inputHeight The height of the input panorama.
  52930. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52931. * @return The cubemap data
  52932. */
  52933. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52934. private static CreateCubemapTexture;
  52935. private static CalcProjectionSpherical;
  52936. }
  52937. }
  52938. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  52939. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52941. import { Nullable } from "babylonjs/types";
  52942. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52943. /**
  52944. * Helper class dealing with the extraction of spherical polynomial dataArray
  52945. * from a cube map.
  52946. */
  52947. export class CubeMapToSphericalPolynomialTools {
  52948. private static FileFaces;
  52949. /**
  52950. * Converts a texture to the according Spherical Polynomial data.
  52951. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52952. *
  52953. * @param texture The texture to extract the information from.
  52954. * @return The Spherical Polynomial data.
  52955. */
  52956. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52957. /**
  52958. * Converts a cubemap to the according Spherical Polynomial data.
  52959. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52960. *
  52961. * @param cubeInfo The Cube map to extract the information from.
  52962. * @return The Spherical Polynomial data.
  52963. */
  52964. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52965. }
  52966. }
  52967. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  52968. import { Nullable } from "babylonjs/types";
  52969. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52970. module "babylonjs/Materials/Textures/baseTexture" {
  52971. interface BaseTexture {
  52972. /**
  52973. * Get the polynomial representation of the texture data.
  52974. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52975. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52976. */
  52977. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52978. }
  52979. }
  52980. }
  52981. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  52982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52983. /** @hidden */
  52984. export var rgbdEncodePixelShader: {
  52985. name: string;
  52986. shader: string;
  52987. };
  52988. }
  52989. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  52990. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52991. /** @hidden */
  52992. export var rgbdDecodePixelShader: {
  52993. name: string;
  52994. shader: string;
  52995. };
  52996. }
  52997. declare module "babylonjs/Misc/environmentTextureTools" {
  52998. import { Nullable } from "babylonjs/types";
  52999. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53000. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53002. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53003. import "babylonjs/Engines/Extensions/engine.readTexture";
  53004. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53005. import "babylonjs/Shaders/rgbdEncode.fragment";
  53006. import "babylonjs/Shaders/rgbdDecode.fragment";
  53007. /**
  53008. * Raw texture data and descriptor sufficient for WebGL texture upload
  53009. */
  53010. export interface EnvironmentTextureInfo {
  53011. /**
  53012. * Version of the environment map
  53013. */
  53014. version: number;
  53015. /**
  53016. * Width of image
  53017. */
  53018. width: number;
  53019. /**
  53020. * Irradiance information stored in the file.
  53021. */
  53022. irradiance: any;
  53023. /**
  53024. * Specular information stored in the file.
  53025. */
  53026. specular: any;
  53027. }
  53028. /**
  53029. * Defines One Image in the file. It requires only the position in the file
  53030. * as well as the length.
  53031. */
  53032. interface BufferImageData {
  53033. /**
  53034. * Length of the image data.
  53035. */
  53036. length: number;
  53037. /**
  53038. * Position of the data from the null terminator delimiting the end of the JSON.
  53039. */
  53040. position: number;
  53041. }
  53042. /**
  53043. * Defines the specular data enclosed in the file.
  53044. * This corresponds to the version 1 of the data.
  53045. */
  53046. export interface EnvironmentTextureSpecularInfoV1 {
  53047. /**
  53048. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53049. */
  53050. specularDataPosition?: number;
  53051. /**
  53052. * This contains all the images data needed to reconstruct the cubemap.
  53053. */
  53054. mipmaps: Array<BufferImageData>;
  53055. /**
  53056. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53057. */
  53058. lodGenerationScale: number;
  53059. }
  53060. /**
  53061. * Sets of helpers addressing the serialization and deserialization of environment texture
  53062. * stored in a BabylonJS env file.
  53063. * Those files are usually stored as .env files.
  53064. */
  53065. export class EnvironmentTextureTools {
  53066. /**
  53067. * Magic number identifying the env file.
  53068. */
  53069. private static _MagicBytes;
  53070. /**
  53071. * Gets the environment info from an env file.
  53072. * @param data The array buffer containing the .env bytes.
  53073. * @returns the environment file info (the json header) if successfully parsed.
  53074. */
  53075. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53076. /**
  53077. * Creates an environment texture from a loaded cube texture.
  53078. * @param texture defines the cube texture to convert in env file
  53079. * @return a promise containing the environment data if succesfull.
  53080. */
  53081. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53082. /**
  53083. * Creates a JSON representation of the spherical data.
  53084. * @param texture defines the texture containing the polynomials
  53085. * @return the JSON representation of the spherical info
  53086. */
  53087. private static _CreateEnvTextureIrradiance;
  53088. /**
  53089. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53090. * @param data the image data
  53091. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53092. * @return the views described by info providing access to the underlying buffer
  53093. */
  53094. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53095. /**
  53096. * Uploads the texture info contained in the env file to the GPU.
  53097. * @param texture defines the internal texture to upload to
  53098. * @param data defines the data to load
  53099. * @param info defines the texture info retrieved through the GetEnvInfo method
  53100. * @returns a promise
  53101. */
  53102. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53103. private static _OnImageReadyAsync;
  53104. /**
  53105. * Uploads the levels of image data to the GPU.
  53106. * @param texture defines the internal texture to upload to
  53107. * @param imageData defines the array buffer views of image data [mipmap][face]
  53108. * @returns a promise
  53109. */
  53110. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53111. /**
  53112. * Uploads spherical polynomials information to the texture.
  53113. * @param texture defines the texture we are trying to upload the information to
  53114. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53115. */
  53116. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53117. /** @hidden */
  53118. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53119. }
  53120. }
  53121. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53122. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53123. /** @hidden */
  53124. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53125. private _genericAttributeLocation;
  53126. private _varyingLocationCount;
  53127. private _varyingLocationMap;
  53128. private _replacements;
  53129. private _textureCount;
  53130. private _uniforms;
  53131. lineProcessor(line: string): string;
  53132. attributeProcessor(attribute: string): string;
  53133. varyingProcessor(varying: string, isFragment: boolean): string;
  53134. uniformProcessor(uniform: string): string;
  53135. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53136. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53137. }
  53138. }
  53139. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53140. /**
  53141. * Class used to inline functions in shader code
  53142. */
  53143. export class ShaderCodeInliner {
  53144. private static readonly _RegexpFindFunctionNameAndType;
  53145. private _sourceCode;
  53146. private _functionDescr;
  53147. private _numMaxIterations;
  53148. /** Gets or sets the token used to mark the functions to inline */
  53149. inlineToken: string;
  53150. /** Gets or sets the debug mode */
  53151. debug: boolean;
  53152. /** Gets the code after the inlining process */
  53153. get code(): string;
  53154. /**
  53155. * Initializes the inliner
  53156. * @param sourceCode shader code source to inline
  53157. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53158. */
  53159. constructor(sourceCode: string, numMaxIterations?: number);
  53160. /**
  53161. * Start the processing of the shader code
  53162. */
  53163. processCode(): void;
  53164. private _collectFunctions;
  53165. private _processInlining;
  53166. private _extractBetweenMarkers;
  53167. private _skipWhitespaces;
  53168. private _removeComments;
  53169. private _replaceFunctionCallsByCode;
  53170. private _findBackward;
  53171. private _escapeRegExp;
  53172. private _replaceNames;
  53173. }
  53174. }
  53175. declare module "babylonjs/Engines/nativeEngine" {
  53176. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53177. import { Engine } from "babylonjs/Engines/engine";
  53178. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53181. import { Effect } from "babylonjs/Materials/effect";
  53182. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53183. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53184. import { IColor4Like } from "babylonjs/Maths/math.like";
  53185. import { Scene } from "babylonjs/scene";
  53186. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53187. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53188. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53189. /**
  53190. * Container for accessors for natively-stored mesh data buffers.
  53191. */
  53192. class NativeDataBuffer extends DataBuffer {
  53193. /**
  53194. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53195. */
  53196. nativeIndexBuffer?: any;
  53197. /**
  53198. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53199. */
  53200. nativeVertexBuffer?: any;
  53201. }
  53202. /** @hidden */
  53203. class NativeTexture extends InternalTexture {
  53204. getInternalTexture(): InternalTexture;
  53205. getViewCount(): number;
  53206. }
  53207. /** @hidden */
  53208. export class NativeEngine extends Engine {
  53209. private readonly _native;
  53210. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53211. private readonly INVALID_HANDLE;
  53212. getHardwareScalingLevel(): number;
  53213. constructor();
  53214. dispose(): void;
  53215. /**
  53216. * Can be used to override the current requestAnimationFrame requester.
  53217. * @hidden
  53218. */
  53219. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53220. /**
  53221. * Override default engine behavior.
  53222. * @param color
  53223. * @param backBuffer
  53224. * @param depth
  53225. * @param stencil
  53226. */
  53227. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53228. /**
  53229. * Gets host document
  53230. * @returns the host document object
  53231. */
  53232. getHostDocument(): Nullable<Document>;
  53233. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53234. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53235. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53236. recordVertexArrayObject(vertexBuffers: {
  53237. [key: string]: VertexBuffer;
  53238. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53239. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53240. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53241. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53242. /**
  53243. * Draw a list of indexed primitives
  53244. * @param fillMode defines the primitive to use
  53245. * @param indexStart defines the starting index
  53246. * @param indexCount defines the number of index to draw
  53247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53248. */
  53249. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53250. /**
  53251. * Draw a list of unindexed primitives
  53252. * @param fillMode defines the primitive to use
  53253. * @param verticesStart defines the index of first vertex to draw
  53254. * @param verticesCount defines the count of vertices to draw
  53255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53256. */
  53257. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53258. createPipelineContext(): IPipelineContext;
  53259. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53260. /** @hidden */
  53261. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53262. /** @hidden */
  53263. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53264. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53265. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53266. protected _setProgram(program: WebGLProgram): void;
  53267. _releaseEffect(effect: Effect): void;
  53268. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53269. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53270. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53271. bindSamplers(effect: Effect): void;
  53272. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53273. getRenderWidth(useScreen?: boolean): number;
  53274. getRenderHeight(useScreen?: boolean): number;
  53275. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53276. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53277. /**
  53278. * Set the z offset to apply to current rendering
  53279. * @param value defines the offset to apply
  53280. */
  53281. setZOffset(value: number): void;
  53282. /**
  53283. * Gets the current value of the zOffset
  53284. * @returns the current zOffset state
  53285. */
  53286. getZOffset(): number;
  53287. /**
  53288. * Enable or disable depth buffering
  53289. * @param enable defines the state to set
  53290. */
  53291. setDepthBuffer(enable: boolean): void;
  53292. /**
  53293. * Gets a boolean indicating if depth writing is enabled
  53294. * @returns the current depth writing state
  53295. */
  53296. getDepthWrite(): boolean;
  53297. /**
  53298. * Enable or disable depth writing
  53299. * @param enable defines the state to set
  53300. */
  53301. setDepthWrite(enable: boolean): void;
  53302. /**
  53303. * Enable or disable color writing
  53304. * @param enable defines the state to set
  53305. */
  53306. setColorWrite(enable: boolean): void;
  53307. /**
  53308. * Gets a boolean indicating if color writing is enabled
  53309. * @returns the current color writing state
  53310. */
  53311. getColorWrite(): boolean;
  53312. /**
  53313. * Sets alpha constants used by some alpha blending modes
  53314. * @param r defines the red component
  53315. * @param g defines the green component
  53316. * @param b defines the blue component
  53317. * @param a defines the alpha component
  53318. */
  53319. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53320. /**
  53321. * Sets the current alpha mode
  53322. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53323. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53324. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53325. */
  53326. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53327. /**
  53328. * Gets the current alpha mode
  53329. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53330. * @returns the current alpha mode
  53331. */
  53332. getAlphaMode(): number;
  53333. setInt(uniform: WebGLUniformLocation, int: number): void;
  53334. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53335. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53336. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53337. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53338. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53339. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53340. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53341. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53342. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53343. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53344. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53345. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53346. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53347. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53348. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53349. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53350. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53351. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53352. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53353. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53354. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53355. wipeCaches(bruteForce?: boolean): void;
  53356. _createTexture(): WebGLTexture;
  53357. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53358. /**
  53359. * Usually called from Texture.ts.
  53360. * Passed information to create a WebGLTexture
  53361. * @param url defines a value which contains one of the following:
  53362. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53363. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53364. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53365. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53366. * @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)
  53367. * @param scene needed for loading to the correct scene
  53368. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53369. * @param onLoad optional callback to be called upon successful completion
  53370. * @param onError optional callback to be called upon failure
  53371. * @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
  53372. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53373. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53374. * @param forcedExtension defines the extension to use to pick the right loader
  53375. * @param mimeType defines an optional mime type
  53376. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53377. */
  53378. 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;
  53379. /**
  53380. * Creates a cube texture
  53381. * @param rootUrl defines the url where the files to load is located
  53382. * @param scene defines the current scene
  53383. * @param files defines the list of files to load (1 per face)
  53384. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53385. * @param onLoad defines an optional callback raised when the texture is loaded
  53386. * @param onError defines an optional callback raised if there is an issue to load the texture
  53387. * @param format defines the format of the data
  53388. * @param forcedExtension defines the extension to use to pick the right loader
  53389. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53390. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53391. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53392. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53393. * @returns the cube texture as an InternalTexture
  53394. */
  53395. 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;
  53396. private _getSamplingFilter;
  53397. private static _GetNativeTextureFormat;
  53398. createRenderTargetTexture(size: number | {
  53399. width: number;
  53400. height: number;
  53401. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53402. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53403. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53404. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53405. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53406. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53407. /**
  53408. * Updates a dynamic vertex buffer.
  53409. * @param vertexBuffer the vertex buffer to update
  53410. * @param data the data used to update the vertex buffer
  53411. * @param byteOffset the byte offset of the data (optional)
  53412. * @param byteLength the byte length of the data (optional)
  53413. */
  53414. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53415. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53416. private _updateAnisotropicLevel;
  53417. private _getAddressMode;
  53418. /** @hidden */
  53419. _bindTexture(channel: number, texture: InternalTexture): void;
  53420. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53421. releaseEffects(): void;
  53422. /** @hidden */
  53423. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53424. /** @hidden */
  53425. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53426. /** @hidden */
  53427. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53428. /** @hidden */
  53429. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53430. }
  53431. }
  53432. declare module "babylonjs/Engines/index" {
  53433. export * from "babylonjs/Engines/constants";
  53434. export * from "babylonjs/Engines/engineCapabilities";
  53435. export * from "babylonjs/Engines/instancingAttributeInfo";
  53436. export * from "babylonjs/Engines/thinEngine";
  53437. export * from "babylonjs/Engines/engine";
  53438. export * from "babylonjs/Engines/engineStore";
  53439. export * from "babylonjs/Engines/nullEngine";
  53440. export * from "babylonjs/Engines/Extensions/index";
  53441. export * from "babylonjs/Engines/IPipelineContext";
  53442. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53443. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53444. export * from "babylonjs/Engines/nativeEngine";
  53445. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53446. }
  53447. declare module "babylonjs/Events/clipboardEvents" {
  53448. /**
  53449. * Gather the list of clipboard event types as constants.
  53450. */
  53451. export class ClipboardEventTypes {
  53452. /**
  53453. * The clipboard event is fired when a copy command is active (pressed).
  53454. */
  53455. static readonly COPY: number;
  53456. /**
  53457. * The clipboard event is fired when a cut command is active (pressed).
  53458. */
  53459. static readonly CUT: number;
  53460. /**
  53461. * The clipboard event is fired when a paste command is active (pressed).
  53462. */
  53463. static readonly PASTE: number;
  53464. }
  53465. /**
  53466. * This class is used to store clipboard related info for the onClipboardObservable event.
  53467. */
  53468. export class ClipboardInfo {
  53469. /**
  53470. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53471. */
  53472. type: number;
  53473. /**
  53474. * Defines the related dom event
  53475. */
  53476. event: ClipboardEvent;
  53477. /**
  53478. *Creates an instance of ClipboardInfo.
  53479. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53480. * @param event Defines the related dom event
  53481. */
  53482. constructor(
  53483. /**
  53484. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53485. */
  53486. type: number,
  53487. /**
  53488. * Defines the related dom event
  53489. */
  53490. event: ClipboardEvent);
  53491. /**
  53492. * Get the clipboard event's type from the keycode.
  53493. * @param keyCode Defines the keyCode for the current keyboard event.
  53494. * @return {number}
  53495. */
  53496. static GetTypeFromCharacter(keyCode: number): number;
  53497. }
  53498. }
  53499. declare module "babylonjs/Events/index" {
  53500. export * from "babylonjs/Events/keyboardEvents";
  53501. export * from "babylonjs/Events/pointerEvents";
  53502. export * from "babylonjs/Events/clipboardEvents";
  53503. }
  53504. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53505. import { Scene } from "babylonjs/scene";
  53506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53507. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53508. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53509. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53510. /**
  53511. * Google Daydream controller
  53512. */
  53513. export class DaydreamController extends WebVRController {
  53514. /**
  53515. * Base Url for the controller model.
  53516. */
  53517. static MODEL_BASE_URL: string;
  53518. /**
  53519. * File name for the controller model.
  53520. */
  53521. static MODEL_FILENAME: string;
  53522. /**
  53523. * Gamepad Id prefix used to identify Daydream Controller.
  53524. */
  53525. static readonly GAMEPAD_ID_PREFIX: string;
  53526. /**
  53527. * Creates a new DaydreamController from a gamepad
  53528. * @param vrGamepad the gamepad that the controller should be created from
  53529. */
  53530. constructor(vrGamepad: any);
  53531. /**
  53532. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53533. * @param scene scene in which to add meshes
  53534. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53535. */
  53536. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53537. /**
  53538. * Called once for each button that changed state since the last frame
  53539. * @param buttonIdx Which button index changed
  53540. * @param state New state of the button
  53541. * @param changes Which properties on the state changed since last frame
  53542. */
  53543. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53544. }
  53545. }
  53546. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53547. import { Scene } from "babylonjs/scene";
  53548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53549. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53550. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53551. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53552. /**
  53553. * Gear VR Controller
  53554. */
  53555. export class GearVRController extends WebVRController {
  53556. /**
  53557. * Base Url for the controller model.
  53558. */
  53559. static MODEL_BASE_URL: string;
  53560. /**
  53561. * File name for the controller model.
  53562. */
  53563. static MODEL_FILENAME: string;
  53564. /**
  53565. * Gamepad Id prefix used to identify this controller.
  53566. */
  53567. static readonly GAMEPAD_ID_PREFIX: string;
  53568. private readonly _buttonIndexToObservableNameMap;
  53569. /**
  53570. * Creates a new GearVRController from a gamepad
  53571. * @param vrGamepad the gamepad that the controller should be created from
  53572. */
  53573. constructor(vrGamepad: any);
  53574. /**
  53575. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53576. * @param scene scene in which to add meshes
  53577. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53578. */
  53579. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53580. /**
  53581. * Called once for each button that changed state since the last frame
  53582. * @param buttonIdx Which button index changed
  53583. * @param state New state of the button
  53584. * @param changes Which properties on the state changed since last frame
  53585. */
  53586. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53587. }
  53588. }
  53589. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53590. import { Scene } from "babylonjs/scene";
  53591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53592. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53593. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53594. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53595. /**
  53596. * Generic Controller
  53597. */
  53598. export class GenericController extends WebVRController {
  53599. /**
  53600. * Base Url for the controller model.
  53601. */
  53602. static readonly MODEL_BASE_URL: string;
  53603. /**
  53604. * File name for the controller model.
  53605. */
  53606. static readonly MODEL_FILENAME: string;
  53607. /**
  53608. * Creates a new GenericController from a gamepad
  53609. * @param vrGamepad the gamepad that the controller should be created from
  53610. */
  53611. constructor(vrGamepad: any);
  53612. /**
  53613. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53614. * @param scene scene in which to add meshes
  53615. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53616. */
  53617. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53618. /**
  53619. * Called once for each button that changed state since the last frame
  53620. * @param buttonIdx Which button index changed
  53621. * @param state New state of the button
  53622. * @param changes Which properties on the state changed since last frame
  53623. */
  53624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53625. }
  53626. }
  53627. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  53628. import { Observable } from "babylonjs/Misc/observable";
  53629. import { Scene } from "babylonjs/scene";
  53630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53631. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53632. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53633. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53634. /**
  53635. * Oculus Touch Controller
  53636. */
  53637. export class OculusTouchController extends WebVRController {
  53638. /**
  53639. * Base Url for the controller model.
  53640. */
  53641. static MODEL_BASE_URL: string;
  53642. /**
  53643. * File name for the left controller model.
  53644. */
  53645. static MODEL_LEFT_FILENAME: string;
  53646. /**
  53647. * File name for the right controller model.
  53648. */
  53649. static MODEL_RIGHT_FILENAME: string;
  53650. /**
  53651. * Base Url for the Quest controller model.
  53652. */
  53653. static QUEST_MODEL_BASE_URL: string;
  53654. /**
  53655. * @hidden
  53656. * If the controllers are running on a device that needs the updated Quest controller models
  53657. */
  53658. static _IsQuest: boolean;
  53659. /**
  53660. * Fired when the secondary trigger on this controller is modified
  53661. */
  53662. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53663. /**
  53664. * Fired when the thumb rest on this controller is modified
  53665. */
  53666. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53667. /**
  53668. * Creates a new OculusTouchController from a gamepad
  53669. * @param vrGamepad the gamepad that the controller should be created from
  53670. */
  53671. constructor(vrGamepad: any);
  53672. /**
  53673. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53674. * @param scene scene in which to add meshes
  53675. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53676. */
  53677. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53678. /**
  53679. * Fired when the A button on this controller is modified
  53680. */
  53681. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53682. /**
  53683. * Fired when the B button on this controller is modified
  53684. */
  53685. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53686. /**
  53687. * Fired when the X button on this controller is modified
  53688. */
  53689. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53690. /**
  53691. * Fired when the Y button on this controller is modified
  53692. */
  53693. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53694. /**
  53695. * Called once for each button that changed state since the last frame
  53696. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53697. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53698. * 2) secondary trigger (same)
  53699. * 3) A (right) X (left), touch, pressed = value
  53700. * 4) B / Y
  53701. * 5) thumb rest
  53702. * @param buttonIdx Which button index changed
  53703. * @param state New state of the button
  53704. * @param changes Which properties on the state changed since last frame
  53705. */
  53706. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53707. }
  53708. }
  53709. declare module "babylonjs/Gamepads/Controllers/viveController" {
  53710. import { Scene } from "babylonjs/scene";
  53711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53712. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53713. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53714. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53715. import { Observable } from "babylonjs/Misc/observable";
  53716. /**
  53717. * Vive Controller
  53718. */
  53719. export class ViveController extends WebVRController {
  53720. /**
  53721. * Base Url for the controller model.
  53722. */
  53723. static MODEL_BASE_URL: string;
  53724. /**
  53725. * File name for the controller model.
  53726. */
  53727. static MODEL_FILENAME: string;
  53728. /**
  53729. * Creates a new ViveController from a gamepad
  53730. * @param vrGamepad the gamepad that the controller should be created from
  53731. */
  53732. constructor(vrGamepad: any);
  53733. /**
  53734. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53735. * @param scene scene in which to add meshes
  53736. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53737. */
  53738. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53739. /**
  53740. * Fired when the left button on this controller is modified
  53741. */
  53742. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53743. /**
  53744. * Fired when the right button on this controller is modified
  53745. */
  53746. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53747. /**
  53748. * Fired when the menu button on this controller is modified
  53749. */
  53750. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53751. /**
  53752. * Called once for each button that changed state since the last frame
  53753. * Vive mapping:
  53754. * 0: touchpad
  53755. * 1: trigger
  53756. * 2: left AND right buttons
  53757. * 3: menu button
  53758. * @param buttonIdx Which button index changed
  53759. * @param state New state of the button
  53760. * @param changes Which properties on the state changed since last frame
  53761. */
  53762. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53763. }
  53764. }
  53765. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  53766. import { Observable } from "babylonjs/Misc/observable";
  53767. import { Scene } from "babylonjs/scene";
  53768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53769. import { Ray } from "babylonjs/Culling/ray";
  53770. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53771. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53772. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53773. /**
  53774. * Defines the WindowsMotionController object that the state of the windows motion controller
  53775. */
  53776. export class WindowsMotionController extends WebVRController {
  53777. /**
  53778. * The base url used to load the left and right controller models
  53779. */
  53780. static MODEL_BASE_URL: string;
  53781. /**
  53782. * The name of the left controller model file
  53783. */
  53784. static MODEL_LEFT_FILENAME: string;
  53785. /**
  53786. * The name of the right controller model file
  53787. */
  53788. static MODEL_RIGHT_FILENAME: string;
  53789. /**
  53790. * The controller name prefix for this controller type
  53791. */
  53792. static readonly GAMEPAD_ID_PREFIX: string;
  53793. /**
  53794. * The controller id pattern for this controller type
  53795. */
  53796. private static readonly GAMEPAD_ID_PATTERN;
  53797. private _loadedMeshInfo;
  53798. protected readonly _mapping: {
  53799. buttons: string[];
  53800. buttonMeshNames: {
  53801. trigger: string;
  53802. menu: string;
  53803. grip: string;
  53804. thumbstick: string;
  53805. trackpad: string;
  53806. };
  53807. buttonObservableNames: {
  53808. trigger: string;
  53809. menu: string;
  53810. grip: string;
  53811. thumbstick: string;
  53812. trackpad: string;
  53813. };
  53814. axisMeshNames: string[];
  53815. pointingPoseMeshName: string;
  53816. };
  53817. /**
  53818. * Fired when the trackpad on this controller is clicked
  53819. */
  53820. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53821. /**
  53822. * Fired when the trackpad on this controller is modified
  53823. */
  53824. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53825. /**
  53826. * The current x and y values of this controller's trackpad
  53827. */
  53828. trackpad: StickValues;
  53829. /**
  53830. * Creates a new WindowsMotionController from a gamepad
  53831. * @param vrGamepad the gamepad that the controller should be created from
  53832. */
  53833. constructor(vrGamepad: any);
  53834. /**
  53835. * Fired when the trigger on this controller is modified
  53836. */
  53837. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53838. /**
  53839. * Fired when the menu button on this controller is modified
  53840. */
  53841. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53842. /**
  53843. * Fired when the grip button on this controller is modified
  53844. */
  53845. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53846. /**
  53847. * Fired when the thumbstick button on this controller is modified
  53848. */
  53849. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53850. /**
  53851. * Fired when the touchpad button on this controller is modified
  53852. */
  53853. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53854. /**
  53855. * Fired when the touchpad values on this controller are modified
  53856. */
  53857. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53858. protected _updateTrackpad(): void;
  53859. /**
  53860. * Called once per frame by the engine.
  53861. */
  53862. update(): void;
  53863. /**
  53864. * Called once for each button that changed state since the last frame
  53865. * @param buttonIdx Which button index changed
  53866. * @param state New state of the button
  53867. * @param changes Which properties on the state changed since last frame
  53868. */
  53869. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53870. /**
  53871. * Moves the buttons on the controller mesh based on their current state
  53872. * @param buttonName the name of the button to move
  53873. * @param buttonValue the value of the button which determines the buttons new position
  53874. */
  53875. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53876. /**
  53877. * Moves the axis on the controller mesh based on its current state
  53878. * @param axis the index of the axis
  53879. * @param axisValue the value of the axis which determines the meshes new position
  53880. * @hidden
  53881. */
  53882. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53883. /**
  53884. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53885. * @param scene scene in which to add meshes
  53886. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53887. */
  53888. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53889. /**
  53890. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53891. * can be transformed by button presses and axes values, based on this._mapping.
  53892. *
  53893. * @param scene scene in which the meshes exist
  53894. * @param meshes list of meshes that make up the controller model to process
  53895. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53896. */
  53897. private processModel;
  53898. private createMeshInfo;
  53899. /**
  53900. * Gets the ray of the controller in the direction the controller is pointing
  53901. * @param length the length the resulting ray should be
  53902. * @returns a ray in the direction the controller is pointing
  53903. */
  53904. getForwardRay(length?: number): Ray;
  53905. /**
  53906. * Disposes of the controller
  53907. */
  53908. dispose(): void;
  53909. }
  53910. /**
  53911. * This class represents a new windows motion controller in XR.
  53912. */
  53913. export class XRWindowsMotionController extends WindowsMotionController {
  53914. /**
  53915. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53916. */
  53917. protected readonly _mapping: {
  53918. buttons: string[];
  53919. buttonMeshNames: {
  53920. trigger: string;
  53921. menu: string;
  53922. grip: string;
  53923. thumbstick: string;
  53924. trackpad: string;
  53925. };
  53926. buttonObservableNames: {
  53927. trigger: string;
  53928. menu: string;
  53929. grip: string;
  53930. thumbstick: string;
  53931. trackpad: string;
  53932. };
  53933. axisMeshNames: string[];
  53934. pointingPoseMeshName: string;
  53935. };
  53936. /**
  53937. * Construct a new XR-Based windows motion controller
  53938. *
  53939. * @param gamepadInfo the gamepad object from the browser
  53940. */
  53941. constructor(gamepadInfo: any);
  53942. /**
  53943. * holds the thumbstick values (X,Y)
  53944. */
  53945. thumbstickValues: StickValues;
  53946. /**
  53947. * Fired when the thumbstick on this controller is clicked
  53948. */
  53949. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53950. /**
  53951. * Fired when the thumbstick on this controller is modified
  53952. */
  53953. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53954. /**
  53955. * Fired when the touchpad button on this controller is modified
  53956. */
  53957. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53958. /**
  53959. * Fired when the touchpad values on this controller are modified
  53960. */
  53961. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53962. /**
  53963. * Fired when the thumbstick button on this controller is modified
  53964. * here to prevent breaking changes
  53965. */
  53966. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53967. /**
  53968. * updating the thumbstick(!) and not the trackpad.
  53969. * This is named this way due to the difference between WebVR and XR and to avoid
  53970. * changing the parent class.
  53971. */
  53972. protected _updateTrackpad(): void;
  53973. /**
  53974. * Disposes the class with joy
  53975. */
  53976. dispose(): void;
  53977. }
  53978. }
  53979. declare module "babylonjs/Gamepads/Controllers/index" {
  53980. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  53981. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  53982. export * from "babylonjs/Gamepads/Controllers/genericController";
  53983. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  53984. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53985. export * from "babylonjs/Gamepads/Controllers/viveController";
  53986. export * from "babylonjs/Gamepads/Controllers/webVRController";
  53987. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  53988. }
  53989. declare module "babylonjs/Gamepads/index" {
  53990. export * from "babylonjs/Gamepads/Controllers/index";
  53991. export * from "babylonjs/Gamepads/gamepad";
  53992. export * from "babylonjs/Gamepads/gamepadManager";
  53993. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  53994. export * from "babylonjs/Gamepads/xboxGamepad";
  53995. export * from "babylonjs/Gamepads/dualShockGamepad";
  53996. }
  53997. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  53998. import { Scene } from "babylonjs/scene";
  53999. import { Vector4 } from "babylonjs/Maths/math.vector";
  54000. import { Color4 } from "babylonjs/Maths/math.color";
  54001. import { Mesh } from "babylonjs/Meshes/mesh";
  54002. import { Nullable } from "babylonjs/types";
  54003. /**
  54004. * Class containing static functions to help procedurally build meshes
  54005. */
  54006. export class PolyhedronBuilder {
  54007. /**
  54008. * Creates a polyhedron mesh
  54009. * * 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
  54010. * * The parameter `size` (positive float, default 1) sets the polygon size
  54011. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54012. * * 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`
  54013. * * 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
  54014. * * 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)`)
  54015. * * 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
  54016. * * 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
  54017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54020. * @param name defines the name of the mesh
  54021. * @param options defines the options used to create the mesh
  54022. * @param scene defines the hosting scene
  54023. * @returns the polyhedron mesh
  54024. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54025. */
  54026. static CreatePolyhedron(name: string, options: {
  54027. type?: number;
  54028. size?: number;
  54029. sizeX?: number;
  54030. sizeY?: number;
  54031. sizeZ?: number;
  54032. custom?: any;
  54033. faceUV?: Vector4[];
  54034. faceColors?: Color4[];
  54035. flat?: boolean;
  54036. updatable?: boolean;
  54037. sideOrientation?: number;
  54038. frontUVs?: Vector4;
  54039. backUVs?: Vector4;
  54040. }, scene?: Nullable<Scene>): Mesh;
  54041. }
  54042. }
  54043. declare module "babylonjs/Gizmos/scaleGizmo" {
  54044. import { Observable } from "babylonjs/Misc/observable";
  54045. import { Nullable } from "babylonjs/types";
  54046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54047. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54048. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54049. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54050. /**
  54051. * Gizmo that enables scaling a mesh along 3 axis
  54052. */
  54053. export class ScaleGizmo extends Gizmo {
  54054. /**
  54055. * Internal gizmo used for interactions on the x axis
  54056. */
  54057. xGizmo: AxisScaleGizmo;
  54058. /**
  54059. * Internal gizmo used for interactions on the y axis
  54060. */
  54061. yGizmo: AxisScaleGizmo;
  54062. /**
  54063. * Internal gizmo used for interactions on the z axis
  54064. */
  54065. zGizmo: AxisScaleGizmo;
  54066. /**
  54067. * Internal gizmo used to scale all axis equally
  54068. */
  54069. uniformScaleGizmo: AxisScaleGizmo;
  54070. private _meshAttached;
  54071. private _updateGizmoRotationToMatchAttachedMesh;
  54072. private _snapDistance;
  54073. private _scaleRatio;
  54074. private _uniformScalingMesh;
  54075. private _octahedron;
  54076. private _sensitivity;
  54077. /** Fires an event when any of it's sub gizmos are dragged */
  54078. onDragStartObservable: Observable<unknown>;
  54079. /** Fires an event when any of it's sub gizmos are released from dragging */
  54080. onDragEndObservable: Observable<unknown>;
  54081. get attachedMesh(): Nullable<AbstractMesh>;
  54082. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54083. /**
  54084. * Creates a ScaleGizmo
  54085. * @param gizmoLayer The utility layer the gizmo will be added to
  54086. */
  54087. constructor(gizmoLayer?: UtilityLayerRenderer);
  54088. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54089. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54090. /**
  54091. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54092. */
  54093. set snapDistance(value: number);
  54094. get snapDistance(): number;
  54095. /**
  54096. * Ratio for the scale of the gizmo (Default: 1)
  54097. */
  54098. set scaleRatio(value: number);
  54099. get scaleRatio(): number;
  54100. /**
  54101. * Sensitivity factor for dragging (Default: 1)
  54102. */
  54103. set sensitivity(value: number);
  54104. get sensitivity(): number;
  54105. /**
  54106. * Disposes of the gizmo
  54107. */
  54108. dispose(): void;
  54109. }
  54110. }
  54111. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54112. import { Observable } from "babylonjs/Misc/observable";
  54113. import { Nullable } from "babylonjs/types";
  54114. import { Vector3 } from "babylonjs/Maths/math.vector";
  54115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54116. import { Mesh } from "babylonjs/Meshes/mesh";
  54117. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54118. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54119. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54120. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54121. import { Color3 } from "babylonjs/Maths/math.color";
  54122. /**
  54123. * Single axis scale gizmo
  54124. */
  54125. export class AxisScaleGizmo extends Gizmo {
  54126. /**
  54127. * Drag behavior responsible for the gizmos dragging interactions
  54128. */
  54129. dragBehavior: PointerDragBehavior;
  54130. private _pointerObserver;
  54131. /**
  54132. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54133. */
  54134. snapDistance: number;
  54135. /**
  54136. * Event that fires each time the gizmo snaps to a new location.
  54137. * * snapDistance is the the change in distance
  54138. */
  54139. onSnapObservable: Observable<{
  54140. snapDistance: number;
  54141. }>;
  54142. /**
  54143. * If the scaling operation should be done on all axis (default: false)
  54144. */
  54145. uniformScaling: boolean;
  54146. /**
  54147. * Custom sensitivity value for the drag strength
  54148. */
  54149. sensitivity: number;
  54150. private _isEnabled;
  54151. private _parent;
  54152. private _arrow;
  54153. private _coloredMaterial;
  54154. private _hoverMaterial;
  54155. /**
  54156. * Creates an AxisScaleGizmo
  54157. * @param gizmoLayer The utility layer the gizmo will be added to
  54158. * @param dragAxis The axis which the gizmo will be able to scale on
  54159. * @param color The color of the gizmo
  54160. */
  54161. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54163. /**
  54164. * If the gizmo is enabled
  54165. */
  54166. set isEnabled(value: boolean);
  54167. get isEnabled(): boolean;
  54168. /**
  54169. * Disposes of the gizmo
  54170. */
  54171. dispose(): void;
  54172. /**
  54173. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54174. * @param mesh The mesh to replace the default mesh of the gizmo
  54175. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54176. */
  54177. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54178. }
  54179. }
  54180. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54181. import { Observable } from "babylonjs/Misc/observable";
  54182. import { Nullable } from "babylonjs/types";
  54183. import { Vector3 } from "babylonjs/Maths/math.vector";
  54184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54185. import { Mesh } from "babylonjs/Meshes/mesh";
  54186. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54187. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54188. import { Color3 } from "babylonjs/Maths/math.color";
  54189. import "babylonjs/Meshes/Builders/boxBuilder";
  54190. /**
  54191. * Bounding box gizmo
  54192. */
  54193. export class BoundingBoxGizmo extends Gizmo {
  54194. private _lineBoundingBox;
  54195. private _rotateSpheresParent;
  54196. private _scaleBoxesParent;
  54197. private _boundingDimensions;
  54198. private _renderObserver;
  54199. private _pointerObserver;
  54200. private _scaleDragSpeed;
  54201. private _tmpQuaternion;
  54202. private _tmpVector;
  54203. private _tmpRotationMatrix;
  54204. /**
  54205. * 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)
  54206. */
  54207. ignoreChildren: boolean;
  54208. /**
  54209. * 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)
  54210. */
  54211. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54212. /**
  54213. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54214. */
  54215. rotationSphereSize: number;
  54216. /**
  54217. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54218. */
  54219. scaleBoxSize: number;
  54220. /**
  54221. * 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)
  54222. */
  54223. fixedDragMeshScreenSize: boolean;
  54224. /**
  54225. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54226. */
  54227. fixedDragMeshScreenSizeDistanceFactor: number;
  54228. /**
  54229. * Fired when a rotation sphere or scale box is dragged
  54230. */
  54231. onDragStartObservable: Observable<{}>;
  54232. /**
  54233. * Fired when a scale box is dragged
  54234. */
  54235. onScaleBoxDragObservable: Observable<{}>;
  54236. /**
  54237. * Fired when a scale box drag is ended
  54238. */
  54239. onScaleBoxDragEndObservable: Observable<{}>;
  54240. /**
  54241. * Fired when a rotation sphere is dragged
  54242. */
  54243. onRotationSphereDragObservable: Observable<{}>;
  54244. /**
  54245. * Fired when a rotation sphere drag is ended
  54246. */
  54247. onRotationSphereDragEndObservable: Observable<{}>;
  54248. /**
  54249. * 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)
  54250. */
  54251. scalePivot: Nullable<Vector3>;
  54252. /**
  54253. * Mesh used as a pivot to rotate the attached mesh
  54254. */
  54255. private _anchorMesh;
  54256. private _existingMeshScale;
  54257. private _dragMesh;
  54258. private pointerDragBehavior;
  54259. private coloredMaterial;
  54260. private hoverColoredMaterial;
  54261. /**
  54262. * Sets the color of the bounding box gizmo
  54263. * @param color the color to set
  54264. */
  54265. setColor(color: Color3): void;
  54266. /**
  54267. * Creates an BoundingBoxGizmo
  54268. * @param gizmoLayer The utility layer the gizmo will be added to
  54269. * @param color The color of the gizmo
  54270. */
  54271. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54272. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54273. private _selectNode;
  54274. /**
  54275. * Updates the bounding box information for the Gizmo
  54276. */
  54277. updateBoundingBox(): void;
  54278. private _updateRotationSpheres;
  54279. private _updateScaleBoxes;
  54280. /**
  54281. * Enables rotation on the specified axis and disables rotation on the others
  54282. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54283. */
  54284. setEnabledRotationAxis(axis: string): void;
  54285. /**
  54286. * Enables/disables scaling
  54287. * @param enable if scaling should be enabled
  54288. * @param homogeneousScaling defines if scaling should only be homogeneous
  54289. */
  54290. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54291. private _updateDummy;
  54292. /**
  54293. * Enables a pointer drag behavior on the bounding box of the gizmo
  54294. */
  54295. enableDragBehavior(): void;
  54296. /**
  54297. * Disposes of the gizmo
  54298. */
  54299. dispose(): void;
  54300. /**
  54301. * 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)
  54302. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54303. * @returns the bounding box mesh with the passed in mesh as a child
  54304. */
  54305. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54306. /**
  54307. * CustomMeshes are not supported by this gizmo
  54308. * @param mesh The mesh to replace the default mesh of the gizmo
  54309. */
  54310. setCustomMesh(mesh: Mesh): void;
  54311. }
  54312. }
  54313. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54314. import { Observable } from "babylonjs/Misc/observable";
  54315. import { Nullable } from "babylonjs/types";
  54316. import { Vector3 } from "babylonjs/Maths/math.vector";
  54317. import { Color3 } from "babylonjs/Maths/math.color";
  54318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54319. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54321. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54322. import "babylonjs/Meshes/Builders/linesBuilder";
  54323. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54324. /**
  54325. * Single plane rotation gizmo
  54326. */
  54327. export class PlaneRotationGizmo extends Gizmo {
  54328. /**
  54329. * Drag behavior responsible for the gizmos dragging interactions
  54330. */
  54331. dragBehavior: PointerDragBehavior;
  54332. private _pointerObserver;
  54333. /**
  54334. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54335. */
  54336. snapDistance: number;
  54337. /**
  54338. * Event that fires each time the gizmo snaps to a new location.
  54339. * * snapDistance is the the change in distance
  54340. */
  54341. onSnapObservable: Observable<{
  54342. snapDistance: number;
  54343. }>;
  54344. private _isEnabled;
  54345. private _parent;
  54346. /**
  54347. * Creates a PlaneRotationGizmo
  54348. * @param gizmoLayer The utility layer the gizmo will be added to
  54349. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54350. * @param color The color of the gizmo
  54351. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54352. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54353. */
  54354. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54355. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54356. /**
  54357. * If the gizmo is enabled
  54358. */
  54359. set isEnabled(value: boolean);
  54360. get isEnabled(): boolean;
  54361. /**
  54362. * Disposes of the gizmo
  54363. */
  54364. dispose(): void;
  54365. }
  54366. }
  54367. declare module "babylonjs/Gizmos/rotationGizmo" {
  54368. import { Observable } from "babylonjs/Misc/observable";
  54369. import { Nullable } from "babylonjs/types";
  54370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54371. import { Mesh } from "babylonjs/Meshes/mesh";
  54372. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54373. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54374. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54375. /**
  54376. * Gizmo that enables rotating a mesh along 3 axis
  54377. */
  54378. export class RotationGizmo extends Gizmo {
  54379. /**
  54380. * Internal gizmo used for interactions on the x axis
  54381. */
  54382. xGizmo: PlaneRotationGizmo;
  54383. /**
  54384. * Internal gizmo used for interactions on the y axis
  54385. */
  54386. yGizmo: PlaneRotationGizmo;
  54387. /**
  54388. * Internal gizmo used for interactions on the z axis
  54389. */
  54390. zGizmo: PlaneRotationGizmo;
  54391. /** Fires an event when any of it's sub gizmos are dragged */
  54392. onDragStartObservable: Observable<unknown>;
  54393. /** Fires an event when any of it's sub gizmos are released from dragging */
  54394. onDragEndObservable: Observable<unknown>;
  54395. private _meshAttached;
  54396. get attachedMesh(): Nullable<AbstractMesh>;
  54397. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54398. /**
  54399. * Creates a RotationGizmo
  54400. * @param gizmoLayer The utility layer the gizmo will be added to
  54401. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54402. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54403. */
  54404. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54405. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54406. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54407. /**
  54408. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54409. */
  54410. set snapDistance(value: number);
  54411. get snapDistance(): number;
  54412. /**
  54413. * Ratio for the scale of the gizmo (Default: 1)
  54414. */
  54415. set scaleRatio(value: number);
  54416. get scaleRatio(): number;
  54417. /**
  54418. * Disposes of the gizmo
  54419. */
  54420. dispose(): void;
  54421. /**
  54422. * CustomMeshes are not supported by this gizmo
  54423. * @param mesh The mesh to replace the default mesh of the gizmo
  54424. */
  54425. setCustomMesh(mesh: Mesh): void;
  54426. }
  54427. }
  54428. declare module "babylonjs/Gizmos/gizmoManager" {
  54429. import { Observable } from "babylonjs/Misc/observable";
  54430. import { Nullable } from "babylonjs/types";
  54431. import { Scene, IDisposable } from "babylonjs/scene";
  54432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54433. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54434. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54435. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54436. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54437. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54438. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54439. /**
  54440. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54441. */
  54442. export class GizmoManager implements IDisposable {
  54443. private scene;
  54444. /**
  54445. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54446. */
  54447. gizmos: {
  54448. positionGizmo: Nullable<PositionGizmo>;
  54449. rotationGizmo: Nullable<RotationGizmo>;
  54450. scaleGizmo: Nullable<ScaleGizmo>;
  54451. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54452. };
  54453. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54454. clearGizmoOnEmptyPointerEvent: boolean;
  54455. /** Fires an event when the manager is attached to a mesh */
  54456. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54457. private _gizmosEnabled;
  54458. private _pointerObserver;
  54459. private _attachedMesh;
  54460. private _boundingBoxColor;
  54461. private _defaultUtilityLayer;
  54462. private _defaultKeepDepthUtilityLayer;
  54463. /**
  54464. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54465. */
  54466. boundingBoxDragBehavior: SixDofDragBehavior;
  54467. /**
  54468. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54469. */
  54470. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54471. /**
  54472. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54473. */
  54474. usePointerToAttachGizmos: boolean;
  54475. /**
  54476. * Utility layer that the bounding box gizmo belongs to
  54477. */
  54478. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54479. /**
  54480. * Utility layer that all gizmos besides bounding box belong to
  54481. */
  54482. get utilityLayer(): UtilityLayerRenderer;
  54483. /**
  54484. * Instatiates a gizmo manager
  54485. * @param scene the scene to overlay the gizmos on top of
  54486. */
  54487. constructor(scene: Scene);
  54488. /**
  54489. * Attaches a set of gizmos to the specified mesh
  54490. * @param mesh The mesh the gizmo's should be attached to
  54491. */
  54492. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54493. /**
  54494. * If the position gizmo is enabled
  54495. */
  54496. set positionGizmoEnabled(value: boolean);
  54497. get positionGizmoEnabled(): boolean;
  54498. /**
  54499. * If the rotation gizmo is enabled
  54500. */
  54501. set rotationGizmoEnabled(value: boolean);
  54502. get rotationGizmoEnabled(): boolean;
  54503. /**
  54504. * If the scale gizmo is enabled
  54505. */
  54506. set scaleGizmoEnabled(value: boolean);
  54507. get scaleGizmoEnabled(): boolean;
  54508. /**
  54509. * If the boundingBox gizmo is enabled
  54510. */
  54511. set boundingBoxGizmoEnabled(value: boolean);
  54512. get boundingBoxGizmoEnabled(): boolean;
  54513. /**
  54514. * Disposes of the gizmo manager
  54515. */
  54516. dispose(): void;
  54517. }
  54518. }
  54519. declare module "babylonjs/Lights/directionalLight" {
  54520. import { Camera } from "babylonjs/Cameras/camera";
  54521. import { Scene } from "babylonjs/scene";
  54522. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54524. import { Light } from "babylonjs/Lights/light";
  54525. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54526. import { Effect } from "babylonjs/Materials/effect";
  54527. /**
  54528. * A directional light is defined by a direction (what a surprise!).
  54529. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54530. * 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.
  54531. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54532. */
  54533. export class DirectionalLight extends ShadowLight {
  54534. private _shadowFrustumSize;
  54535. /**
  54536. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54537. */
  54538. get shadowFrustumSize(): number;
  54539. /**
  54540. * Specifies a fix frustum size for the shadow generation.
  54541. */
  54542. set shadowFrustumSize(value: number);
  54543. private _shadowOrthoScale;
  54544. /**
  54545. * Gets the shadow projection scale against the optimal computed one.
  54546. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54547. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54548. */
  54549. get shadowOrthoScale(): number;
  54550. /**
  54551. * Sets the shadow projection scale against the optimal computed one.
  54552. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54553. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54554. */
  54555. set shadowOrthoScale(value: number);
  54556. /**
  54557. * Automatically compute the projection matrix to best fit (including all the casters)
  54558. * on each frame.
  54559. */
  54560. autoUpdateExtends: boolean;
  54561. /**
  54562. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54563. * on each frame. autoUpdateExtends must be set to true for this to work
  54564. */
  54565. autoCalcShadowZBounds: boolean;
  54566. private _orthoLeft;
  54567. private _orthoRight;
  54568. private _orthoTop;
  54569. private _orthoBottom;
  54570. /**
  54571. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54572. * The directional light is emitted from everywhere in the given direction.
  54573. * It can cast shadows.
  54574. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54575. * @param name The friendly name of the light
  54576. * @param direction The direction of the light
  54577. * @param scene The scene the light belongs to
  54578. */
  54579. constructor(name: string, direction: Vector3, scene: Scene);
  54580. /**
  54581. * Returns the string "DirectionalLight".
  54582. * @return The class name
  54583. */
  54584. getClassName(): string;
  54585. /**
  54586. * Returns the integer 1.
  54587. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54588. */
  54589. getTypeID(): number;
  54590. /**
  54591. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54592. * Returns the DirectionalLight Shadow projection matrix.
  54593. */
  54594. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54595. /**
  54596. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54597. * Returns the DirectionalLight Shadow projection matrix.
  54598. */
  54599. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54600. /**
  54601. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54602. * Returns the DirectionalLight Shadow projection matrix.
  54603. */
  54604. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54605. protected _buildUniformLayout(): void;
  54606. /**
  54607. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54608. * @param effect The effect to update
  54609. * @param lightIndex The index of the light in the effect to update
  54610. * @returns The directional light
  54611. */
  54612. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54613. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54614. /**
  54615. * Gets the minZ used for shadow according to both the scene and the light.
  54616. *
  54617. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54618. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54619. * @param activeCamera The camera we are returning the min for
  54620. * @returns the depth min z
  54621. */
  54622. getDepthMinZ(activeCamera: Camera): number;
  54623. /**
  54624. * Gets the maxZ used for shadow according to both the scene and the light.
  54625. *
  54626. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54627. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54628. * @param activeCamera The camera we are returning the max for
  54629. * @returns the depth max z
  54630. */
  54631. getDepthMaxZ(activeCamera: Camera): number;
  54632. /**
  54633. * Prepares the list of defines specific to the light type.
  54634. * @param defines the list of defines
  54635. * @param lightIndex defines the index of the light for the effect
  54636. */
  54637. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54638. }
  54639. }
  54640. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  54641. import { Mesh } from "babylonjs/Meshes/mesh";
  54642. /**
  54643. * Class containing static functions to help procedurally build meshes
  54644. */
  54645. export class HemisphereBuilder {
  54646. /**
  54647. * Creates a hemisphere mesh
  54648. * @param name defines the name of the mesh
  54649. * @param options defines the options used to create the mesh
  54650. * @param scene defines the hosting scene
  54651. * @returns the hemisphere mesh
  54652. */
  54653. static CreateHemisphere(name: string, options: {
  54654. segments?: number;
  54655. diameter?: number;
  54656. sideOrientation?: number;
  54657. }, scene: any): Mesh;
  54658. }
  54659. }
  54660. declare module "babylonjs/Lights/spotLight" {
  54661. import { Nullable } from "babylonjs/types";
  54662. import { Scene } from "babylonjs/scene";
  54663. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54665. import { Effect } from "babylonjs/Materials/effect";
  54666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54667. import { Light } from "babylonjs/Lights/light";
  54668. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54669. /**
  54670. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54671. * These values define a cone of light starting from the position, emitting toward the direction.
  54672. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54673. * and the exponent defines the speed of the decay of the light with distance (reach).
  54674. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54675. */
  54676. export class SpotLight extends ShadowLight {
  54677. private _angle;
  54678. private _innerAngle;
  54679. private _cosHalfAngle;
  54680. private _lightAngleScale;
  54681. private _lightAngleOffset;
  54682. /**
  54683. * Gets the cone angle of the spot light in Radians.
  54684. */
  54685. get angle(): number;
  54686. /**
  54687. * Sets the cone angle of the spot light in Radians.
  54688. */
  54689. set angle(value: number);
  54690. /**
  54691. * Only used in gltf falloff mode, this defines the angle where
  54692. * the directional falloff will start before cutting at angle which could be seen
  54693. * as outer angle.
  54694. */
  54695. get innerAngle(): number;
  54696. /**
  54697. * Only used in gltf falloff mode, this defines the angle where
  54698. * the directional falloff will start before cutting at angle which could be seen
  54699. * as outer angle.
  54700. */
  54701. set innerAngle(value: number);
  54702. private _shadowAngleScale;
  54703. /**
  54704. * Allows scaling the angle of the light for shadow generation only.
  54705. */
  54706. get shadowAngleScale(): number;
  54707. /**
  54708. * Allows scaling the angle of the light for shadow generation only.
  54709. */
  54710. set shadowAngleScale(value: number);
  54711. /**
  54712. * The light decay speed with the distance from the emission spot.
  54713. */
  54714. exponent: number;
  54715. private _projectionTextureMatrix;
  54716. /**
  54717. * Allows reading the projecton texture
  54718. */
  54719. get projectionTextureMatrix(): Matrix;
  54720. protected _projectionTextureLightNear: number;
  54721. /**
  54722. * Gets the near clip of the Spotlight for texture projection.
  54723. */
  54724. get projectionTextureLightNear(): number;
  54725. /**
  54726. * Sets the near clip of the Spotlight for texture projection.
  54727. */
  54728. set projectionTextureLightNear(value: number);
  54729. protected _projectionTextureLightFar: number;
  54730. /**
  54731. * Gets the far clip of the Spotlight for texture projection.
  54732. */
  54733. get projectionTextureLightFar(): number;
  54734. /**
  54735. * Sets the far clip of the Spotlight for texture projection.
  54736. */
  54737. set projectionTextureLightFar(value: number);
  54738. protected _projectionTextureUpDirection: Vector3;
  54739. /**
  54740. * Gets the Up vector of the Spotlight for texture projection.
  54741. */
  54742. get projectionTextureUpDirection(): Vector3;
  54743. /**
  54744. * Sets the Up vector of the Spotlight for texture projection.
  54745. */
  54746. set projectionTextureUpDirection(value: Vector3);
  54747. private _projectionTexture;
  54748. /**
  54749. * Gets the projection texture of the light.
  54750. */
  54751. get projectionTexture(): Nullable<BaseTexture>;
  54752. /**
  54753. * Sets the projection texture of the light.
  54754. */
  54755. set projectionTexture(value: Nullable<BaseTexture>);
  54756. private _projectionTextureViewLightDirty;
  54757. private _projectionTextureProjectionLightDirty;
  54758. private _projectionTextureDirty;
  54759. private _projectionTextureViewTargetVector;
  54760. private _projectionTextureViewLightMatrix;
  54761. private _projectionTextureProjectionLightMatrix;
  54762. private _projectionTextureScalingMatrix;
  54763. /**
  54764. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54765. * It can cast shadows.
  54766. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54767. * @param name The light friendly name
  54768. * @param position The position of the spot light in the scene
  54769. * @param direction The direction of the light in the scene
  54770. * @param angle The cone angle of the light in Radians
  54771. * @param exponent The light decay speed with the distance from the emission spot
  54772. * @param scene The scene the lights belongs to
  54773. */
  54774. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54775. /**
  54776. * Returns the string "SpotLight".
  54777. * @returns the class name
  54778. */
  54779. getClassName(): string;
  54780. /**
  54781. * Returns the integer 2.
  54782. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54783. */
  54784. getTypeID(): number;
  54785. /**
  54786. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54787. */
  54788. protected _setDirection(value: Vector3): void;
  54789. /**
  54790. * Overrides the position setter to recompute the projection texture view light Matrix.
  54791. */
  54792. protected _setPosition(value: Vector3): void;
  54793. /**
  54794. * 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.
  54795. * Returns the SpotLight.
  54796. */
  54797. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54798. protected _computeProjectionTextureViewLightMatrix(): void;
  54799. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54800. /**
  54801. * Main function for light texture projection matrix computing.
  54802. */
  54803. protected _computeProjectionTextureMatrix(): void;
  54804. protected _buildUniformLayout(): void;
  54805. private _computeAngleValues;
  54806. /**
  54807. * Sets the passed Effect "effect" with the Light textures.
  54808. * @param effect The effect to update
  54809. * @param lightIndex The index of the light in the effect to update
  54810. * @returns The light
  54811. */
  54812. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54813. /**
  54814. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54815. * @param effect The effect to update
  54816. * @param lightIndex The index of the light in the effect to update
  54817. * @returns The spot light
  54818. */
  54819. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54820. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54821. /**
  54822. * Disposes the light and the associated resources.
  54823. */
  54824. dispose(): void;
  54825. /**
  54826. * Prepares the list of defines specific to the light type.
  54827. * @param defines the list of defines
  54828. * @param lightIndex defines the index of the light for the effect
  54829. */
  54830. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54831. }
  54832. }
  54833. declare module "babylonjs/Gizmos/lightGizmo" {
  54834. import { Nullable } from "babylonjs/types";
  54835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54836. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54837. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  54838. import { Light } from "babylonjs/Lights/light";
  54839. /**
  54840. * Gizmo that enables viewing a light
  54841. */
  54842. export class LightGizmo extends Gizmo {
  54843. private _lightMesh;
  54844. private _material;
  54845. private _cachedPosition;
  54846. private _cachedForward;
  54847. private _attachedMeshParent;
  54848. /**
  54849. * Creates a LightGizmo
  54850. * @param gizmoLayer The utility layer the gizmo will be added to
  54851. */
  54852. constructor(gizmoLayer?: UtilityLayerRenderer);
  54853. private _light;
  54854. /**
  54855. * The light that the gizmo is attached to
  54856. */
  54857. set light(light: Nullable<Light>);
  54858. get light(): Nullable<Light>;
  54859. /**
  54860. * Gets the material used to render the light gizmo
  54861. */
  54862. get material(): StandardMaterial;
  54863. /**
  54864. * @hidden
  54865. * Updates the gizmo to match the attached mesh's position/rotation
  54866. */
  54867. protected _update(): void;
  54868. private static _Scale;
  54869. /**
  54870. * Creates the lines for a light mesh
  54871. */
  54872. private static _CreateLightLines;
  54873. /**
  54874. * Disposes of the light gizmo
  54875. */
  54876. dispose(): void;
  54877. private static _CreateHemisphericLightMesh;
  54878. private static _CreatePointLightMesh;
  54879. private static _CreateSpotLightMesh;
  54880. private static _CreateDirectionalLightMesh;
  54881. }
  54882. }
  54883. declare module "babylonjs/Gizmos/index" {
  54884. export * from "babylonjs/Gizmos/axisDragGizmo";
  54885. export * from "babylonjs/Gizmos/axisScaleGizmo";
  54886. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  54887. export * from "babylonjs/Gizmos/gizmo";
  54888. export * from "babylonjs/Gizmos/gizmoManager";
  54889. export * from "babylonjs/Gizmos/planeRotationGizmo";
  54890. export * from "babylonjs/Gizmos/positionGizmo";
  54891. export * from "babylonjs/Gizmos/rotationGizmo";
  54892. export * from "babylonjs/Gizmos/scaleGizmo";
  54893. export * from "babylonjs/Gizmos/lightGizmo";
  54894. export * from "babylonjs/Gizmos/planeDragGizmo";
  54895. }
  54896. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  54897. /** @hidden */
  54898. export var backgroundFragmentDeclaration: {
  54899. name: string;
  54900. shader: string;
  54901. };
  54902. }
  54903. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  54904. /** @hidden */
  54905. export var backgroundUboDeclaration: {
  54906. name: string;
  54907. shader: string;
  54908. };
  54909. }
  54910. declare module "babylonjs/Shaders/background.fragment" {
  54911. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  54912. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54913. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54914. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  54915. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54916. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54917. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54918. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  54919. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  54920. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  54921. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  54922. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  54923. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  54924. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  54925. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  54926. /** @hidden */
  54927. export var backgroundPixelShader: {
  54928. name: string;
  54929. shader: string;
  54930. };
  54931. }
  54932. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  54933. /** @hidden */
  54934. export var backgroundVertexDeclaration: {
  54935. name: string;
  54936. shader: string;
  54937. };
  54938. }
  54939. declare module "babylonjs/Shaders/background.vertex" {
  54940. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  54941. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54942. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54943. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54944. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54945. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  54946. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  54947. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54948. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54949. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54950. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54951. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  54952. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  54953. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  54954. /** @hidden */
  54955. export var backgroundVertexShader: {
  54956. name: string;
  54957. shader: string;
  54958. };
  54959. }
  54960. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  54961. import { Nullable, int, float } from "babylonjs/types";
  54962. import { Scene } from "babylonjs/scene";
  54963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54964. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54966. import { Mesh } from "babylonjs/Meshes/mesh";
  54967. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54968. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54969. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54971. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  54972. import { Color3 } from "babylonjs/Maths/math.color";
  54973. import "babylonjs/Shaders/background.fragment";
  54974. import "babylonjs/Shaders/background.vertex";
  54975. /**
  54976. * Background material used to create an efficient environement around your scene.
  54977. */
  54978. export class BackgroundMaterial extends PushMaterial {
  54979. /**
  54980. * Standard reflectance value at parallel view angle.
  54981. */
  54982. static StandardReflectance0: number;
  54983. /**
  54984. * Standard reflectance value at grazing angle.
  54985. */
  54986. static StandardReflectance90: number;
  54987. protected _primaryColor: Color3;
  54988. /**
  54989. * Key light Color (multiply against the environement texture)
  54990. */
  54991. primaryColor: Color3;
  54992. protected __perceptualColor: Nullable<Color3>;
  54993. /**
  54994. * Experimental Internal Use Only.
  54995. *
  54996. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54997. * This acts as a helper to set the primary color to a more "human friendly" value.
  54998. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54999. * output color as close as possible from the chosen value.
  55000. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55001. * part of lighting setup.)
  55002. */
  55003. get _perceptualColor(): Nullable<Color3>;
  55004. set _perceptualColor(value: Nullable<Color3>);
  55005. protected _primaryColorShadowLevel: float;
  55006. /**
  55007. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55008. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55009. */
  55010. get primaryColorShadowLevel(): float;
  55011. set primaryColorShadowLevel(value: float);
  55012. protected _primaryColorHighlightLevel: float;
  55013. /**
  55014. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55015. * The primary color is used at the level chosen to define what the white area would look.
  55016. */
  55017. get primaryColorHighlightLevel(): float;
  55018. set primaryColorHighlightLevel(value: float);
  55019. protected _reflectionTexture: Nullable<BaseTexture>;
  55020. /**
  55021. * Reflection Texture used in the material.
  55022. * Should be author in a specific way for the best result (refer to the documentation).
  55023. */
  55024. reflectionTexture: Nullable<BaseTexture>;
  55025. protected _reflectionBlur: float;
  55026. /**
  55027. * Reflection Texture level of blur.
  55028. *
  55029. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55030. * texture twice.
  55031. */
  55032. reflectionBlur: float;
  55033. protected _diffuseTexture: Nullable<BaseTexture>;
  55034. /**
  55035. * Diffuse Texture used in the material.
  55036. * Should be author in a specific way for the best result (refer to the documentation).
  55037. */
  55038. diffuseTexture: Nullable<BaseTexture>;
  55039. protected _shadowLights: Nullable<IShadowLight[]>;
  55040. /**
  55041. * Specify the list of lights casting shadow on the material.
  55042. * All scene shadow lights will be included if null.
  55043. */
  55044. shadowLights: Nullable<IShadowLight[]>;
  55045. protected _shadowLevel: float;
  55046. /**
  55047. * Helps adjusting the shadow to a softer level if required.
  55048. * 0 means black shadows and 1 means no shadows.
  55049. */
  55050. shadowLevel: float;
  55051. protected _sceneCenter: Vector3;
  55052. /**
  55053. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55054. * It is usually zero but might be interesting to modify according to your setup.
  55055. */
  55056. sceneCenter: Vector3;
  55057. protected _opacityFresnel: boolean;
  55058. /**
  55059. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55060. * This helps ensuring a nice transition when the camera goes under the ground.
  55061. */
  55062. opacityFresnel: boolean;
  55063. protected _reflectionFresnel: boolean;
  55064. /**
  55065. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55066. * This helps adding a mirror texture on the ground.
  55067. */
  55068. reflectionFresnel: boolean;
  55069. protected _reflectionFalloffDistance: number;
  55070. /**
  55071. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55072. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55073. */
  55074. reflectionFalloffDistance: number;
  55075. protected _reflectionAmount: number;
  55076. /**
  55077. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55078. */
  55079. reflectionAmount: number;
  55080. protected _reflectionReflectance0: number;
  55081. /**
  55082. * This specifies the weight of the reflection at grazing angle.
  55083. */
  55084. reflectionReflectance0: number;
  55085. protected _reflectionReflectance90: number;
  55086. /**
  55087. * This specifies the weight of the reflection at a perpendicular point of view.
  55088. */
  55089. reflectionReflectance90: number;
  55090. /**
  55091. * Sets the reflection reflectance fresnel values according to the default standard
  55092. * empirically know to work well :-)
  55093. */
  55094. set reflectionStandardFresnelWeight(value: number);
  55095. protected _useRGBColor: boolean;
  55096. /**
  55097. * Helps to directly use the maps channels instead of their level.
  55098. */
  55099. useRGBColor: boolean;
  55100. protected _enableNoise: boolean;
  55101. /**
  55102. * This helps reducing the banding effect that could occur on the background.
  55103. */
  55104. enableNoise: boolean;
  55105. /**
  55106. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55107. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55108. * Recommended to be keep at 1.0 except for special cases.
  55109. */
  55110. get fovMultiplier(): number;
  55111. set fovMultiplier(value: number);
  55112. private _fovMultiplier;
  55113. /**
  55114. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55115. */
  55116. useEquirectangularFOV: boolean;
  55117. private _maxSimultaneousLights;
  55118. /**
  55119. * Number of Simultaneous lights allowed on the material.
  55120. */
  55121. maxSimultaneousLights: int;
  55122. /**
  55123. * Default configuration related to image processing available in the Background Material.
  55124. */
  55125. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55126. /**
  55127. * Keep track of the image processing observer to allow dispose and replace.
  55128. */
  55129. private _imageProcessingObserver;
  55130. /**
  55131. * Attaches a new image processing configuration to the PBR Material.
  55132. * @param configuration (if null the scene configuration will be use)
  55133. */
  55134. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55135. /**
  55136. * Gets the image processing configuration used either in this material.
  55137. */
  55138. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55139. /**
  55140. * Sets the Default image processing configuration used either in the this material.
  55141. *
  55142. * If sets to null, the scene one is in use.
  55143. */
  55144. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55145. /**
  55146. * Gets wether the color curves effect is enabled.
  55147. */
  55148. get cameraColorCurvesEnabled(): boolean;
  55149. /**
  55150. * Sets wether the color curves effect is enabled.
  55151. */
  55152. set cameraColorCurvesEnabled(value: boolean);
  55153. /**
  55154. * Gets wether the color grading effect is enabled.
  55155. */
  55156. get cameraColorGradingEnabled(): boolean;
  55157. /**
  55158. * Gets wether the color grading effect is enabled.
  55159. */
  55160. set cameraColorGradingEnabled(value: boolean);
  55161. /**
  55162. * Gets wether tonemapping is enabled or not.
  55163. */
  55164. get cameraToneMappingEnabled(): boolean;
  55165. /**
  55166. * Sets wether tonemapping is enabled or not
  55167. */
  55168. set cameraToneMappingEnabled(value: boolean);
  55169. /**
  55170. * The camera exposure used on this material.
  55171. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55172. * This corresponds to a photographic exposure.
  55173. */
  55174. get cameraExposure(): float;
  55175. /**
  55176. * The camera exposure used on this material.
  55177. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55178. * This corresponds to a photographic exposure.
  55179. */
  55180. set cameraExposure(value: float);
  55181. /**
  55182. * Gets The camera contrast used on this material.
  55183. */
  55184. get cameraContrast(): float;
  55185. /**
  55186. * Sets The camera contrast used on this material.
  55187. */
  55188. set cameraContrast(value: float);
  55189. /**
  55190. * Gets the Color Grading 2D Lookup Texture.
  55191. */
  55192. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55193. /**
  55194. * Sets the Color Grading 2D Lookup Texture.
  55195. */
  55196. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55197. /**
  55198. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55199. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55200. * 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;
  55201. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55202. */
  55203. get cameraColorCurves(): Nullable<ColorCurves>;
  55204. /**
  55205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55207. * 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;
  55208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55209. */
  55210. set cameraColorCurves(value: Nullable<ColorCurves>);
  55211. /**
  55212. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55213. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55214. */
  55215. switchToBGR: boolean;
  55216. private _renderTargets;
  55217. private _reflectionControls;
  55218. private _white;
  55219. private _primaryShadowColor;
  55220. private _primaryHighlightColor;
  55221. /**
  55222. * Instantiates a Background Material in the given scene
  55223. * @param name The friendly name of the material
  55224. * @param scene The scene to add the material to
  55225. */
  55226. constructor(name: string, scene: Scene);
  55227. /**
  55228. * Gets a boolean indicating that current material needs to register RTT
  55229. */
  55230. get hasRenderTargetTextures(): boolean;
  55231. /**
  55232. * The entire material has been created in order to prevent overdraw.
  55233. * @returns false
  55234. */
  55235. needAlphaTesting(): boolean;
  55236. /**
  55237. * The entire material has been created in order to prevent overdraw.
  55238. * @returns true if blending is enable
  55239. */
  55240. needAlphaBlending(): boolean;
  55241. /**
  55242. * Checks wether the material is ready to be rendered for a given mesh.
  55243. * @param mesh The mesh to render
  55244. * @param subMesh The submesh to check against
  55245. * @param useInstances Specify wether or not the material is used with instances
  55246. * @returns true if all the dependencies are ready (Textures, Effects...)
  55247. */
  55248. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55249. /**
  55250. * Compute the primary color according to the chosen perceptual color.
  55251. */
  55252. private _computePrimaryColorFromPerceptualColor;
  55253. /**
  55254. * Compute the highlights and shadow colors according to their chosen levels.
  55255. */
  55256. private _computePrimaryColors;
  55257. /**
  55258. * Build the uniform buffer used in the material.
  55259. */
  55260. buildUniformLayout(): void;
  55261. /**
  55262. * Unbind the material.
  55263. */
  55264. unbind(): void;
  55265. /**
  55266. * Bind only the world matrix to the material.
  55267. * @param world The world matrix to bind.
  55268. */
  55269. bindOnlyWorldMatrix(world: Matrix): void;
  55270. /**
  55271. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55272. * @param world The world matrix to bind.
  55273. * @param subMesh The submesh to bind for.
  55274. */
  55275. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55276. /**
  55277. * Checks to see if a texture is used in the material.
  55278. * @param texture - Base texture to use.
  55279. * @returns - Boolean specifying if a texture is used in the material.
  55280. */
  55281. hasTexture(texture: BaseTexture): boolean;
  55282. /**
  55283. * Dispose the material.
  55284. * @param forceDisposeEffect Force disposal of the associated effect.
  55285. * @param forceDisposeTextures Force disposal of the associated textures.
  55286. */
  55287. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55288. /**
  55289. * Clones the material.
  55290. * @param name The cloned name.
  55291. * @returns The cloned material.
  55292. */
  55293. clone(name: string): BackgroundMaterial;
  55294. /**
  55295. * Serializes the current material to its JSON representation.
  55296. * @returns The JSON representation.
  55297. */
  55298. serialize(): any;
  55299. /**
  55300. * Gets the class name of the material
  55301. * @returns "BackgroundMaterial"
  55302. */
  55303. getClassName(): string;
  55304. /**
  55305. * Parse a JSON input to create back a background material.
  55306. * @param source The JSON data to parse
  55307. * @param scene The scene to create the parsed material in
  55308. * @param rootUrl The root url of the assets the material depends upon
  55309. * @returns the instantiated BackgroundMaterial.
  55310. */
  55311. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55312. }
  55313. }
  55314. declare module "babylonjs/Helpers/environmentHelper" {
  55315. import { Observable } from "babylonjs/Misc/observable";
  55316. import { Nullable } from "babylonjs/types";
  55317. import { Scene } from "babylonjs/scene";
  55318. import { Vector3 } from "babylonjs/Maths/math.vector";
  55319. import { Color3 } from "babylonjs/Maths/math.color";
  55320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55321. import { Mesh } from "babylonjs/Meshes/mesh";
  55322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55323. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55324. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55325. import "babylonjs/Meshes/Builders/planeBuilder";
  55326. import "babylonjs/Meshes/Builders/boxBuilder";
  55327. /**
  55328. * Represents the different options available during the creation of
  55329. * a Environment helper.
  55330. *
  55331. * This can control the default ground, skybox and image processing setup of your scene.
  55332. */
  55333. export interface IEnvironmentHelperOptions {
  55334. /**
  55335. * Specifies whether or not to create a ground.
  55336. * True by default.
  55337. */
  55338. createGround: boolean;
  55339. /**
  55340. * Specifies the ground size.
  55341. * 15 by default.
  55342. */
  55343. groundSize: number;
  55344. /**
  55345. * The texture used on the ground for the main color.
  55346. * Comes from the BabylonJS CDN by default.
  55347. *
  55348. * Remarks: Can be either a texture or a url.
  55349. */
  55350. groundTexture: string | BaseTexture;
  55351. /**
  55352. * The color mixed in the ground texture by default.
  55353. * BabylonJS clearColor by default.
  55354. */
  55355. groundColor: Color3;
  55356. /**
  55357. * Specifies the ground opacity.
  55358. * 1 by default.
  55359. */
  55360. groundOpacity: number;
  55361. /**
  55362. * Enables the ground to receive shadows.
  55363. * True by default.
  55364. */
  55365. enableGroundShadow: boolean;
  55366. /**
  55367. * Helps preventing the shadow to be fully black on the ground.
  55368. * 0.5 by default.
  55369. */
  55370. groundShadowLevel: number;
  55371. /**
  55372. * Creates a mirror texture attach to the ground.
  55373. * false by default.
  55374. */
  55375. enableGroundMirror: boolean;
  55376. /**
  55377. * Specifies the ground mirror size ratio.
  55378. * 0.3 by default as the default kernel is 64.
  55379. */
  55380. groundMirrorSizeRatio: number;
  55381. /**
  55382. * Specifies the ground mirror blur kernel size.
  55383. * 64 by default.
  55384. */
  55385. groundMirrorBlurKernel: number;
  55386. /**
  55387. * Specifies the ground mirror visibility amount.
  55388. * 1 by default
  55389. */
  55390. groundMirrorAmount: number;
  55391. /**
  55392. * Specifies the ground mirror reflectance weight.
  55393. * This uses the standard weight of the background material to setup the fresnel effect
  55394. * of the mirror.
  55395. * 1 by default.
  55396. */
  55397. groundMirrorFresnelWeight: number;
  55398. /**
  55399. * Specifies the ground mirror Falloff distance.
  55400. * This can helps reducing the size of the reflection.
  55401. * 0 by Default.
  55402. */
  55403. groundMirrorFallOffDistance: number;
  55404. /**
  55405. * Specifies the ground mirror texture type.
  55406. * Unsigned Int by Default.
  55407. */
  55408. groundMirrorTextureType: number;
  55409. /**
  55410. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55411. * the shown objects.
  55412. */
  55413. groundYBias: number;
  55414. /**
  55415. * Specifies whether or not to create a skybox.
  55416. * True by default.
  55417. */
  55418. createSkybox: boolean;
  55419. /**
  55420. * Specifies the skybox size.
  55421. * 20 by default.
  55422. */
  55423. skyboxSize: number;
  55424. /**
  55425. * The texture used on the skybox for the main color.
  55426. * Comes from the BabylonJS CDN by default.
  55427. *
  55428. * Remarks: Can be either a texture or a url.
  55429. */
  55430. skyboxTexture: string | BaseTexture;
  55431. /**
  55432. * The color mixed in the skybox texture by default.
  55433. * BabylonJS clearColor by default.
  55434. */
  55435. skyboxColor: Color3;
  55436. /**
  55437. * The background rotation around the Y axis of the scene.
  55438. * This helps aligning the key lights of your scene with the background.
  55439. * 0 by default.
  55440. */
  55441. backgroundYRotation: number;
  55442. /**
  55443. * Compute automatically the size of the elements to best fit with the scene.
  55444. */
  55445. sizeAuto: boolean;
  55446. /**
  55447. * Default position of the rootMesh if autoSize is not true.
  55448. */
  55449. rootPosition: Vector3;
  55450. /**
  55451. * Sets up the image processing in the scene.
  55452. * true by default.
  55453. */
  55454. setupImageProcessing: boolean;
  55455. /**
  55456. * The texture used as your environment texture in the scene.
  55457. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55458. *
  55459. * Remarks: Can be either a texture or a url.
  55460. */
  55461. environmentTexture: string | BaseTexture;
  55462. /**
  55463. * The value of the exposure to apply to the scene.
  55464. * 0.6 by default if setupImageProcessing is true.
  55465. */
  55466. cameraExposure: number;
  55467. /**
  55468. * The value of the contrast to apply to the scene.
  55469. * 1.6 by default if setupImageProcessing is true.
  55470. */
  55471. cameraContrast: number;
  55472. /**
  55473. * Specifies whether or not tonemapping should be enabled in the scene.
  55474. * true by default if setupImageProcessing is true.
  55475. */
  55476. toneMappingEnabled: boolean;
  55477. }
  55478. /**
  55479. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55480. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55481. * It also helps with the default setup of your imageProcessing configuration.
  55482. */
  55483. export class EnvironmentHelper {
  55484. /**
  55485. * Default ground texture URL.
  55486. */
  55487. private static _groundTextureCDNUrl;
  55488. /**
  55489. * Default skybox texture URL.
  55490. */
  55491. private static _skyboxTextureCDNUrl;
  55492. /**
  55493. * Default environment texture URL.
  55494. */
  55495. private static _environmentTextureCDNUrl;
  55496. /**
  55497. * Creates the default options for the helper.
  55498. */
  55499. private static _getDefaultOptions;
  55500. private _rootMesh;
  55501. /**
  55502. * Gets the root mesh created by the helper.
  55503. */
  55504. get rootMesh(): Mesh;
  55505. private _skybox;
  55506. /**
  55507. * Gets the skybox created by the helper.
  55508. */
  55509. get skybox(): Nullable<Mesh>;
  55510. private _skyboxTexture;
  55511. /**
  55512. * Gets the skybox texture created by the helper.
  55513. */
  55514. get skyboxTexture(): Nullable<BaseTexture>;
  55515. private _skyboxMaterial;
  55516. /**
  55517. * Gets the skybox material created by the helper.
  55518. */
  55519. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55520. private _ground;
  55521. /**
  55522. * Gets the ground mesh created by the helper.
  55523. */
  55524. get ground(): Nullable<Mesh>;
  55525. private _groundTexture;
  55526. /**
  55527. * Gets the ground texture created by the helper.
  55528. */
  55529. get groundTexture(): Nullable<BaseTexture>;
  55530. private _groundMirror;
  55531. /**
  55532. * Gets the ground mirror created by the helper.
  55533. */
  55534. get groundMirror(): Nullable<MirrorTexture>;
  55535. /**
  55536. * Gets the ground mirror render list to helps pushing the meshes
  55537. * you wish in the ground reflection.
  55538. */
  55539. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55540. private _groundMaterial;
  55541. /**
  55542. * Gets the ground material created by the helper.
  55543. */
  55544. get groundMaterial(): Nullable<BackgroundMaterial>;
  55545. /**
  55546. * Stores the creation options.
  55547. */
  55548. private readonly _scene;
  55549. private _options;
  55550. /**
  55551. * This observable will be notified with any error during the creation of the environment,
  55552. * mainly texture creation errors.
  55553. */
  55554. onErrorObservable: Observable<{
  55555. message?: string;
  55556. exception?: any;
  55557. }>;
  55558. /**
  55559. * constructor
  55560. * @param options Defines the options we want to customize the helper
  55561. * @param scene The scene to add the material to
  55562. */
  55563. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55564. /**
  55565. * Updates the background according to the new options
  55566. * @param options
  55567. */
  55568. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55569. /**
  55570. * Sets the primary color of all the available elements.
  55571. * @param color the main color to affect to the ground and the background
  55572. */
  55573. setMainColor(color: Color3): void;
  55574. /**
  55575. * Setup the image processing according to the specified options.
  55576. */
  55577. private _setupImageProcessing;
  55578. /**
  55579. * Setup the environment texture according to the specified options.
  55580. */
  55581. private _setupEnvironmentTexture;
  55582. /**
  55583. * Setup the background according to the specified options.
  55584. */
  55585. private _setupBackground;
  55586. /**
  55587. * Get the scene sizes according to the setup.
  55588. */
  55589. private _getSceneSize;
  55590. /**
  55591. * Setup the ground according to the specified options.
  55592. */
  55593. private _setupGround;
  55594. /**
  55595. * Setup the ground material according to the specified options.
  55596. */
  55597. private _setupGroundMaterial;
  55598. /**
  55599. * Setup the ground diffuse texture according to the specified options.
  55600. */
  55601. private _setupGroundDiffuseTexture;
  55602. /**
  55603. * Setup the ground mirror texture according to the specified options.
  55604. */
  55605. private _setupGroundMirrorTexture;
  55606. /**
  55607. * Setup the ground to receive the mirror texture.
  55608. */
  55609. private _setupMirrorInGroundMaterial;
  55610. /**
  55611. * Setup the skybox according to the specified options.
  55612. */
  55613. private _setupSkybox;
  55614. /**
  55615. * Setup the skybox material according to the specified options.
  55616. */
  55617. private _setupSkyboxMaterial;
  55618. /**
  55619. * Setup the skybox reflection texture according to the specified options.
  55620. */
  55621. private _setupSkyboxReflectionTexture;
  55622. private _errorHandler;
  55623. /**
  55624. * Dispose all the elements created by the Helper.
  55625. */
  55626. dispose(): void;
  55627. }
  55628. }
  55629. declare module "babylonjs/Helpers/photoDome" {
  55630. import { Observable } from "babylonjs/Misc/observable";
  55631. import { Nullable } from "babylonjs/types";
  55632. import { Scene } from "babylonjs/scene";
  55633. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55634. import { Mesh } from "babylonjs/Meshes/mesh";
  55635. import { Texture } from "babylonjs/Materials/Textures/texture";
  55636. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55637. import "babylonjs/Meshes/Builders/sphereBuilder";
  55638. /**
  55639. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55640. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55641. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55642. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55643. */
  55644. export class PhotoDome extends TransformNode {
  55645. /**
  55646. * Define the image as a Monoscopic panoramic 360 image.
  55647. */
  55648. static readonly MODE_MONOSCOPIC: number;
  55649. /**
  55650. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55651. */
  55652. static readonly MODE_TOPBOTTOM: number;
  55653. /**
  55654. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55655. */
  55656. static readonly MODE_SIDEBYSIDE: number;
  55657. private _useDirectMapping;
  55658. /**
  55659. * The texture being displayed on the sphere
  55660. */
  55661. protected _photoTexture: Texture;
  55662. /**
  55663. * Gets or sets the texture being displayed on the sphere
  55664. */
  55665. get photoTexture(): Texture;
  55666. set photoTexture(value: Texture);
  55667. /**
  55668. * Observable raised when an error occured while loading the 360 image
  55669. */
  55670. onLoadErrorObservable: Observable<string>;
  55671. /**
  55672. * The skybox material
  55673. */
  55674. protected _material: BackgroundMaterial;
  55675. /**
  55676. * The surface used for the skybox
  55677. */
  55678. protected _mesh: Mesh;
  55679. /**
  55680. * Gets the mesh used for the skybox.
  55681. */
  55682. get mesh(): Mesh;
  55683. /**
  55684. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55685. * Also see the options.resolution property.
  55686. */
  55687. get fovMultiplier(): number;
  55688. set fovMultiplier(value: number);
  55689. private _imageMode;
  55690. /**
  55691. * Gets or set the current video mode for the video. It can be:
  55692. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  55693. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55694. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55695. */
  55696. get imageMode(): number;
  55697. set imageMode(value: number);
  55698. /**
  55699. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  55700. * @param name Element's name, child elements will append suffixes for their own names.
  55701. * @param urlsOfPhoto defines the url of the photo to display
  55702. * @param options defines an object containing optional or exposed sub element properties
  55703. * @param onError defines a callback called when an error occured while loading the texture
  55704. */
  55705. constructor(name: string, urlOfPhoto: string, options: {
  55706. resolution?: number;
  55707. size?: number;
  55708. useDirectMapping?: boolean;
  55709. faceForward?: boolean;
  55710. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55711. private _onBeforeCameraRenderObserver;
  55712. private _changeImageMode;
  55713. /**
  55714. * Releases resources associated with this node.
  55715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55717. */
  55718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55719. }
  55720. }
  55721. declare module "babylonjs/Misc/rgbdTextureTools" {
  55722. import "babylonjs/Shaders/rgbdDecode.fragment";
  55723. import "babylonjs/Engines/Extensions/engine.renderTarget";
  55724. import { Texture } from "babylonjs/Materials/Textures/texture";
  55725. /**
  55726. * Class used to host RGBD texture specific utilities
  55727. */
  55728. export class RGBDTextureTools {
  55729. /**
  55730. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55731. * @param texture the texture to expand.
  55732. */
  55733. static ExpandRGBDTexture(texture: Texture): void;
  55734. }
  55735. }
  55736. declare module "babylonjs/Misc/brdfTextureTools" {
  55737. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55738. import { Scene } from "babylonjs/scene";
  55739. /**
  55740. * Class used to host texture specific utilities
  55741. */
  55742. export class BRDFTextureTools {
  55743. /**
  55744. * Prevents texture cache collision
  55745. */
  55746. private static _instanceNumber;
  55747. /**
  55748. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55749. * @param scene defines the hosting scene
  55750. * @returns the environment BRDF texture
  55751. */
  55752. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55753. private static _environmentBRDFBase64Texture;
  55754. }
  55755. }
  55756. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  55757. import { Nullable } from "babylonjs/types";
  55758. import { Color3 } from "babylonjs/Maths/math.color";
  55759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55760. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55761. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55762. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55763. import { Engine } from "babylonjs/Engines/engine";
  55764. import { Scene } from "babylonjs/scene";
  55765. /**
  55766. * @hidden
  55767. */
  55768. export interface IMaterialClearCoatDefines {
  55769. CLEARCOAT: boolean;
  55770. CLEARCOAT_DEFAULTIOR: boolean;
  55771. CLEARCOAT_TEXTURE: boolean;
  55772. CLEARCOAT_TEXTUREDIRECTUV: number;
  55773. CLEARCOAT_BUMP: boolean;
  55774. CLEARCOAT_BUMPDIRECTUV: number;
  55775. CLEARCOAT_TINT: boolean;
  55776. CLEARCOAT_TINT_TEXTURE: boolean;
  55777. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55778. /** @hidden */
  55779. _areTexturesDirty: boolean;
  55780. }
  55781. /**
  55782. * Define the code related to the clear coat parameters of the pbr material.
  55783. */
  55784. export class PBRClearCoatConfiguration {
  55785. /**
  55786. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55787. * The default fits with a polyurethane material.
  55788. */
  55789. private static readonly _DefaultIndexOfRefraction;
  55790. private _isEnabled;
  55791. /**
  55792. * Defines if the clear coat is enabled in the material.
  55793. */
  55794. isEnabled: boolean;
  55795. /**
  55796. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55797. */
  55798. intensity: number;
  55799. /**
  55800. * Defines the clear coat layer roughness.
  55801. */
  55802. roughness: number;
  55803. private _indexOfRefraction;
  55804. /**
  55805. * Defines the index of refraction of the clear coat.
  55806. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55807. * The default fits with a polyurethane material.
  55808. * Changing the default value is more performance intensive.
  55809. */
  55810. indexOfRefraction: number;
  55811. private _texture;
  55812. /**
  55813. * Stores the clear coat values in a texture.
  55814. */
  55815. texture: Nullable<BaseTexture>;
  55816. private _bumpTexture;
  55817. /**
  55818. * Define the clear coat specific bump texture.
  55819. */
  55820. bumpTexture: Nullable<BaseTexture>;
  55821. private _isTintEnabled;
  55822. /**
  55823. * Defines if the clear coat tint is enabled in the material.
  55824. */
  55825. isTintEnabled: boolean;
  55826. /**
  55827. * Defines the clear coat tint of the material.
  55828. * This is only use if tint is enabled
  55829. */
  55830. tintColor: Color3;
  55831. /**
  55832. * Defines the distance at which the tint color should be found in the
  55833. * clear coat media.
  55834. * This is only use if tint is enabled
  55835. */
  55836. tintColorAtDistance: number;
  55837. /**
  55838. * Defines the clear coat layer thickness.
  55839. * This is only use if tint is enabled
  55840. */
  55841. tintThickness: number;
  55842. private _tintTexture;
  55843. /**
  55844. * Stores the clear tint values in a texture.
  55845. * rgb is tint
  55846. * a is a thickness factor
  55847. */
  55848. tintTexture: Nullable<BaseTexture>;
  55849. /** @hidden */
  55850. private _internalMarkAllSubMeshesAsTexturesDirty;
  55851. /** @hidden */
  55852. _markAllSubMeshesAsTexturesDirty(): void;
  55853. /**
  55854. * Instantiate a new istance of clear coat configuration.
  55855. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55856. */
  55857. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55858. /**
  55859. * Gets wehter the submesh is ready to be used or not.
  55860. * @param defines the list of "defines" to update.
  55861. * @param scene defines the scene the material belongs to.
  55862. * @param engine defines the engine the material belongs to.
  55863. * @param disableBumpMap defines wether the material disables bump or not.
  55864. * @returns - boolean indicating that the submesh is ready or not.
  55865. */
  55866. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55867. /**
  55868. * Checks to see if a texture is used in the material.
  55869. * @param defines the list of "defines" to update.
  55870. * @param scene defines the scene to the material belongs to.
  55871. */
  55872. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55873. /**
  55874. * Binds the material data.
  55875. * @param uniformBuffer defines the Uniform buffer to fill in.
  55876. * @param scene defines the scene the material belongs to.
  55877. * @param engine defines the engine the material belongs to.
  55878. * @param disableBumpMap defines wether the material disables bump or not.
  55879. * @param isFrozen defines wether the material is frozen or not.
  55880. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55881. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55882. */
  55883. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55884. /**
  55885. * Checks to see if a texture is used in the material.
  55886. * @param texture - Base texture to use.
  55887. * @returns - Boolean specifying if a texture is used in the material.
  55888. */
  55889. hasTexture(texture: BaseTexture): boolean;
  55890. /**
  55891. * Returns an array of the actively used textures.
  55892. * @param activeTextures Array of BaseTextures
  55893. */
  55894. getActiveTextures(activeTextures: BaseTexture[]): void;
  55895. /**
  55896. * Returns the animatable textures.
  55897. * @param animatables Array of animatable textures.
  55898. */
  55899. getAnimatables(animatables: IAnimatable[]): void;
  55900. /**
  55901. * Disposes the resources of the material.
  55902. * @param forceDisposeTextures - Forces the disposal of all textures.
  55903. */
  55904. dispose(forceDisposeTextures?: boolean): void;
  55905. /**
  55906. * Get the current class name of the texture useful for serialization or dynamic coding.
  55907. * @returns "PBRClearCoatConfiguration"
  55908. */
  55909. getClassName(): string;
  55910. /**
  55911. * Add fallbacks to the effect fallbacks list.
  55912. * @param defines defines the Base texture to use.
  55913. * @param fallbacks defines the current fallback list.
  55914. * @param currentRank defines the current fallback rank.
  55915. * @returns the new fallback rank.
  55916. */
  55917. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55918. /**
  55919. * Add the required uniforms to the current list.
  55920. * @param uniforms defines the current uniform list.
  55921. */
  55922. static AddUniforms(uniforms: string[]): void;
  55923. /**
  55924. * Add the required samplers to the current list.
  55925. * @param samplers defines the current sampler list.
  55926. */
  55927. static AddSamplers(samplers: string[]): void;
  55928. /**
  55929. * Add the required uniforms to the current buffer.
  55930. * @param uniformBuffer defines the current uniform buffer.
  55931. */
  55932. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55933. /**
  55934. * Makes a duplicate of the current configuration into another one.
  55935. * @param clearCoatConfiguration define the config where to copy the info
  55936. */
  55937. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55938. /**
  55939. * Serializes this clear coat configuration.
  55940. * @returns - An object with the serialized config.
  55941. */
  55942. serialize(): any;
  55943. /**
  55944. * Parses a anisotropy Configuration from a serialized object.
  55945. * @param source - Serialized object.
  55946. * @param scene Defines the scene we are parsing for
  55947. * @param rootUrl Defines the rootUrl to load from
  55948. */
  55949. parse(source: any, scene: Scene, rootUrl: string): void;
  55950. }
  55951. }
  55952. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  55953. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55955. import { Vector2 } from "babylonjs/Maths/math.vector";
  55956. import { Scene } from "babylonjs/scene";
  55957. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55958. import { Nullable } from "babylonjs/types";
  55959. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55960. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55961. /**
  55962. * @hidden
  55963. */
  55964. export interface IMaterialAnisotropicDefines {
  55965. ANISOTROPIC: boolean;
  55966. ANISOTROPIC_TEXTURE: boolean;
  55967. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55968. MAINUV1: boolean;
  55969. _areTexturesDirty: boolean;
  55970. _needUVs: boolean;
  55971. }
  55972. /**
  55973. * Define the code related to the anisotropic parameters of the pbr material.
  55974. */
  55975. export class PBRAnisotropicConfiguration {
  55976. private _isEnabled;
  55977. /**
  55978. * Defines if the anisotropy is enabled in the material.
  55979. */
  55980. isEnabled: boolean;
  55981. /**
  55982. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55983. */
  55984. intensity: number;
  55985. /**
  55986. * Defines if the effect is along the tangents, bitangents or in between.
  55987. * By default, the effect is "strectching" the highlights along the tangents.
  55988. */
  55989. direction: Vector2;
  55990. private _texture;
  55991. /**
  55992. * Stores the anisotropy values in a texture.
  55993. * rg is direction (like normal from -1 to 1)
  55994. * b is a intensity
  55995. */
  55996. texture: Nullable<BaseTexture>;
  55997. /** @hidden */
  55998. private _internalMarkAllSubMeshesAsTexturesDirty;
  55999. /** @hidden */
  56000. _markAllSubMeshesAsTexturesDirty(): void;
  56001. /**
  56002. * Instantiate a new istance of anisotropy configuration.
  56003. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56004. */
  56005. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56006. /**
  56007. * Specifies that the submesh is ready to be used.
  56008. * @param defines the list of "defines" to update.
  56009. * @param scene defines the scene the material belongs to.
  56010. * @returns - boolean indicating that the submesh is ready or not.
  56011. */
  56012. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56013. /**
  56014. * Checks to see if a texture is used in the material.
  56015. * @param defines the list of "defines" to update.
  56016. * @param mesh the mesh we are preparing the defines for.
  56017. * @param scene defines the scene the material belongs to.
  56018. */
  56019. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56020. /**
  56021. * Binds the material data.
  56022. * @param uniformBuffer defines the Uniform buffer to fill in.
  56023. * @param scene defines the scene the material belongs to.
  56024. * @param isFrozen defines wether the material is frozen or not.
  56025. */
  56026. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56027. /**
  56028. * Checks to see if a texture is used in the material.
  56029. * @param texture - Base texture to use.
  56030. * @returns - Boolean specifying if a texture is used in the material.
  56031. */
  56032. hasTexture(texture: BaseTexture): boolean;
  56033. /**
  56034. * Returns an array of the actively used textures.
  56035. * @param activeTextures Array of BaseTextures
  56036. */
  56037. getActiveTextures(activeTextures: BaseTexture[]): void;
  56038. /**
  56039. * Returns the animatable textures.
  56040. * @param animatables Array of animatable textures.
  56041. */
  56042. getAnimatables(animatables: IAnimatable[]): void;
  56043. /**
  56044. * Disposes the resources of the material.
  56045. * @param forceDisposeTextures - Forces the disposal of all textures.
  56046. */
  56047. dispose(forceDisposeTextures?: boolean): void;
  56048. /**
  56049. * Get the current class name of the texture useful for serialization or dynamic coding.
  56050. * @returns "PBRAnisotropicConfiguration"
  56051. */
  56052. getClassName(): string;
  56053. /**
  56054. * Add fallbacks to the effect fallbacks list.
  56055. * @param defines defines the Base texture to use.
  56056. * @param fallbacks defines the current fallback list.
  56057. * @param currentRank defines the current fallback rank.
  56058. * @returns the new fallback rank.
  56059. */
  56060. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56061. /**
  56062. * Add the required uniforms to the current list.
  56063. * @param uniforms defines the current uniform list.
  56064. */
  56065. static AddUniforms(uniforms: string[]): void;
  56066. /**
  56067. * Add the required uniforms to the current buffer.
  56068. * @param uniformBuffer defines the current uniform buffer.
  56069. */
  56070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56071. /**
  56072. * Add the required samplers to the current list.
  56073. * @param samplers defines the current sampler list.
  56074. */
  56075. static AddSamplers(samplers: string[]): void;
  56076. /**
  56077. * Makes a duplicate of the current configuration into another one.
  56078. * @param anisotropicConfiguration define the config where to copy the info
  56079. */
  56080. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56081. /**
  56082. * Serializes this anisotropy configuration.
  56083. * @returns - An object with the serialized config.
  56084. */
  56085. serialize(): any;
  56086. /**
  56087. * Parses a anisotropy Configuration from a serialized object.
  56088. * @param source - Serialized object.
  56089. * @param scene Defines the scene we are parsing for
  56090. * @param rootUrl Defines the rootUrl to load from
  56091. */
  56092. parse(source: any, scene: Scene, rootUrl: string): void;
  56093. }
  56094. }
  56095. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56096. import { Scene } from "babylonjs/scene";
  56097. /**
  56098. * @hidden
  56099. */
  56100. export interface IMaterialBRDFDefines {
  56101. BRDF_V_HEIGHT_CORRELATED: boolean;
  56102. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56103. SPHERICAL_HARMONICS: boolean;
  56104. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56105. /** @hidden */
  56106. _areMiscDirty: boolean;
  56107. }
  56108. /**
  56109. * Define the code related to the BRDF parameters of the pbr material.
  56110. */
  56111. export class PBRBRDFConfiguration {
  56112. /**
  56113. * Default value used for the energy conservation.
  56114. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56115. */
  56116. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56117. /**
  56118. * Default value used for the Smith Visibility Height Correlated mode.
  56119. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56120. */
  56121. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56122. /**
  56123. * Default value used for the IBL diffuse part.
  56124. * This can help switching back to the polynomials mode globally which is a tiny bit
  56125. * less GPU intensive at the drawback of a lower quality.
  56126. */
  56127. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56128. /**
  56129. * Default value used for activating energy conservation for the specular workflow.
  56130. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56131. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56132. */
  56133. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56134. private _useEnergyConservation;
  56135. /**
  56136. * Defines if the material uses energy conservation.
  56137. */
  56138. useEnergyConservation: boolean;
  56139. private _useSmithVisibilityHeightCorrelated;
  56140. /**
  56141. * LEGACY Mode set to false
  56142. * Defines if the material uses height smith correlated visibility term.
  56143. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56144. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56145. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56146. * Not relying on height correlated will also disable energy conservation.
  56147. */
  56148. useSmithVisibilityHeightCorrelated: boolean;
  56149. private _useSphericalHarmonics;
  56150. /**
  56151. * LEGACY Mode set to false
  56152. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56153. * diffuse part of the IBL.
  56154. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56155. * to the ground truth.
  56156. */
  56157. useSphericalHarmonics: boolean;
  56158. private _useSpecularGlossinessInputEnergyConservation;
  56159. /**
  56160. * Defines if the material uses energy conservation, when the specular workflow is active.
  56161. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56162. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56163. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56164. */
  56165. useSpecularGlossinessInputEnergyConservation: boolean;
  56166. /** @hidden */
  56167. private _internalMarkAllSubMeshesAsMiscDirty;
  56168. /** @hidden */
  56169. _markAllSubMeshesAsMiscDirty(): void;
  56170. /**
  56171. * Instantiate a new istance of clear coat configuration.
  56172. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56173. */
  56174. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56175. /**
  56176. * Checks to see if a texture is used in the material.
  56177. * @param defines the list of "defines" to update.
  56178. */
  56179. prepareDefines(defines: IMaterialBRDFDefines): void;
  56180. /**
  56181. * Get the current class name of the texture useful for serialization or dynamic coding.
  56182. * @returns "PBRClearCoatConfiguration"
  56183. */
  56184. getClassName(): string;
  56185. /**
  56186. * Makes a duplicate of the current configuration into another one.
  56187. * @param brdfConfiguration define the config where to copy the info
  56188. */
  56189. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56190. /**
  56191. * Serializes this BRDF configuration.
  56192. * @returns - An object with the serialized config.
  56193. */
  56194. serialize(): any;
  56195. /**
  56196. * Parses a anisotropy Configuration from a serialized object.
  56197. * @param source - Serialized object.
  56198. * @param scene Defines the scene we are parsing for
  56199. * @param rootUrl Defines the rootUrl to load from
  56200. */
  56201. parse(source: any, scene: Scene, rootUrl: string): void;
  56202. }
  56203. }
  56204. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56205. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56206. import { Color3 } from "babylonjs/Maths/math.color";
  56207. import { Scene } from "babylonjs/scene";
  56208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56209. import { Nullable } from "babylonjs/types";
  56210. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56211. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56212. /**
  56213. * @hidden
  56214. */
  56215. export interface IMaterialSheenDefines {
  56216. SHEEN: boolean;
  56217. SHEEN_TEXTURE: boolean;
  56218. SHEEN_TEXTUREDIRECTUV: number;
  56219. SHEEN_LINKWITHALBEDO: boolean;
  56220. SHEEN_ROUGHNESS: boolean;
  56221. SHEEN_ALBEDOSCALING: boolean;
  56222. /** @hidden */
  56223. _areTexturesDirty: boolean;
  56224. }
  56225. /**
  56226. * Define the code related to the Sheen parameters of the pbr material.
  56227. */
  56228. export class PBRSheenConfiguration {
  56229. private _isEnabled;
  56230. /**
  56231. * Defines if the material uses sheen.
  56232. */
  56233. isEnabled: boolean;
  56234. private _linkSheenWithAlbedo;
  56235. /**
  56236. * Defines if the sheen is linked to the sheen color.
  56237. */
  56238. linkSheenWithAlbedo: boolean;
  56239. /**
  56240. * Defines the sheen intensity.
  56241. */
  56242. intensity: number;
  56243. /**
  56244. * Defines the sheen color.
  56245. */
  56246. color: Color3;
  56247. private _texture;
  56248. /**
  56249. * Stores the sheen tint values in a texture.
  56250. * rgb is tint
  56251. * a is a intensity
  56252. */
  56253. texture: Nullable<BaseTexture>;
  56254. private _roughness;
  56255. /**
  56256. * Defines the sheen roughness.
  56257. * It is not taken into account if linkSheenWithAlbedo is true.
  56258. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56259. */
  56260. roughness: Nullable<number>;
  56261. private _albedoScaling;
  56262. /**
  56263. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56264. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56265. * making it easier to setup and tweak the effect
  56266. */
  56267. albedoScaling: boolean;
  56268. /** @hidden */
  56269. private _internalMarkAllSubMeshesAsTexturesDirty;
  56270. /** @hidden */
  56271. _markAllSubMeshesAsTexturesDirty(): void;
  56272. /**
  56273. * Instantiate a new istance of clear coat configuration.
  56274. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56275. */
  56276. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56277. /**
  56278. * Specifies that the submesh is ready to be used.
  56279. * @param defines the list of "defines" to update.
  56280. * @param scene defines the scene the material belongs to.
  56281. * @returns - boolean indicating that the submesh is ready or not.
  56282. */
  56283. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56284. /**
  56285. * Checks to see if a texture is used in the material.
  56286. * @param defines the list of "defines" to update.
  56287. * @param scene defines the scene the material belongs to.
  56288. */
  56289. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56290. /**
  56291. * Binds the material data.
  56292. * @param uniformBuffer defines the Uniform buffer to fill in.
  56293. * @param scene defines the scene the material belongs to.
  56294. * @param isFrozen defines wether the material is frozen or not.
  56295. */
  56296. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56297. /**
  56298. * Checks to see if a texture is used in the material.
  56299. * @param texture - Base texture to use.
  56300. * @returns - Boolean specifying if a texture is used in the material.
  56301. */
  56302. hasTexture(texture: BaseTexture): boolean;
  56303. /**
  56304. * Returns an array of the actively used textures.
  56305. * @param activeTextures Array of BaseTextures
  56306. */
  56307. getActiveTextures(activeTextures: BaseTexture[]): void;
  56308. /**
  56309. * Returns the animatable textures.
  56310. * @param animatables Array of animatable textures.
  56311. */
  56312. getAnimatables(animatables: IAnimatable[]): void;
  56313. /**
  56314. * Disposes the resources of the material.
  56315. * @param forceDisposeTextures - Forces the disposal of all textures.
  56316. */
  56317. dispose(forceDisposeTextures?: boolean): void;
  56318. /**
  56319. * Get the current class name of the texture useful for serialization or dynamic coding.
  56320. * @returns "PBRSheenConfiguration"
  56321. */
  56322. getClassName(): string;
  56323. /**
  56324. * Add fallbacks to the effect fallbacks list.
  56325. * @param defines defines the Base texture to use.
  56326. * @param fallbacks defines the current fallback list.
  56327. * @param currentRank defines the current fallback rank.
  56328. * @returns the new fallback rank.
  56329. */
  56330. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56331. /**
  56332. * Add the required uniforms to the current list.
  56333. * @param uniforms defines the current uniform list.
  56334. */
  56335. static AddUniforms(uniforms: string[]): void;
  56336. /**
  56337. * Add the required uniforms to the current buffer.
  56338. * @param uniformBuffer defines the current uniform buffer.
  56339. */
  56340. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56341. /**
  56342. * Add the required samplers to the current list.
  56343. * @param samplers defines the current sampler list.
  56344. */
  56345. static AddSamplers(samplers: string[]): void;
  56346. /**
  56347. * Makes a duplicate of the current configuration into another one.
  56348. * @param sheenConfiguration define the config where to copy the info
  56349. */
  56350. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56351. /**
  56352. * Serializes this BRDF configuration.
  56353. * @returns - An object with the serialized config.
  56354. */
  56355. serialize(): any;
  56356. /**
  56357. * Parses a anisotropy Configuration from a serialized object.
  56358. * @param source - Serialized object.
  56359. * @param scene Defines the scene we are parsing for
  56360. * @param rootUrl Defines the rootUrl to load from
  56361. */
  56362. parse(source: any, scene: Scene, rootUrl: string): void;
  56363. }
  56364. }
  56365. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56366. import { Nullable } from "babylonjs/types";
  56367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56368. import { Color3 } from "babylonjs/Maths/math.color";
  56369. import { SmartArray } from "babylonjs/Misc/smartArray";
  56370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56371. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56372. import { Effect } from "babylonjs/Materials/effect";
  56373. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56374. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56375. import { Engine } from "babylonjs/Engines/engine";
  56376. import { Scene } from "babylonjs/scene";
  56377. /**
  56378. * @hidden
  56379. */
  56380. export interface IMaterialSubSurfaceDefines {
  56381. SUBSURFACE: boolean;
  56382. SS_REFRACTION: boolean;
  56383. SS_TRANSLUCENCY: boolean;
  56384. SS_SCATERRING: boolean;
  56385. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56386. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56387. SS_REFRACTIONMAP_3D: boolean;
  56388. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56389. SS_LODINREFRACTIONALPHA: boolean;
  56390. SS_GAMMAREFRACTION: boolean;
  56391. SS_RGBDREFRACTION: boolean;
  56392. SS_LINEARSPECULARREFRACTION: boolean;
  56393. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56394. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56395. /** @hidden */
  56396. _areTexturesDirty: boolean;
  56397. }
  56398. /**
  56399. * Define the code related to the sub surface parameters of the pbr material.
  56400. */
  56401. export class PBRSubSurfaceConfiguration {
  56402. private _isRefractionEnabled;
  56403. /**
  56404. * Defines if the refraction is enabled in the material.
  56405. */
  56406. isRefractionEnabled: boolean;
  56407. private _isTranslucencyEnabled;
  56408. /**
  56409. * Defines if the translucency is enabled in the material.
  56410. */
  56411. isTranslucencyEnabled: boolean;
  56412. private _isScatteringEnabled;
  56413. /**
  56414. * Defines the refraction intensity of the material.
  56415. * The refraction when enabled replaces the Diffuse part of the material.
  56416. * The intensity helps transitionning between diffuse and refraction.
  56417. */
  56418. refractionIntensity: number;
  56419. /**
  56420. * Defines the translucency intensity of the material.
  56421. * When translucency has been enabled, this defines how much of the "translucency"
  56422. * is addded to the diffuse part of the material.
  56423. */
  56424. translucencyIntensity: number;
  56425. /**
  56426. * Defines the scattering intensity of the material.
  56427. * When scattering has been enabled, this defines how much of the "scattered light"
  56428. * is addded to the diffuse part of the material.
  56429. */
  56430. scatteringIntensity: number;
  56431. private _thicknessTexture;
  56432. /**
  56433. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56434. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56435. * 0 would mean minimumThickness
  56436. * 1 would mean maximumThickness
  56437. * The other channels might be use as a mask to vary the different effects intensity.
  56438. */
  56439. thicknessTexture: Nullable<BaseTexture>;
  56440. private _refractionTexture;
  56441. /**
  56442. * Defines the texture to use for refraction.
  56443. */
  56444. refractionTexture: Nullable<BaseTexture>;
  56445. private _indexOfRefraction;
  56446. /**
  56447. * Index of refraction of the material base layer.
  56448. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56449. *
  56450. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56451. *
  56452. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56453. */
  56454. indexOfRefraction: number;
  56455. private _invertRefractionY;
  56456. /**
  56457. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56458. */
  56459. invertRefractionY: boolean;
  56460. private _linkRefractionWithTransparency;
  56461. /**
  56462. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56463. * Materials half opaque for instance using refraction could benefit from this control.
  56464. */
  56465. linkRefractionWithTransparency: boolean;
  56466. /**
  56467. * Defines the minimum thickness stored in the thickness map.
  56468. * If no thickness map is defined, this value will be used to simulate thickness.
  56469. */
  56470. minimumThickness: number;
  56471. /**
  56472. * Defines the maximum thickness stored in the thickness map.
  56473. */
  56474. maximumThickness: number;
  56475. /**
  56476. * Defines the volume tint of the material.
  56477. * This is used for both translucency and scattering.
  56478. */
  56479. tintColor: Color3;
  56480. /**
  56481. * Defines the distance at which the tint color should be found in the media.
  56482. * This is used for refraction only.
  56483. */
  56484. tintColorAtDistance: number;
  56485. /**
  56486. * Defines how far each channel transmit through the media.
  56487. * It is defined as a color to simplify it selection.
  56488. */
  56489. diffusionDistance: Color3;
  56490. private _useMaskFromThicknessTexture;
  56491. /**
  56492. * Stores the intensity of the different subsurface effects in the thickness texture.
  56493. * * the green channel is the translucency intensity.
  56494. * * the blue channel is the scattering intensity.
  56495. * * the alpha channel is the refraction intensity.
  56496. */
  56497. useMaskFromThicknessTexture: boolean;
  56498. /** @hidden */
  56499. private _internalMarkAllSubMeshesAsTexturesDirty;
  56500. /** @hidden */
  56501. _markAllSubMeshesAsTexturesDirty(): void;
  56502. /**
  56503. * Instantiate a new istance of sub surface configuration.
  56504. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56505. */
  56506. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56507. /**
  56508. * Gets wehter the submesh is ready to be used or not.
  56509. * @param defines the list of "defines" to update.
  56510. * @param scene defines the scene the material belongs to.
  56511. * @returns - boolean indicating that the submesh is ready or not.
  56512. */
  56513. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56514. /**
  56515. * Checks to see if a texture is used in the material.
  56516. * @param defines the list of "defines" to update.
  56517. * @param scene defines the scene to the material belongs to.
  56518. */
  56519. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56520. /**
  56521. * Binds the material data.
  56522. * @param uniformBuffer defines the Uniform buffer to fill in.
  56523. * @param scene defines the scene the material belongs to.
  56524. * @param engine defines the engine the material belongs to.
  56525. * @param isFrozen defines whether the material is frozen or not.
  56526. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56527. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56528. */
  56529. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56530. /**
  56531. * Unbinds the material from the mesh.
  56532. * @param activeEffect defines the effect that should be unbound from.
  56533. * @returns true if unbound, otherwise false
  56534. */
  56535. unbind(activeEffect: Effect): boolean;
  56536. /**
  56537. * Returns the texture used for refraction or null if none is used.
  56538. * @param scene defines the scene the material belongs to.
  56539. * @returns - Refraction texture if present. If no refraction texture and refraction
  56540. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56541. */
  56542. private _getRefractionTexture;
  56543. /**
  56544. * Returns true if alpha blending should be disabled.
  56545. */
  56546. get disableAlphaBlending(): boolean;
  56547. /**
  56548. * Fills the list of render target textures.
  56549. * @param renderTargets the list of render targets to update
  56550. */
  56551. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56552. /**
  56553. * Checks to see if a texture is used in the material.
  56554. * @param texture - Base texture to use.
  56555. * @returns - Boolean specifying if a texture is used in the material.
  56556. */
  56557. hasTexture(texture: BaseTexture): boolean;
  56558. /**
  56559. * Gets a boolean indicating that current material needs to register RTT
  56560. * @returns true if this uses a render target otherwise false.
  56561. */
  56562. hasRenderTargetTextures(): boolean;
  56563. /**
  56564. * Returns an array of the actively used textures.
  56565. * @param activeTextures Array of BaseTextures
  56566. */
  56567. getActiveTextures(activeTextures: BaseTexture[]): void;
  56568. /**
  56569. * Returns the animatable textures.
  56570. * @param animatables Array of animatable textures.
  56571. */
  56572. getAnimatables(animatables: IAnimatable[]): void;
  56573. /**
  56574. * Disposes the resources of the material.
  56575. * @param forceDisposeTextures - Forces the disposal of all textures.
  56576. */
  56577. dispose(forceDisposeTextures?: boolean): void;
  56578. /**
  56579. * Get the current class name of the texture useful for serialization or dynamic coding.
  56580. * @returns "PBRSubSurfaceConfiguration"
  56581. */
  56582. getClassName(): string;
  56583. /**
  56584. * Add fallbacks to the effect fallbacks list.
  56585. * @param defines defines the Base texture to use.
  56586. * @param fallbacks defines the current fallback list.
  56587. * @param currentRank defines the current fallback rank.
  56588. * @returns the new fallback rank.
  56589. */
  56590. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56591. /**
  56592. * Add the required uniforms to the current list.
  56593. * @param uniforms defines the current uniform list.
  56594. */
  56595. static AddUniforms(uniforms: string[]): void;
  56596. /**
  56597. * Add the required samplers to the current list.
  56598. * @param samplers defines the current sampler list.
  56599. */
  56600. static AddSamplers(samplers: string[]): void;
  56601. /**
  56602. * Add the required uniforms to the current buffer.
  56603. * @param uniformBuffer defines the current uniform buffer.
  56604. */
  56605. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56606. /**
  56607. * Makes a duplicate of the current configuration into another one.
  56608. * @param configuration define the config where to copy the info
  56609. */
  56610. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56611. /**
  56612. * Serializes this Sub Surface configuration.
  56613. * @returns - An object with the serialized config.
  56614. */
  56615. serialize(): any;
  56616. /**
  56617. * Parses a anisotropy Configuration from a serialized object.
  56618. * @param source - Serialized object.
  56619. * @param scene Defines the scene we are parsing for
  56620. * @param rootUrl Defines the rootUrl to load from
  56621. */
  56622. parse(source: any, scene: Scene, rootUrl: string): void;
  56623. }
  56624. }
  56625. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  56626. /** @hidden */
  56627. export var pbrFragmentDeclaration: {
  56628. name: string;
  56629. shader: string;
  56630. };
  56631. }
  56632. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  56633. /** @hidden */
  56634. export var pbrUboDeclaration: {
  56635. name: string;
  56636. shader: string;
  56637. };
  56638. }
  56639. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  56640. /** @hidden */
  56641. export var pbrFragmentExtraDeclaration: {
  56642. name: string;
  56643. shader: string;
  56644. };
  56645. }
  56646. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  56647. /** @hidden */
  56648. export var pbrFragmentSamplersDeclaration: {
  56649. name: string;
  56650. shader: string;
  56651. };
  56652. }
  56653. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  56654. /** @hidden */
  56655. export var importanceSampling: {
  56656. name: string;
  56657. shader: string;
  56658. };
  56659. }
  56660. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  56661. /** @hidden */
  56662. export var pbrHelperFunctions: {
  56663. name: string;
  56664. shader: string;
  56665. };
  56666. }
  56667. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  56668. /** @hidden */
  56669. export var harmonicsFunctions: {
  56670. name: string;
  56671. shader: string;
  56672. };
  56673. }
  56674. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  56675. /** @hidden */
  56676. export var pbrDirectLightingSetupFunctions: {
  56677. name: string;
  56678. shader: string;
  56679. };
  56680. }
  56681. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  56682. /** @hidden */
  56683. export var pbrDirectLightingFalloffFunctions: {
  56684. name: string;
  56685. shader: string;
  56686. };
  56687. }
  56688. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  56689. /** @hidden */
  56690. export var pbrBRDFFunctions: {
  56691. name: string;
  56692. shader: string;
  56693. };
  56694. }
  56695. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  56696. /** @hidden */
  56697. export var hdrFilteringFunctions: {
  56698. name: string;
  56699. shader: string;
  56700. };
  56701. }
  56702. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  56703. /** @hidden */
  56704. export var pbrDirectLightingFunctions: {
  56705. name: string;
  56706. shader: string;
  56707. };
  56708. }
  56709. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  56710. /** @hidden */
  56711. export var pbrIBLFunctions: {
  56712. name: string;
  56713. shader: string;
  56714. };
  56715. }
  56716. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  56717. /** @hidden */
  56718. export var pbrBlockAlbedoOpacity: {
  56719. name: string;
  56720. shader: string;
  56721. };
  56722. }
  56723. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  56724. /** @hidden */
  56725. export var pbrBlockReflectivity: {
  56726. name: string;
  56727. shader: string;
  56728. };
  56729. }
  56730. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  56731. /** @hidden */
  56732. export var pbrBlockAmbientOcclusion: {
  56733. name: string;
  56734. shader: string;
  56735. };
  56736. }
  56737. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  56738. /** @hidden */
  56739. export var pbrBlockAlphaFresnel: {
  56740. name: string;
  56741. shader: string;
  56742. };
  56743. }
  56744. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  56745. /** @hidden */
  56746. export var pbrBlockAnisotropic: {
  56747. name: string;
  56748. shader: string;
  56749. };
  56750. }
  56751. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  56752. /** @hidden */
  56753. export var pbrBlockReflection: {
  56754. name: string;
  56755. shader: string;
  56756. };
  56757. }
  56758. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  56759. /** @hidden */
  56760. export var pbrBlockSheen: {
  56761. name: string;
  56762. shader: string;
  56763. };
  56764. }
  56765. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  56766. /** @hidden */
  56767. export var pbrBlockClearcoat: {
  56768. name: string;
  56769. shader: string;
  56770. };
  56771. }
  56772. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  56773. /** @hidden */
  56774. export var pbrBlockSubSurface: {
  56775. name: string;
  56776. shader: string;
  56777. };
  56778. }
  56779. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  56780. /** @hidden */
  56781. export var pbrBlockNormalGeometric: {
  56782. name: string;
  56783. shader: string;
  56784. };
  56785. }
  56786. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  56787. /** @hidden */
  56788. export var pbrBlockNormalFinal: {
  56789. name: string;
  56790. shader: string;
  56791. };
  56792. }
  56793. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  56794. /** @hidden */
  56795. export var pbrBlockGeometryInfo: {
  56796. name: string;
  56797. shader: string;
  56798. };
  56799. }
  56800. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  56801. /** @hidden */
  56802. export var pbrBlockReflectance0: {
  56803. name: string;
  56804. shader: string;
  56805. };
  56806. }
  56807. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  56808. /** @hidden */
  56809. export var pbrBlockReflectance: {
  56810. name: string;
  56811. shader: string;
  56812. };
  56813. }
  56814. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  56815. /** @hidden */
  56816. export var pbrBlockDirectLighting: {
  56817. name: string;
  56818. shader: string;
  56819. };
  56820. }
  56821. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  56822. /** @hidden */
  56823. export var pbrBlockFinalLitComponents: {
  56824. name: string;
  56825. shader: string;
  56826. };
  56827. }
  56828. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  56829. /** @hidden */
  56830. export var pbrBlockFinalUnlitComponents: {
  56831. name: string;
  56832. shader: string;
  56833. };
  56834. }
  56835. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  56836. /** @hidden */
  56837. export var pbrBlockFinalColorComposition: {
  56838. name: string;
  56839. shader: string;
  56840. };
  56841. }
  56842. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  56843. /** @hidden */
  56844. export var pbrBlockImageProcessing: {
  56845. name: string;
  56846. shader: string;
  56847. };
  56848. }
  56849. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  56850. /** @hidden */
  56851. export var pbrDebug: {
  56852. name: string;
  56853. shader: string;
  56854. };
  56855. }
  56856. declare module "babylonjs/Shaders/pbr.fragment" {
  56857. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  56858. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56859. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  56860. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56861. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56862. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  56863. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56864. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56865. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56866. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56867. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56868. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  56869. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  56870. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56871. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56872. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56873. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  56874. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  56875. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  56876. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  56877. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  56878. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  56879. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  56880. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56881. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56882. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  56883. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  56884. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  56885. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  56886. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  56887. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  56888. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  56889. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  56890. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  56891. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56892. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  56893. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56894. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  56895. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  56896. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  56897. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  56898. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  56899. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  56900. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56901. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  56902. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  56903. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  56904. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56905. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56906. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  56907. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  56908. /** @hidden */
  56909. export var pbrPixelShader: {
  56910. name: string;
  56911. shader: string;
  56912. };
  56913. }
  56914. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  56915. /** @hidden */
  56916. export var pbrVertexDeclaration: {
  56917. name: string;
  56918. shader: string;
  56919. };
  56920. }
  56921. declare module "babylonjs/Shaders/pbr.vertex" {
  56922. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  56923. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56924. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56925. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56926. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56927. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56928. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  56929. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56930. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56931. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56932. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56933. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56934. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56935. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56936. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56937. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56938. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56939. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  56940. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56941. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56942. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56943. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56944. /** @hidden */
  56945. export var pbrVertexShader: {
  56946. name: string;
  56947. shader: string;
  56948. };
  56949. }
  56950. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  56951. import { Nullable } from "babylonjs/types";
  56952. import { Scene } from "babylonjs/scene";
  56953. import { Matrix } from "babylonjs/Maths/math.vector";
  56954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56956. import { Mesh } from "babylonjs/Meshes/mesh";
  56957. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  56958. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  56959. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  56960. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  56961. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  56962. import { Color3 } from "babylonjs/Maths/math.color";
  56963. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56964. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  56965. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56966. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56968. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56969. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56970. import "babylonjs/Shaders/pbr.fragment";
  56971. import "babylonjs/Shaders/pbr.vertex";
  56972. /**
  56973. * Manages the defines for the PBR Material.
  56974. * @hidden
  56975. */
  56976. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  56977. PBR: boolean;
  56978. NUM_SAMPLES: string;
  56979. REALTIME_FILTERING: boolean;
  56980. MAINUV1: boolean;
  56981. MAINUV2: boolean;
  56982. UV1: boolean;
  56983. UV2: boolean;
  56984. ALBEDO: boolean;
  56985. GAMMAALBEDO: boolean;
  56986. ALBEDODIRECTUV: number;
  56987. VERTEXCOLOR: boolean;
  56988. AMBIENT: boolean;
  56989. AMBIENTDIRECTUV: number;
  56990. AMBIENTINGRAYSCALE: boolean;
  56991. OPACITY: boolean;
  56992. VERTEXALPHA: boolean;
  56993. OPACITYDIRECTUV: number;
  56994. OPACITYRGB: boolean;
  56995. ALPHATEST: boolean;
  56996. DEPTHPREPASS: boolean;
  56997. ALPHABLEND: boolean;
  56998. ALPHAFROMALBEDO: boolean;
  56999. ALPHATESTVALUE: string;
  57000. SPECULAROVERALPHA: boolean;
  57001. RADIANCEOVERALPHA: boolean;
  57002. ALPHAFRESNEL: boolean;
  57003. LINEARALPHAFRESNEL: boolean;
  57004. PREMULTIPLYALPHA: boolean;
  57005. EMISSIVE: boolean;
  57006. EMISSIVEDIRECTUV: number;
  57007. REFLECTIVITY: boolean;
  57008. REFLECTIVITYDIRECTUV: number;
  57009. SPECULARTERM: boolean;
  57010. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57011. MICROSURFACEAUTOMATIC: boolean;
  57012. LODBASEDMICROSFURACE: boolean;
  57013. MICROSURFACEMAP: boolean;
  57014. MICROSURFACEMAPDIRECTUV: number;
  57015. METALLICWORKFLOW: boolean;
  57016. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57017. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57018. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57019. AOSTOREINMETALMAPRED: boolean;
  57020. METALLIC_REFLECTANCE: boolean;
  57021. METALLIC_REFLECTANCEDIRECTUV: number;
  57022. ENVIRONMENTBRDF: boolean;
  57023. ENVIRONMENTBRDF_RGBD: boolean;
  57024. NORMAL: boolean;
  57025. TANGENT: boolean;
  57026. BUMP: boolean;
  57027. BUMPDIRECTUV: number;
  57028. OBJECTSPACE_NORMALMAP: boolean;
  57029. PARALLAX: boolean;
  57030. PARALLAXOCCLUSION: boolean;
  57031. NORMALXYSCALE: boolean;
  57032. LIGHTMAP: boolean;
  57033. LIGHTMAPDIRECTUV: number;
  57034. USELIGHTMAPASSHADOWMAP: boolean;
  57035. GAMMALIGHTMAP: boolean;
  57036. RGBDLIGHTMAP: boolean;
  57037. REFLECTION: boolean;
  57038. REFLECTIONMAP_3D: boolean;
  57039. REFLECTIONMAP_SPHERICAL: boolean;
  57040. REFLECTIONMAP_PLANAR: boolean;
  57041. REFLECTIONMAP_CUBIC: boolean;
  57042. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57043. REFLECTIONMAP_PROJECTION: boolean;
  57044. REFLECTIONMAP_SKYBOX: boolean;
  57045. REFLECTIONMAP_EXPLICIT: boolean;
  57046. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57047. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57048. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57049. INVERTCUBICMAP: boolean;
  57050. USESPHERICALFROMREFLECTIONMAP: boolean;
  57051. USEIRRADIANCEMAP: boolean;
  57052. SPHERICAL_HARMONICS: boolean;
  57053. USESPHERICALINVERTEX: boolean;
  57054. REFLECTIONMAP_OPPOSITEZ: boolean;
  57055. LODINREFLECTIONALPHA: boolean;
  57056. GAMMAREFLECTION: boolean;
  57057. RGBDREFLECTION: boolean;
  57058. LINEARSPECULARREFLECTION: boolean;
  57059. RADIANCEOCCLUSION: boolean;
  57060. HORIZONOCCLUSION: boolean;
  57061. INSTANCES: boolean;
  57062. THIN_INSTANCES: boolean;
  57063. NUM_BONE_INFLUENCERS: number;
  57064. BonesPerMesh: number;
  57065. BONETEXTURE: boolean;
  57066. NONUNIFORMSCALING: boolean;
  57067. MORPHTARGETS: boolean;
  57068. MORPHTARGETS_NORMAL: boolean;
  57069. MORPHTARGETS_TANGENT: boolean;
  57070. MORPHTARGETS_UV: boolean;
  57071. NUM_MORPH_INFLUENCERS: number;
  57072. IMAGEPROCESSING: boolean;
  57073. VIGNETTE: boolean;
  57074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57075. VIGNETTEBLENDMODEOPAQUE: boolean;
  57076. TONEMAPPING: boolean;
  57077. TONEMAPPING_ACES: boolean;
  57078. CONTRAST: boolean;
  57079. COLORCURVES: boolean;
  57080. COLORGRADING: boolean;
  57081. COLORGRADING3D: boolean;
  57082. SAMPLER3DGREENDEPTH: boolean;
  57083. SAMPLER3DBGRMAP: boolean;
  57084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57085. EXPOSURE: boolean;
  57086. MULTIVIEW: boolean;
  57087. USEPHYSICALLIGHTFALLOFF: boolean;
  57088. USEGLTFLIGHTFALLOFF: boolean;
  57089. TWOSIDEDLIGHTING: boolean;
  57090. SHADOWFLOAT: boolean;
  57091. CLIPPLANE: boolean;
  57092. CLIPPLANE2: boolean;
  57093. CLIPPLANE3: boolean;
  57094. CLIPPLANE4: boolean;
  57095. CLIPPLANE5: boolean;
  57096. CLIPPLANE6: boolean;
  57097. POINTSIZE: boolean;
  57098. FOG: boolean;
  57099. LOGARITHMICDEPTH: boolean;
  57100. FORCENORMALFORWARD: boolean;
  57101. SPECULARAA: boolean;
  57102. CLEARCOAT: boolean;
  57103. CLEARCOAT_DEFAULTIOR: boolean;
  57104. CLEARCOAT_TEXTURE: boolean;
  57105. CLEARCOAT_TEXTUREDIRECTUV: number;
  57106. CLEARCOAT_BUMP: boolean;
  57107. CLEARCOAT_BUMPDIRECTUV: number;
  57108. CLEARCOAT_TINT: boolean;
  57109. CLEARCOAT_TINT_TEXTURE: boolean;
  57110. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57111. ANISOTROPIC: boolean;
  57112. ANISOTROPIC_TEXTURE: boolean;
  57113. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57114. BRDF_V_HEIGHT_CORRELATED: boolean;
  57115. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57116. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57117. SHEEN: boolean;
  57118. SHEEN_TEXTURE: boolean;
  57119. SHEEN_TEXTUREDIRECTUV: number;
  57120. SHEEN_LINKWITHALBEDO: boolean;
  57121. SHEEN_ROUGHNESS: boolean;
  57122. SHEEN_ALBEDOSCALING: boolean;
  57123. SUBSURFACE: boolean;
  57124. SS_REFRACTION: boolean;
  57125. SS_TRANSLUCENCY: boolean;
  57126. SS_SCATERRING: boolean;
  57127. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57128. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57129. SS_REFRACTIONMAP_3D: boolean;
  57130. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57131. SS_LODINREFRACTIONALPHA: boolean;
  57132. SS_GAMMAREFRACTION: boolean;
  57133. SS_RGBDREFRACTION: boolean;
  57134. SS_LINEARSPECULARREFRACTION: boolean;
  57135. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57136. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57137. UNLIT: boolean;
  57138. DEBUGMODE: number;
  57139. /**
  57140. * Initializes the PBR Material defines.
  57141. */
  57142. constructor();
  57143. /**
  57144. * Resets the PBR Material defines.
  57145. */
  57146. reset(): void;
  57147. }
  57148. /**
  57149. * The Physically based material base class of BJS.
  57150. *
  57151. * This offers the main features of a standard PBR material.
  57152. * For more information, please refer to the documentation :
  57153. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57154. */
  57155. export abstract class PBRBaseMaterial extends PushMaterial {
  57156. /**
  57157. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57158. */
  57159. static readonly PBRMATERIAL_OPAQUE: number;
  57160. /**
  57161. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57162. */
  57163. static readonly PBRMATERIAL_ALPHATEST: number;
  57164. /**
  57165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57166. */
  57167. static readonly PBRMATERIAL_ALPHABLEND: number;
  57168. /**
  57169. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57170. * They are also discarded below the alpha cutoff threshold to improve performances.
  57171. */
  57172. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57173. /**
  57174. * Defines the default value of how much AO map is occluding the analytical lights
  57175. * (point spot...).
  57176. */
  57177. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57178. /**
  57179. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57180. */
  57181. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57182. /**
  57183. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57184. * to enhance interoperability with other engines.
  57185. */
  57186. static readonly LIGHTFALLOFF_GLTF: number;
  57187. /**
  57188. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57189. * to enhance interoperability with other materials.
  57190. */
  57191. static readonly LIGHTFALLOFF_STANDARD: number;
  57192. /**
  57193. * Intensity of the direct lights e.g. the four lights available in your scene.
  57194. * This impacts both the direct diffuse and specular highlights.
  57195. */
  57196. protected _directIntensity: number;
  57197. /**
  57198. * Intensity of the emissive part of the material.
  57199. * This helps controlling the emissive effect without modifying the emissive color.
  57200. */
  57201. protected _emissiveIntensity: number;
  57202. /**
  57203. * Intensity of the environment e.g. how much the environment will light the object
  57204. * either through harmonics for rough material or through the refelction for shiny ones.
  57205. */
  57206. protected _environmentIntensity: number;
  57207. /**
  57208. * This is a special control allowing the reduction of the specular highlights coming from the
  57209. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57210. */
  57211. protected _specularIntensity: number;
  57212. /**
  57213. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57214. */
  57215. private _lightingInfos;
  57216. /**
  57217. * Debug Control allowing disabling the bump map on this material.
  57218. */
  57219. protected _disableBumpMap: boolean;
  57220. /**
  57221. * AKA Diffuse Texture in standard nomenclature.
  57222. */
  57223. protected _albedoTexture: Nullable<BaseTexture>;
  57224. /**
  57225. * AKA Occlusion Texture in other nomenclature.
  57226. */
  57227. protected _ambientTexture: Nullable<BaseTexture>;
  57228. /**
  57229. * AKA Occlusion Texture Intensity in other nomenclature.
  57230. */
  57231. protected _ambientTextureStrength: number;
  57232. /**
  57233. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57234. * 1 means it completely occludes it
  57235. * 0 mean it has no impact
  57236. */
  57237. protected _ambientTextureImpactOnAnalyticalLights: number;
  57238. /**
  57239. * Stores the alpha values in a texture.
  57240. */
  57241. protected _opacityTexture: Nullable<BaseTexture>;
  57242. /**
  57243. * Stores the reflection values in a texture.
  57244. */
  57245. protected _reflectionTexture: Nullable<BaseTexture>;
  57246. /**
  57247. * Stores the emissive values in a texture.
  57248. */
  57249. protected _emissiveTexture: Nullable<BaseTexture>;
  57250. /**
  57251. * AKA Specular texture in other nomenclature.
  57252. */
  57253. protected _reflectivityTexture: Nullable<BaseTexture>;
  57254. /**
  57255. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57256. */
  57257. protected _metallicTexture: Nullable<BaseTexture>;
  57258. /**
  57259. * Specifies the metallic scalar of the metallic/roughness workflow.
  57260. * Can also be used to scale the metalness values of the metallic texture.
  57261. */
  57262. protected _metallic: Nullable<number>;
  57263. /**
  57264. * Specifies the roughness scalar of the metallic/roughness workflow.
  57265. * Can also be used to scale the roughness values of the metallic texture.
  57266. */
  57267. protected _roughness: Nullable<number>;
  57268. /**
  57269. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57270. * By default the indexOfrefraction is used to compute F0;
  57271. *
  57272. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57273. *
  57274. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57275. * F90 = metallicReflectanceColor;
  57276. */
  57277. protected _metallicF0Factor: number;
  57278. /**
  57279. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57280. * By default the F90 is always 1;
  57281. *
  57282. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57283. *
  57284. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57285. * F90 = metallicReflectanceColor;
  57286. */
  57287. protected _metallicReflectanceColor: Color3;
  57288. /**
  57289. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57290. * This is multiply against the scalar values defined in the material.
  57291. */
  57292. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57293. /**
  57294. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57295. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57296. */
  57297. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57298. /**
  57299. * Stores surface normal data used to displace a mesh in a texture.
  57300. */
  57301. protected _bumpTexture: Nullable<BaseTexture>;
  57302. /**
  57303. * Stores the pre-calculated light information of a mesh in a texture.
  57304. */
  57305. protected _lightmapTexture: Nullable<BaseTexture>;
  57306. /**
  57307. * The color of a material in ambient lighting.
  57308. */
  57309. protected _ambientColor: Color3;
  57310. /**
  57311. * AKA Diffuse Color in other nomenclature.
  57312. */
  57313. protected _albedoColor: Color3;
  57314. /**
  57315. * AKA Specular Color in other nomenclature.
  57316. */
  57317. protected _reflectivityColor: Color3;
  57318. /**
  57319. * The color applied when light is reflected from a material.
  57320. */
  57321. protected _reflectionColor: Color3;
  57322. /**
  57323. * The color applied when light is emitted from a material.
  57324. */
  57325. protected _emissiveColor: Color3;
  57326. /**
  57327. * AKA Glossiness in other nomenclature.
  57328. */
  57329. protected _microSurface: number;
  57330. /**
  57331. * Specifies that the material will use the light map as a show map.
  57332. */
  57333. protected _useLightmapAsShadowmap: boolean;
  57334. /**
  57335. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57336. * makes the reflect vector face the model (under horizon).
  57337. */
  57338. protected _useHorizonOcclusion: boolean;
  57339. /**
  57340. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57341. * too much the area relying on ambient texture to define their ambient occlusion.
  57342. */
  57343. protected _useRadianceOcclusion: boolean;
  57344. /**
  57345. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57346. */
  57347. protected _useAlphaFromAlbedoTexture: boolean;
  57348. /**
  57349. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57350. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57351. */
  57352. protected _useSpecularOverAlpha: boolean;
  57353. /**
  57354. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57355. */
  57356. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57357. /**
  57358. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57359. */
  57360. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57361. /**
  57362. * Specifies if the metallic texture contains the roughness information in its green channel.
  57363. */
  57364. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57365. /**
  57366. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57367. */
  57368. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57369. /**
  57370. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57371. */
  57372. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57373. /**
  57374. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57375. */
  57376. protected _useAmbientInGrayScale: boolean;
  57377. /**
  57378. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57379. * The material will try to infer what glossiness each pixel should be.
  57380. */
  57381. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57382. /**
  57383. * Defines the falloff type used in this material.
  57384. * It by default is Physical.
  57385. */
  57386. protected _lightFalloff: number;
  57387. /**
  57388. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57389. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57390. */
  57391. protected _useRadianceOverAlpha: boolean;
  57392. /**
  57393. * Allows using an object space normal map (instead of tangent space).
  57394. */
  57395. protected _useObjectSpaceNormalMap: boolean;
  57396. /**
  57397. * Allows using the bump map in parallax mode.
  57398. */
  57399. protected _useParallax: boolean;
  57400. /**
  57401. * Allows using the bump map in parallax occlusion mode.
  57402. */
  57403. protected _useParallaxOcclusion: boolean;
  57404. /**
  57405. * Controls the scale bias of the parallax mode.
  57406. */
  57407. protected _parallaxScaleBias: number;
  57408. /**
  57409. * If sets to true, disables all the lights affecting the material.
  57410. */
  57411. protected _disableLighting: boolean;
  57412. /**
  57413. * Number of Simultaneous lights allowed on the material.
  57414. */
  57415. protected _maxSimultaneousLights: number;
  57416. /**
  57417. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57418. */
  57419. protected _invertNormalMapX: boolean;
  57420. /**
  57421. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57422. */
  57423. protected _invertNormalMapY: boolean;
  57424. /**
  57425. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57426. */
  57427. protected _twoSidedLighting: boolean;
  57428. /**
  57429. * Defines the alpha limits in alpha test mode.
  57430. */
  57431. protected _alphaCutOff: number;
  57432. /**
  57433. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57434. */
  57435. protected _forceAlphaTest: boolean;
  57436. /**
  57437. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57438. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57439. */
  57440. protected _useAlphaFresnel: boolean;
  57441. /**
  57442. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57443. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57444. */
  57445. protected _useLinearAlphaFresnel: boolean;
  57446. /**
  57447. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57448. * from cos thetav and roughness:
  57449. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57450. */
  57451. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57452. /**
  57453. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57454. */
  57455. protected _forceIrradianceInFragment: boolean;
  57456. private _realTimeFiltering;
  57457. /**
  57458. * Enables realtime filtering on the texture.
  57459. */
  57460. get realTimeFiltering(): boolean;
  57461. set realTimeFiltering(b: boolean);
  57462. private _realTimeFilteringQuality;
  57463. /**
  57464. * Quality switch for realtime filtering
  57465. */
  57466. get realTimeFilteringQuality(): number;
  57467. set realTimeFilteringQuality(n: number);
  57468. /**
  57469. * Force normal to face away from face.
  57470. */
  57471. protected _forceNormalForward: boolean;
  57472. /**
  57473. * Enables specular anti aliasing in the PBR shader.
  57474. * It will both interacts on the Geometry for analytical and IBL lighting.
  57475. * It also prefilter the roughness map based on the bump values.
  57476. */
  57477. protected _enableSpecularAntiAliasing: boolean;
  57478. /**
  57479. * Default configuration related to image processing available in the PBR Material.
  57480. */
  57481. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57482. /**
  57483. * Keep track of the image processing observer to allow dispose and replace.
  57484. */
  57485. private _imageProcessingObserver;
  57486. /**
  57487. * Attaches a new image processing configuration to the PBR Material.
  57488. * @param configuration
  57489. */
  57490. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57491. /**
  57492. * Stores the available render targets.
  57493. */
  57494. private _renderTargets;
  57495. /**
  57496. * Sets the global ambient color for the material used in lighting calculations.
  57497. */
  57498. private _globalAmbientColor;
  57499. /**
  57500. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57501. */
  57502. private _useLogarithmicDepth;
  57503. /**
  57504. * If set to true, no lighting calculations will be applied.
  57505. */
  57506. private _unlit;
  57507. private _debugMode;
  57508. /**
  57509. * @hidden
  57510. * This is reserved for the inspector.
  57511. * Defines the material debug mode.
  57512. * It helps seeing only some components of the material while troubleshooting.
  57513. */
  57514. debugMode: number;
  57515. /**
  57516. * @hidden
  57517. * This is reserved for the inspector.
  57518. * Specify from where on screen the debug mode should start.
  57519. * The value goes from -1 (full screen) to 1 (not visible)
  57520. * It helps with side by side comparison against the final render
  57521. * This defaults to -1
  57522. */
  57523. private debugLimit;
  57524. /**
  57525. * @hidden
  57526. * This is reserved for the inspector.
  57527. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57528. * You can use the factor to better multiply the final value.
  57529. */
  57530. private debugFactor;
  57531. /**
  57532. * Defines the clear coat layer parameters for the material.
  57533. */
  57534. readonly clearCoat: PBRClearCoatConfiguration;
  57535. /**
  57536. * Defines the anisotropic parameters for the material.
  57537. */
  57538. readonly anisotropy: PBRAnisotropicConfiguration;
  57539. /**
  57540. * Defines the BRDF parameters for the material.
  57541. */
  57542. readonly brdf: PBRBRDFConfiguration;
  57543. /**
  57544. * Defines the Sheen parameters for the material.
  57545. */
  57546. readonly sheen: PBRSheenConfiguration;
  57547. /**
  57548. * Defines the SubSurface parameters for the material.
  57549. */
  57550. readonly subSurface: PBRSubSurfaceConfiguration;
  57551. protected _rebuildInParallel: boolean;
  57552. /**
  57553. * Instantiates a new PBRMaterial instance.
  57554. *
  57555. * @param name The material name
  57556. * @param scene The scene the material will be use in.
  57557. */
  57558. constructor(name: string, scene: Scene);
  57559. /**
  57560. * Gets a boolean indicating that current material needs to register RTT
  57561. */
  57562. get hasRenderTargetTextures(): boolean;
  57563. /**
  57564. * Gets the name of the material class.
  57565. */
  57566. getClassName(): string;
  57567. /**
  57568. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57569. */
  57570. get useLogarithmicDepth(): boolean;
  57571. /**
  57572. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57573. */
  57574. set useLogarithmicDepth(value: boolean);
  57575. /**
  57576. * Returns true if alpha blending should be disabled.
  57577. */
  57578. protected get _disableAlphaBlending(): boolean;
  57579. /**
  57580. * Specifies whether or not this material should be rendered in alpha blend mode.
  57581. */
  57582. needAlphaBlending(): boolean;
  57583. /**
  57584. * Specifies whether or not this material should be rendered in alpha test mode.
  57585. */
  57586. needAlphaTesting(): boolean;
  57587. /**
  57588. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57589. */
  57590. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57591. /**
  57592. * Gets the texture used for the alpha test.
  57593. */
  57594. getAlphaTestTexture(): Nullable<BaseTexture>;
  57595. /**
  57596. * Specifies that the submesh is ready to be used.
  57597. * @param mesh - BJS mesh.
  57598. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57599. * @param useInstances - Specifies that instances should be used.
  57600. * @returns - boolean indicating that the submesh is ready or not.
  57601. */
  57602. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57603. /**
  57604. * Specifies if the material uses metallic roughness workflow.
  57605. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57606. */
  57607. isMetallicWorkflow(): boolean;
  57608. private _prepareEffect;
  57609. private _prepareDefines;
  57610. /**
  57611. * Force shader compilation
  57612. */
  57613. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57614. /**
  57615. * Initializes the uniform buffer layout for the shader.
  57616. */
  57617. buildUniformLayout(): void;
  57618. /**
  57619. * Unbinds the material from the mesh
  57620. */
  57621. unbind(): void;
  57622. /**
  57623. * Binds the submesh data.
  57624. * @param world - The world matrix.
  57625. * @param mesh - The BJS mesh.
  57626. * @param subMesh - A submesh of the BJS mesh.
  57627. */
  57628. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57629. /**
  57630. * Returns the animatable textures.
  57631. * @returns - Array of animatable textures.
  57632. */
  57633. getAnimatables(): IAnimatable[];
  57634. /**
  57635. * Returns the texture used for reflections.
  57636. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57637. */
  57638. private _getReflectionTexture;
  57639. /**
  57640. * Returns an array of the actively used textures.
  57641. * @returns - Array of BaseTextures
  57642. */
  57643. getActiveTextures(): BaseTexture[];
  57644. /**
  57645. * Checks to see if a texture is used in the material.
  57646. * @param texture - Base texture to use.
  57647. * @returns - Boolean specifying if a texture is used in the material.
  57648. */
  57649. hasTexture(texture: BaseTexture): boolean;
  57650. /**
  57651. * Disposes the resources of the material.
  57652. * @param forceDisposeEffect - Forces the disposal of effects.
  57653. * @param forceDisposeTextures - Forces the disposal of all textures.
  57654. */
  57655. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57656. }
  57657. }
  57658. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  57659. import { Nullable } from "babylonjs/types";
  57660. import { Scene } from "babylonjs/scene";
  57661. import { Color3 } from "babylonjs/Maths/math.color";
  57662. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57663. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57665. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57666. /**
  57667. * The Physically based material of BJS.
  57668. *
  57669. * This offers the main features of a standard PBR material.
  57670. * For more information, please refer to the documentation :
  57671. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57672. */
  57673. export class PBRMaterial extends PBRBaseMaterial {
  57674. /**
  57675. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57676. */
  57677. static readonly PBRMATERIAL_OPAQUE: number;
  57678. /**
  57679. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57680. */
  57681. static readonly PBRMATERIAL_ALPHATEST: number;
  57682. /**
  57683. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57684. */
  57685. static readonly PBRMATERIAL_ALPHABLEND: number;
  57686. /**
  57687. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57688. * They are also discarded below the alpha cutoff threshold to improve performances.
  57689. */
  57690. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57691. /**
  57692. * Defines the default value of how much AO map is occluding the analytical lights
  57693. * (point spot...).
  57694. */
  57695. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57696. /**
  57697. * Intensity of the direct lights e.g. the four lights available in your scene.
  57698. * This impacts both the direct diffuse and specular highlights.
  57699. */
  57700. directIntensity: number;
  57701. /**
  57702. * Intensity of the emissive part of the material.
  57703. * This helps controlling the emissive effect without modifying the emissive color.
  57704. */
  57705. emissiveIntensity: number;
  57706. /**
  57707. * Intensity of the environment e.g. how much the environment will light the object
  57708. * either through harmonics for rough material or through the refelction for shiny ones.
  57709. */
  57710. environmentIntensity: number;
  57711. /**
  57712. * This is a special control allowing the reduction of the specular highlights coming from the
  57713. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57714. */
  57715. specularIntensity: number;
  57716. /**
  57717. * Debug Control allowing disabling the bump map on this material.
  57718. */
  57719. disableBumpMap: boolean;
  57720. /**
  57721. * AKA Diffuse Texture in standard nomenclature.
  57722. */
  57723. albedoTexture: BaseTexture;
  57724. /**
  57725. * AKA Occlusion Texture in other nomenclature.
  57726. */
  57727. ambientTexture: BaseTexture;
  57728. /**
  57729. * AKA Occlusion Texture Intensity in other nomenclature.
  57730. */
  57731. ambientTextureStrength: number;
  57732. /**
  57733. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57734. * 1 means it completely occludes it
  57735. * 0 mean it has no impact
  57736. */
  57737. ambientTextureImpactOnAnalyticalLights: number;
  57738. /**
  57739. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57740. */
  57741. opacityTexture: BaseTexture;
  57742. /**
  57743. * Stores the reflection values in a texture.
  57744. */
  57745. reflectionTexture: Nullable<BaseTexture>;
  57746. /**
  57747. * Stores the emissive values in a texture.
  57748. */
  57749. emissiveTexture: BaseTexture;
  57750. /**
  57751. * AKA Specular texture in other nomenclature.
  57752. */
  57753. reflectivityTexture: BaseTexture;
  57754. /**
  57755. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57756. */
  57757. metallicTexture: BaseTexture;
  57758. /**
  57759. * Specifies the metallic scalar of the metallic/roughness workflow.
  57760. * Can also be used to scale the metalness values of the metallic texture.
  57761. */
  57762. metallic: Nullable<number>;
  57763. /**
  57764. * Specifies the roughness scalar of the metallic/roughness workflow.
  57765. * Can also be used to scale the roughness values of the metallic texture.
  57766. */
  57767. roughness: Nullable<number>;
  57768. /**
  57769. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57770. * By default the indexOfrefraction is used to compute F0;
  57771. *
  57772. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57773. *
  57774. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57775. * F90 = metallicReflectanceColor;
  57776. */
  57777. metallicF0Factor: number;
  57778. /**
  57779. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57780. * By default the F90 is always 1;
  57781. *
  57782. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57783. *
  57784. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57785. * F90 = metallicReflectanceColor;
  57786. */
  57787. metallicReflectanceColor: Color3;
  57788. /**
  57789. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57790. * This is multiply against the scalar values defined in the material.
  57791. */
  57792. metallicReflectanceTexture: Nullable<BaseTexture>;
  57793. /**
  57794. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57795. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57796. */
  57797. microSurfaceTexture: BaseTexture;
  57798. /**
  57799. * Stores surface normal data used to displace a mesh in a texture.
  57800. */
  57801. bumpTexture: BaseTexture;
  57802. /**
  57803. * Stores the pre-calculated light information of a mesh in a texture.
  57804. */
  57805. lightmapTexture: BaseTexture;
  57806. /**
  57807. * Stores the refracted light information in a texture.
  57808. */
  57809. get refractionTexture(): Nullable<BaseTexture>;
  57810. set refractionTexture(value: Nullable<BaseTexture>);
  57811. /**
  57812. * The color of a material in ambient lighting.
  57813. */
  57814. ambientColor: Color3;
  57815. /**
  57816. * AKA Diffuse Color in other nomenclature.
  57817. */
  57818. albedoColor: Color3;
  57819. /**
  57820. * AKA Specular Color in other nomenclature.
  57821. */
  57822. reflectivityColor: Color3;
  57823. /**
  57824. * The color reflected from the material.
  57825. */
  57826. reflectionColor: Color3;
  57827. /**
  57828. * The color emitted from the material.
  57829. */
  57830. emissiveColor: Color3;
  57831. /**
  57832. * AKA Glossiness in other nomenclature.
  57833. */
  57834. microSurface: number;
  57835. /**
  57836. * Index of refraction of the material base layer.
  57837. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57838. *
  57839. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57840. *
  57841. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57842. */
  57843. get indexOfRefraction(): number;
  57844. set indexOfRefraction(value: number);
  57845. /**
  57846. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57847. */
  57848. get invertRefractionY(): boolean;
  57849. set invertRefractionY(value: boolean);
  57850. /**
  57851. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57852. * Materials half opaque for instance using refraction could benefit from this control.
  57853. */
  57854. get linkRefractionWithTransparency(): boolean;
  57855. set linkRefractionWithTransparency(value: boolean);
  57856. /**
  57857. * If true, the light map contains occlusion information instead of lighting info.
  57858. */
  57859. useLightmapAsShadowmap: boolean;
  57860. /**
  57861. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57862. */
  57863. useAlphaFromAlbedoTexture: boolean;
  57864. /**
  57865. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57866. */
  57867. forceAlphaTest: boolean;
  57868. /**
  57869. * Defines the alpha limits in alpha test mode.
  57870. */
  57871. alphaCutOff: number;
  57872. /**
  57873. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57874. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57875. */
  57876. useSpecularOverAlpha: boolean;
  57877. /**
  57878. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57879. */
  57880. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57881. /**
  57882. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57883. */
  57884. useRoughnessFromMetallicTextureAlpha: boolean;
  57885. /**
  57886. * Specifies if the metallic texture contains the roughness information in its green channel.
  57887. */
  57888. useRoughnessFromMetallicTextureGreen: boolean;
  57889. /**
  57890. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57891. */
  57892. useMetallnessFromMetallicTextureBlue: boolean;
  57893. /**
  57894. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57895. */
  57896. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57897. /**
  57898. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57899. */
  57900. useAmbientInGrayScale: boolean;
  57901. /**
  57902. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57903. * The material will try to infer what glossiness each pixel should be.
  57904. */
  57905. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57906. /**
  57907. * BJS is using an harcoded light falloff based on a manually sets up range.
  57908. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57909. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57910. */
  57911. get usePhysicalLightFalloff(): boolean;
  57912. /**
  57913. * BJS is using an harcoded light falloff based on a manually sets up range.
  57914. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57915. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57916. */
  57917. set usePhysicalLightFalloff(value: boolean);
  57918. /**
  57919. * In order to support the falloff compatibility with gltf, a special mode has been added
  57920. * to reproduce the gltf light falloff.
  57921. */
  57922. get useGLTFLightFalloff(): boolean;
  57923. /**
  57924. * In order to support the falloff compatibility with gltf, a special mode has been added
  57925. * to reproduce the gltf light falloff.
  57926. */
  57927. set useGLTFLightFalloff(value: boolean);
  57928. /**
  57929. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57930. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57931. */
  57932. useRadianceOverAlpha: boolean;
  57933. /**
  57934. * Allows using an object space normal map (instead of tangent space).
  57935. */
  57936. useObjectSpaceNormalMap: boolean;
  57937. /**
  57938. * Allows using the bump map in parallax mode.
  57939. */
  57940. useParallax: boolean;
  57941. /**
  57942. * Allows using the bump map in parallax occlusion mode.
  57943. */
  57944. useParallaxOcclusion: boolean;
  57945. /**
  57946. * Controls the scale bias of the parallax mode.
  57947. */
  57948. parallaxScaleBias: number;
  57949. /**
  57950. * If sets to true, disables all the lights affecting the material.
  57951. */
  57952. disableLighting: boolean;
  57953. /**
  57954. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57955. */
  57956. forceIrradianceInFragment: boolean;
  57957. /**
  57958. * Number of Simultaneous lights allowed on the material.
  57959. */
  57960. maxSimultaneousLights: number;
  57961. /**
  57962. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57963. */
  57964. invertNormalMapX: boolean;
  57965. /**
  57966. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57967. */
  57968. invertNormalMapY: boolean;
  57969. /**
  57970. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57971. */
  57972. twoSidedLighting: boolean;
  57973. /**
  57974. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57975. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57976. */
  57977. useAlphaFresnel: boolean;
  57978. /**
  57979. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57980. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57981. */
  57982. useLinearAlphaFresnel: boolean;
  57983. /**
  57984. * Let user defines the brdf lookup texture used for IBL.
  57985. * A default 8bit version is embedded but you could point at :
  57986. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57987. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57988. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57989. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57990. */
  57991. environmentBRDFTexture: Nullable<BaseTexture>;
  57992. /**
  57993. * Force normal to face away from face.
  57994. */
  57995. forceNormalForward: boolean;
  57996. /**
  57997. * Enables specular anti aliasing in the PBR shader.
  57998. * It will both interacts on the Geometry for analytical and IBL lighting.
  57999. * It also prefilter the roughness map based on the bump values.
  58000. */
  58001. enableSpecularAntiAliasing: boolean;
  58002. /**
  58003. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58004. * makes the reflect vector face the model (under horizon).
  58005. */
  58006. useHorizonOcclusion: boolean;
  58007. /**
  58008. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58009. * too much the area relying on ambient texture to define their ambient occlusion.
  58010. */
  58011. useRadianceOcclusion: boolean;
  58012. /**
  58013. * If set to true, no lighting calculations will be applied.
  58014. */
  58015. unlit: boolean;
  58016. /**
  58017. * Gets the image processing configuration used either in this material.
  58018. */
  58019. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58020. /**
  58021. * Sets the Default image processing configuration used either in the this material.
  58022. *
  58023. * If sets to null, the scene one is in use.
  58024. */
  58025. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58026. /**
  58027. * Gets wether the color curves effect is enabled.
  58028. */
  58029. get cameraColorCurvesEnabled(): boolean;
  58030. /**
  58031. * Sets wether the color curves effect is enabled.
  58032. */
  58033. set cameraColorCurvesEnabled(value: boolean);
  58034. /**
  58035. * Gets wether the color grading effect is enabled.
  58036. */
  58037. get cameraColorGradingEnabled(): boolean;
  58038. /**
  58039. * Gets wether the color grading effect is enabled.
  58040. */
  58041. set cameraColorGradingEnabled(value: boolean);
  58042. /**
  58043. * Gets wether tonemapping is enabled or not.
  58044. */
  58045. get cameraToneMappingEnabled(): boolean;
  58046. /**
  58047. * Sets wether tonemapping is enabled or not
  58048. */
  58049. set cameraToneMappingEnabled(value: boolean);
  58050. /**
  58051. * The camera exposure used on this material.
  58052. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58053. * This corresponds to a photographic exposure.
  58054. */
  58055. get cameraExposure(): number;
  58056. /**
  58057. * The camera exposure used on this material.
  58058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58059. * This corresponds to a photographic exposure.
  58060. */
  58061. set cameraExposure(value: number);
  58062. /**
  58063. * Gets The camera contrast used on this material.
  58064. */
  58065. get cameraContrast(): number;
  58066. /**
  58067. * Sets The camera contrast used on this material.
  58068. */
  58069. set cameraContrast(value: number);
  58070. /**
  58071. * Gets the Color Grading 2D Lookup Texture.
  58072. */
  58073. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58074. /**
  58075. * Sets the Color Grading 2D Lookup Texture.
  58076. */
  58077. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58078. /**
  58079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58081. * 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;
  58082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58083. */
  58084. get cameraColorCurves(): Nullable<ColorCurves>;
  58085. /**
  58086. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58087. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58088. * 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;
  58089. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58090. */
  58091. set cameraColorCurves(value: Nullable<ColorCurves>);
  58092. /**
  58093. * Instantiates a new PBRMaterial instance.
  58094. *
  58095. * @param name The material name
  58096. * @param scene The scene the material will be use in.
  58097. */
  58098. constructor(name: string, scene: Scene);
  58099. /**
  58100. * Returns the name of this material class.
  58101. */
  58102. getClassName(): string;
  58103. /**
  58104. * Makes a duplicate of the current material.
  58105. * @param name - name to use for the new material.
  58106. */
  58107. clone(name: string): PBRMaterial;
  58108. /**
  58109. * Serializes this PBR Material.
  58110. * @returns - An object with the serialized material.
  58111. */
  58112. serialize(): any;
  58113. /**
  58114. * Parses a PBR Material from a serialized object.
  58115. * @param source - Serialized object.
  58116. * @param scene - BJS scene instance.
  58117. * @param rootUrl - url for the scene object
  58118. * @returns - PBRMaterial
  58119. */
  58120. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58121. }
  58122. }
  58123. declare module "babylonjs/Misc/dds" {
  58124. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58126. import { Nullable } from "babylonjs/types";
  58127. import { Scene } from "babylonjs/scene";
  58128. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58129. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58130. /**
  58131. * Direct draw surface info
  58132. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58133. */
  58134. export interface DDSInfo {
  58135. /**
  58136. * Width of the texture
  58137. */
  58138. width: number;
  58139. /**
  58140. * Width of the texture
  58141. */
  58142. height: number;
  58143. /**
  58144. * Number of Mipmaps for the texture
  58145. * @see https://en.wikipedia.org/wiki/Mipmap
  58146. */
  58147. mipmapCount: number;
  58148. /**
  58149. * If the textures format is a known fourCC format
  58150. * @see https://www.fourcc.org/
  58151. */
  58152. isFourCC: boolean;
  58153. /**
  58154. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58155. */
  58156. isRGB: boolean;
  58157. /**
  58158. * If the texture is a lumincance format
  58159. */
  58160. isLuminance: boolean;
  58161. /**
  58162. * If this is a cube texture
  58163. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58164. */
  58165. isCube: boolean;
  58166. /**
  58167. * If the texture is a compressed format eg. FOURCC_DXT1
  58168. */
  58169. isCompressed: boolean;
  58170. /**
  58171. * The dxgiFormat of the texture
  58172. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58173. */
  58174. dxgiFormat: number;
  58175. /**
  58176. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58177. */
  58178. textureType: number;
  58179. /**
  58180. * Sphericle polynomial created for the dds texture
  58181. */
  58182. sphericalPolynomial?: SphericalPolynomial;
  58183. }
  58184. /**
  58185. * Class used to provide DDS decompression tools
  58186. */
  58187. export class DDSTools {
  58188. /**
  58189. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58190. */
  58191. static StoreLODInAlphaChannel: boolean;
  58192. /**
  58193. * Gets DDS information from an array buffer
  58194. * @param data defines the array buffer view to read data from
  58195. * @returns the DDS information
  58196. */
  58197. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58198. private static _FloatView;
  58199. private static _Int32View;
  58200. private static _ToHalfFloat;
  58201. private static _FromHalfFloat;
  58202. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58203. private static _GetHalfFloatRGBAArrayBuffer;
  58204. private static _GetFloatRGBAArrayBuffer;
  58205. private static _GetFloatAsUIntRGBAArrayBuffer;
  58206. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58207. private static _GetRGBAArrayBuffer;
  58208. private static _ExtractLongWordOrder;
  58209. private static _GetRGBArrayBuffer;
  58210. private static _GetLuminanceArrayBuffer;
  58211. /**
  58212. * Uploads DDS Levels to a Babylon Texture
  58213. * @hidden
  58214. */
  58215. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58216. }
  58217. module "babylonjs/Engines/thinEngine" {
  58218. interface ThinEngine {
  58219. /**
  58220. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58221. * @param rootUrl defines the url where the file to load is located
  58222. * @param scene defines the current scene
  58223. * @param lodScale defines scale to apply to the mip map selection
  58224. * @param lodOffset defines offset to apply to the mip map selection
  58225. * @param onLoad defines an optional callback raised when the texture is loaded
  58226. * @param onError defines an optional callback raised if there is an issue to load the texture
  58227. * @param format defines the format of the data
  58228. * @param forcedExtension defines the extension to use to pick the right loader
  58229. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58230. * @returns the cube texture as an InternalTexture
  58231. */
  58232. 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;
  58233. }
  58234. }
  58235. }
  58236. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58237. import { Nullable } from "babylonjs/types";
  58238. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58239. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58240. /**
  58241. * Implementation of the DDS Texture Loader.
  58242. * @hidden
  58243. */
  58244. export class _DDSTextureLoader implements IInternalTextureLoader {
  58245. /**
  58246. * Defines wether the loader supports cascade loading the different faces.
  58247. */
  58248. readonly supportCascades: boolean;
  58249. /**
  58250. * This returns if the loader support the current file information.
  58251. * @param extension defines the file extension of the file being loaded
  58252. * @returns true if the loader can load the specified file
  58253. */
  58254. canLoad(extension: string): boolean;
  58255. /**
  58256. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58257. * @param data contains the texture data
  58258. * @param texture defines the BabylonJS internal texture
  58259. * @param createPolynomials will be true if polynomials have been requested
  58260. * @param onLoad defines the callback to trigger once the texture is ready
  58261. * @param onError defines the callback to trigger in case of error
  58262. */
  58263. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58264. /**
  58265. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58266. * @param data contains the texture data
  58267. * @param texture defines the BabylonJS internal texture
  58268. * @param callback defines the method to call once ready to upload
  58269. */
  58270. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58271. }
  58272. }
  58273. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58274. import { Nullable } from "babylonjs/types";
  58275. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58276. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58277. /**
  58278. * Implementation of the ENV Texture Loader.
  58279. * @hidden
  58280. */
  58281. export class _ENVTextureLoader implements IInternalTextureLoader {
  58282. /**
  58283. * Defines wether the loader supports cascade loading the different faces.
  58284. */
  58285. readonly supportCascades: boolean;
  58286. /**
  58287. * This returns if the loader support the current file information.
  58288. * @param extension defines the file extension of the file being loaded
  58289. * @returns true if the loader can load the specified file
  58290. */
  58291. canLoad(extension: string): boolean;
  58292. /**
  58293. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58294. * @param data contains the texture data
  58295. * @param texture defines the BabylonJS internal texture
  58296. * @param createPolynomials will be true if polynomials have been requested
  58297. * @param onLoad defines the callback to trigger once the texture is ready
  58298. * @param onError defines the callback to trigger in case of error
  58299. */
  58300. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58301. /**
  58302. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58303. * @param data contains the texture data
  58304. * @param texture defines the BabylonJS internal texture
  58305. * @param callback defines the method to call once ready to upload
  58306. */
  58307. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58308. }
  58309. }
  58310. declare module "babylonjs/Misc/khronosTextureContainer" {
  58311. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58312. /**
  58313. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58314. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58315. */
  58316. export class KhronosTextureContainer {
  58317. /** contents of the KTX container file */
  58318. data: ArrayBufferView;
  58319. private static HEADER_LEN;
  58320. private static COMPRESSED_2D;
  58321. private static COMPRESSED_3D;
  58322. private static TEX_2D;
  58323. private static TEX_3D;
  58324. /**
  58325. * Gets the openGL type
  58326. */
  58327. glType: number;
  58328. /**
  58329. * Gets the openGL type size
  58330. */
  58331. glTypeSize: number;
  58332. /**
  58333. * Gets the openGL format
  58334. */
  58335. glFormat: number;
  58336. /**
  58337. * Gets the openGL internal format
  58338. */
  58339. glInternalFormat: number;
  58340. /**
  58341. * Gets the base internal format
  58342. */
  58343. glBaseInternalFormat: number;
  58344. /**
  58345. * Gets image width in pixel
  58346. */
  58347. pixelWidth: number;
  58348. /**
  58349. * Gets image height in pixel
  58350. */
  58351. pixelHeight: number;
  58352. /**
  58353. * Gets image depth in pixels
  58354. */
  58355. pixelDepth: number;
  58356. /**
  58357. * Gets the number of array elements
  58358. */
  58359. numberOfArrayElements: number;
  58360. /**
  58361. * Gets the number of faces
  58362. */
  58363. numberOfFaces: number;
  58364. /**
  58365. * Gets the number of mipmap levels
  58366. */
  58367. numberOfMipmapLevels: number;
  58368. /**
  58369. * Gets the bytes of key value data
  58370. */
  58371. bytesOfKeyValueData: number;
  58372. /**
  58373. * Gets the load type
  58374. */
  58375. loadType: number;
  58376. /**
  58377. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58378. */
  58379. isInvalid: boolean;
  58380. /**
  58381. * Creates a new KhronosTextureContainer
  58382. * @param data contents of the KTX container file
  58383. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58384. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58385. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58386. */
  58387. constructor(
  58388. /** contents of the KTX container file */
  58389. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58390. /**
  58391. * Uploads KTX content to a Babylon Texture.
  58392. * It is assumed that the texture has already been created & is currently bound
  58393. * @hidden
  58394. */
  58395. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58396. private _upload2DCompressedLevels;
  58397. /**
  58398. * Checks if the given data starts with a KTX file identifier.
  58399. * @param data the data to check
  58400. * @returns true if the data is a KTX file or false otherwise
  58401. */
  58402. static IsValid(data: ArrayBufferView): boolean;
  58403. }
  58404. }
  58405. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58406. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58407. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58408. /**
  58409. * Class for loading KTX2 files
  58410. * !!! Experimental Extension Subject to Changes !!!
  58411. * @hidden
  58412. */
  58413. export class KhronosTextureContainer2 {
  58414. private static _ModulePromise;
  58415. private static _TranscodeFormat;
  58416. constructor(engine: ThinEngine);
  58417. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58418. private _determineTranscodeFormat;
  58419. /**
  58420. * Checks if the given data starts with a KTX2 file identifier.
  58421. * @param data the data to check
  58422. * @returns true if the data is a KTX2 file or false otherwise
  58423. */
  58424. static IsValid(data: ArrayBufferView): boolean;
  58425. }
  58426. }
  58427. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58428. import { Nullable } from "babylonjs/types";
  58429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58430. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58431. /**
  58432. * Implementation of the KTX Texture Loader.
  58433. * @hidden
  58434. */
  58435. export class _KTXTextureLoader implements IInternalTextureLoader {
  58436. /**
  58437. * Defines wether the loader supports cascade loading the different faces.
  58438. */
  58439. readonly supportCascades: boolean;
  58440. /**
  58441. * This returns if the loader support the current file information.
  58442. * @param extension defines the file extension of the file being loaded
  58443. * @returns true if the loader can load the specified file
  58444. */
  58445. canLoad(extension: string): boolean;
  58446. /**
  58447. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58448. * @param data contains the texture data
  58449. * @param texture defines the BabylonJS internal texture
  58450. * @param createPolynomials will be true if polynomials have been requested
  58451. * @param onLoad defines the callback to trigger once the texture is ready
  58452. * @param onError defines the callback to trigger in case of error
  58453. */
  58454. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58455. /**
  58456. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58457. * @param data contains the texture data
  58458. * @param texture defines the BabylonJS internal texture
  58459. * @param callback defines the method to call once ready to upload
  58460. */
  58461. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58462. }
  58463. }
  58464. declare module "babylonjs/Helpers/sceneHelpers" {
  58465. import { Nullable } from "babylonjs/types";
  58466. import { Mesh } from "babylonjs/Meshes/mesh";
  58467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58468. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58469. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58470. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58471. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58472. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58473. import "babylonjs/Meshes/Builders/boxBuilder";
  58474. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58475. /** @hidden */
  58476. export var _forceSceneHelpersToBundle: boolean;
  58477. module "babylonjs/scene" {
  58478. interface Scene {
  58479. /**
  58480. * Creates a default light for the scene.
  58481. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58482. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58483. */
  58484. createDefaultLight(replace?: boolean): void;
  58485. /**
  58486. * Creates a default camera for the scene.
  58487. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58488. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58489. * @param replace has default false, when true replaces the active camera in the scene
  58490. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58491. */
  58492. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58493. /**
  58494. * Creates a default camera and a default light.
  58495. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58496. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58497. * @param replace has the default false, when true replaces the active camera/light in the scene
  58498. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58499. */
  58500. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58501. /**
  58502. * Creates a new sky box
  58503. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58504. * @param environmentTexture defines the texture to use as environment texture
  58505. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58506. * @param scale defines the overall scale of the skybox
  58507. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58508. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58509. * @returns a new mesh holding the sky box
  58510. */
  58511. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58512. /**
  58513. * Creates a new environment
  58514. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58515. * @param options defines the options you can use to configure the environment
  58516. * @returns the new EnvironmentHelper
  58517. */
  58518. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58519. /**
  58520. * Creates a new VREXperienceHelper
  58521. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58522. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58523. * @returns a new VREXperienceHelper
  58524. */
  58525. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58526. /**
  58527. * Creates a new WebXRDefaultExperience
  58528. * @see http://doc.babylonjs.com/how_to/webxr
  58529. * @param options experience options
  58530. * @returns a promise for a new WebXRDefaultExperience
  58531. */
  58532. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58533. }
  58534. }
  58535. }
  58536. declare module "babylonjs/Helpers/videoDome" {
  58537. import { Scene } from "babylonjs/scene";
  58538. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58539. import { Mesh } from "babylonjs/Meshes/mesh";
  58540. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58541. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58542. import "babylonjs/Meshes/Builders/sphereBuilder";
  58543. /**
  58544. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58545. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58546. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58547. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58548. */
  58549. export class VideoDome extends TransformNode {
  58550. /**
  58551. * Define the video source as a Monoscopic panoramic 360 video.
  58552. */
  58553. static readonly MODE_MONOSCOPIC: number;
  58554. /**
  58555. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58556. */
  58557. static readonly MODE_TOPBOTTOM: number;
  58558. /**
  58559. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58560. */
  58561. static readonly MODE_SIDEBYSIDE: number;
  58562. private _halfDome;
  58563. private _useDirectMapping;
  58564. /**
  58565. * The video texture being displayed on the sphere
  58566. */
  58567. protected _videoTexture: VideoTexture;
  58568. /**
  58569. * Gets the video texture being displayed on the sphere
  58570. */
  58571. get videoTexture(): VideoTexture;
  58572. /**
  58573. * The skybox material
  58574. */
  58575. protected _material: BackgroundMaterial;
  58576. /**
  58577. * The surface used for the skybox
  58578. */
  58579. protected _mesh: Mesh;
  58580. /**
  58581. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  58582. */
  58583. private _halfDomeMask;
  58584. /**
  58585. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58586. * Also see the options.resolution property.
  58587. */
  58588. get fovMultiplier(): number;
  58589. set fovMultiplier(value: number);
  58590. private _videoMode;
  58591. /**
  58592. * Gets or set the current video mode for the video. It can be:
  58593. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  58594. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58595. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58596. */
  58597. get videoMode(): number;
  58598. set videoMode(value: number);
  58599. /**
  58600. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  58601. *
  58602. */
  58603. get halfDome(): boolean;
  58604. /**
  58605. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58606. */
  58607. set halfDome(enabled: boolean);
  58608. /**
  58609. * Oberserver used in Stereoscopic VR Mode.
  58610. */
  58611. private _onBeforeCameraRenderObserver;
  58612. /**
  58613. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  58614. * @param name Element's name, child elements will append suffixes for their own names.
  58615. * @param urlsOrVideo defines the url(s) or the video element to use
  58616. * @param options An object containing optional or exposed sub element properties
  58617. */
  58618. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  58619. resolution?: number;
  58620. clickToPlay?: boolean;
  58621. autoPlay?: boolean;
  58622. loop?: boolean;
  58623. size?: number;
  58624. poster?: string;
  58625. faceForward?: boolean;
  58626. useDirectMapping?: boolean;
  58627. halfDomeMode?: boolean;
  58628. }, scene: Scene);
  58629. private _changeVideoMode;
  58630. /**
  58631. * Releases resources associated with this node.
  58632. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58633. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58634. */
  58635. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58636. }
  58637. }
  58638. declare module "babylonjs/Helpers/index" {
  58639. export * from "babylonjs/Helpers/environmentHelper";
  58640. export * from "babylonjs/Helpers/photoDome";
  58641. export * from "babylonjs/Helpers/sceneHelpers";
  58642. export * from "babylonjs/Helpers/videoDome";
  58643. }
  58644. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  58645. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58646. import { IDisposable } from "babylonjs/scene";
  58647. import { Engine } from "babylonjs/Engines/engine";
  58648. /**
  58649. * This class can be used to get instrumentation data from a Babylon engine
  58650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58651. */
  58652. export class EngineInstrumentation implements IDisposable {
  58653. /**
  58654. * Define the instrumented engine.
  58655. */
  58656. engine: Engine;
  58657. private _captureGPUFrameTime;
  58658. private _gpuFrameTimeToken;
  58659. private _gpuFrameTime;
  58660. private _captureShaderCompilationTime;
  58661. private _shaderCompilationTime;
  58662. private _onBeginFrameObserver;
  58663. private _onEndFrameObserver;
  58664. private _onBeforeShaderCompilationObserver;
  58665. private _onAfterShaderCompilationObserver;
  58666. /**
  58667. * Gets the perf counter used for GPU frame time
  58668. */
  58669. get gpuFrameTimeCounter(): PerfCounter;
  58670. /**
  58671. * Gets the GPU frame time capture status
  58672. */
  58673. get captureGPUFrameTime(): boolean;
  58674. /**
  58675. * Enable or disable the GPU frame time capture
  58676. */
  58677. set captureGPUFrameTime(value: boolean);
  58678. /**
  58679. * Gets the perf counter used for shader compilation time
  58680. */
  58681. get shaderCompilationTimeCounter(): PerfCounter;
  58682. /**
  58683. * Gets the shader compilation time capture status
  58684. */
  58685. get captureShaderCompilationTime(): boolean;
  58686. /**
  58687. * Enable or disable the shader compilation time capture
  58688. */
  58689. set captureShaderCompilationTime(value: boolean);
  58690. /**
  58691. * Instantiates a new engine instrumentation.
  58692. * This class can be used to get instrumentation data from a Babylon engine
  58693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58694. * @param engine Defines the engine to instrument
  58695. */
  58696. constructor(
  58697. /**
  58698. * Define the instrumented engine.
  58699. */
  58700. engine: Engine);
  58701. /**
  58702. * Dispose and release associated resources.
  58703. */
  58704. dispose(): void;
  58705. }
  58706. }
  58707. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  58708. import { Scene, IDisposable } from "babylonjs/scene";
  58709. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58710. /**
  58711. * This class can be used to get instrumentation data from a Babylon engine
  58712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58713. */
  58714. export class SceneInstrumentation implements IDisposable {
  58715. /**
  58716. * Defines the scene to instrument
  58717. */
  58718. scene: Scene;
  58719. private _captureActiveMeshesEvaluationTime;
  58720. private _activeMeshesEvaluationTime;
  58721. private _captureRenderTargetsRenderTime;
  58722. private _renderTargetsRenderTime;
  58723. private _captureFrameTime;
  58724. private _frameTime;
  58725. private _captureRenderTime;
  58726. private _renderTime;
  58727. private _captureInterFrameTime;
  58728. private _interFrameTime;
  58729. private _captureParticlesRenderTime;
  58730. private _particlesRenderTime;
  58731. private _captureSpritesRenderTime;
  58732. private _spritesRenderTime;
  58733. private _capturePhysicsTime;
  58734. private _physicsTime;
  58735. private _captureAnimationsTime;
  58736. private _animationsTime;
  58737. private _captureCameraRenderTime;
  58738. private _cameraRenderTime;
  58739. private _onBeforeActiveMeshesEvaluationObserver;
  58740. private _onAfterActiveMeshesEvaluationObserver;
  58741. private _onBeforeRenderTargetsRenderObserver;
  58742. private _onAfterRenderTargetsRenderObserver;
  58743. private _onAfterRenderObserver;
  58744. private _onBeforeDrawPhaseObserver;
  58745. private _onAfterDrawPhaseObserver;
  58746. private _onBeforeAnimationsObserver;
  58747. private _onBeforeParticlesRenderingObserver;
  58748. private _onAfterParticlesRenderingObserver;
  58749. private _onBeforeSpritesRenderingObserver;
  58750. private _onAfterSpritesRenderingObserver;
  58751. private _onBeforePhysicsObserver;
  58752. private _onAfterPhysicsObserver;
  58753. private _onAfterAnimationsObserver;
  58754. private _onBeforeCameraRenderObserver;
  58755. private _onAfterCameraRenderObserver;
  58756. /**
  58757. * Gets the perf counter used for active meshes evaluation time
  58758. */
  58759. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58760. /**
  58761. * Gets the active meshes evaluation time capture status
  58762. */
  58763. get captureActiveMeshesEvaluationTime(): boolean;
  58764. /**
  58765. * Enable or disable the active meshes evaluation time capture
  58766. */
  58767. set captureActiveMeshesEvaluationTime(value: boolean);
  58768. /**
  58769. * Gets the perf counter used for render targets render time
  58770. */
  58771. get renderTargetsRenderTimeCounter(): PerfCounter;
  58772. /**
  58773. * Gets the render targets render time capture status
  58774. */
  58775. get captureRenderTargetsRenderTime(): boolean;
  58776. /**
  58777. * Enable or disable the render targets render time capture
  58778. */
  58779. set captureRenderTargetsRenderTime(value: boolean);
  58780. /**
  58781. * Gets the perf counter used for particles render time
  58782. */
  58783. get particlesRenderTimeCounter(): PerfCounter;
  58784. /**
  58785. * Gets the particles render time capture status
  58786. */
  58787. get captureParticlesRenderTime(): boolean;
  58788. /**
  58789. * Enable or disable the particles render time capture
  58790. */
  58791. set captureParticlesRenderTime(value: boolean);
  58792. /**
  58793. * Gets the perf counter used for sprites render time
  58794. */
  58795. get spritesRenderTimeCounter(): PerfCounter;
  58796. /**
  58797. * Gets the sprites render time capture status
  58798. */
  58799. get captureSpritesRenderTime(): boolean;
  58800. /**
  58801. * Enable or disable the sprites render time capture
  58802. */
  58803. set captureSpritesRenderTime(value: boolean);
  58804. /**
  58805. * Gets the perf counter used for physics time
  58806. */
  58807. get physicsTimeCounter(): PerfCounter;
  58808. /**
  58809. * Gets the physics time capture status
  58810. */
  58811. get capturePhysicsTime(): boolean;
  58812. /**
  58813. * Enable or disable the physics time capture
  58814. */
  58815. set capturePhysicsTime(value: boolean);
  58816. /**
  58817. * Gets the perf counter used for animations time
  58818. */
  58819. get animationsTimeCounter(): PerfCounter;
  58820. /**
  58821. * Gets the animations time capture status
  58822. */
  58823. get captureAnimationsTime(): boolean;
  58824. /**
  58825. * Enable or disable the animations time capture
  58826. */
  58827. set captureAnimationsTime(value: boolean);
  58828. /**
  58829. * Gets the perf counter used for frame time capture
  58830. */
  58831. get frameTimeCounter(): PerfCounter;
  58832. /**
  58833. * Gets the frame time capture status
  58834. */
  58835. get captureFrameTime(): boolean;
  58836. /**
  58837. * Enable or disable the frame time capture
  58838. */
  58839. set captureFrameTime(value: boolean);
  58840. /**
  58841. * Gets the perf counter used for inter-frames time capture
  58842. */
  58843. get interFrameTimeCounter(): PerfCounter;
  58844. /**
  58845. * Gets the inter-frames time capture status
  58846. */
  58847. get captureInterFrameTime(): boolean;
  58848. /**
  58849. * Enable or disable the inter-frames time capture
  58850. */
  58851. set captureInterFrameTime(value: boolean);
  58852. /**
  58853. * Gets the perf counter used for render time capture
  58854. */
  58855. get renderTimeCounter(): PerfCounter;
  58856. /**
  58857. * Gets the render time capture status
  58858. */
  58859. get captureRenderTime(): boolean;
  58860. /**
  58861. * Enable or disable the render time capture
  58862. */
  58863. set captureRenderTime(value: boolean);
  58864. /**
  58865. * Gets the perf counter used for camera render time capture
  58866. */
  58867. get cameraRenderTimeCounter(): PerfCounter;
  58868. /**
  58869. * Gets the camera render time capture status
  58870. */
  58871. get captureCameraRenderTime(): boolean;
  58872. /**
  58873. * Enable or disable the camera render time capture
  58874. */
  58875. set captureCameraRenderTime(value: boolean);
  58876. /**
  58877. * Gets the perf counter used for draw calls
  58878. */
  58879. get drawCallsCounter(): PerfCounter;
  58880. /**
  58881. * Instantiates a new scene instrumentation.
  58882. * This class can be used to get instrumentation data from a Babylon engine
  58883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58884. * @param scene Defines the scene to instrument
  58885. */
  58886. constructor(
  58887. /**
  58888. * Defines the scene to instrument
  58889. */
  58890. scene: Scene);
  58891. /**
  58892. * Dispose and release associated resources.
  58893. */
  58894. dispose(): void;
  58895. }
  58896. }
  58897. declare module "babylonjs/Instrumentation/index" {
  58898. export * from "babylonjs/Instrumentation/engineInstrumentation";
  58899. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  58900. export * from "babylonjs/Instrumentation/timeToken";
  58901. }
  58902. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  58903. /** @hidden */
  58904. export var glowMapGenerationPixelShader: {
  58905. name: string;
  58906. shader: string;
  58907. };
  58908. }
  58909. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  58910. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58911. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58913. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58914. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58915. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58916. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58917. /** @hidden */
  58918. export var glowMapGenerationVertexShader: {
  58919. name: string;
  58920. shader: string;
  58921. };
  58922. }
  58923. declare module "babylonjs/Layers/effectLayer" {
  58924. import { Observable } from "babylonjs/Misc/observable";
  58925. import { Nullable } from "babylonjs/types";
  58926. import { Camera } from "babylonjs/Cameras/camera";
  58927. import { Scene } from "babylonjs/scene";
  58928. import { ISize } from "babylonjs/Maths/math.size";
  58929. import { Color4 } from "babylonjs/Maths/math.color";
  58930. import { Engine } from "babylonjs/Engines/engine";
  58931. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58933. import { Mesh } from "babylonjs/Meshes/mesh";
  58934. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58936. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58937. import { Effect } from "babylonjs/Materials/effect";
  58938. import { Material } from "babylonjs/Materials/material";
  58939. import "babylonjs/Shaders/glowMapGeneration.fragment";
  58940. import "babylonjs/Shaders/glowMapGeneration.vertex";
  58941. /**
  58942. * Effect layer options. This helps customizing the behaviour
  58943. * of the effect layer.
  58944. */
  58945. export interface IEffectLayerOptions {
  58946. /**
  58947. * Multiplication factor apply to the canvas size to compute the render target size
  58948. * used to generated the objects (the smaller the faster).
  58949. */
  58950. mainTextureRatio: number;
  58951. /**
  58952. * Enforces a fixed size texture to ensure effect stability across devices.
  58953. */
  58954. mainTextureFixedSize?: number;
  58955. /**
  58956. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58957. */
  58958. alphaBlendingMode: number;
  58959. /**
  58960. * The camera attached to the layer.
  58961. */
  58962. camera: Nullable<Camera>;
  58963. /**
  58964. * The rendering group to draw the layer in.
  58965. */
  58966. renderingGroupId: number;
  58967. }
  58968. /**
  58969. * The effect layer Helps adding post process effect blended with the main pass.
  58970. *
  58971. * This can be for instance use to generate glow or higlight effects on the scene.
  58972. *
  58973. * The effect layer class can not be used directly and is intented to inherited from to be
  58974. * customized per effects.
  58975. */
  58976. export abstract class EffectLayer {
  58977. private _vertexBuffers;
  58978. private _indexBuffer;
  58979. private _cachedDefines;
  58980. private _effectLayerMapGenerationEffect;
  58981. private _effectLayerOptions;
  58982. private _mergeEffect;
  58983. protected _scene: Scene;
  58984. protected _engine: Engine;
  58985. protected _maxSize: number;
  58986. protected _mainTextureDesiredSize: ISize;
  58987. protected _mainTexture: RenderTargetTexture;
  58988. protected _shouldRender: boolean;
  58989. protected _postProcesses: PostProcess[];
  58990. protected _textures: BaseTexture[];
  58991. protected _emissiveTextureAndColor: {
  58992. texture: Nullable<BaseTexture>;
  58993. color: Color4;
  58994. };
  58995. /**
  58996. * The name of the layer
  58997. */
  58998. name: string;
  58999. /**
  59000. * The clear color of the texture used to generate the glow map.
  59001. */
  59002. neutralColor: Color4;
  59003. /**
  59004. * Specifies whether the highlight layer is enabled or not.
  59005. */
  59006. isEnabled: boolean;
  59007. /**
  59008. * Gets the camera attached to the layer.
  59009. */
  59010. get camera(): Nullable<Camera>;
  59011. /**
  59012. * Gets the rendering group id the layer should render in.
  59013. */
  59014. get renderingGroupId(): number;
  59015. set renderingGroupId(renderingGroupId: number);
  59016. /**
  59017. * An event triggered when the effect layer has been disposed.
  59018. */
  59019. onDisposeObservable: Observable<EffectLayer>;
  59020. /**
  59021. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59022. */
  59023. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59024. /**
  59025. * An event triggered when the generated texture is being merged in the scene.
  59026. */
  59027. onBeforeComposeObservable: Observable<EffectLayer>;
  59028. /**
  59029. * An event triggered when the mesh is rendered into the effect render target.
  59030. */
  59031. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59032. /**
  59033. * An event triggered after the mesh has been rendered into the effect render target.
  59034. */
  59035. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59036. /**
  59037. * An event triggered when the generated texture has been merged in the scene.
  59038. */
  59039. onAfterComposeObservable: Observable<EffectLayer>;
  59040. /**
  59041. * An event triggered when the efffect layer changes its size.
  59042. */
  59043. onSizeChangedObservable: Observable<EffectLayer>;
  59044. /** @hidden */
  59045. static _SceneComponentInitialization: (scene: Scene) => void;
  59046. /**
  59047. * Instantiates a new effect Layer and references it in the scene.
  59048. * @param name The name of the layer
  59049. * @param scene The scene to use the layer in
  59050. */
  59051. constructor(
  59052. /** The Friendly of the effect in the scene */
  59053. name: string, scene: Scene);
  59054. /**
  59055. * Get the effect name of the layer.
  59056. * @return The effect name
  59057. */
  59058. abstract getEffectName(): string;
  59059. /**
  59060. * Checks for the readiness of the element composing the layer.
  59061. * @param subMesh the mesh to check for
  59062. * @param useInstances specify whether or not to use instances to render the mesh
  59063. * @return true if ready otherwise, false
  59064. */
  59065. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59066. /**
  59067. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59068. * @returns true if the effect requires stencil during the main canvas render pass.
  59069. */
  59070. abstract needStencil(): boolean;
  59071. /**
  59072. * Create the merge effect. This is the shader use to blit the information back
  59073. * to the main canvas at the end of the scene rendering.
  59074. * @returns The effect containing the shader used to merge the effect on the main canvas
  59075. */
  59076. protected abstract _createMergeEffect(): Effect;
  59077. /**
  59078. * Creates the render target textures and post processes used in the effect layer.
  59079. */
  59080. protected abstract _createTextureAndPostProcesses(): void;
  59081. /**
  59082. * Implementation specific of rendering the generating effect on the main canvas.
  59083. * @param effect The effect used to render through
  59084. */
  59085. protected abstract _internalRender(effect: Effect): void;
  59086. /**
  59087. * Sets the required values for both the emissive texture and and the main color.
  59088. */
  59089. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59090. /**
  59091. * Free any resources and references associated to a mesh.
  59092. * Internal use
  59093. * @param mesh The mesh to free.
  59094. */
  59095. abstract _disposeMesh(mesh: Mesh): void;
  59096. /**
  59097. * Serializes this layer (Glow or Highlight for example)
  59098. * @returns a serialized layer object
  59099. */
  59100. abstract serialize?(): any;
  59101. /**
  59102. * Initializes the effect layer with the required options.
  59103. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59104. */
  59105. protected _init(options: Partial<IEffectLayerOptions>): void;
  59106. /**
  59107. * Generates the index buffer of the full screen quad blending to the main canvas.
  59108. */
  59109. private _generateIndexBuffer;
  59110. /**
  59111. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59112. */
  59113. private _generateVertexBuffer;
  59114. /**
  59115. * Sets the main texture desired size which is the closest power of two
  59116. * of the engine canvas size.
  59117. */
  59118. private _setMainTextureSize;
  59119. /**
  59120. * Creates the main texture for the effect layer.
  59121. */
  59122. protected _createMainTexture(): void;
  59123. /**
  59124. * Adds specific effects defines.
  59125. * @param defines The defines to add specifics to.
  59126. */
  59127. protected _addCustomEffectDefines(defines: string[]): void;
  59128. /**
  59129. * Checks for the readiness of the element composing the layer.
  59130. * @param subMesh the mesh to check for
  59131. * @param useInstances specify whether or not to use instances to render the mesh
  59132. * @param emissiveTexture the associated emissive texture used to generate the glow
  59133. * @return true if ready otherwise, false
  59134. */
  59135. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59136. /**
  59137. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59138. */
  59139. render(): void;
  59140. /**
  59141. * Determine if a given mesh will be used in the current effect.
  59142. * @param mesh mesh to test
  59143. * @returns true if the mesh will be used
  59144. */
  59145. hasMesh(mesh: AbstractMesh): boolean;
  59146. /**
  59147. * Returns true if the layer contains information to display, otherwise false.
  59148. * @returns true if the glow layer should be rendered
  59149. */
  59150. shouldRender(): boolean;
  59151. /**
  59152. * Returns true if the mesh should render, otherwise false.
  59153. * @param mesh The mesh to render
  59154. * @returns true if it should render otherwise false
  59155. */
  59156. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59157. /**
  59158. * Returns true if the mesh can be rendered, otherwise false.
  59159. * @param mesh The mesh to render
  59160. * @param material The material used on the mesh
  59161. * @returns true if it can be rendered otherwise false
  59162. */
  59163. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59164. /**
  59165. * Returns true if the mesh should render, otherwise false.
  59166. * @param mesh The mesh to render
  59167. * @returns true if it should render otherwise false
  59168. */
  59169. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59170. /**
  59171. * Renders the submesh passed in parameter to the generation map.
  59172. */
  59173. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59174. /**
  59175. * Defines whether the current material of the mesh should be use to render the effect.
  59176. * @param mesh defines the current mesh to render
  59177. */
  59178. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59179. /**
  59180. * Rebuild the required buffers.
  59181. * @hidden Internal use only.
  59182. */
  59183. _rebuild(): void;
  59184. /**
  59185. * Dispose only the render target textures and post process.
  59186. */
  59187. private _disposeTextureAndPostProcesses;
  59188. /**
  59189. * Dispose the highlight layer and free resources.
  59190. */
  59191. dispose(): void;
  59192. /**
  59193. * Gets the class name of the effect layer
  59194. * @returns the string with the class name of the effect layer
  59195. */
  59196. getClassName(): string;
  59197. /**
  59198. * Creates an effect layer from parsed effect layer data
  59199. * @param parsedEffectLayer defines effect layer data
  59200. * @param scene defines the current scene
  59201. * @param rootUrl defines the root URL containing the effect layer information
  59202. * @returns a parsed effect Layer
  59203. */
  59204. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59205. }
  59206. }
  59207. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59208. import { Scene } from "babylonjs/scene";
  59209. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59210. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59211. import { AbstractScene } from "babylonjs/abstractScene";
  59212. module "babylonjs/abstractScene" {
  59213. interface AbstractScene {
  59214. /**
  59215. * The list of effect layers (highlights/glow) added to the scene
  59216. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59217. * @see http://doc.babylonjs.com/how_to/glow_layer
  59218. */
  59219. effectLayers: Array<EffectLayer>;
  59220. /**
  59221. * Removes the given effect layer from this scene.
  59222. * @param toRemove defines the effect layer to remove
  59223. * @returns the index of the removed effect layer
  59224. */
  59225. removeEffectLayer(toRemove: EffectLayer): number;
  59226. /**
  59227. * Adds the given effect layer to this scene
  59228. * @param newEffectLayer defines the effect layer to add
  59229. */
  59230. addEffectLayer(newEffectLayer: EffectLayer): void;
  59231. }
  59232. }
  59233. /**
  59234. * Defines the layer scene component responsible to manage any effect layers
  59235. * in a given scene.
  59236. */
  59237. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59238. /**
  59239. * The component name helpfull to identify the component in the list of scene components.
  59240. */
  59241. readonly name: string;
  59242. /**
  59243. * The scene the component belongs to.
  59244. */
  59245. scene: Scene;
  59246. private _engine;
  59247. private _renderEffects;
  59248. private _needStencil;
  59249. private _previousStencilState;
  59250. /**
  59251. * Creates a new instance of the component for the given scene
  59252. * @param scene Defines the scene to register the component in
  59253. */
  59254. constructor(scene: Scene);
  59255. /**
  59256. * Registers the component in a given scene
  59257. */
  59258. register(): void;
  59259. /**
  59260. * Rebuilds the elements related to this component in case of
  59261. * context lost for instance.
  59262. */
  59263. rebuild(): void;
  59264. /**
  59265. * Serializes the component data to the specified json object
  59266. * @param serializationObject The object to serialize to
  59267. */
  59268. serialize(serializationObject: any): void;
  59269. /**
  59270. * Adds all the elements from the container to the scene
  59271. * @param container the container holding the elements
  59272. */
  59273. addFromContainer(container: AbstractScene): void;
  59274. /**
  59275. * Removes all the elements in the container from the scene
  59276. * @param container contains the elements to remove
  59277. * @param dispose if the removed element should be disposed (default: false)
  59278. */
  59279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59280. /**
  59281. * Disposes the component and the associated ressources.
  59282. */
  59283. dispose(): void;
  59284. private _isReadyForMesh;
  59285. private _renderMainTexture;
  59286. private _setStencil;
  59287. private _setStencilBack;
  59288. private _draw;
  59289. private _drawCamera;
  59290. private _drawRenderingGroup;
  59291. }
  59292. }
  59293. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59294. /** @hidden */
  59295. export var glowMapMergePixelShader: {
  59296. name: string;
  59297. shader: string;
  59298. };
  59299. }
  59300. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59301. /** @hidden */
  59302. export var glowMapMergeVertexShader: {
  59303. name: string;
  59304. shader: string;
  59305. };
  59306. }
  59307. declare module "babylonjs/Layers/glowLayer" {
  59308. import { Nullable } from "babylonjs/types";
  59309. import { Camera } from "babylonjs/Cameras/camera";
  59310. import { Scene } from "babylonjs/scene";
  59311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59313. import { Mesh } from "babylonjs/Meshes/mesh";
  59314. import { Texture } from "babylonjs/Materials/Textures/texture";
  59315. import { Effect } from "babylonjs/Materials/effect";
  59316. import { Material } from "babylonjs/Materials/material";
  59317. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59318. import { Color4 } from "babylonjs/Maths/math.color";
  59319. import "babylonjs/Shaders/glowMapMerge.fragment";
  59320. import "babylonjs/Shaders/glowMapMerge.vertex";
  59321. import "babylonjs/Layers/effectLayerSceneComponent";
  59322. module "babylonjs/abstractScene" {
  59323. interface AbstractScene {
  59324. /**
  59325. * Return a the first highlight layer of the scene with a given name.
  59326. * @param name The name of the highlight layer to look for.
  59327. * @return The highlight layer if found otherwise null.
  59328. */
  59329. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59330. }
  59331. }
  59332. /**
  59333. * Glow layer options. This helps customizing the behaviour
  59334. * of the glow layer.
  59335. */
  59336. export interface IGlowLayerOptions {
  59337. /**
  59338. * Multiplication factor apply to the canvas size to compute the render target size
  59339. * used to generated the glowing objects (the smaller the faster).
  59340. */
  59341. mainTextureRatio: number;
  59342. /**
  59343. * Enforces a fixed size texture to ensure resize independant blur.
  59344. */
  59345. mainTextureFixedSize?: number;
  59346. /**
  59347. * How big is the kernel of the blur texture.
  59348. */
  59349. blurKernelSize: number;
  59350. /**
  59351. * The camera attached to the layer.
  59352. */
  59353. camera: Nullable<Camera>;
  59354. /**
  59355. * Enable MSAA by chosing the number of samples.
  59356. */
  59357. mainTextureSamples?: number;
  59358. /**
  59359. * The rendering group to draw the layer in.
  59360. */
  59361. renderingGroupId: number;
  59362. }
  59363. /**
  59364. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59365. *
  59366. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59367. *
  59368. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59369. */
  59370. export class GlowLayer extends EffectLayer {
  59371. /**
  59372. * Effect Name of the layer.
  59373. */
  59374. static readonly EffectName: string;
  59375. /**
  59376. * The default blur kernel size used for the glow.
  59377. */
  59378. static DefaultBlurKernelSize: number;
  59379. /**
  59380. * The default texture size ratio used for the glow.
  59381. */
  59382. static DefaultTextureRatio: number;
  59383. /**
  59384. * Sets the kernel size of the blur.
  59385. */
  59386. set blurKernelSize(value: number);
  59387. /**
  59388. * Gets the kernel size of the blur.
  59389. */
  59390. get blurKernelSize(): number;
  59391. /**
  59392. * Sets the glow intensity.
  59393. */
  59394. set intensity(value: number);
  59395. /**
  59396. * Gets the glow intensity.
  59397. */
  59398. get intensity(): number;
  59399. private _options;
  59400. private _intensity;
  59401. private _horizontalBlurPostprocess1;
  59402. private _verticalBlurPostprocess1;
  59403. private _horizontalBlurPostprocess2;
  59404. private _verticalBlurPostprocess2;
  59405. private _blurTexture1;
  59406. private _blurTexture2;
  59407. private _postProcesses1;
  59408. private _postProcesses2;
  59409. private _includedOnlyMeshes;
  59410. private _excludedMeshes;
  59411. private _meshesUsingTheirOwnMaterials;
  59412. /**
  59413. * Callback used to let the user override the color selection on a per mesh basis
  59414. */
  59415. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59416. /**
  59417. * Callback used to let the user override the texture selection on a per mesh basis
  59418. */
  59419. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59420. /**
  59421. * Instantiates a new glow Layer and references it to the scene.
  59422. * @param name The name of the layer
  59423. * @param scene The scene to use the layer in
  59424. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59425. */
  59426. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59427. /**
  59428. * Get the effect name of the layer.
  59429. * @return The effect name
  59430. */
  59431. getEffectName(): string;
  59432. /**
  59433. * Create the merge effect. This is the shader use to blit the information back
  59434. * to the main canvas at the end of the scene rendering.
  59435. */
  59436. protected _createMergeEffect(): Effect;
  59437. /**
  59438. * Creates the render target textures and post processes used in the glow layer.
  59439. */
  59440. protected _createTextureAndPostProcesses(): void;
  59441. /**
  59442. * Checks for the readiness of the element composing the layer.
  59443. * @param subMesh the mesh to check for
  59444. * @param useInstances specify wether or not to use instances to render the mesh
  59445. * @param emissiveTexture the associated emissive texture used to generate the glow
  59446. * @return true if ready otherwise, false
  59447. */
  59448. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59449. /**
  59450. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59451. */
  59452. needStencil(): boolean;
  59453. /**
  59454. * Returns true if the mesh can be rendered, otherwise false.
  59455. * @param mesh The mesh to render
  59456. * @param material The material used on the mesh
  59457. * @returns true if it can be rendered otherwise false
  59458. */
  59459. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59460. /**
  59461. * Implementation specific of rendering the generating effect on the main canvas.
  59462. * @param effect The effect used to render through
  59463. */
  59464. protected _internalRender(effect: Effect): void;
  59465. /**
  59466. * Sets the required values for both the emissive texture and and the main color.
  59467. */
  59468. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59469. /**
  59470. * Returns true if the mesh should render, otherwise false.
  59471. * @param mesh The mesh to render
  59472. * @returns true if it should render otherwise false
  59473. */
  59474. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59475. /**
  59476. * Adds specific effects defines.
  59477. * @param defines The defines to add specifics to.
  59478. */
  59479. protected _addCustomEffectDefines(defines: string[]): void;
  59480. /**
  59481. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59482. * @param mesh The mesh to exclude from the glow layer
  59483. */
  59484. addExcludedMesh(mesh: Mesh): void;
  59485. /**
  59486. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59487. * @param mesh The mesh to remove
  59488. */
  59489. removeExcludedMesh(mesh: Mesh): void;
  59490. /**
  59491. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59492. * @param mesh The mesh to include in the glow layer
  59493. */
  59494. addIncludedOnlyMesh(mesh: Mesh): void;
  59495. /**
  59496. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59497. * @param mesh The mesh to remove
  59498. */
  59499. removeIncludedOnlyMesh(mesh: Mesh): void;
  59500. /**
  59501. * Determine if a given mesh will be used in the glow layer
  59502. * @param mesh The mesh to test
  59503. * @returns true if the mesh will be highlighted by the current glow layer
  59504. */
  59505. hasMesh(mesh: AbstractMesh): boolean;
  59506. /**
  59507. * Defines whether the current material of the mesh should be use to render the effect.
  59508. * @param mesh defines the current mesh to render
  59509. */
  59510. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59511. /**
  59512. * Add a mesh to be rendered through its own material and not with emissive only.
  59513. * @param mesh The mesh for which we need to use its material
  59514. */
  59515. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59516. /**
  59517. * Remove a mesh from being rendered through its own material and not with emissive only.
  59518. * @param mesh The mesh for which we need to not use its material
  59519. */
  59520. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59521. /**
  59522. * Free any resources and references associated to a mesh.
  59523. * Internal use
  59524. * @param mesh The mesh to free.
  59525. * @hidden
  59526. */
  59527. _disposeMesh(mesh: Mesh): void;
  59528. /**
  59529. * Gets the class name of the effect layer
  59530. * @returns the string with the class name of the effect layer
  59531. */
  59532. getClassName(): string;
  59533. /**
  59534. * Serializes this glow layer
  59535. * @returns a serialized glow layer object
  59536. */
  59537. serialize(): any;
  59538. /**
  59539. * Creates a Glow Layer from parsed glow layer data
  59540. * @param parsedGlowLayer defines glow layer data
  59541. * @param scene defines the current scene
  59542. * @param rootUrl defines the root URL containing the glow layer information
  59543. * @returns a parsed Glow Layer
  59544. */
  59545. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59546. }
  59547. }
  59548. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59549. /** @hidden */
  59550. export var glowBlurPostProcessPixelShader: {
  59551. name: string;
  59552. shader: string;
  59553. };
  59554. }
  59555. declare module "babylonjs/Layers/highlightLayer" {
  59556. import { Observable } from "babylonjs/Misc/observable";
  59557. import { Nullable } from "babylonjs/types";
  59558. import { Camera } from "babylonjs/Cameras/camera";
  59559. import { Scene } from "babylonjs/scene";
  59560. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59562. import { Mesh } from "babylonjs/Meshes/mesh";
  59563. import { Effect } from "babylonjs/Materials/effect";
  59564. import { Material } from "babylonjs/Materials/material";
  59565. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59566. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59567. import "babylonjs/Shaders/glowMapMerge.fragment";
  59568. import "babylonjs/Shaders/glowMapMerge.vertex";
  59569. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59570. module "babylonjs/abstractScene" {
  59571. interface AbstractScene {
  59572. /**
  59573. * Return a the first highlight layer of the scene with a given name.
  59574. * @param name The name of the highlight layer to look for.
  59575. * @return The highlight layer if found otherwise null.
  59576. */
  59577. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59578. }
  59579. }
  59580. /**
  59581. * Highlight layer options. This helps customizing the behaviour
  59582. * of the highlight layer.
  59583. */
  59584. export interface IHighlightLayerOptions {
  59585. /**
  59586. * Multiplication factor apply to the canvas size to compute the render target size
  59587. * used to generated the glowing objects (the smaller the faster).
  59588. */
  59589. mainTextureRatio: number;
  59590. /**
  59591. * Enforces a fixed size texture to ensure resize independant blur.
  59592. */
  59593. mainTextureFixedSize?: number;
  59594. /**
  59595. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59596. * of the picture to blur (the smaller the faster).
  59597. */
  59598. blurTextureSizeRatio: number;
  59599. /**
  59600. * How big in texel of the blur texture is the vertical blur.
  59601. */
  59602. blurVerticalSize: number;
  59603. /**
  59604. * How big in texel of the blur texture is the horizontal blur.
  59605. */
  59606. blurHorizontalSize: number;
  59607. /**
  59608. * Alpha blending mode used to apply the blur. Default is combine.
  59609. */
  59610. alphaBlendingMode: number;
  59611. /**
  59612. * The camera attached to the layer.
  59613. */
  59614. camera: Nullable<Camera>;
  59615. /**
  59616. * Should we display highlight as a solid stroke?
  59617. */
  59618. isStroke?: boolean;
  59619. /**
  59620. * The rendering group to draw the layer in.
  59621. */
  59622. renderingGroupId: number;
  59623. }
  59624. /**
  59625. * The highlight layer Helps adding a glow effect around a mesh.
  59626. *
  59627. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59628. * glowy meshes to your scene.
  59629. *
  59630. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59631. */
  59632. export class HighlightLayer extends EffectLayer {
  59633. name: string;
  59634. /**
  59635. * Effect Name of the highlight layer.
  59636. */
  59637. static readonly EffectName: string;
  59638. /**
  59639. * The neutral color used during the preparation of the glow effect.
  59640. * This is black by default as the blend operation is a blend operation.
  59641. */
  59642. static NeutralColor: Color4;
  59643. /**
  59644. * Stencil value used for glowing meshes.
  59645. */
  59646. static GlowingMeshStencilReference: number;
  59647. /**
  59648. * Stencil value used for the other meshes in the scene.
  59649. */
  59650. static NormalMeshStencilReference: number;
  59651. /**
  59652. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59653. */
  59654. innerGlow: boolean;
  59655. /**
  59656. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59657. */
  59658. outerGlow: boolean;
  59659. /**
  59660. * Specifies the horizontal size of the blur.
  59661. */
  59662. set blurHorizontalSize(value: number);
  59663. /**
  59664. * Specifies the vertical size of the blur.
  59665. */
  59666. set blurVerticalSize(value: number);
  59667. /**
  59668. * Gets the horizontal size of the blur.
  59669. */
  59670. get blurHorizontalSize(): number;
  59671. /**
  59672. * Gets the vertical size of the blur.
  59673. */
  59674. get blurVerticalSize(): number;
  59675. /**
  59676. * An event triggered when the highlight layer is being blurred.
  59677. */
  59678. onBeforeBlurObservable: Observable<HighlightLayer>;
  59679. /**
  59680. * An event triggered when the highlight layer has been blurred.
  59681. */
  59682. onAfterBlurObservable: Observable<HighlightLayer>;
  59683. private _instanceGlowingMeshStencilReference;
  59684. private _options;
  59685. private _downSamplePostprocess;
  59686. private _horizontalBlurPostprocess;
  59687. private _verticalBlurPostprocess;
  59688. private _blurTexture;
  59689. private _meshes;
  59690. private _excludedMeshes;
  59691. /**
  59692. * Instantiates a new highlight Layer and references it to the scene..
  59693. * @param name The name of the layer
  59694. * @param scene The scene to use the layer in
  59695. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59696. */
  59697. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59698. /**
  59699. * Get the effect name of the layer.
  59700. * @return The effect name
  59701. */
  59702. getEffectName(): string;
  59703. /**
  59704. * Create the merge effect. This is the shader use to blit the information back
  59705. * to the main canvas at the end of the scene rendering.
  59706. */
  59707. protected _createMergeEffect(): Effect;
  59708. /**
  59709. * Creates the render target textures and post processes used in the highlight layer.
  59710. */
  59711. protected _createTextureAndPostProcesses(): void;
  59712. /**
  59713. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59714. */
  59715. needStencil(): boolean;
  59716. /**
  59717. * Checks for the readiness of the element composing the layer.
  59718. * @param subMesh the mesh to check for
  59719. * @param useInstances specify wether or not to use instances to render the mesh
  59720. * @param emissiveTexture the associated emissive texture used to generate the glow
  59721. * @return true if ready otherwise, false
  59722. */
  59723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59724. /**
  59725. * Implementation specific of rendering the generating effect on the main canvas.
  59726. * @param effect The effect used to render through
  59727. */
  59728. protected _internalRender(effect: Effect): void;
  59729. /**
  59730. * Returns true if the layer contains information to display, otherwise false.
  59731. */
  59732. shouldRender(): boolean;
  59733. /**
  59734. * Returns true if the mesh should render, otherwise false.
  59735. * @param mesh The mesh to render
  59736. * @returns true if it should render otherwise false
  59737. */
  59738. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59739. /**
  59740. * Adds specific effects defines.
  59741. * @param defines The defines to add specifics to.
  59742. */
  59743. protected _addCustomEffectDefines(defines: string[]): void;
  59744. /**
  59745. * Sets the required values for both the emissive texture and and the main color.
  59746. */
  59747. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59748. /**
  59749. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59750. * @param mesh The mesh to exclude from the highlight layer
  59751. */
  59752. addExcludedMesh(mesh: Mesh): void;
  59753. /**
  59754. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59755. * @param mesh The mesh to highlight
  59756. */
  59757. removeExcludedMesh(mesh: Mesh): void;
  59758. /**
  59759. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59760. * @param mesh mesh to test
  59761. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59762. */
  59763. hasMesh(mesh: AbstractMesh): boolean;
  59764. /**
  59765. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59766. * @param mesh The mesh to highlight
  59767. * @param color The color of the highlight
  59768. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59769. */
  59770. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59771. /**
  59772. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59773. * @param mesh The mesh to highlight
  59774. */
  59775. removeMesh(mesh: Mesh): void;
  59776. /**
  59777. * Remove all the meshes currently referenced in the highlight layer
  59778. */
  59779. removeAllMeshes(): void;
  59780. /**
  59781. * Force the stencil to the normal expected value for none glowing parts
  59782. */
  59783. private _defaultStencilReference;
  59784. /**
  59785. * Free any resources and references associated to a mesh.
  59786. * Internal use
  59787. * @param mesh The mesh to free.
  59788. * @hidden
  59789. */
  59790. _disposeMesh(mesh: Mesh): void;
  59791. /**
  59792. * Dispose the highlight layer and free resources.
  59793. */
  59794. dispose(): void;
  59795. /**
  59796. * Gets the class name of the effect layer
  59797. * @returns the string with the class name of the effect layer
  59798. */
  59799. getClassName(): string;
  59800. /**
  59801. * Serializes this Highlight layer
  59802. * @returns a serialized Highlight layer object
  59803. */
  59804. serialize(): any;
  59805. /**
  59806. * Creates a Highlight layer from parsed Highlight layer data
  59807. * @param parsedHightlightLayer defines the Highlight layer data
  59808. * @param scene defines the current scene
  59809. * @param rootUrl defines the root URL containing the Highlight layer information
  59810. * @returns a parsed Highlight layer
  59811. */
  59812. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59813. }
  59814. }
  59815. declare module "babylonjs/Layers/layerSceneComponent" {
  59816. import { Scene } from "babylonjs/scene";
  59817. import { ISceneComponent } from "babylonjs/sceneComponent";
  59818. import { Layer } from "babylonjs/Layers/layer";
  59819. import { AbstractScene } from "babylonjs/abstractScene";
  59820. module "babylonjs/abstractScene" {
  59821. interface AbstractScene {
  59822. /**
  59823. * The list of layers (background and foreground) of the scene
  59824. */
  59825. layers: Array<Layer>;
  59826. }
  59827. }
  59828. /**
  59829. * Defines the layer scene component responsible to manage any layers
  59830. * in a given scene.
  59831. */
  59832. export class LayerSceneComponent implements ISceneComponent {
  59833. /**
  59834. * The component name helpfull to identify the component in the list of scene components.
  59835. */
  59836. readonly name: string;
  59837. /**
  59838. * The scene the component belongs to.
  59839. */
  59840. scene: Scene;
  59841. private _engine;
  59842. /**
  59843. * Creates a new instance of the component for the given scene
  59844. * @param scene Defines the scene to register the component in
  59845. */
  59846. constructor(scene: Scene);
  59847. /**
  59848. * Registers the component in a given scene
  59849. */
  59850. register(): void;
  59851. /**
  59852. * Rebuilds the elements related to this component in case of
  59853. * context lost for instance.
  59854. */
  59855. rebuild(): void;
  59856. /**
  59857. * Disposes the component and the associated ressources.
  59858. */
  59859. dispose(): void;
  59860. private _draw;
  59861. private _drawCameraPredicate;
  59862. private _drawCameraBackground;
  59863. private _drawCameraForeground;
  59864. private _drawRenderTargetPredicate;
  59865. private _drawRenderTargetBackground;
  59866. private _drawRenderTargetForeground;
  59867. /**
  59868. * Adds all the elements from the container to the scene
  59869. * @param container the container holding the elements
  59870. */
  59871. addFromContainer(container: AbstractScene): void;
  59872. /**
  59873. * Removes all the elements in the container from the scene
  59874. * @param container contains the elements to remove
  59875. * @param dispose if the removed element should be disposed (default: false)
  59876. */
  59877. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59878. }
  59879. }
  59880. declare module "babylonjs/Shaders/layer.fragment" {
  59881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59882. /** @hidden */
  59883. export var layerPixelShader: {
  59884. name: string;
  59885. shader: string;
  59886. };
  59887. }
  59888. declare module "babylonjs/Shaders/layer.vertex" {
  59889. /** @hidden */
  59890. export var layerVertexShader: {
  59891. name: string;
  59892. shader: string;
  59893. };
  59894. }
  59895. declare module "babylonjs/Layers/layer" {
  59896. import { Observable } from "babylonjs/Misc/observable";
  59897. import { Nullable } from "babylonjs/types";
  59898. import { Scene } from "babylonjs/scene";
  59899. import { Vector2 } from "babylonjs/Maths/math.vector";
  59900. import { Color4 } from "babylonjs/Maths/math.color";
  59901. import { Texture } from "babylonjs/Materials/Textures/texture";
  59902. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59903. import "babylonjs/Shaders/layer.fragment";
  59904. import "babylonjs/Shaders/layer.vertex";
  59905. /**
  59906. * This represents a full screen 2d layer.
  59907. * This can be useful to display a picture in the background of your scene for instance.
  59908. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59909. */
  59910. export class Layer {
  59911. /**
  59912. * Define the name of the layer.
  59913. */
  59914. name: string;
  59915. /**
  59916. * Define the texture the layer should display.
  59917. */
  59918. texture: Nullable<Texture>;
  59919. /**
  59920. * Is the layer in background or foreground.
  59921. */
  59922. isBackground: boolean;
  59923. /**
  59924. * Define the color of the layer (instead of texture).
  59925. */
  59926. color: Color4;
  59927. /**
  59928. * Define the scale of the layer in order to zoom in out of the texture.
  59929. */
  59930. scale: Vector2;
  59931. /**
  59932. * Define an offset for the layer in order to shift the texture.
  59933. */
  59934. offset: Vector2;
  59935. /**
  59936. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59937. */
  59938. alphaBlendingMode: number;
  59939. /**
  59940. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59941. * Alpha test will not mix with the background color in case of transparency.
  59942. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59943. */
  59944. alphaTest: boolean;
  59945. /**
  59946. * Define a mask to restrict the layer to only some of the scene cameras.
  59947. */
  59948. layerMask: number;
  59949. /**
  59950. * Define the list of render target the layer is visible into.
  59951. */
  59952. renderTargetTextures: RenderTargetTexture[];
  59953. /**
  59954. * Define if the layer is only used in renderTarget or if it also
  59955. * renders in the main frame buffer of the canvas.
  59956. */
  59957. renderOnlyInRenderTargetTextures: boolean;
  59958. private _scene;
  59959. private _vertexBuffers;
  59960. private _indexBuffer;
  59961. private _effect;
  59962. private _previousDefines;
  59963. /**
  59964. * An event triggered when the layer is disposed.
  59965. */
  59966. onDisposeObservable: Observable<Layer>;
  59967. private _onDisposeObserver;
  59968. /**
  59969. * Back compatibility with callback before the onDisposeObservable existed.
  59970. * The set callback will be triggered when the layer has been disposed.
  59971. */
  59972. set onDispose(callback: () => void);
  59973. /**
  59974. * An event triggered before rendering the scene
  59975. */
  59976. onBeforeRenderObservable: Observable<Layer>;
  59977. private _onBeforeRenderObserver;
  59978. /**
  59979. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59980. * The set callback will be triggered just before rendering the layer.
  59981. */
  59982. set onBeforeRender(callback: () => void);
  59983. /**
  59984. * An event triggered after rendering the scene
  59985. */
  59986. onAfterRenderObservable: Observable<Layer>;
  59987. private _onAfterRenderObserver;
  59988. /**
  59989. * Back compatibility with callback before the onAfterRenderObservable existed.
  59990. * The set callback will be triggered just after rendering the layer.
  59991. */
  59992. set onAfterRender(callback: () => void);
  59993. /**
  59994. * Instantiates a new layer.
  59995. * This represents a full screen 2d layer.
  59996. * This can be useful to display a picture in the background of your scene for instance.
  59997. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59998. * @param name Define the name of the layer in the scene
  59999. * @param imgUrl Define the url of the texture to display in the layer
  60000. * @param scene Define the scene the layer belongs to
  60001. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60002. * @param color Defines a color for the layer
  60003. */
  60004. constructor(
  60005. /**
  60006. * Define the name of the layer.
  60007. */
  60008. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60009. private _createIndexBuffer;
  60010. /** @hidden */
  60011. _rebuild(): void;
  60012. /**
  60013. * Renders the layer in the scene.
  60014. */
  60015. render(): void;
  60016. /**
  60017. * Disposes and releases the associated ressources.
  60018. */
  60019. dispose(): void;
  60020. }
  60021. }
  60022. declare module "babylonjs/Layers/index" {
  60023. export * from "babylonjs/Layers/effectLayer";
  60024. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60025. export * from "babylonjs/Layers/glowLayer";
  60026. export * from "babylonjs/Layers/highlightLayer";
  60027. export * from "babylonjs/Layers/layer";
  60028. export * from "babylonjs/Layers/layerSceneComponent";
  60029. }
  60030. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60031. /** @hidden */
  60032. export var lensFlarePixelShader: {
  60033. name: string;
  60034. shader: string;
  60035. };
  60036. }
  60037. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60038. /** @hidden */
  60039. export var lensFlareVertexShader: {
  60040. name: string;
  60041. shader: string;
  60042. };
  60043. }
  60044. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60045. import { Scene } from "babylonjs/scene";
  60046. import { Vector3 } from "babylonjs/Maths/math.vector";
  60047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60048. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60049. import "babylonjs/Shaders/lensFlare.fragment";
  60050. import "babylonjs/Shaders/lensFlare.vertex";
  60051. import { Viewport } from "babylonjs/Maths/math.viewport";
  60052. /**
  60053. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60054. * It is usually composed of several `lensFlare`.
  60055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60056. */
  60057. export class LensFlareSystem {
  60058. /**
  60059. * Define the name of the lens flare system
  60060. */
  60061. name: string;
  60062. /**
  60063. * List of lens flares used in this system.
  60064. */
  60065. lensFlares: LensFlare[];
  60066. /**
  60067. * Define a limit from the border the lens flare can be visible.
  60068. */
  60069. borderLimit: number;
  60070. /**
  60071. * Define a viewport border we do not want to see the lens flare in.
  60072. */
  60073. viewportBorder: number;
  60074. /**
  60075. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60076. */
  60077. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60078. /**
  60079. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60080. */
  60081. layerMask: number;
  60082. /**
  60083. * Define the id of the lens flare system in the scene.
  60084. * (equal to name by default)
  60085. */
  60086. id: string;
  60087. private _scene;
  60088. private _emitter;
  60089. private _vertexBuffers;
  60090. private _indexBuffer;
  60091. private _effect;
  60092. private _positionX;
  60093. private _positionY;
  60094. private _isEnabled;
  60095. /** @hidden */
  60096. static _SceneComponentInitialization: (scene: Scene) => void;
  60097. /**
  60098. * Instantiates a lens flare system.
  60099. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60100. * It is usually composed of several `lensFlare`.
  60101. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60102. * @param name Define the name of the lens flare system in the scene
  60103. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60104. * @param scene Define the scene the lens flare system belongs to
  60105. */
  60106. constructor(
  60107. /**
  60108. * Define the name of the lens flare system
  60109. */
  60110. name: string, emitter: any, scene: Scene);
  60111. /**
  60112. * Define if the lens flare system is enabled.
  60113. */
  60114. get isEnabled(): boolean;
  60115. set isEnabled(value: boolean);
  60116. /**
  60117. * Get the scene the effects belongs to.
  60118. * @returns the scene holding the lens flare system
  60119. */
  60120. getScene(): Scene;
  60121. /**
  60122. * Get the emitter of the lens flare system.
  60123. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60124. * @returns the emitter of the lens flare system
  60125. */
  60126. getEmitter(): any;
  60127. /**
  60128. * Set the emitter of the lens flare system.
  60129. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60130. * @param newEmitter Define the new emitter of the system
  60131. */
  60132. setEmitter(newEmitter: any): void;
  60133. /**
  60134. * Get the lens flare system emitter position.
  60135. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60136. * @returns the position
  60137. */
  60138. getEmitterPosition(): Vector3;
  60139. /**
  60140. * @hidden
  60141. */
  60142. computeEffectivePosition(globalViewport: Viewport): boolean;
  60143. /** @hidden */
  60144. _isVisible(): boolean;
  60145. /**
  60146. * @hidden
  60147. */
  60148. render(): boolean;
  60149. /**
  60150. * Dispose and release the lens flare with its associated resources.
  60151. */
  60152. dispose(): void;
  60153. /**
  60154. * Parse a lens flare system from a JSON repressentation
  60155. * @param parsedLensFlareSystem Define the JSON to parse
  60156. * @param scene Define the scene the parsed system should be instantiated in
  60157. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60158. * @returns the parsed system
  60159. */
  60160. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60161. /**
  60162. * Serialize the current Lens Flare System into a JSON representation.
  60163. * @returns the serialized JSON
  60164. */
  60165. serialize(): any;
  60166. }
  60167. }
  60168. declare module "babylonjs/LensFlares/lensFlare" {
  60169. import { Nullable } from "babylonjs/types";
  60170. import { Color3 } from "babylonjs/Maths/math.color";
  60171. import { Texture } from "babylonjs/Materials/Textures/texture";
  60172. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60173. /**
  60174. * This represents one of the lens effect in a `lensFlareSystem`.
  60175. * It controls one of the indiviual texture used in the effect.
  60176. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60177. */
  60178. export class LensFlare {
  60179. /**
  60180. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60181. */
  60182. size: number;
  60183. /**
  60184. * 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.
  60185. */
  60186. position: number;
  60187. /**
  60188. * Define the lens color.
  60189. */
  60190. color: Color3;
  60191. /**
  60192. * Define the lens texture.
  60193. */
  60194. texture: Nullable<Texture>;
  60195. /**
  60196. * Define the alpha mode to render this particular lens.
  60197. */
  60198. alphaMode: number;
  60199. private _system;
  60200. /**
  60201. * Creates a new Lens Flare.
  60202. * This represents one of the lens effect in a `lensFlareSystem`.
  60203. * It controls one of the indiviual texture used in the effect.
  60204. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60205. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60206. * @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.
  60207. * @param color Define the lens color
  60208. * @param imgUrl Define the lens texture url
  60209. * @param system Define the `lensFlareSystem` this flare is part of
  60210. * @returns The newly created Lens Flare
  60211. */
  60212. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60213. /**
  60214. * Instantiates a new Lens Flare.
  60215. * This represents one of the lens effect in a `lensFlareSystem`.
  60216. * It controls one of the indiviual texture used in the effect.
  60217. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60218. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60219. * @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.
  60220. * @param color Define the lens color
  60221. * @param imgUrl Define the lens texture url
  60222. * @param system Define the `lensFlareSystem` this flare is part of
  60223. */
  60224. constructor(
  60225. /**
  60226. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60227. */
  60228. size: number,
  60229. /**
  60230. * 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.
  60231. */
  60232. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60233. /**
  60234. * Dispose and release the lens flare with its associated resources.
  60235. */
  60236. dispose(): void;
  60237. }
  60238. }
  60239. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60240. import { Nullable } from "babylonjs/types";
  60241. import { Scene } from "babylonjs/scene";
  60242. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60243. import { AbstractScene } from "babylonjs/abstractScene";
  60244. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60245. module "babylonjs/abstractScene" {
  60246. interface AbstractScene {
  60247. /**
  60248. * The list of lens flare system added to the scene
  60249. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60250. */
  60251. lensFlareSystems: Array<LensFlareSystem>;
  60252. /**
  60253. * Removes the given lens flare system from this scene.
  60254. * @param toRemove The lens flare system to remove
  60255. * @returns The index of the removed lens flare system
  60256. */
  60257. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60258. /**
  60259. * Adds the given lens flare system to this scene
  60260. * @param newLensFlareSystem The lens flare system to add
  60261. */
  60262. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60263. /**
  60264. * Gets a lens flare system using its name
  60265. * @param name defines the name to look for
  60266. * @returns the lens flare system or null if not found
  60267. */
  60268. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60269. /**
  60270. * Gets a lens flare system using its id
  60271. * @param id defines the id to look for
  60272. * @returns the lens flare system or null if not found
  60273. */
  60274. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60275. }
  60276. }
  60277. /**
  60278. * Defines the lens flare scene component responsible to manage any lens flares
  60279. * in a given scene.
  60280. */
  60281. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60282. /**
  60283. * The component name helpfull to identify the component in the list of scene components.
  60284. */
  60285. readonly name: string;
  60286. /**
  60287. * The scene the component belongs to.
  60288. */
  60289. scene: Scene;
  60290. /**
  60291. * Creates a new instance of the component for the given scene
  60292. * @param scene Defines the scene to register the component in
  60293. */
  60294. constructor(scene: Scene);
  60295. /**
  60296. * Registers the component in a given scene
  60297. */
  60298. register(): void;
  60299. /**
  60300. * Rebuilds the elements related to this component in case of
  60301. * context lost for instance.
  60302. */
  60303. rebuild(): void;
  60304. /**
  60305. * Adds all the elements from the container to the scene
  60306. * @param container the container holding the elements
  60307. */
  60308. addFromContainer(container: AbstractScene): void;
  60309. /**
  60310. * Removes all the elements in the container from the scene
  60311. * @param container contains the elements to remove
  60312. * @param dispose if the removed element should be disposed (default: false)
  60313. */
  60314. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60315. /**
  60316. * Serializes the component data to the specified json object
  60317. * @param serializationObject The object to serialize to
  60318. */
  60319. serialize(serializationObject: any): void;
  60320. /**
  60321. * Disposes the component and the associated ressources.
  60322. */
  60323. dispose(): void;
  60324. private _draw;
  60325. }
  60326. }
  60327. declare module "babylonjs/LensFlares/index" {
  60328. export * from "babylonjs/LensFlares/lensFlare";
  60329. export * from "babylonjs/LensFlares/lensFlareSystem";
  60330. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60331. }
  60332. declare module "babylonjs/Shaders/depth.fragment" {
  60333. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60334. /** @hidden */
  60335. export var depthPixelShader: {
  60336. name: string;
  60337. shader: string;
  60338. };
  60339. }
  60340. declare module "babylonjs/Shaders/depth.vertex" {
  60341. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60343. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60344. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60345. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60346. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60347. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60348. /** @hidden */
  60349. export var depthVertexShader: {
  60350. name: string;
  60351. shader: string;
  60352. };
  60353. }
  60354. declare module "babylonjs/Rendering/depthRenderer" {
  60355. import { Nullable } from "babylonjs/types";
  60356. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60357. import { Scene } from "babylonjs/scene";
  60358. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60359. import { Camera } from "babylonjs/Cameras/camera";
  60360. import "babylonjs/Shaders/depth.fragment";
  60361. import "babylonjs/Shaders/depth.vertex";
  60362. /**
  60363. * This represents a depth renderer in Babylon.
  60364. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60365. */
  60366. export class DepthRenderer {
  60367. private _scene;
  60368. private _depthMap;
  60369. private _effect;
  60370. private readonly _storeNonLinearDepth;
  60371. private readonly _clearColor;
  60372. /** Get if the depth renderer is using packed depth or not */
  60373. readonly isPacked: boolean;
  60374. private _cachedDefines;
  60375. private _camera;
  60376. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60377. enabled: boolean;
  60378. /**
  60379. * Specifiess that the depth renderer will only be used within
  60380. * the camera it is created for.
  60381. * This can help forcing its rendering during the camera processing.
  60382. */
  60383. useOnlyInActiveCamera: boolean;
  60384. /** @hidden */
  60385. static _SceneComponentInitialization: (scene: Scene) => void;
  60386. /**
  60387. * Instantiates a depth renderer
  60388. * @param scene The scene the renderer belongs to
  60389. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60390. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60391. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60392. */
  60393. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60394. /**
  60395. * Creates the depth rendering effect and checks if the effect is ready.
  60396. * @param subMesh The submesh to be used to render the depth map of
  60397. * @param useInstances If multiple world instances should be used
  60398. * @returns if the depth renderer is ready to render the depth map
  60399. */
  60400. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60401. /**
  60402. * Gets the texture which the depth map will be written to.
  60403. * @returns The depth map texture
  60404. */
  60405. getDepthMap(): RenderTargetTexture;
  60406. /**
  60407. * Disposes of the depth renderer.
  60408. */
  60409. dispose(): void;
  60410. }
  60411. }
  60412. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60413. /** @hidden */
  60414. export var minmaxReduxPixelShader: {
  60415. name: string;
  60416. shader: string;
  60417. };
  60418. }
  60419. declare module "babylonjs/Misc/minMaxReducer" {
  60420. import { Nullable } from "babylonjs/types";
  60421. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60422. import { Camera } from "babylonjs/Cameras/camera";
  60423. import { Observer } from "babylonjs/Misc/observable";
  60424. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60425. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60426. import { Observable } from "babylonjs/Misc/observable";
  60427. import "babylonjs/Shaders/minmaxRedux.fragment";
  60428. /**
  60429. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60430. * and maximum values from all values of the texture.
  60431. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60432. * The source values are read from the red channel of the texture.
  60433. */
  60434. export class MinMaxReducer {
  60435. /**
  60436. * Observable triggered when the computation has been performed
  60437. */
  60438. onAfterReductionPerformed: Observable<{
  60439. min: number;
  60440. max: number;
  60441. }>;
  60442. protected _camera: Camera;
  60443. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60444. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60445. protected _postProcessManager: PostProcessManager;
  60446. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60447. protected _forceFullscreenViewport: boolean;
  60448. /**
  60449. * Creates a min/max reducer
  60450. * @param camera The camera to use for the post processes
  60451. */
  60452. constructor(camera: Camera);
  60453. /**
  60454. * Gets the texture used to read the values from.
  60455. */
  60456. get sourceTexture(): Nullable<RenderTargetTexture>;
  60457. /**
  60458. * Sets the source texture to read the values from.
  60459. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60460. * because in such textures '1' value must not be taken into account to compute the maximum
  60461. * as this value is used to clear the texture.
  60462. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60463. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60464. * @param depthRedux Indicates if the texture is a depth texture or not
  60465. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60466. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60467. */
  60468. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60469. /**
  60470. * Defines the refresh rate of the computation.
  60471. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60472. */
  60473. get refreshRate(): number;
  60474. set refreshRate(value: number);
  60475. protected _activated: boolean;
  60476. /**
  60477. * Gets the activation status of the reducer
  60478. */
  60479. get activated(): boolean;
  60480. /**
  60481. * Activates the reduction computation.
  60482. * When activated, the observers registered in onAfterReductionPerformed are
  60483. * called after the compuation is performed
  60484. */
  60485. activate(): void;
  60486. /**
  60487. * Deactivates the reduction computation.
  60488. */
  60489. deactivate(): void;
  60490. /**
  60491. * Disposes the min/max reducer
  60492. * @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.
  60493. */
  60494. dispose(disposeAll?: boolean): void;
  60495. }
  60496. }
  60497. declare module "babylonjs/Misc/depthReducer" {
  60498. import { Nullable } from "babylonjs/types";
  60499. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60500. import { Camera } from "babylonjs/Cameras/camera";
  60501. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60502. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60503. /**
  60504. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60505. */
  60506. export class DepthReducer extends MinMaxReducer {
  60507. private _depthRenderer;
  60508. private _depthRendererId;
  60509. /**
  60510. * Gets the depth renderer used for the computation.
  60511. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60512. */
  60513. get depthRenderer(): Nullable<DepthRenderer>;
  60514. /**
  60515. * Creates a depth reducer
  60516. * @param camera The camera used to render the depth texture
  60517. */
  60518. constructor(camera: Camera);
  60519. /**
  60520. * Sets the depth renderer to use to generate the depth map
  60521. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60522. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60523. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60524. */
  60525. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60526. /** @hidden */
  60527. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60528. /**
  60529. * Activates the reduction computation.
  60530. * When activated, the observers registered in onAfterReductionPerformed are
  60531. * called after the compuation is performed
  60532. */
  60533. activate(): void;
  60534. /**
  60535. * Deactivates the reduction computation.
  60536. */
  60537. deactivate(): void;
  60538. /**
  60539. * Disposes the depth reducer
  60540. * @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.
  60541. */
  60542. dispose(disposeAll?: boolean): void;
  60543. }
  60544. }
  60545. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60546. import { Nullable } from "babylonjs/types";
  60547. import { Scene } from "babylonjs/scene";
  60548. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60549. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60551. import { Effect } from "babylonjs/Materials/effect";
  60552. import "babylonjs/Shaders/shadowMap.fragment";
  60553. import "babylonjs/Shaders/shadowMap.vertex";
  60554. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60555. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60556. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60557. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60558. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60559. /**
  60560. * A CSM implementation allowing casting shadows on large scenes.
  60561. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60562. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60563. */
  60564. export class CascadedShadowGenerator extends ShadowGenerator {
  60565. private static readonly frustumCornersNDCSpace;
  60566. /**
  60567. * Name of the CSM class
  60568. */
  60569. static CLASSNAME: string;
  60570. /**
  60571. * Defines the default number of cascades used by the CSM.
  60572. */
  60573. static readonly DEFAULT_CASCADES_COUNT: number;
  60574. /**
  60575. * Defines the minimum number of cascades used by the CSM.
  60576. */
  60577. static readonly MIN_CASCADES_COUNT: number;
  60578. /**
  60579. * Defines the maximum number of cascades used by the CSM.
  60580. */
  60581. static readonly MAX_CASCADES_COUNT: number;
  60582. protected _validateFilter(filter: number): number;
  60583. /**
  60584. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60585. */
  60586. penumbraDarkness: number;
  60587. private _numCascades;
  60588. /**
  60589. * Gets or set the number of cascades used by the CSM.
  60590. */
  60591. get numCascades(): number;
  60592. set numCascades(value: number);
  60593. /**
  60594. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60595. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60596. */
  60597. stabilizeCascades: boolean;
  60598. private _freezeShadowCastersBoundingInfo;
  60599. private _freezeShadowCastersBoundingInfoObservable;
  60600. /**
  60601. * Enables or disables the shadow casters bounding info computation.
  60602. * If your shadow casters don't move, you can disable this feature.
  60603. * If it is enabled, the bounding box computation is done every frame.
  60604. */
  60605. get freezeShadowCastersBoundingInfo(): boolean;
  60606. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60607. private _scbiMin;
  60608. private _scbiMax;
  60609. protected _computeShadowCastersBoundingInfo(): void;
  60610. protected _shadowCastersBoundingInfo: BoundingInfo;
  60611. /**
  60612. * Gets or sets the shadow casters bounding info.
  60613. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60614. * so that the system won't overwrite the bounds you provide
  60615. */
  60616. get shadowCastersBoundingInfo(): BoundingInfo;
  60617. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60618. protected _breaksAreDirty: boolean;
  60619. protected _minDistance: number;
  60620. protected _maxDistance: number;
  60621. /**
  60622. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60623. *
  60624. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60625. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60626. * @param min minimal distance for the breaks (default to 0.)
  60627. * @param max maximal distance for the breaks (default to 1.)
  60628. */
  60629. setMinMaxDistance(min: number, max: number): void;
  60630. /** Gets the minimal distance used in the cascade break computation */
  60631. get minDistance(): number;
  60632. /** Gets the maximal distance used in the cascade break computation */
  60633. get maxDistance(): number;
  60634. /**
  60635. * Gets the class name of that object
  60636. * @returns "CascadedShadowGenerator"
  60637. */
  60638. getClassName(): string;
  60639. private _cascadeMinExtents;
  60640. private _cascadeMaxExtents;
  60641. /**
  60642. * Gets a cascade minimum extents
  60643. * @param cascadeIndex index of the cascade
  60644. * @returns the minimum cascade extents
  60645. */
  60646. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60647. /**
  60648. * Gets a cascade maximum extents
  60649. * @param cascadeIndex index of the cascade
  60650. * @returns the maximum cascade extents
  60651. */
  60652. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60653. private _cascades;
  60654. private _currentLayer;
  60655. private _viewSpaceFrustumsZ;
  60656. private _viewMatrices;
  60657. private _projectionMatrices;
  60658. private _transformMatrices;
  60659. private _transformMatricesAsArray;
  60660. private _frustumLengths;
  60661. private _lightSizeUVCorrection;
  60662. private _depthCorrection;
  60663. private _frustumCornersWorldSpace;
  60664. private _frustumCenter;
  60665. private _shadowCameraPos;
  60666. private _shadowMaxZ;
  60667. /**
  60668. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60669. * It defaults to camera.maxZ
  60670. */
  60671. get shadowMaxZ(): number;
  60672. /**
  60673. * Sets the shadow max z distance.
  60674. */
  60675. set shadowMaxZ(value: number);
  60676. protected _debug: boolean;
  60677. /**
  60678. * Gets or sets the debug flag.
  60679. * When enabled, the cascades are materialized by different colors on the screen.
  60680. */
  60681. get debug(): boolean;
  60682. set debug(dbg: boolean);
  60683. private _depthClamp;
  60684. /**
  60685. * Gets or sets the depth clamping value.
  60686. *
  60687. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60688. * to account for the shadow casters far away.
  60689. *
  60690. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60691. */
  60692. get depthClamp(): boolean;
  60693. set depthClamp(value: boolean);
  60694. private _cascadeBlendPercentage;
  60695. /**
  60696. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60697. * It defaults to 0.1 (10% blending).
  60698. */
  60699. get cascadeBlendPercentage(): number;
  60700. set cascadeBlendPercentage(value: number);
  60701. private _lambda;
  60702. /**
  60703. * Gets or set the lambda parameter.
  60704. * This parameter is used to split the camera frustum and create the cascades.
  60705. * 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.
  60706. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60707. */
  60708. get lambda(): number;
  60709. set lambda(value: number);
  60710. /**
  60711. * Gets the view matrix corresponding to a given cascade
  60712. * @param cascadeNum cascade to retrieve the view matrix from
  60713. * @returns the cascade view matrix
  60714. */
  60715. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60716. /**
  60717. * Gets the projection matrix corresponding to a given cascade
  60718. * @param cascadeNum cascade to retrieve the projection matrix from
  60719. * @returns the cascade projection matrix
  60720. */
  60721. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60722. /**
  60723. * Gets the transformation matrix corresponding to a given cascade
  60724. * @param cascadeNum cascade to retrieve the transformation matrix from
  60725. * @returns the cascade transformation matrix
  60726. */
  60727. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60728. private _depthRenderer;
  60729. /**
  60730. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60731. *
  60732. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60733. *
  60734. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60735. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60736. * @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
  60737. */
  60738. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60739. private _depthReducer;
  60740. private _autoCalcDepthBounds;
  60741. /**
  60742. * Gets or sets the autoCalcDepthBounds property.
  60743. *
  60744. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60745. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60746. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60747. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60748. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60749. */
  60750. get autoCalcDepthBounds(): boolean;
  60751. set autoCalcDepthBounds(value: boolean);
  60752. /**
  60753. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60754. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60755. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60756. * for setting the refresh rate on the renderer yourself!
  60757. */
  60758. get autoCalcDepthBoundsRefreshRate(): number;
  60759. set autoCalcDepthBoundsRefreshRate(value: number);
  60760. /**
  60761. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60762. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60763. * you change the camera near/far planes!
  60764. */
  60765. splitFrustum(): void;
  60766. private _splitFrustum;
  60767. private _computeMatrices;
  60768. private _computeFrustumInWorldSpace;
  60769. private _computeCascadeFrustum;
  60770. /**
  60771. * Support test.
  60772. */
  60773. static get IsSupported(): boolean;
  60774. /** @hidden */
  60775. static _SceneComponentInitialization: (scene: Scene) => void;
  60776. /**
  60777. * Creates a Cascaded Shadow Generator object.
  60778. * A ShadowGenerator is the required tool to use the shadows.
  60779. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60780. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60781. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60782. * @param light The directional light object generating the shadows.
  60783. * @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.
  60784. */
  60785. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60786. protected _initializeGenerator(): void;
  60787. protected _createTargetRenderTexture(): void;
  60788. protected _initializeShadowMap(): void;
  60789. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60790. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60791. /**
  60792. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60793. * @param defines Defines of the material we want to update
  60794. * @param lightIndex Index of the light in the enabled light list of the material
  60795. */
  60796. prepareDefines(defines: any, lightIndex: number): void;
  60797. /**
  60798. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60799. * defined in the generator but impacting the effect).
  60800. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60801. * @param effect The effect we are binfing the information for
  60802. */
  60803. bindShadowLight(lightIndex: string, effect: Effect): void;
  60804. /**
  60805. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60806. * (eq to view projection * shadow projection matrices)
  60807. * @returns The transform matrix used to create the shadow map
  60808. */
  60809. getTransformMatrix(): Matrix;
  60810. /**
  60811. * Disposes the ShadowGenerator.
  60812. * Returns nothing.
  60813. */
  60814. dispose(): void;
  60815. /**
  60816. * Serializes the shadow generator setup to a json object.
  60817. * @returns The serialized JSON object
  60818. */
  60819. serialize(): any;
  60820. /**
  60821. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60822. * @param parsedShadowGenerator The JSON object to parse
  60823. * @param scene The scene to create the shadow map for
  60824. * @returns The parsed shadow generator
  60825. */
  60826. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60827. }
  60828. }
  60829. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  60830. import { Scene } from "babylonjs/scene";
  60831. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60832. import { AbstractScene } from "babylonjs/abstractScene";
  60833. /**
  60834. * Defines the shadow generator component responsible to manage any shadow generators
  60835. * in a given scene.
  60836. */
  60837. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60838. /**
  60839. * The component name helpfull to identify the component in the list of scene components.
  60840. */
  60841. readonly name: string;
  60842. /**
  60843. * The scene the component belongs to.
  60844. */
  60845. scene: Scene;
  60846. /**
  60847. * Creates a new instance of the component for the given scene
  60848. * @param scene Defines the scene to register the component in
  60849. */
  60850. constructor(scene: Scene);
  60851. /**
  60852. * Registers the component in a given scene
  60853. */
  60854. register(): void;
  60855. /**
  60856. * Rebuilds the elements related to this component in case of
  60857. * context lost for instance.
  60858. */
  60859. rebuild(): void;
  60860. /**
  60861. * Serializes the component data to the specified json object
  60862. * @param serializationObject The object to serialize to
  60863. */
  60864. serialize(serializationObject: any): void;
  60865. /**
  60866. * Adds all the elements from the container to the scene
  60867. * @param container the container holding the elements
  60868. */
  60869. addFromContainer(container: AbstractScene): void;
  60870. /**
  60871. * Removes all the elements in the container from the scene
  60872. * @param container contains the elements to remove
  60873. * @param dispose if the removed element should be disposed (default: false)
  60874. */
  60875. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60876. /**
  60877. * Rebuilds the elements related to this component in case of
  60878. * context lost for instance.
  60879. */
  60880. dispose(): void;
  60881. private _gatherRenderTargets;
  60882. }
  60883. }
  60884. declare module "babylonjs/Lights/Shadows/index" {
  60885. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  60886. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  60887. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  60888. }
  60889. declare module "babylonjs/Lights/pointLight" {
  60890. import { Scene } from "babylonjs/scene";
  60891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60893. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60894. import { Effect } from "babylonjs/Materials/effect";
  60895. /**
  60896. * A point light is a light defined by an unique point in world space.
  60897. * The light is emitted in every direction from this point.
  60898. * A good example of a point light is a standard light bulb.
  60899. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60900. */
  60901. export class PointLight extends ShadowLight {
  60902. private _shadowAngle;
  60903. /**
  60904. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60905. * This specifies what angle the shadow will use to be created.
  60906. *
  60907. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60908. */
  60909. get shadowAngle(): number;
  60910. /**
  60911. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60912. * This specifies what angle the shadow will use to be created.
  60913. *
  60914. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60915. */
  60916. set shadowAngle(value: number);
  60917. /**
  60918. * Gets the direction if it has been set.
  60919. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60920. */
  60921. get direction(): Vector3;
  60922. /**
  60923. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60924. */
  60925. set direction(value: Vector3);
  60926. /**
  60927. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60928. * A PointLight emits the light in every direction.
  60929. * It can cast shadows.
  60930. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60931. * ```javascript
  60932. * var pointLight = new PointLight("pl", camera.position, scene);
  60933. * ```
  60934. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60935. * @param name The light friendly name
  60936. * @param position The position of the point light in the scene
  60937. * @param scene The scene the lights belongs to
  60938. */
  60939. constructor(name: string, position: Vector3, scene: Scene);
  60940. /**
  60941. * Returns the string "PointLight"
  60942. * @returns the class name
  60943. */
  60944. getClassName(): string;
  60945. /**
  60946. * Returns the integer 0.
  60947. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60948. */
  60949. getTypeID(): number;
  60950. /**
  60951. * Specifies wether or not the shadowmap should be a cube texture.
  60952. * @returns true if the shadowmap needs to be a cube texture.
  60953. */
  60954. needCube(): boolean;
  60955. /**
  60956. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60957. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60958. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60959. */
  60960. getShadowDirection(faceIndex?: number): Vector3;
  60961. /**
  60962. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60963. * - fov = PI / 2
  60964. * - aspect ratio : 1.0
  60965. * - z-near and far equal to the active camera minZ and maxZ.
  60966. * Returns the PointLight.
  60967. */
  60968. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60969. protected _buildUniformLayout(): void;
  60970. /**
  60971. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60972. * @param effect The effect to update
  60973. * @param lightIndex The index of the light in the effect to update
  60974. * @returns The point light
  60975. */
  60976. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60977. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60978. /**
  60979. * Prepares the list of defines specific to the light type.
  60980. * @param defines the list of defines
  60981. * @param lightIndex defines the index of the light for the effect
  60982. */
  60983. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60984. }
  60985. }
  60986. declare module "babylonjs/Lights/index" {
  60987. export * from "babylonjs/Lights/light";
  60988. export * from "babylonjs/Lights/shadowLight";
  60989. export * from "babylonjs/Lights/Shadows/index";
  60990. export * from "babylonjs/Lights/directionalLight";
  60991. export * from "babylonjs/Lights/hemisphericLight";
  60992. export * from "babylonjs/Lights/pointLight";
  60993. export * from "babylonjs/Lights/spotLight";
  60994. }
  60995. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  60996. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  60997. /**
  60998. * Header information of HDR texture files.
  60999. */
  61000. export interface HDRInfo {
  61001. /**
  61002. * The height of the texture in pixels.
  61003. */
  61004. height: number;
  61005. /**
  61006. * The width of the texture in pixels.
  61007. */
  61008. width: number;
  61009. /**
  61010. * The index of the beginning of the data in the binary file.
  61011. */
  61012. dataPosition: number;
  61013. }
  61014. /**
  61015. * This groups tools to convert HDR texture to native colors array.
  61016. */
  61017. export class HDRTools {
  61018. private static Ldexp;
  61019. private static Rgbe2float;
  61020. private static readStringLine;
  61021. /**
  61022. * Reads header information from an RGBE texture stored in a native array.
  61023. * More information on this format are available here:
  61024. * https://en.wikipedia.org/wiki/RGBE_image_format
  61025. *
  61026. * @param uint8array The binary file stored in native array.
  61027. * @return The header information.
  61028. */
  61029. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61030. /**
  61031. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61032. * This RGBE texture needs to store the information as a panorama.
  61033. *
  61034. * More information on this format are available here:
  61035. * https://en.wikipedia.org/wiki/RGBE_image_format
  61036. *
  61037. * @param buffer The binary file stored in an array buffer.
  61038. * @param size The expected size of the extracted cubemap.
  61039. * @return The Cube Map information.
  61040. */
  61041. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61042. /**
  61043. * Returns the pixels data extracted from an RGBE texture.
  61044. * This pixels will be stored left to right up to down in the R G B order in one array.
  61045. *
  61046. * More information on this format are available here:
  61047. * https://en.wikipedia.org/wiki/RGBE_image_format
  61048. *
  61049. * @param uint8array The binary file stored in an array buffer.
  61050. * @param hdrInfo The header information of the file.
  61051. * @return The pixels data in RGB right to left up to down order.
  61052. */
  61053. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61054. private static RGBE_ReadPixels_RLE;
  61055. }
  61056. }
  61057. declare module "babylonjs/Materials/effectRenderer" {
  61058. import { Nullable } from "babylonjs/types";
  61059. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61060. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61061. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61062. import { Viewport } from "babylonjs/Maths/math.viewport";
  61063. import { Observable } from "babylonjs/Misc/observable";
  61064. import { Effect } from "babylonjs/Materials/effect";
  61065. import "babylonjs/Shaders/postprocess.vertex";
  61066. /**
  61067. * Effect Render Options
  61068. */
  61069. export interface IEffectRendererOptions {
  61070. /**
  61071. * Defines the vertices positions.
  61072. */
  61073. positions?: number[];
  61074. /**
  61075. * Defines the indices.
  61076. */
  61077. indices?: number[];
  61078. }
  61079. /**
  61080. * Helper class to render one or more effects.
  61081. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61082. */
  61083. export class EffectRenderer {
  61084. private engine;
  61085. private static _DefaultOptions;
  61086. private _vertexBuffers;
  61087. private _indexBuffer;
  61088. private _fullscreenViewport;
  61089. /**
  61090. * Creates an effect renderer
  61091. * @param engine the engine to use for rendering
  61092. * @param options defines the options of the effect renderer
  61093. */
  61094. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61095. /**
  61096. * Sets the current viewport in normalized coordinates 0-1
  61097. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61098. */
  61099. setViewport(viewport?: Viewport): void;
  61100. /**
  61101. * Binds the embedded attributes buffer to the effect.
  61102. * @param effect Defines the effect to bind the attributes for
  61103. */
  61104. bindBuffers(effect: Effect): void;
  61105. /**
  61106. * Sets the current effect wrapper to use during draw.
  61107. * The effect needs to be ready before calling this api.
  61108. * This also sets the default full screen position attribute.
  61109. * @param effectWrapper Defines the effect to draw with
  61110. */
  61111. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61112. /**
  61113. * Restores engine states
  61114. */
  61115. restoreStates(): void;
  61116. /**
  61117. * Draws a full screen quad.
  61118. */
  61119. draw(): void;
  61120. private isRenderTargetTexture;
  61121. /**
  61122. * renders one or more effects to a specified texture
  61123. * @param effectWrapper the effect to renderer
  61124. * @param outputTexture texture to draw to, if null it will render to the screen.
  61125. */
  61126. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61127. /**
  61128. * Disposes of the effect renderer
  61129. */
  61130. dispose(): void;
  61131. }
  61132. /**
  61133. * Options to create an EffectWrapper
  61134. */
  61135. interface EffectWrapperCreationOptions {
  61136. /**
  61137. * Engine to use to create the effect
  61138. */
  61139. engine: ThinEngine;
  61140. /**
  61141. * Fragment shader for the effect
  61142. */
  61143. fragmentShader: string;
  61144. /**
  61145. * Use the shader store instead of direct source code
  61146. */
  61147. useShaderStore?: boolean;
  61148. /**
  61149. * Vertex shader for the effect
  61150. */
  61151. vertexShader?: string;
  61152. /**
  61153. * Attributes to use in the shader
  61154. */
  61155. attributeNames?: Array<string>;
  61156. /**
  61157. * Uniforms to use in the shader
  61158. */
  61159. uniformNames?: Array<string>;
  61160. /**
  61161. * Texture sampler names to use in the shader
  61162. */
  61163. samplerNames?: Array<string>;
  61164. /**
  61165. * Defines to use in the shader
  61166. */
  61167. defines?: Array<string>;
  61168. /**
  61169. * Callback when effect is compiled
  61170. */
  61171. onCompiled?: Nullable<(effect: Effect) => void>;
  61172. /**
  61173. * The friendly name of the effect displayed in Spector.
  61174. */
  61175. name?: string;
  61176. }
  61177. /**
  61178. * Wraps an effect to be used for rendering
  61179. */
  61180. export class EffectWrapper {
  61181. /**
  61182. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61183. */
  61184. onApplyObservable: Observable<{}>;
  61185. /**
  61186. * The underlying effect
  61187. */
  61188. effect: Effect;
  61189. /**
  61190. * Creates an effect to be renderer
  61191. * @param creationOptions options to create the effect
  61192. */
  61193. constructor(creationOptions: EffectWrapperCreationOptions);
  61194. /**
  61195. * Disposes of the effect wrapper
  61196. */
  61197. dispose(): void;
  61198. }
  61199. }
  61200. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61201. /** @hidden */
  61202. export var hdrFilteringVertexShader: {
  61203. name: string;
  61204. shader: string;
  61205. };
  61206. }
  61207. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61209. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61210. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61211. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61212. /** @hidden */
  61213. export var hdrFilteringPixelShader: {
  61214. name: string;
  61215. shader: string;
  61216. };
  61217. }
  61218. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61220. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61221. import { Nullable } from "babylonjs/types";
  61222. import "babylonjs/Shaders/hdrFiltering.vertex";
  61223. import "babylonjs/Shaders/hdrFiltering.fragment";
  61224. /**
  61225. * Options for texture filtering
  61226. */
  61227. interface IHDRFilteringOptions {
  61228. /**
  61229. * Scales pixel intensity for the input HDR map.
  61230. */
  61231. hdrScale?: number;
  61232. /**
  61233. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61234. */
  61235. quality?: number;
  61236. }
  61237. /**
  61238. * Filters HDR maps to get correct renderings of PBR reflections
  61239. */
  61240. export class HDRFiltering {
  61241. private _engine;
  61242. private _effectRenderer;
  61243. private _effectWrapper;
  61244. private _lodGenerationOffset;
  61245. private _lodGenerationScale;
  61246. /**
  61247. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61248. * you care about baking speed.
  61249. */
  61250. quality: number;
  61251. /**
  61252. * Scales pixel intensity for the input HDR map.
  61253. */
  61254. hdrScale: number;
  61255. /**
  61256. * Instantiates HDR filter for reflection maps
  61257. *
  61258. * @param engine Thin engine
  61259. * @param options Options
  61260. */
  61261. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61262. private _createRenderTarget;
  61263. private _prefilterInternal;
  61264. private _createEffect;
  61265. /**
  61266. * Get a value indicating if the filter is ready to be used
  61267. * @param texture Texture to filter
  61268. * @returns true if the filter is ready
  61269. */
  61270. isReady(texture: BaseTexture): boolean;
  61271. /**
  61272. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61273. * Prefiltering will be invoked at the end of next rendering pass.
  61274. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61275. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61276. * @param texture Texture to filter
  61277. * @param onFinished Callback when filtering is done
  61278. * @return Promise called when prefiltering is done
  61279. */
  61280. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61281. }
  61282. }
  61283. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61284. import { Nullable } from "babylonjs/types";
  61285. import { Scene } from "babylonjs/scene";
  61286. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61288. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61289. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61290. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61291. /**
  61292. * This represents a texture coming from an HDR input.
  61293. *
  61294. * The only supported format is currently panorama picture stored in RGBE format.
  61295. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61296. */
  61297. export class HDRCubeTexture extends BaseTexture {
  61298. private static _facesMapping;
  61299. private _generateHarmonics;
  61300. private _noMipmap;
  61301. private _prefilterOnLoad;
  61302. private _textureMatrix;
  61303. private _size;
  61304. private _onLoad;
  61305. private _onError;
  61306. /**
  61307. * The texture URL.
  61308. */
  61309. url: string;
  61310. /**
  61311. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61312. */
  61313. coordinatesMode: number;
  61314. protected _isBlocking: boolean;
  61315. /**
  61316. * Sets wether or not the texture is blocking during loading.
  61317. */
  61318. set isBlocking(value: boolean);
  61319. /**
  61320. * Gets wether or not the texture is blocking during loading.
  61321. */
  61322. get isBlocking(): boolean;
  61323. protected _rotationY: number;
  61324. /**
  61325. * Sets texture matrix rotation angle around Y axis in radians.
  61326. */
  61327. set rotationY(value: number);
  61328. /**
  61329. * Gets texture matrix rotation angle around Y axis radians.
  61330. */
  61331. get rotationY(): number;
  61332. /**
  61333. * Gets or sets the center of the bounding box associated with the cube texture
  61334. * It must define where the camera used to render the texture was set
  61335. */
  61336. boundingBoxPosition: Vector3;
  61337. private _boundingBoxSize;
  61338. /**
  61339. * Gets or sets the size of the bounding box associated with the cube texture
  61340. * When defined, the cubemap will switch to local mode
  61341. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61342. * @example https://www.babylonjs-playground.com/#RNASML
  61343. */
  61344. set boundingBoxSize(value: Vector3);
  61345. get boundingBoxSize(): Vector3;
  61346. /**
  61347. * Instantiates an HDRTexture from the following parameters.
  61348. *
  61349. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61350. * @param sceneOrEngine The scene or engine the texture will be used in
  61351. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61352. * @param noMipmap Forces to not generate the mipmap if true
  61353. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61354. * @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)
  61355. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61356. */
  61357. 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>);
  61358. /**
  61359. * Get the current class name of the texture useful for serialization or dynamic coding.
  61360. * @returns "HDRCubeTexture"
  61361. */
  61362. getClassName(): string;
  61363. /**
  61364. * Occurs when the file is raw .hdr file.
  61365. */
  61366. private loadTexture;
  61367. clone(): HDRCubeTexture;
  61368. delayLoad(): void;
  61369. /**
  61370. * Get the texture reflection matrix used to rotate/transform the reflection.
  61371. * @returns the reflection matrix
  61372. */
  61373. getReflectionTextureMatrix(): Matrix;
  61374. /**
  61375. * Set the texture reflection matrix used to rotate/transform the reflection.
  61376. * @param value Define the reflection matrix to set
  61377. */
  61378. setReflectionTextureMatrix(value: Matrix): void;
  61379. /**
  61380. * Parses a JSON representation of an HDR Texture in order to create the texture
  61381. * @param parsedTexture Define the JSON representation
  61382. * @param scene Define the scene the texture should be created in
  61383. * @param rootUrl Define the root url in case we need to load relative dependencies
  61384. * @returns the newly created texture after parsing
  61385. */
  61386. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61387. serialize(): any;
  61388. }
  61389. }
  61390. declare module "babylonjs/Physics/physicsEngine" {
  61391. import { Nullable } from "babylonjs/types";
  61392. import { Vector3 } from "babylonjs/Maths/math.vector";
  61393. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61394. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61395. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61396. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61397. /**
  61398. * Class used to control physics engine
  61399. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61400. */
  61401. export class PhysicsEngine implements IPhysicsEngine {
  61402. private _physicsPlugin;
  61403. /**
  61404. * Global value used to control the smallest number supported by the simulation
  61405. */
  61406. static Epsilon: number;
  61407. private _impostors;
  61408. private _joints;
  61409. private _subTimeStep;
  61410. /**
  61411. * Gets the gravity vector used by the simulation
  61412. */
  61413. gravity: Vector3;
  61414. /**
  61415. * Factory used to create the default physics plugin.
  61416. * @returns The default physics plugin
  61417. */
  61418. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61419. /**
  61420. * Creates a new Physics Engine
  61421. * @param gravity defines the gravity vector used by the simulation
  61422. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61423. */
  61424. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61425. /**
  61426. * Sets the gravity vector used by the simulation
  61427. * @param gravity defines the gravity vector to use
  61428. */
  61429. setGravity(gravity: Vector3): void;
  61430. /**
  61431. * Set the time step of the physics engine.
  61432. * Default is 1/60.
  61433. * To slow it down, enter 1/600 for example.
  61434. * To speed it up, 1/30
  61435. * @param newTimeStep defines the new timestep to apply to this world.
  61436. */
  61437. setTimeStep(newTimeStep?: number): void;
  61438. /**
  61439. * Get the time step of the physics engine.
  61440. * @returns the current time step
  61441. */
  61442. getTimeStep(): number;
  61443. /**
  61444. * Set the sub time step of the physics engine.
  61445. * Default is 0 meaning there is no sub steps
  61446. * To increase physics resolution precision, set a small value (like 1 ms)
  61447. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61448. */
  61449. setSubTimeStep(subTimeStep?: number): void;
  61450. /**
  61451. * Get the sub time step of the physics engine.
  61452. * @returns the current sub time step
  61453. */
  61454. getSubTimeStep(): number;
  61455. /**
  61456. * Release all resources
  61457. */
  61458. dispose(): void;
  61459. /**
  61460. * Gets the name of the current physics plugin
  61461. * @returns the name of the plugin
  61462. */
  61463. getPhysicsPluginName(): string;
  61464. /**
  61465. * Adding a new impostor for the impostor tracking.
  61466. * This will be done by the impostor itself.
  61467. * @param impostor the impostor to add
  61468. */
  61469. addImpostor(impostor: PhysicsImpostor): void;
  61470. /**
  61471. * Remove an impostor from the engine.
  61472. * This impostor and its mesh will not longer be updated by the physics engine.
  61473. * @param impostor the impostor to remove
  61474. */
  61475. removeImpostor(impostor: PhysicsImpostor): void;
  61476. /**
  61477. * Add a joint to the physics engine
  61478. * @param mainImpostor defines the main impostor to which the joint is added.
  61479. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61480. * @param joint defines the joint that will connect both impostors.
  61481. */
  61482. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61483. /**
  61484. * Removes a joint from the simulation
  61485. * @param mainImpostor defines the impostor used with the joint
  61486. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61487. * @param joint defines the joint to remove
  61488. */
  61489. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61490. /**
  61491. * Called by the scene. No need to call it.
  61492. * @param delta defines the timespam between frames
  61493. */
  61494. _step(delta: number): void;
  61495. /**
  61496. * Gets the current plugin used to run the simulation
  61497. * @returns current plugin
  61498. */
  61499. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61500. /**
  61501. * Gets the list of physic impostors
  61502. * @returns an array of PhysicsImpostor
  61503. */
  61504. getImpostors(): Array<PhysicsImpostor>;
  61505. /**
  61506. * Gets the impostor for a physics enabled object
  61507. * @param object defines the object impersonated by the impostor
  61508. * @returns the PhysicsImpostor or null if not found
  61509. */
  61510. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61511. /**
  61512. * Gets the impostor for a physics body object
  61513. * @param body defines physics body used by the impostor
  61514. * @returns the PhysicsImpostor or null if not found
  61515. */
  61516. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61517. /**
  61518. * Does a raycast in the physics world
  61519. * @param from when should the ray start?
  61520. * @param to when should the ray end?
  61521. * @returns PhysicsRaycastResult
  61522. */
  61523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61524. }
  61525. }
  61526. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61527. import { Nullable } from "babylonjs/types";
  61528. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61530. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61531. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61532. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61533. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61534. /** @hidden */
  61535. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61536. private _useDeltaForWorldStep;
  61537. world: any;
  61538. name: string;
  61539. private _physicsMaterials;
  61540. private _fixedTimeStep;
  61541. private _cannonRaycastResult;
  61542. private _raycastResult;
  61543. private _physicsBodysToRemoveAfterStep;
  61544. private _firstFrame;
  61545. BJSCANNON: any;
  61546. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61547. setGravity(gravity: Vector3): void;
  61548. setTimeStep(timeStep: number): void;
  61549. getTimeStep(): number;
  61550. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61551. private _removeMarkedPhysicsBodiesFromWorld;
  61552. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61553. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61554. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61555. private _processChildMeshes;
  61556. removePhysicsBody(impostor: PhysicsImpostor): void;
  61557. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61558. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61559. private _addMaterial;
  61560. private _checkWithEpsilon;
  61561. private _createShape;
  61562. private _createHeightmap;
  61563. private _minus90X;
  61564. private _plus90X;
  61565. private _tmpPosition;
  61566. private _tmpDeltaPosition;
  61567. private _tmpUnityRotation;
  61568. private _updatePhysicsBodyTransformation;
  61569. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61570. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61571. isSupported(): boolean;
  61572. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61573. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61574. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61575. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61576. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61577. getBodyMass(impostor: PhysicsImpostor): number;
  61578. getBodyFriction(impostor: PhysicsImpostor): number;
  61579. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61580. getBodyRestitution(impostor: PhysicsImpostor): number;
  61581. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61582. sleepBody(impostor: PhysicsImpostor): void;
  61583. wakeUpBody(impostor: PhysicsImpostor): void;
  61584. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61585. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61586. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61587. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61588. getRadius(impostor: PhysicsImpostor): number;
  61589. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61590. dispose(): void;
  61591. private _extendNamespace;
  61592. /**
  61593. * Does a raycast in the physics world
  61594. * @param from when should the ray start?
  61595. * @param to when should the ray end?
  61596. * @returns PhysicsRaycastResult
  61597. */
  61598. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61599. }
  61600. }
  61601. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  61602. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61603. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61604. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61606. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61607. import { Nullable } from "babylonjs/types";
  61608. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61609. /** @hidden */
  61610. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61611. private _useDeltaForWorldStep;
  61612. world: any;
  61613. name: string;
  61614. BJSOIMO: any;
  61615. private _raycastResult;
  61616. private _fixedTimeStep;
  61617. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61618. setGravity(gravity: Vector3): void;
  61619. setTimeStep(timeStep: number): void;
  61620. getTimeStep(): number;
  61621. private _tmpImpostorsArray;
  61622. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61623. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61624. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61625. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61626. private _tmpPositionVector;
  61627. removePhysicsBody(impostor: PhysicsImpostor): void;
  61628. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61629. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61630. isSupported(): boolean;
  61631. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61633. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61634. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61635. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61636. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61637. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61638. getBodyMass(impostor: PhysicsImpostor): number;
  61639. getBodyFriction(impostor: PhysicsImpostor): number;
  61640. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61641. getBodyRestitution(impostor: PhysicsImpostor): number;
  61642. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61643. sleepBody(impostor: PhysicsImpostor): void;
  61644. wakeUpBody(impostor: PhysicsImpostor): void;
  61645. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61646. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61647. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61648. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61649. getRadius(impostor: PhysicsImpostor): number;
  61650. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61651. dispose(): void;
  61652. /**
  61653. * Does a raycast in the physics world
  61654. * @param from when should the ray start?
  61655. * @param to when should the ray end?
  61656. * @returns PhysicsRaycastResult
  61657. */
  61658. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61659. }
  61660. }
  61661. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61662. import { Nullable } from "babylonjs/types";
  61663. import { Scene } from "babylonjs/scene";
  61664. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61665. import { Color4 } from "babylonjs/Maths/math.color";
  61666. import { Mesh } from "babylonjs/Meshes/mesh";
  61667. /**
  61668. * Class containing static functions to help procedurally build meshes
  61669. */
  61670. export class RibbonBuilder {
  61671. /**
  61672. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61673. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61674. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61675. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61676. * * 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
  61677. * * 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
  61678. * * 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
  61679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61682. * * 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
  61683. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61684. * * 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
  61685. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61687. * @param name defines the name of the mesh
  61688. * @param options defines the options used to create the mesh
  61689. * @param scene defines the hosting scene
  61690. * @returns the ribbon mesh
  61691. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61692. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61693. */
  61694. static CreateRibbon(name: string, options: {
  61695. pathArray: Vector3[][];
  61696. closeArray?: boolean;
  61697. closePath?: boolean;
  61698. offset?: number;
  61699. updatable?: boolean;
  61700. sideOrientation?: number;
  61701. frontUVs?: Vector4;
  61702. backUVs?: Vector4;
  61703. instance?: Mesh;
  61704. invertUV?: boolean;
  61705. uvs?: Vector2[];
  61706. colors?: Color4[];
  61707. }, scene?: Nullable<Scene>): Mesh;
  61708. }
  61709. }
  61710. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61711. import { Nullable } from "babylonjs/types";
  61712. import { Scene } from "babylonjs/scene";
  61713. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61714. import { Mesh } from "babylonjs/Meshes/mesh";
  61715. /**
  61716. * Class containing static functions to help procedurally build meshes
  61717. */
  61718. export class ShapeBuilder {
  61719. /**
  61720. * 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.
  61721. * * 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.
  61722. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61723. * * 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.
  61724. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61725. * * 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
  61726. * * 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
  61727. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61732. * @param name defines the name of the mesh
  61733. * @param options defines the options used to create the mesh
  61734. * @param scene defines the hosting scene
  61735. * @returns the extruded shape mesh
  61736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61738. */
  61739. static ExtrudeShape(name: string, options: {
  61740. shape: Vector3[];
  61741. path: Vector3[];
  61742. scale?: number;
  61743. rotation?: number;
  61744. cap?: number;
  61745. updatable?: boolean;
  61746. sideOrientation?: number;
  61747. frontUVs?: Vector4;
  61748. backUVs?: Vector4;
  61749. instance?: Mesh;
  61750. invertUV?: boolean;
  61751. }, scene?: Nullable<Scene>): Mesh;
  61752. /**
  61753. * Creates an custom extruded shape mesh.
  61754. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61755. * * 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.
  61756. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61757. * * 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
  61758. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61759. * * 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
  61760. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61761. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61762. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61763. * * 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
  61764. * * 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
  61765. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61768. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61770. * @param name defines the name of the mesh
  61771. * @param options defines the options used to create the mesh
  61772. * @param scene defines the hosting scene
  61773. * @returns the custom extruded shape mesh
  61774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61777. */
  61778. static ExtrudeShapeCustom(name: string, options: {
  61779. shape: Vector3[];
  61780. path: Vector3[];
  61781. scaleFunction?: any;
  61782. rotationFunction?: any;
  61783. ribbonCloseArray?: boolean;
  61784. ribbonClosePath?: boolean;
  61785. cap?: number;
  61786. updatable?: boolean;
  61787. sideOrientation?: number;
  61788. frontUVs?: Vector4;
  61789. backUVs?: Vector4;
  61790. instance?: Mesh;
  61791. invertUV?: boolean;
  61792. }, scene?: Nullable<Scene>): Mesh;
  61793. private static _ExtrudeShapeGeneric;
  61794. }
  61795. }
  61796. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  61797. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  61798. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61799. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61800. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61801. import { Nullable } from "babylonjs/types";
  61802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61803. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61804. /**
  61805. * AmmoJS Physics plugin
  61806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61807. * @see https://github.com/kripken/ammo.js/
  61808. */
  61809. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61810. private _useDeltaForWorldStep;
  61811. /**
  61812. * Reference to the Ammo library
  61813. */
  61814. bjsAMMO: any;
  61815. /**
  61816. * Created ammoJS world which physics bodies are added to
  61817. */
  61818. world: any;
  61819. /**
  61820. * Name of the plugin
  61821. */
  61822. name: string;
  61823. private _timeStep;
  61824. private _fixedTimeStep;
  61825. private _maxSteps;
  61826. private _tmpQuaternion;
  61827. private _tmpAmmoTransform;
  61828. private _tmpAmmoQuaternion;
  61829. private _tmpAmmoConcreteContactResultCallback;
  61830. private _collisionConfiguration;
  61831. private _dispatcher;
  61832. private _overlappingPairCache;
  61833. private _solver;
  61834. private _softBodySolver;
  61835. private _tmpAmmoVectorA;
  61836. private _tmpAmmoVectorB;
  61837. private _tmpAmmoVectorC;
  61838. private _tmpAmmoVectorD;
  61839. private _tmpContactCallbackResult;
  61840. private _tmpAmmoVectorRCA;
  61841. private _tmpAmmoVectorRCB;
  61842. private _raycastResult;
  61843. private static readonly DISABLE_COLLISION_FLAG;
  61844. private static readonly KINEMATIC_FLAG;
  61845. private static readonly DISABLE_DEACTIVATION_FLAG;
  61846. /**
  61847. * Initializes the ammoJS plugin
  61848. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61849. * @param ammoInjection can be used to inject your own ammo reference
  61850. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61851. */
  61852. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61853. /**
  61854. * Sets the gravity of the physics world (m/(s^2))
  61855. * @param gravity Gravity to set
  61856. */
  61857. setGravity(gravity: Vector3): void;
  61858. /**
  61859. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61860. * @param timeStep timestep to use in seconds
  61861. */
  61862. setTimeStep(timeStep: number): void;
  61863. /**
  61864. * 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)
  61865. * @param fixedTimeStep fixedTimeStep to use in seconds
  61866. */
  61867. setFixedTimeStep(fixedTimeStep: number): void;
  61868. /**
  61869. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61870. * @param maxSteps the maximum number of steps by the physics engine per frame
  61871. */
  61872. setMaxSteps(maxSteps: number): void;
  61873. /**
  61874. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61875. * @returns the current timestep in seconds
  61876. */
  61877. getTimeStep(): number;
  61878. /**
  61879. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61880. */
  61881. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61882. private _isImpostorInContact;
  61883. private _isImpostorPairInContact;
  61884. private _stepSimulation;
  61885. /**
  61886. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61887. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61888. * After the step the babylon meshes are set to the position of the physics imposters
  61889. * @param delta amount of time to step forward
  61890. * @param impostors array of imposters to update before/after the step
  61891. */
  61892. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61893. /**
  61894. * Update babylon mesh to match physics world object
  61895. * @param impostor imposter to match
  61896. */
  61897. private _afterSoftStep;
  61898. /**
  61899. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61900. * @param impostor imposter to match
  61901. */
  61902. private _ropeStep;
  61903. /**
  61904. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61905. * @param impostor imposter to match
  61906. */
  61907. private _softbodyOrClothStep;
  61908. private _tmpMatrix;
  61909. /**
  61910. * Applies an impulse on the imposter
  61911. * @param impostor imposter to apply impulse to
  61912. * @param force amount of force to be applied to the imposter
  61913. * @param contactPoint the location to apply the impulse on the imposter
  61914. */
  61915. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61916. /**
  61917. * Applies a force on the imposter
  61918. * @param impostor imposter to apply force
  61919. * @param force amount of force to be applied to the imposter
  61920. * @param contactPoint the location to apply the force on the imposter
  61921. */
  61922. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61923. /**
  61924. * Creates a physics body using the plugin
  61925. * @param impostor the imposter to create the physics body on
  61926. */
  61927. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61928. /**
  61929. * Removes the physics body from the imposter and disposes of the body's memory
  61930. * @param impostor imposter to remove the physics body from
  61931. */
  61932. removePhysicsBody(impostor: PhysicsImpostor): void;
  61933. /**
  61934. * Generates a joint
  61935. * @param impostorJoint the imposter joint to create the joint with
  61936. */
  61937. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61938. /**
  61939. * Removes a joint
  61940. * @param impostorJoint the imposter joint to remove the joint from
  61941. */
  61942. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61943. private _addMeshVerts;
  61944. /**
  61945. * Initialise the soft body vertices to match its object's (mesh) vertices
  61946. * Softbody vertices (nodes) are in world space and to match this
  61947. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61948. * @param impostor to create the softbody for
  61949. */
  61950. private _softVertexData;
  61951. /**
  61952. * Create an impostor's soft body
  61953. * @param impostor to create the softbody for
  61954. */
  61955. private _createSoftbody;
  61956. /**
  61957. * Create cloth for an impostor
  61958. * @param impostor to create the softbody for
  61959. */
  61960. private _createCloth;
  61961. /**
  61962. * Create rope for an impostor
  61963. * @param impostor to create the softbody for
  61964. */
  61965. private _createRope;
  61966. /**
  61967. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61968. * @param impostor to create the custom physics shape for
  61969. */
  61970. private _createCustom;
  61971. private _addHullVerts;
  61972. private _createShape;
  61973. /**
  61974. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61975. * @param impostor imposter containing the physics body and babylon object
  61976. */
  61977. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61978. /**
  61979. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61980. * @param impostor imposter containing the physics body and babylon object
  61981. * @param newPosition new position
  61982. * @param newRotation new rotation
  61983. */
  61984. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61985. /**
  61986. * If this plugin is supported
  61987. * @returns true if its supported
  61988. */
  61989. isSupported(): boolean;
  61990. /**
  61991. * Sets the linear velocity of the physics body
  61992. * @param impostor imposter to set the velocity on
  61993. * @param velocity velocity to set
  61994. */
  61995. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61996. /**
  61997. * Sets the angular velocity of the physics body
  61998. * @param impostor imposter to set the velocity on
  61999. * @param velocity velocity to set
  62000. */
  62001. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62002. /**
  62003. * gets the linear velocity
  62004. * @param impostor imposter to get linear velocity from
  62005. * @returns linear velocity
  62006. */
  62007. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62008. /**
  62009. * gets the angular velocity
  62010. * @param impostor imposter to get angular velocity from
  62011. * @returns angular velocity
  62012. */
  62013. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62014. /**
  62015. * Sets the mass of physics body
  62016. * @param impostor imposter to set the mass on
  62017. * @param mass mass to set
  62018. */
  62019. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62020. /**
  62021. * Gets the mass of the physics body
  62022. * @param impostor imposter to get the mass from
  62023. * @returns mass
  62024. */
  62025. getBodyMass(impostor: PhysicsImpostor): number;
  62026. /**
  62027. * Gets friction of the impostor
  62028. * @param impostor impostor to get friction from
  62029. * @returns friction value
  62030. */
  62031. getBodyFriction(impostor: PhysicsImpostor): number;
  62032. /**
  62033. * Sets friction of the impostor
  62034. * @param impostor impostor to set friction on
  62035. * @param friction friction value
  62036. */
  62037. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62038. /**
  62039. * Gets restitution of the impostor
  62040. * @param impostor impostor to get restitution from
  62041. * @returns restitution value
  62042. */
  62043. getBodyRestitution(impostor: PhysicsImpostor): number;
  62044. /**
  62045. * Sets resitution of the impostor
  62046. * @param impostor impostor to set resitution on
  62047. * @param restitution resitution value
  62048. */
  62049. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62050. /**
  62051. * Gets pressure inside the impostor
  62052. * @param impostor impostor to get pressure from
  62053. * @returns pressure value
  62054. */
  62055. getBodyPressure(impostor: PhysicsImpostor): number;
  62056. /**
  62057. * Sets pressure inside a soft body impostor
  62058. * Cloth and rope must remain 0 pressure
  62059. * @param impostor impostor to set pressure on
  62060. * @param pressure pressure value
  62061. */
  62062. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62063. /**
  62064. * Gets stiffness of the impostor
  62065. * @param impostor impostor to get stiffness from
  62066. * @returns pressure value
  62067. */
  62068. getBodyStiffness(impostor: PhysicsImpostor): number;
  62069. /**
  62070. * Sets stiffness of the impostor
  62071. * @param impostor impostor to set stiffness on
  62072. * @param stiffness stiffness value from 0 to 1
  62073. */
  62074. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62075. /**
  62076. * Gets velocityIterations of the impostor
  62077. * @param impostor impostor to get velocity iterations from
  62078. * @returns velocityIterations value
  62079. */
  62080. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62081. /**
  62082. * Sets velocityIterations of the impostor
  62083. * @param impostor impostor to set velocity iterations on
  62084. * @param velocityIterations velocityIterations value
  62085. */
  62086. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62087. /**
  62088. * Gets positionIterations of the impostor
  62089. * @param impostor impostor to get position iterations from
  62090. * @returns positionIterations value
  62091. */
  62092. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62093. /**
  62094. * Sets positionIterations of the impostor
  62095. * @param impostor impostor to set position on
  62096. * @param positionIterations positionIterations value
  62097. */
  62098. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62099. /**
  62100. * Append an anchor to a cloth object
  62101. * @param impostor is the cloth impostor to add anchor to
  62102. * @param otherImpostor is the rigid impostor to anchor to
  62103. * @param width ratio across width from 0 to 1
  62104. * @param height ratio up height from 0 to 1
  62105. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62106. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62107. */
  62108. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62109. /**
  62110. * Append an hook to a rope object
  62111. * @param impostor is the rope impostor to add hook to
  62112. * @param otherImpostor is the rigid impostor to hook to
  62113. * @param length ratio along the rope from 0 to 1
  62114. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62115. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62116. */
  62117. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62118. /**
  62119. * Sleeps the physics body and stops it from being active
  62120. * @param impostor impostor to sleep
  62121. */
  62122. sleepBody(impostor: PhysicsImpostor): void;
  62123. /**
  62124. * Activates the physics body
  62125. * @param impostor impostor to activate
  62126. */
  62127. wakeUpBody(impostor: PhysicsImpostor): void;
  62128. /**
  62129. * Updates the distance parameters of the joint
  62130. * @param joint joint to update
  62131. * @param maxDistance maximum distance of the joint
  62132. * @param minDistance minimum distance of the joint
  62133. */
  62134. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62135. /**
  62136. * Sets a motor on the joint
  62137. * @param joint joint to set motor on
  62138. * @param speed speed of the motor
  62139. * @param maxForce maximum force of the motor
  62140. * @param motorIndex index of the motor
  62141. */
  62142. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62143. /**
  62144. * Sets the motors limit
  62145. * @param joint joint to set limit on
  62146. * @param upperLimit upper limit
  62147. * @param lowerLimit lower limit
  62148. */
  62149. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62150. /**
  62151. * Syncs the position and rotation of a mesh with the impostor
  62152. * @param mesh mesh to sync
  62153. * @param impostor impostor to update the mesh with
  62154. */
  62155. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62156. /**
  62157. * Gets the radius of the impostor
  62158. * @param impostor impostor to get radius from
  62159. * @returns the radius
  62160. */
  62161. getRadius(impostor: PhysicsImpostor): number;
  62162. /**
  62163. * Gets the box size of the impostor
  62164. * @param impostor impostor to get box size from
  62165. * @param result the resulting box size
  62166. */
  62167. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62168. /**
  62169. * Disposes of the impostor
  62170. */
  62171. dispose(): void;
  62172. /**
  62173. * Does a raycast in the physics world
  62174. * @param from when should the ray start?
  62175. * @param to when should the ray end?
  62176. * @returns PhysicsRaycastResult
  62177. */
  62178. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62179. }
  62180. }
  62181. declare module "babylonjs/Probes/reflectionProbe" {
  62182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62183. import { Vector3 } from "babylonjs/Maths/math.vector";
  62184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62185. import { Nullable } from "babylonjs/types";
  62186. import { Scene } from "babylonjs/scene";
  62187. module "babylonjs/abstractScene" {
  62188. interface AbstractScene {
  62189. /**
  62190. * The list of reflection probes added to the scene
  62191. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62192. */
  62193. reflectionProbes: Array<ReflectionProbe>;
  62194. /**
  62195. * Removes the given reflection probe from this scene.
  62196. * @param toRemove The reflection probe to remove
  62197. * @returns The index of the removed reflection probe
  62198. */
  62199. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62200. /**
  62201. * Adds the given reflection probe to this scene.
  62202. * @param newReflectionProbe The reflection probe to add
  62203. */
  62204. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62205. }
  62206. }
  62207. /**
  62208. * Class used to generate realtime reflection / refraction cube textures
  62209. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62210. */
  62211. export class ReflectionProbe {
  62212. /** defines the name of the probe */
  62213. name: string;
  62214. private _scene;
  62215. private _renderTargetTexture;
  62216. private _projectionMatrix;
  62217. private _viewMatrix;
  62218. private _target;
  62219. private _add;
  62220. private _attachedMesh;
  62221. private _invertYAxis;
  62222. /** Gets or sets probe position (center of the cube map) */
  62223. position: Vector3;
  62224. /**
  62225. * Creates a new reflection probe
  62226. * @param name defines the name of the probe
  62227. * @param size defines the texture resolution (for each face)
  62228. * @param scene defines the hosting scene
  62229. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62230. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62231. */
  62232. constructor(
  62233. /** defines the name of the probe */
  62234. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62235. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62236. get samples(): number;
  62237. set samples(value: number);
  62238. /** Gets or sets the refresh rate to use (on every frame by default) */
  62239. get refreshRate(): number;
  62240. set refreshRate(value: number);
  62241. /**
  62242. * Gets the hosting scene
  62243. * @returns a Scene
  62244. */
  62245. getScene(): Scene;
  62246. /** Gets the internal CubeTexture used to render to */
  62247. get cubeTexture(): RenderTargetTexture;
  62248. /** Gets the list of meshes to render */
  62249. get renderList(): Nullable<AbstractMesh[]>;
  62250. /**
  62251. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62252. * @param mesh defines the mesh to attach to
  62253. */
  62254. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62255. /**
  62256. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62257. * @param renderingGroupId The rendering group id corresponding to its index
  62258. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62259. */
  62260. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62261. /**
  62262. * Clean all associated resources
  62263. */
  62264. dispose(): void;
  62265. /**
  62266. * Converts the reflection probe information to a readable string for debug purpose.
  62267. * @param fullDetails Supports for multiple levels of logging within scene loading
  62268. * @returns the human readable reflection probe info
  62269. */
  62270. toString(fullDetails?: boolean): string;
  62271. /**
  62272. * Get the class name of the relfection probe.
  62273. * @returns "ReflectionProbe"
  62274. */
  62275. getClassName(): string;
  62276. /**
  62277. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62278. * @returns The JSON representation of the texture
  62279. */
  62280. serialize(): any;
  62281. /**
  62282. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62283. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62284. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62285. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62286. * @returns The parsed reflection probe if successful
  62287. */
  62288. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62289. }
  62290. }
  62291. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62292. /** @hidden */
  62293. export var _BabylonLoaderRegistered: boolean;
  62294. /**
  62295. * Helps setting up some configuration for the babylon file loader.
  62296. */
  62297. export class BabylonFileLoaderConfiguration {
  62298. /**
  62299. * The loader does not allow injecting custom physix engine into the plugins.
  62300. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62301. * So you could set this variable to your engine import to make it work.
  62302. */
  62303. static LoaderInjectedPhysicsEngine: any;
  62304. }
  62305. }
  62306. declare module "babylonjs/Loading/Plugins/index" {
  62307. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62308. }
  62309. declare module "babylonjs/Loading/index" {
  62310. export * from "babylonjs/Loading/loadingScreen";
  62311. export * from "babylonjs/Loading/Plugins/index";
  62312. export * from "babylonjs/Loading/sceneLoader";
  62313. export * from "babylonjs/Loading/sceneLoaderFlags";
  62314. }
  62315. declare module "babylonjs/Materials/Background/index" {
  62316. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62317. }
  62318. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62319. import { Scene } from "babylonjs/scene";
  62320. import { Color3 } from "babylonjs/Maths/math.color";
  62321. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62323. /**
  62324. * The Physically based simple base material of BJS.
  62325. *
  62326. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62327. * It is used as the base class for both the specGloss and metalRough conventions.
  62328. */
  62329. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62330. /**
  62331. * Number of Simultaneous lights allowed on the material.
  62332. */
  62333. maxSimultaneousLights: number;
  62334. /**
  62335. * If sets to true, disables all the lights affecting the material.
  62336. */
  62337. disableLighting: boolean;
  62338. /**
  62339. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62340. */
  62341. environmentTexture: BaseTexture;
  62342. /**
  62343. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62344. */
  62345. invertNormalMapX: boolean;
  62346. /**
  62347. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62348. */
  62349. invertNormalMapY: boolean;
  62350. /**
  62351. * Normal map used in the model.
  62352. */
  62353. normalTexture: BaseTexture;
  62354. /**
  62355. * Emissivie color used to self-illuminate the model.
  62356. */
  62357. emissiveColor: Color3;
  62358. /**
  62359. * Emissivie texture used to self-illuminate the model.
  62360. */
  62361. emissiveTexture: BaseTexture;
  62362. /**
  62363. * Occlusion Channel Strenght.
  62364. */
  62365. occlusionStrength: number;
  62366. /**
  62367. * Occlusion Texture of the material (adding extra occlusion effects).
  62368. */
  62369. occlusionTexture: BaseTexture;
  62370. /**
  62371. * Defines the alpha limits in alpha test mode.
  62372. */
  62373. alphaCutOff: number;
  62374. /**
  62375. * Gets the current double sided mode.
  62376. */
  62377. get doubleSided(): boolean;
  62378. /**
  62379. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62380. */
  62381. set doubleSided(value: boolean);
  62382. /**
  62383. * Stores the pre-calculated light information of a mesh in a texture.
  62384. */
  62385. lightmapTexture: BaseTexture;
  62386. /**
  62387. * If true, the light map contains occlusion information instead of lighting info.
  62388. */
  62389. useLightmapAsShadowmap: boolean;
  62390. /**
  62391. * Instantiates a new PBRMaterial instance.
  62392. *
  62393. * @param name The material name
  62394. * @param scene The scene the material will be use in.
  62395. */
  62396. constructor(name: string, scene: Scene);
  62397. getClassName(): string;
  62398. }
  62399. }
  62400. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62401. import { Scene } from "babylonjs/scene";
  62402. import { Color3 } from "babylonjs/Maths/math.color";
  62403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62404. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62405. /**
  62406. * The PBR material of BJS following the metal roughness convention.
  62407. *
  62408. * This fits to the PBR convention in the GLTF definition:
  62409. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62410. */
  62411. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62412. /**
  62413. * The base color has two different interpretations depending on the value of metalness.
  62414. * When the material is a metal, the base color is the specific measured reflectance value
  62415. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62416. * of the material.
  62417. */
  62418. baseColor: Color3;
  62419. /**
  62420. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62421. * well as opacity information in the alpha channel.
  62422. */
  62423. baseTexture: BaseTexture;
  62424. /**
  62425. * Specifies the metallic scalar value of the material.
  62426. * Can also be used to scale the metalness values of the metallic texture.
  62427. */
  62428. metallic: number;
  62429. /**
  62430. * Specifies the roughness scalar value of the material.
  62431. * Can also be used to scale the roughness values of the metallic texture.
  62432. */
  62433. roughness: number;
  62434. /**
  62435. * Texture containing both the metallic value in the B channel and the
  62436. * roughness value in the G channel to keep better precision.
  62437. */
  62438. metallicRoughnessTexture: BaseTexture;
  62439. /**
  62440. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62441. *
  62442. * @param name The material name
  62443. * @param scene The scene the material will be use in.
  62444. */
  62445. constructor(name: string, scene: Scene);
  62446. /**
  62447. * Return the currrent class name of the material.
  62448. */
  62449. getClassName(): string;
  62450. /**
  62451. * Makes a duplicate of the current material.
  62452. * @param name - name to use for the new material.
  62453. */
  62454. clone(name: string): PBRMetallicRoughnessMaterial;
  62455. /**
  62456. * Serialize the material to a parsable JSON object.
  62457. */
  62458. serialize(): any;
  62459. /**
  62460. * Parses a JSON object correponding to the serialize function.
  62461. */
  62462. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62463. }
  62464. }
  62465. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62466. import { Scene } from "babylonjs/scene";
  62467. import { Color3 } from "babylonjs/Maths/math.color";
  62468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62469. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62470. /**
  62471. * The PBR material of BJS following the specular glossiness convention.
  62472. *
  62473. * This fits to the PBR convention in the GLTF definition:
  62474. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62475. */
  62476. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62477. /**
  62478. * Specifies the diffuse color of the material.
  62479. */
  62480. diffuseColor: Color3;
  62481. /**
  62482. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62483. * channel.
  62484. */
  62485. diffuseTexture: BaseTexture;
  62486. /**
  62487. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62488. */
  62489. specularColor: Color3;
  62490. /**
  62491. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62492. */
  62493. glossiness: number;
  62494. /**
  62495. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62496. */
  62497. specularGlossinessTexture: BaseTexture;
  62498. /**
  62499. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62500. *
  62501. * @param name The material name
  62502. * @param scene The scene the material will be use in.
  62503. */
  62504. constructor(name: string, scene: Scene);
  62505. /**
  62506. * Return the currrent class name of the material.
  62507. */
  62508. getClassName(): string;
  62509. /**
  62510. * Makes a duplicate of the current material.
  62511. * @param name - name to use for the new material.
  62512. */
  62513. clone(name: string): PBRSpecularGlossinessMaterial;
  62514. /**
  62515. * Serialize the material to a parsable JSON object.
  62516. */
  62517. serialize(): any;
  62518. /**
  62519. * Parses a JSON object correponding to the serialize function.
  62520. */
  62521. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62522. }
  62523. }
  62524. declare module "babylonjs/Materials/PBR/index" {
  62525. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62526. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62527. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62528. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62529. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62530. }
  62531. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62532. import { Nullable } from "babylonjs/types";
  62533. import { Scene } from "babylonjs/scene";
  62534. import { Matrix } from "babylonjs/Maths/math.vector";
  62535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62536. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62537. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62538. /**
  62539. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62540. * It can help converting any input color in a desired output one. This can then be used to create effects
  62541. * from sepia, black and white to sixties or futuristic rendering...
  62542. *
  62543. * The only supported format is currently 3dl.
  62544. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62545. */
  62546. export class ColorGradingTexture extends BaseTexture {
  62547. /**
  62548. * The texture URL.
  62549. */
  62550. url: string;
  62551. /**
  62552. * Empty line regex stored for GC.
  62553. */
  62554. private static _noneEmptyLineRegex;
  62555. private _textureMatrix;
  62556. private _onLoad;
  62557. /**
  62558. * Instantiates a ColorGradingTexture from the following parameters.
  62559. *
  62560. * @param url The location of the color gradind data (currently only supporting 3dl)
  62561. * @param sceneOrEngine The scene or engine the texture will be used in
  62562. * @param onLoad defines a callback triggered when the texture has been loaded
  62563. */
  62564. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62565. /**
  62566. * Fires the onload event from the constructor if requested.
  62567. */
  62568. private _triggerOnLoad;
  62569. /**
  62570. * Returns the texture matrix used in most of the material.
  62571. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62572. */
  62573. getTextureMatrix(): Matrix;
  62574. /**
  62575. * Occurs when the file being loaded is a .3dl LUT file.
  62576. */
  62577. private load3dlTexture;
  62578. /**
  62579. * Starts the loading process of the texture.
  62580. */
  62581. private loadTexture;
  62582. /**
  62583. * Clones the color gradind texture.
  62584. */
  62585. clone(): ColorGradingTexture;
  62586. /**
  62587. * Called during delayed load for textures.
  62588. */
  62589. delayLoad(): void;
  62590. /**
  62591. * Parses a color grading texture serialized by Babylon.
  62592. * @param parsedTexture The texture information being parsedTexture
  62593. * @param scene The scene to load the texture in
  62594. * @param rootUrl The root url of the data assets to load
  62595. * @return A color gradind texture
  62596. */
  62597. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62598. /**
  62599. * Serializes the LUT texture to json format.
  62600. */
  62601. serialize(): any;
  62602. }
  62603. }
  62604. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  62605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62606. import { Scene } from "babylonjs/scene";
  62607. import { Nullable } from "babylonjs/types";
  62608. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62609. /**
  62610. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62611. */
  62612. export class EquiRectangularCubeTexture extends BaseTexture {
  62613. /** The six faces of the cube. */
  62614. private static _FacesMapping;
  62615. private _noMipmap;
  62616. private _onLoad;
  62617. private _onError;
  62618. /** The size of the cubemap. */
  62619. private _size;
  62620. /** The buffer of the image. */
  62621. private _buffer;
  62622. /** The width of the input image. */
  62623. private _width;
  62624. /** The height of the input image. */
  62625. private _height;
  62626. /** The URL to the image. */
  62627. url: string;
  62628. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  62629. coordinatesMode: number;
  62630. /**
  62631. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62632. * @param url The location of the image
  62633. * @param scene The scene the texture will be used in
  62634. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62635. * @param noMipmap Forces to not generate the mipmap if true
  62636. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62637. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62638. * @param onLoad — defines a callback called when texture is loaded
  62639. * @param onError — defines a callback called if there is an error
  62640. */
  62641. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62642. /**
  62643. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62644. */
  62645. private loadImage;
  62646. /**
  62647. * Convert the image buffer into a cubemap and create a CubeTexture.
  62648. */
  62649. private loadTexture;
  62650. /**
  62651. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62652. * @param buffer The ArrayBuffer that should be converted.
  62653. * @returns The buffer as Float32Array.
  62654. */
  62655. private getFloat32ArrayFromArrayBuffer;
  62656. /**
  62657. * Get the current class name of the texture useful for serialization or dynamic coding.
  62658. * @returns "EquiRectangularCubeTexture"
  62659. */
  62660. getClassName(): string;
  62661. /**
  62662. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62663. * @returns A clone of the current EquiRectangularCubeTexture.
  62664. */
  62665. clone(): EquiRectangularCubeTexture;
  62666. }
  62667. }
  62668. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  62669. import { Nullable } from "babylonjs/types";
  62670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62671. import { Matrix } from "babylonjs/Maths/math.vector";
  62672. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62673. import "babylonjs/Engines/Extensions/engine.videoTexture";
  62674. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62675. import { Scene } from "babylonjs/scene";
  62676. /**
  62677. * Defines the options related to the creation of an HtmlElementTexture
  62678. */
  62679. export interface IHtmlElementTextureOptions {
  62680. /**
  62681. * Defines wether mip maps should be created or not.
  62682. */
  62683. generateMipMaps?: boolean;
  62684. /**
  62685. * Defines the sampling mode of the texture.
  62686. */
  62687. samplingMode?: number;
  62688. /**
  62689. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62690. */
  62691. engine: Nullable<ThinEngine>;
  62692. /**
  62693. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62694. */
  62695. scene: Nullable<Scene>;
  62696. }
  62697. /**
  62698. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62699. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62700. * is automatically managed.
  62701. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62702. * in your application.
  62703. *
  62704. * As the update is not automatic, you need to call them manually.
  62705. */
  62706. export class HtmlElementTexture extends BaseTexture {
  62707. /**
  62708. * The texture URL.
  62709. */
  62710. element: HTMLVideoElement | HTMLCanvasElement;
  62711. private static readonly DefaultOptions;
  62712. private _textureMatrix;
  62713. private _isVideo;
  62714. private _generateMipMaps;
  62715. private _samplingMode;
  62716. /**
  62717. * Instantiates a HtmlElementTexture from the following parameters.
  62718. *
  62719. * @param name Defines the name of the texture
  62720. * @param element Defines the video or canvas the texture is filled with
  62721. * @param options Defines the other none mandatory texture creation options
  62722. */
  62723. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62724. private _createInternalTexture;
  62725. /**
  62726. * Returns the texture matrix used in most of the material.
  62727. */
  62728. getTextureMatrix(): Matrix;
  62729. /**
  62730. * Updates the content of the texture.
  62731. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62732. */
  62733. update(invertY?: Nullable<boolean>): void;
  62734. }
  62735. }
  62736. declare module "babylonjs/Misc/tga" {
  62737. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62738. /**
  62739. * Based on jsTGALoader - Javascript loader for TGA file
  62740. * By Vincent Thibault
  62741. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62742. */
  62743. export class TGATools {
  62744. private static _TYPE_INDEXED;
  62745. private static _TYPE_RGB;
  62746. private static _TYPE_GREY;
  62747. private static _TYPE_RLE_INDEXED;
  62748. private static _TYPE_RLE_RGB;
  62749. private static _TYPE_RLE_GREY;
  62750. private static _ORIGIN_MASK;
  62751. private static _ORIGIN_SHIFT;
  62752. private static _ORIGIN_BL;
  62753. private static _ORIGIN_BR;
  62754. private static _ORIGIN_UL;
  62755. private static _ORIGIN_UR;
  62756. /**
  62757. * Gets the header of a TGA file
  62758. * @param data defines the TGA data
  62759. * @returns the header
  62760. */
  62761. static GetTGAHeader(data: Uint8Array): any;
  62762. /**
  62763. * Uploads TGA content to a Babylon Texture
  62764. * @hidden
  62765. */
  62766. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62767. /** @hidden */
  62768. 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;
  62769. /** @hidden */
  62770. 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;
  62771. /** @hidden */
  62772. 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;
  62773. /** @hidden */
  62774. 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;
  62775. /** @hidden */
  62776. 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;
  62777. /** @hidden */
  62778. 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;
  62779. }
  62780. }
  62781. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  62782. import { Nullable } from "babylonjs/types";
  62783. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62784. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62785. /**
  62786. * Implementation of the TGA Texture Loader.
  62787. * @hidden
  62788. */
  62789. export class _TGATextureLoader implements IInternalTextureLoader {
  62790. /**
  62791. * Defines wether the loader supports cascade loading the different faces.
  62792. */
  62793. readonly supportCascades: boolean;
  62794. /**
  62795. * This returns if the loader support the current file information.
  62796. * @param extension defines the file extension of the file being loaded
  62797. * @returns true if the loader can load the specified file
  62798. */
  62799. canLoad(extension: string): boolean;
  62800. /**
  62801. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62802. * @param data contains the texture data
  62803. * @param texture defines the BabylonJS internal texture
  62804. * @param createPolynomials will be true if polynomials have been requested
  62805. * @param onLoad defines the callback to trigger once the texture is ready
  62806. * @param onError defines the callback to trigger in case of error
  62807. */
  62808. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62809. /**
  62810. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62811. * @param data contains the texture data
  62812. * @param texture defines the BabylonJS internal texture
  62813. * @param callback defines the method to call once ready to upload
  62814. */
  62815. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62816. }
  62817. }
  62818. declare module "babylonjs/Misc/basis" {
  62819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62820. /**
  62821. * Info about the .basis files
  62822. */
  62823. class BasisFileInfo {
  62824. /**
  62825. * If the file has alpha
  62826. */
  62827. hasAlpha: boolean;
  62828. /**
  62829. * Info about each image of the basis file
  62830. */
  62831. images: Array<{
  62832. levels: Array<{
  62833. width: number;
  62834. height: number;
  62835. transcodedPixels: ArrayBufferView;
  62836. }>;
  62837. }>;
  62838. }
  62839. /**
  62840. * Result of transcoding a basis file
  62841. */
  62842. class TranscodeResult {
  62843. /**
  62844. * Info about the .basis file
  62845. */
  62846. fileInfo: BasisFileInfo;
  62847. /**
  62848. * Format to use when loading the file
  62849. */
  62850. format: number;
  62851. }
  62852. /**
  62853. * Configuration options for the Basis transcoder
  62854. */
  62855. export class BasisTranscodeConfiguration {
  62856. /**
  62857. * Supported compression formats used to determine the supported output format of the transcoder
  62858. */
  62859. supportedCompressionFormats?: {
  62860. /**
  62861. * etc1 compression format
  62862. */
  62863. etc1?: boolean;
  62864. /**
  62865. * s3tc compression format
  62866. */
  62867. s3tc?: boolean;
  62868. /**
  62869. * pvrtc compression format
  62870. */
  62871. pvrtc?: boolean;
  62872. /**
  62873. * etc2 compression format
  62874. */
  62875. etc2?: boolean;
  62876. };
  62877. /**
  62878. * If mipmap levels should be loaded for transcoded images (Default: true)
  62879. */
  62880. loadMipmapLevels?: boolean;
  62881. /**
  62882. * Index of a single image to load (Default: all images)
  62883. */
  62884. loadSingleImage?: number;
  62885. }
  62886. /**
  62887. * Used to load .Basis files
  62888. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62889. */
  62890. export class BasisTools {
  62891. private static _IgnoreSupportedFormats;
  62892. /**
  62893. * URL to use when loading the basis transcoder
  62894. */
  62895. static JSModuleURL: string;
  62896. /**
  62897. * URL to use when loading the wasm module for the transcoder
  62898. */
  62899. static WasmModuleURL: string;
  62900. /**
  62901. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62902. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62903. * @returns internal format corresponding to the Basis format
  62904. */
  62905. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62906. private static _WorkerPromise;
  62907. private static _Worker;
  62908. private static _actionId;
  62909. private static _CreateWorkerAsync;
  62910. /**
  62911. * Transcodes a loaded image file to compressed pixel data
  62912. * @param data image data to transcode
  62913. * @param config configuration options for the transcoding
  62914. * @returns a promise resulting in the transcoded image
  62915. */
  62916. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62917. /**
  62918. * Loads a texture from the transcode result
  62919. * @param texture texture load to
  62920. * @param transcodeResult the result of transcoding the basis file to load from
  62921. */
  62922. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62923. }
  62924. }
  62925. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  62926. import { Nullable } from "babylonjs/types";
  62927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62928. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62929. /**
  62930. * Loader for .basis file format
  62931. */
  62932. export class _BasisTextureLoader implements IInternalTextureLoader {
  62933. /**
  62934. * Defines whether the loader supports cascade loading the different faces.
  62935. */
  62936. readonly supportCascades: boolean;
  62937. /**
  62938. * This returns if the loader support the current file information.
  62939. * @param extension defines the file extension of the file being loaded
  62940. * @returns true if the loader can load the specified file
  62941. */
  62942. canLoad(extension: string): boolean;
  62943. /**
  62944. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62945. * @param data contains the texture data
  62946. * @param texture defines the BabylonJS internal texture
  62947. * @param createPolynomials will be true if polynomials have been requested
  62948. * @param onLoad defines the callback to trigger once the texture is ready
  62949. * @param onError defines the callback to trigger in case of error
  62950. */
  62951. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62952. /**
  62953. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62954. * @param data contains the texture data
  62955. * @param texture defines the BabylonJS internal texture
  62956. * @param callback defines the method to call once ready to upload
  62957. */
  62958. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62959. }
  62960. }
  62961. declare module "babylonjs/Materials/Textures/Loaders/index" {
  62962. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62963. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62964. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62965. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  62966. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  62967. }
  62968. declare module "babylonjs/Materials/Textures/Packer/frame" {
  62969. import { Vector2 } from "babylonjs/Maths/math.vector";
  62970. /**
  62971. * Defines the basic options interface of a TexturePacker Frame
  62972. */
  62973. export interface ITexturePackerFrame {
  62974. /**
  62975. * The frame ID
  62976. */
  62977. id: number;
  62978. /**
  62979. * The frames Scale
  62980. */
  62981. scale: Vector2;
  62982. /**
  62983. * The Frames offset
  62984. */
  62985. offset: Vector2;
  62986. }
  62987. /**
  62988. * This is a support class for frame Data on texture packer sets.
  62989. */
  62990. export class TexturePackerFrame implements ITexturePackerFrame {
  62991. /**
  62992. * The frame ID
  62993. */
  62994. id: number;
  62995. /**
  62996. * The frames Scale
  62997. */
  62998. scale: Vector2;
  62999. /**
  63000. * The Frames offset
  63001. */
  63002. offset: Vector2;
  63003. /**
  63004. * Initializes a texture package frame.
  63005. * @param id The numerical frame identifier
  63006. * @param scale Scalar Vector2 for UV frame
  63007. * @param offset Vector2 for the frame position in UV units.
  63008. * @returns TexturePackerFrame
  63009. */
  63010. constructor(id: number, scale: Vector2, offset: Vector2);
  63011. }
  63012. }
  63013. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63015. import { Scene } from "babylonjs/scene";
  63016. import { Nullable } from "babylonjs/types";
  63017. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63018. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63019. /**
  63020. * Defines the basic options interface of a TexturePacker
  63021. */
  63022. export interface ITexturePackerOptions {
  63023. /**
  63024. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63025. */
  63026. map?: string[];
  63027. /**
  63028. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63029. */
  63030. uvsIn?: string;
  63031. /**
  63032. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63033. */
  63034. uvsOut?: string;
  63035. /**
  63036. * number representing the layout style. Defaults to LAYOUT_STRIP
  63037. */
  63038. layout?: number;
  63039. /**
  63040. * number of columns if using custom column count layout(2). This defaults to 4.
  63041. */
  63042. colnum?: number;
  63043. /**
  63044. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63045. */
  63046. updateInputMeshes?: boolean;
  63047. /**
  63048. * boolean flag to dispose all the source textures. Defaults to true.
  63049. */
  63050. disposeSources?: boolean;
  63051. /**
  63052. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63053. */
  63054. fillBlanks?: boolean;
  63055. /**
  63056. * string value representing the context fill style color. Defaults to 'black'.
  63057. */
  63058. customFillColor?: string;
  63059. /**
  63060. * Width and Height Value of each Frame in the TexturePacker Sets
  63061. */
  63062. frameSize?: number;
  63063. /**
  63064. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63065. */
  63066. paddingRatio?: number;
  63067. /**
  63068. * Number that declares the fill method for the padding gutter.
  63069. */
  63070. paddingMode?: number;
  63071. /**
  63072. * If in SUBUV_COLOR padding mode what color to use.
  63073. */
  63074. paddingColor?: Color3 | Color4;
  63075. }
  63076. /**
  63077. * Defines the basic interface of a TexturePacker JSON File
  63078. */
  63079. export interface ITexturePackerJSON {
  63080. /**
  63081. * The frame ID
  63082. */
  63083. name: string;
  63084. /**
  63085. * The base64 channel data
  63086. */
  63087. sets: any;
  63088. /**
  63089. * The options of the Packer
  63090. */
  63091. options: ITexturePackerOptions;
  63092. /**
  63093. * The frame data of the Packer
  63094. */
  63095. frames: Array<number>;
  63096. }
  63097. /**
  63098. * This is a support class that generates a series of packed texture sets.
  63099. * @see https://doc.babylonjs.com/babylon101/materials
  63100. */
  63101. export class TexturePacker {
  63102. /** Packer Layout Constant 0 */
  63103. static readonly LAYOUT_STRIP: number;
  63104. /** Packer Layout Constant 1 */
  63105. static readonly LAYOUT_POWER2: number;
  63106. /** Packer Layout Constant 2 */
  63107. static readonly LAYOUT_COLNUM: number;
  63108. /** Packer Layout Constant 0 */
  63109. static readonly SUBUV_WRAP: number;
  63110. /** Packer Layout Constant 1 */
  63111. static readonly SUBUV_EXTEND: number;
  63112. /** Packer Layout Constant 2 */
  63113. static readonly SUBUV_COLOR: number;
  63114. /** The Name of the Texture Package */
  63115. name: string;
  63116. /** The scene scope of the TexturePacker */
  63117. scene: Scene;
  63118. /** The Meshes to target */
  63119. meshes: AbstractMesh[];
  63120. /** Arguments passed with the Constructor */
  63121. options: ITexturePackerOptions;
  63122. /** The promise that is started upon initialization */
  63123. promise: Nullable<Promise<TexturePacker | string>>;
  63124. /** The Container object for the channel sets that are generated */
  63125. sets: object;
  63126. /** The Container array for the frames that are generated */
  63127. frames: TexturePackerFrame[];
  63128. /** The expected number of textures the system is parsing. */
  63129. private _expecting;
  63130. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63131. private _paddingValue;
  63132. /**
  63133. * Initializes a texture package series from an array of meshes or a single mesh.
  63134. * @param name The name of the package
  63135. * @param meshes The target meshes to compose the package from
  63136. * @param options The arguments that texture packer should follow while building.
  63137. * @param scene The scene which the textures are scoped to.
  63138. * @returns TexturePacker
  63139. */
  63140. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63141. /**
  63142. * Starts the package process
  63143. * @param resolve The promises resolution function
  63144. * @returns TexturePacker
  63145. */
  63146. private _createFrames;
  63147. /**
  63148. * Calculates the Size of the Channel Sets
  63149. * @returns Vector2
  63150. */
  63151. private _calculateSize;
  63152. /**
  63153. * Calculates the UV data for the frames.
  63154. * @param baseSize the base frameSize
  63155. * @param padding the base frame padding
  63156. * @param dtSize size of the Dynamic Texture for that channel
  63157. * @param dtUnits is 1/dtSize
  63158. * @param update flag to update the input meshes
  63159. */
  63160. private _calculateMeshUVFrames;
  63161. /**
  63162. * Calculates the frames Offset.
  63163. * @param index of the frame
  63164. * @returns Vector2
  63165. */
  63166. private _getFrameOffset;
  63167. /**
  63168. * Updates a Mesh to the frame data
  63169. * @param mesh that is the target
  63170. * @param frameID or the frame index
  63171. */
  63172. private _updateMeshUV;
  63173. /**
  63174. * Updates a Meshes materials to use the texture packer channels
  63175. * @param m is the mesh to target
  63176. * @param force all channels on the packer to be set.
  63177. */
  63178. private _updateTextureReferences;
  63179. /**
  63180. * Public method to set a Mesh to a frame
  63181. * @param m that is the target
  63182. * @param frameID or the frame index
  63183. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63184. */
  63185. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63186. /**
  63187. * Starts the async promise to compile the texture packer.
  63188. * @returns Promise<void>
  63189. */
  63190. processAsync(): Promise<void>;
  63191. /**
  63192. * Disposes all textures associated with this packer
  63193. */
  63194. dispose(): void;
  63195. /**
  63196. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63197. * @param imageType is the image type to use.
  63198. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63199. */
  63200. download(imageType?: string, quality?: number): void;
  63201. /**
  63202. * Public method to load a texturePacker JSON file.
  63203. * @param data of the JSON file in string format.
  63204. */
  63205. updateFromJSON(data: string): void;
  63206. }
  63207. }
  63208. declare module "babylonjs/Materials/Textures/Packer/index" {
  63209. export * from "babylonjs/Materials/Textures/Packer/packer";
  63210. export * from "babylonjs/Materials/Textures/Packer/frame";
  63211. }
  63212. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63213. import { Scene } from "babylonjs/scene";
  63214. import { Texture } from "babylonjs/Materials/Textures/texture";
  63215. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63216. /**
  63217. * 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.
  63218. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63219. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63220. */
  63221. export class CustomProceduralTexture extends ProceduralTexture {
  63222. private _animate;
  63223. private _time;
  63224. private _config;
  63225. private _texturePath;
  63226. /**
  63227. * Instantiates a new Custom Procedural Texture.
  63228. * 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.
  63229. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63230. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63231. * @param name Define the name of the texture
  63232. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63233. * @param size Define the size of the texture to create
  63234. * @param scene Define the scene the texture belongs to
  63235. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63236. * @param generateMipMaps Define if the texture should creates mip maps or not
  63237. */
  63238. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63239. private _loadJson;
  63240. /**
  63241. * Is the texture ready to be used ? (rendered at least once)
  63242. * @returns true if ready, otherwise, false.
  63243. */
  63244. isReady(): boolean;
  63245. /**
  63246. * Render the texture to its associated render target.
  63247. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63248. */
  63249. render(useCameraPostProcess?: boolean): void;
  63250. /**
  63251. * Update the list of dependant textures samplers in the shader.
  63252. */
  63253. updateTextures(): void;
  63254. /**
  63255. * Update the uniform values of the procedural texture in the shader.
  63256. */
  63257. updateShaderUniforms(): void;
  63258. /**
  63259. * Define if the texture animates or not.
  63260. */
  63261. get animate(): boolean;
  63262. set animate(value: boolean);
  63263. }
  63264. }
  63265. declare module "babylonjs/Shaders/noise.fragment" {
  63266. /** @hidden */
  63267. export var noisePixelShader: {
  63268. name: string;
  63269. shader: string;
  63270. };
  63271. }
  63272. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63273. import { Nullable } from "babylonjs/types";
  63274. import { Scene } from "babylonjs/scene";
  63275. import { Texture } from "babylonjs/Materials/Textures/texture";
  63276. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63277. import "babylonjs/Shaders/noise.fragment";
  63278. /**
  63279. * Class used to generate noise procedural textures
  63280. */
  63281. export class NoiseProceduralTexture extends ProceduralTexture {
  63282. private _time;
  63283. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63284. brightness: number;
  63285. /** Defines the number of octaves to process */
  63286. octaves: number;
  63287. /** Defines the level of persistence (0.8 by default) */
  63288. persistence: number;
  63289. /** Gets or sets animation speed factor (default is 1) */
  63290. animationSpeedFactor: number;
  63291. /**
  63292. * Creates a new NoiseProceduralTexture
  63293. * @param name defines the name fo the texture
  63294. * @param size defines the size of the texture (default is 256)
  63295. * @param scene defines the hosting scene
  63296. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63297. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63298. */
  63299. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63300. private _updateShaderUniforms;
  63301. protected _getDefines(): string;
  63302. /** Generate the current state of the procedural texture */
  63303. render(useCameraPostProcess?: boolean): void;
  63304. /**
  63305. * Serializes this noise procedural texture
  63306. * @returns a serialized noise procedural texture object
  63307. */
  63308. serialize(): any;
  63309. /**
  63310. * Clone the texture.
  63311. * @returns the cloned texture
  63312. */
  63313. clone(): NoiseProceduralTexture;
  63314. /**
  63315. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63316. * @param parsedTexture defines parsed texture data
  63317. * @param scene defines the current scene
  63318. * @param rootUrl defines the root URL containing noise procedural texture information
  63319. * @returns a parsed NoiseProceduralTexture
  63320. */
  63321. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63322. }
  63323. }
  63324. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63325. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63326. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63327. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63328. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63329. }
  63330. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63331. import { Nullable } from "babylonjs/types";
  63332. import { Scene } from "babylonjs/scene";
  63333. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63334. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63335. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63336. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63337. /**
  63338. * Raw cube texture where the raw buffers are passed in
  63339. */
  63340. export class RawCubeTexture extends CubeTexture {
  63341. /**
  63342. * Creates a cube texture where the raw buffers are passed in.
  63343. * @param scene defines the scene the texture is attached to
  63344. * @param data defines the array of data to use to create each face
  63345. * @param size defines the size of the textures
  63346. * @param format defines the format of the data
  63347. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63348. * @param generateMipMaps defines if the engine should generate the mip levels
  63349. * @param invertY defines if data must be stored with Y axis inverted
  63350. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63351. * @param compression defines the compression used (null by default)
  63352. */
  63353. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63354. /**
  63355. * Updates the raw cube texture.
  63356. * @param data defines the data to store
  63357. * @param format defines the data format
  63358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63359. * @param invertY defines if data must be stored with Y axis inverted
  63360. * @param compression defines the compression used (null by default)
  63361. * @param level defines which level of the texture to update
  63362. */
  63363. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63364. /**
  63365. * Updates a raw cube texture with RGBD encoded data.
  63366. * @param data defines the array of data [mipmap][face] to use to create each face
  63367. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63368. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63369. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63370. * @returns a promsie that resolves when the operation is complete
  63371. */
  63372. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63373. /**
  63374. * Clones the raw cube texture.
  63375. * @return a new cube texture
  63376. */
  63377. clone(): CubeTexture;
  63378. /** @hidden */
  63379. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63380. }
  63381. }
  63382. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63383. import { Scene } from "babylonjs/scene";
  63384. import { Texture } from "babylonjs/Materials/Textures/texture";
  63385. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63386. /**
  63387. * Class used to store 2D array textures containing user data
  63388. */
  63389. export class RawTexture2DArray extends Texture {
  63390. /** Gets or sets the texture format to use */
  63391. format: number;
  63392. /**
  63393. * Create a new RawTexture2DArray
  63394. * @param data defines the data of the texture
  63395. * @param width defines the width of the texture
  63396. * @param height defines the height of the texture
  63397. * @param depth defines the number of layers of the texture
  63398. * @param format defines the texture format to use
  63399. * @param scene defines the hosting scene
  63400. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63401. * @param invertY defines if texture must be stored with Y axis inverted
  63402. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63403. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63404. */
  63405. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63406. /** Gets or sets the texture format to use */
  63407. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63408. /**
  63409. * Update the texture with new data
  63410. * @param data defines the data to store in the texture
  63411. */
  63412. update(data: ArrayBufferView): void;
  63413. }
  63414. }
  63415. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63416. import { Scene } from "babylonjs/scene";
  63417. import { Texture } from "babylonjs/Materials/Textures/texture";
  63418. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63419. /**
  63420. * Class used to store 3D textures containing user data
  63421. */
  63422. export class RawTexture3D extends Texture {
  63423. /** Gets or sets the texture format to use */
  63424. format: number;
  63425. /**
  63426. * Create a new RawTexture3D
  63427. * @param data defines the data of the texture
  63428. * @param width defines the width of the texture
  63429. * @param height defines the height of the texture
  63430. * @param depth defines the depth of the texture
  63431. * @param format defines the texture format to use
  63432. * @param scene defines the hosting scene
  63433. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63434. * @param invertY defines if texture must be stored with Y axis inverted
  63435. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63436. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63437. */
  63438. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63439. /** Gets or sets the texture format to use */
  63440. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63441. /**
  63442. * Update the texture with new data
  63443. * @param data defines the data to store in the texture
  63444. */
  63445. update(data: ArrayBufferView): void;
  63446. }
  63447. }
  63448. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63449. import { Scene } from "babylonjs/scene";
  63450. import { Plane } from "babylonjs/Maths/math.plane";
  63451. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63452. /**
  63453. * Creates a refraction texture used by refraction channel of the standard material.
  63454. * It is like a mirror but to see through a material.
  63455. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63456. */
  63457. export class RefractionTexture extends RenderTargetTexture {
  63458. /**
  63459. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63460. * 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.
  63461. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63462. */
  63463. refractionPlane: Plane;
  63464. /**
  63465. * Define how deep under the surface we should see.
  63466. */
  63467. depth: number;
  63468. /**
  63469. * Creates a refraction texture used by refraction channel of the standard material.
  63470. * It is like a mirror but to see through a material.
  63471. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63472. * @param name Define the texture name
  63473. * @param size Define the size of the underlying texture
  63474. * @param scene Define the scene the refraction belongs to
  63475. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63476. */
  63477. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63478. /**
  63479. * Clone the refraction texture.
  63480. * @returns the cloned texture
  63481. */
  63482. clone(): RefractionTexture;
  63483. /**
  63484. * Serialize the texture to a JSON representation you could use in Parse later on
  63485. * @returns the serialized JSON representation
  63486. */
  63487. serialize(): any;
  63488. }
  63489. }
  63490. declare module "babylonjs/Materials/Textures/index" {
  63491. export * from "babylonjs/Materials/Textures/baseTexture";
  63492. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63493. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63494. export * from "babylonjs/Materials/Textures/cubeTexture";
  63495. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63496. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63497. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63498. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63499. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63500. export * from "babylonjs/Materials/Textures/internalTexture";
  63501. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63502. export * from "babylonjs/Materials/Textures/Loaders/index";
  63503. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63504. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63505. export * from "babylonjs/Materials/Textures/Packer/index";
  63506. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63507. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63508. export * from "babylonjs/Materials/Textures/rawTexture";
  63509. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63510. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63511. export * from "babylonjs/Materials/Textures/refractionTexture";
  63512. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63513. export * from "babylonjs/Materials/Textures/texture";
  63514. export * from "babylonjs/Materials/Textures/videoTexture";
  63515. }
  63516. declare module "babylonjs/Materials/Node/Enums/index" {
  63517. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63518. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63519. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63520. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63521. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63522. }
  63523. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63527. import { Mesh } from "babylonjs/Meshes/mesh";
  63528. import { Effect } from "babylonjs/Materials/effect";
  63529. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63530. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63531. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63532. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63533. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63534. /**
  63535. * Block used to add support for vertex skinning (bones)
  63536. */
  63537. export class BonesBlock extends NodeMaterialBlock {
  63538. /**
  63539. * Creates a new BonesBlock
  63540. * @param name defines the block name
  63541. */
  63542. constructor(name: string);
  63543. /**
  63544. * Initialize the block and prepare the context for build
  63545. * @param state defines the state that will be used for the build
  63546. */
  63547. initialize(state: NodeMaterialBuildState): void;
  63548. /**
  63549. * Gets the current class name
  63550. * @returns the class name
  63551. */
  63552. getClassName(): string;
  63553. /**
  63554. * Gets the matrix indices input component
  63555. */
  63556. get matricesIndices(): NodeMaterialConnectionPoint;
  63557. /**
  63558. * Gets the matrix weights input component
  63559. */
  63560. get matricesWeights(): NodeMaterialConnectionPoint;
  63561. /**
  63562. * Gets the extra matrix indices input component
  63563. */
  63564. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63565. /**
  63566. * Gets the extra matrix weights input component
  63567. */
  63568. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63569. /**
  63570. * Gets the world input component
  63571. */
  63572. get world(): NodeMaterialConnectionPoint;
  63573. /**
  63574. * Gets the output component
  63575. */
  63576. get output(): NodeMaterialConnectionPoint;
  63577. autoConfigure(material: NodeMaterial): void;
  63578. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63581. protected _buildBlock(state: NodeMaterialBuildState): this;
  63582. }
  63583. }
  63584. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  63585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63591. /**
  63592. * Block used to add support for instances
  63593. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63594. */
  63595. export class InstancesBlock extends NodeMaterialBlock {
  63596. /**
  63597. * Creates a new InstancesBlock
  63598. * @param name defines the block name
  63599. */
  63600. constructor(name: string);
  63601. /**
  63602. * Gets the current class name
  63603. * @returns the class name
  63604. */
  63605. getClassName(): string;
  63606. /**
  63607. * Gets the first world row input component
  63608. */
  63609. get world0(): NodeMaterialConnectionPoint;
  63610. /**
  63611. * Gets the second world row input component
  63612. */
  63613. get world1(): NodeMaterialConnectionPoint;
  63614. /**
  63615. * Gets the third world row input component
  63616. */
  63617. get world2(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the forth world row input component
  63620. */
  63621. get world3(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the world input component
  63624. */
  63625. get world(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the output component
  63628. */
  63629. get output(): NodeMaterialConnectionPoint;
  63630. /**
  63631. * Gets the isntanceID component
  63632. */
  63633. get instanceID(): NodeMaterialConnectionPoint;
  63634. autoConfigure(material: NodeMaterial): void;
  63635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63636. protected _buildBlock(state: NodeMaterialBuildState): this;
  63637. }
  63638. }
  63639. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  63640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63644. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63645. import { Effect } from "babylonjs/Materials/effect";
  63646. import { Mesh } from "babylonjs/Meshes/mesh";
  63647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63648. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63649. /**
  63650. * Block used to add morph targets support to vertex shader
  63651. */
  63652. export class MorphTargetsBlock extends NodeMaterialBlock {
  63653. private _repeatableContentAnchor;
  63654. /**
  63655. * Create a new MorphTargetsBlock
  63656. * @param name defines the block name
  63657. */
  63658. constructor(name: string);
  63659. /**
  63660. * Gets the current class name
  63661. * @returns the class name
  63662. */
  63663. getClassName(): string;
  63664. /**
  63665. * Gets the position input component
  63666. */
  63667. get position(): NodeMaterialConnectionPoint;
  63668. /**
  63669. * Gets the normal input component
  63670. */
  63671. get normal(): NodeMaterialConnectionPoint;
  63672. /**
  63673. * Gets the tangent input component
  63674. */
  63675. get tangent(): NodeMaterialConnectionPoint;
  63676. /**
  63677. * Gets the tangent input component
  63678. */
  63679. get uv(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the position output component
  63682. */
  63683. get positionOutput(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the normal output component
  63686. */
  63687. get normalOutput(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the tangent output component
  63690. */
  63691. get tangentOutput(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the tangent output component
  63694. */
  63695. get uvOutput(): NodeMaterialConnectionPoint;
  63696. initialize(state: NodeMaterialBuildState): void;
  63697. autoConfigure(material: NodeMaterial): void;
  63698. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63699. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63700. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63701. protected _buildBlock(state: NodeMaterialBuildState): this;
  63702. }
  63703. }
  63704. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  63705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63708. import { Nullable } from "babylonjs/types";
  63709. import { Scene } from "babylonjs/scene";
  63710. import { Effect } from "babylonjs/Materials/effect";
  63711. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63712. import { Mesh } from "babylonjs/Meshes/mesh";
  63713. import { Light } from "babylonjs/Lights/light";
  63714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63715. /**
  63716. * Block used to get data information from a light
  63717. */
  63718. export class LightInformationBlock extends NodeMaterialBlock {
  63719. private _lightDataUniformName;
  63720. private _lightColorUniformName;
  63721. private _lightTypeDefineName;
  63722. /**
  63723. * Gets or sets the light associated with this block
  63724. */
  63725. light: Nullable<Light>;
  63726. /**
  63727. * Creates a new LightInformationBlock
  63728. * @param name defines the block name
  63729. */
  63730. constructor(name: string);
  63731. /**
  63732. * Gets the current class name
  63733. * @returns the class name
  63734. */
  63735. getClassName(): string;
  63736. /**
  63737. * Gets the world position input component
  63738. */
  63739. get worldPosition(): NodeMaterialConnectionPoint;
  63740. /**
  63741. * Gets the direction output component
  63742. */
  63743. get direction(): NodeMaterialConnectionPoint;
  63744. /**
  63745. * Gets the direction output component
  63746. */
  63747. get color(): NodeMaterialConnectionPoint;
  63748. /**
  63749. * Gets the direction output component
  63750. */
  63751. get intensity(): NodeMaterialConnectionPoint;
  63752. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63754. protected _buildBlock(state: NodeMaterialBuildState): this;
  63755. serialize(): any;
  63756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63757. }
  63758. }
  63759. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  63760. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  63761. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  63762. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  63763. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  63764. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  63765. }
  63766. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  63767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63771. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63772. import { Effect } from "babylonjs/Materials/effect";
  63773. import { Mesh } from "babylonjs/Meshes/mesh";
  63774. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63776. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63777. /**
  63778. * Block used to add image processing support to fragment shader
  63779. */
  63780. export class ImageProcessingBlock extends NodeMaterialBlock {
  63781. /**
  63782. * Create a new ImageProcessingBlock
  63783. * @param name defines the block name
  63784. */
  63785. constructor(name: string);
  63786. /**
  63787. * Gets the current class name
  63788. * @returns the class name
  63789. */
  63790. getClassName(): string;
  63791. /**
  63792. * Gets the color input component
  63793. */
  63794. get color(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the output component
  63797. */
  63798. get output(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Initialize the block and prepare the context for build
  63801. * @param state defines the state that will be used for the build
  63802. */
  63803. initialize(state: NodeMaterialBuildState): void;
  63804. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63807. protected _buildBlock(state: NodeMaterialBuildState): this;
  63808. }
  63809. }
  63810. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  63811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63814. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63816. import { Effect } from "babylonjs/Materials/effect";
  63817. import { Mesh } from "babylonjs/Meshes/mesh";
  63818. import { Scene } from "babylonjs/scene";
  63819. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  63820. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  63821. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  63822. /**
  63823. * Block used to pertub normals based on a normal map
  63824. */
  63825. export class PerturbNormalBlock extends NodeMaterialBlock {
  63826. private _tangentSpaceParameterName;
  63827. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63828. invertX: boolean;
  63829. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63830. invertY: boolean;
  63831. /**
  63832. * Create a new PerturbNormalBlock
  63833. * @param name defines the block name
  63834. */
  63835. constructor(name: string);
  63836. /**
  63837. * Gets the current class name
  63838. * @returns the class name
  63839. */
  63840. getClassName(): string;
  63841. /**
  63842. * Gets the world position input component
  63843. */
  63844. get worldPosition(): NodeMaterialConnectionPoint;
  63845. /**
  63846. * Gets the world normal input component
  63847. */
  63848. get worldNormal(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Gets the world tangent input component
  63851. */
  63852. get worldTangent(): NodeMaterialConnectionPoint;
  63853. /**
  63854. * Gets the uv input component
  63855. */
  63856. get uv(): NodeMaterialConnectionPoint;
  63857. /**
  63858. * Gets the normal map color input component
  63859. */
  63860. get normalMapColor(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the strength input component
  63863. */
  63864. get strength(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the output component
  63867. */
  63868. get output(): NodeMaterialConnectionPoint;
  63869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63870. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63871. autoConfigure(material: NodeMaterial): void;
  63872. protected _buildBlock(state: NodeMaterialBuildState): this;
  63873. protected _dumpPropertiesCode(): string;
  63874. serialize(): any;
  63875. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63876. }
  63877. }
  63878. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  63879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63882. /**
  63883. * Block used to discard a pixel if a value is smaller than a cutoff
  63884. */
  63885. export class DiscardBlock extends NodeMaterialBlock {
  63886. /**
  63887. * Create a new DiscardBlock
  63888. * @param name defines the block name
  63889. */
  63890. constructor(name: string);
  63891. /**
  63892. * Gets the current class name
  63893. * @returns the class name
  63894. */
  63895. getClassName(): string;
  63896. /**
  63897. * Gets the color input component
  63898. */
  63899. get value(): NodeMaterialConnectionPoint;
  63900. /**
  63901. * Gets the cutoff input component
  63902. */
  63903. get cutoff(): NodeMaterialConnectionPoint;
  63904. protected _buildBlock(state: NodeMaterialBuildState): this;
  63905. }
  63906. }
  63907. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  63908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63911. /**
  63912. * Block used to test if the fragment shader is front facing
  63913. */
  63914. export class FrontFacingBlock extends NodeMaterialBlock {
  63915. /**
  63916. * Creates a new FrontFacingBlock
  63917. * @param name defines the block name
  63918. */
  63919. constructor(name: string);
  63920. /**
  63921. * Gets the current class name
  63922. * @returns the class name
  63923. */
  63924. getClassName(): string;
  63925. /**
  63926. * Gets the output component
  63927. */
  63928. get output(): NodeMaterialConnectionPoint;
  63929. protected _buildBlock(state: NodeMaterialBuildState): this;
  63930. }
  63931. }
  63932. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  63933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63936. /**
  63937. * Block used to get the derivative value on x and y of a given input
  63938. */
  63939. export class DerivativeBlock extends NodeMaterialBlock {
  63940. /**
  63941. * Create a new DerivativeBlock
  63942. * @param name defines the block name
  63943. */
  63944. constructor(name: string);
  63945. /**
  63946. * Gets the current class name
  63947. * @returns the class name
  63948. */
  63949. getClassName(): string;
  63950. /**
  63951. * Gets the input component
  63952. */
  63953. get input(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the derivative output on x
  63956. */
  63957. get dx(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the derivative output on y
  63960. */
  63961. get dy(): NodeMaterialConnectionPoint;
  63962. protected _buildBlock(state: NodeMaterialBuildState): this;
  63963. }
  63964. }
  63965. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  63966. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  63967. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  63968. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  63969. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  63970. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  63971. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  63972. }
  63973. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  63974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63976. import { Mesh } from "babylonjs/Meshes/mesh";
  63977. import { Effect } from "babylonjs/Materials/effect";
  63978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63980. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63981. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63982. /**
  63983. * Block used to add support for scene fog
  63984. */
  63985. export class FogBlock extends NodeMaterialBlock {
  63986. private _fogDistanceName;
  63987. private _fogParameters;
  63988. /**
  63989. * Create a new FogBlock
  63990. * @param name defines the block name
  63991. */
  63992. constructor(name: string);
  63993. /**
  63994. * Gets the current class name
  63995. * @returns the class name
  63996. */
  63997. getClassName(): string;
  63998. /**
  63999. * Gets the world position input component
  64000. */
  64001. get worldPosition(): NodeMaterialConnectionPoint;
  64002. /**
  64003. * Gets the view input component
  64004. */
  64005. get view(): NodeMaterialConnectionPoint;
  64006. /**
  64007. * Gets the color input component
  64008. */
  64009. get input(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the fog color input component
  64012. */
  64013. get fogColor(): NodeMaterialConnectionPoint;
  64014. /**
  64015. * Gets the output component
  64016. */
  64017. get output(): NodeMaterialConnectionPoint;
  64018. autoConfigure(material: NodeMaterial): void;
  64019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64021. protected _buildBlock(state: NodeMaterialBuildState): this;
  64022. }
  64023. }
  64024. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64029. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64030. import { Effect } from "babylonjs/Materials/effect";
  64031. import { Mesh } from "babylonjs/Meshes/mesh";
  64032. import { Light } from "babylonjs/Lights/light";
  64033. import { Nullable } from "babylonjs/types";
  64034. import { Scene } from "babylonjs/scene";
  64035. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64036. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64037. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64038. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64039. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64040. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64041. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64042. /**
  64043. * Block used to add light in the fragment shader
  64044. */
  64045. export class LightBlock extends NodeMaterialBlock {
  64046. private _lightId;
  64047. /**
  64048. * Gets or sets the light associated with this block
  64049. */
  64050. light: Nullable<Light>;
  64051. /**
  64052. * Create a new LightBlock
  64053. * @param name defines the block name
  64054. */
  64055. constructor(name: string);
  64056. /**
  64057. * Gets the current class name
  64058. * @returns the class name
  64059. */
  64060. getClassName(): string;
  64061. /**
  64062. * Gets the world position input component
  64063. */
  64064. get worldPosition(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the world normal input component
  64067. */
  64068. get worldNormal(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the camera (or eye) position component
  64071. */
  64072. get cameraPosition(): NodeMaterialConnectionPoint;
  64073. /**
  64074. * Gets the glossiness component
  64075. */
  64076. get glossiness(): NodeMaterialConnectionPoint;
  64077. /**
  64078. * Gets the glossinness power component
  64079. */
  64080. get glossPower(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the diffuse color component
  64083. */
  64084. get diffuseColor(): NodeMaterialConnectionPoint;
  64085. /**
  64086. * Gets the specular color component
  64087. */
  64088. get specularColor(): NodeMaterialConnectionPoint;
  64089. /**
  64090. * Gets the diffuse output component
  64091. */
  64092. get diffuseOutput(): NodeMaterialConnectionPoint;
  64093. /**
  64094. * Gets the specular output component
  64095. */
  64096. get specularOutput(): NodeMaterialConnectionPoint;
  64097. /**
  64098. * Gets the shadow output component
  64099. */
  64100. get shadow(): NodeMaterialConnectionPoint;
  64101. autoConfigure(material: NodeMaterial): void;
  64102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64103. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64105. private _injectVertexCode;
  64106. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64107. serialize(): any;
  64108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64109. }
  64110. }
  64111. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64114. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64115. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64116. /**
  64117. * Block used to read a reflection texture from a sampler
  64118. */
  64119. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64120. /**
  64121. * Create a new ReflectionTextureBlock
  64122. * @param name defines the block name
  64123. */
  64124. constructor(name: string);
  64125. /**
  64126. * Gets the current class name
  64127. * @returns the class name
  64128. */
  64129. getClassName(): string;
  64130. /**
  64131. * Gets the world position input component
  64132. */
  64133. get position(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the world position input component
  64136. */
  64137. get worldPosition(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the world normal input component
  64140. */
  64141. get worldNormal(): NodeMaterialConnectionPoint;
  64142. /**
  64143. * Gets the world input component
  64144. */
  64145. get world(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the camera (or eye) position component
  64148. */
  64149. get cameraPosition(): NodeMaterialConnectionPoint;
  64150. /**
  64151. * Gets the view input component
  64152. */
  64153. get view(): NodeMaterialConnectionPoint;
  64154. /**
  64155. * Gets the rgb output component
  64156. */
  64157. get rgb(): NodeMaterialConnectionPoint;
  64158. /**
  64159. * Gets the r output component
  64160. */
  64161. get r(): NodeMaterialConnectionPoint;
  64162. /**
  64163. * Gets the g output component
  64164. */
  64165. get g(): NodeMaterialConnectionPoint;
  64166. /**
  64167. * Gets the b output component
  64168. */
  64169. get b(): NodeMaterialConnectionPoint;
  64170. autoConfigure(material: NodeMaterial): void;
  64171. protected _buildBlock(state: NodeMaterialBuildState): this;
  64172. }
  64173. }
  64174. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64175. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64176. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64177. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64178. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64179. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64180. }
  64181. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64182. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64183. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64184. }
  64185. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64189. /**
  64190. * Block used to add 2 vectors
  64191. */
  64192. export class AddBlock extends NodeMaterialBlock {
  64193. /**
  64194. * Creates a new AddBlock
  64195. * @param name defines the block name
  64196. */
  64197. constructor(name: string);
  64198. /**
  64199. * Gets the current class name
  64200. * @returns the class name
  64201. */
  64202. getClassName(): string;
  64203. /**
  64204. * Gets the left operand input component
  64205. */
  64206. get left(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the right operand input component
  64209. */
  64210. get right(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this;
  64216. }
  64217. }
  64218. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64222. /**
  64223. * Block used to scale a vector by a float
  64224. */
  64225. export class ScaleBlock extends NodeMaterialBlock {
  64226. /**
  64227. * Creates a new ScaleBlock
  64228. * @param name defines the block name
  64229. */
  64230. constructor(name: string);
  64231. /**
  64232. * Gets the current class name
  64233. * @returns the class name
  64234. */
  64235. getClassName(): string;
  64236. /**
  64237. * Gets the input component
  64238. */
  64239. get input(): NodeMaterialConnectionPoint;
  64240. /**
  64241. * Gets the factor input component
  64242. */
  64243. get factor(): NodeMaterialConnectionPoint;
  64244. /**
  64245. * Gets the output component
  64246. */
  64247. get output(): NodeMaterialConnectionPoint;
  64248. protected _buildBlock(state: NodeMaterialBuildState): this;
  64249. }
  64250. }
  64251. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64255. import { Scene } from "babylonjs/scene";
  64256. /**
  64257. * Block used to clamp a float
  64258. */
  64259. export class ClampBlock extends NodeMaterialBlock {
  64260. /** Gets or sets the minimum range */
  64261. minimum: number;
  64262. /** Gets or sets the maximum range */
  64263. maximum: number;
  64264. /**
  64265. * Creates a new ClampBlock
  64266. * @param name defines the block name
  64267. */
  64268. constructor(name: string);
  64269. /**
  64270. * Gets the current class name
  64271. * @returns the class name
  64272. */
  64273. getClassName(): string;
  64274. /**
  64275. * Gets the value input component
  64276. */
  64277. get value(): NodeMaterialConnectionPoint;
  64278. /**
  64279. * Gets the output component
  64280. */
  64281. get output(): NodeMaterialConnectionPoint;
  64282. protected _buildBlock(state: NodeMaterialBuildState): this;
  64283. protected _dumpPropertiesCode(): string;
  64284. serialize(): any;
  64285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64286. }
  64287. }
  64288. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64292. /**
  64293. * Block used to apply a cross product between 2 vectors
  64294. */
  64295. export class CrossBlock extends NodeMaterialBlock {
  64296. /**
  64297. * Creates a new CrossBlock
  64298. * @param name defines the block name
  64299. */
  64300. constructor(name: string);
  64301. /**
  64302. * Gets the current class name
  64303. * @returns the class name
  64304. */
  64305. getClassName(): string;
  64306. /**
  64307. * Gets the left operand input component
  64308. */
  64309. get left(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the right operand input component
  64312. */
  64313. get right(): NodeMaterialConnectionPoint;
  64314. /**
  64315. * Gets the output component
  64316. */
  64317. get output(): NodeMaterialConnectionPoint;
  64318. protected _buildBlock(state: NodeMaterialBuildState): this;
  64319. }
  64320. }
  64321. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64325. /**
  64326. * Block used to apply a dot product between 2 vectors
  64327. */
  64328. export class DotBlock extends NodeMaterialBlock {
  64329. /**
  64330. * Creates a new DotBlock
  64331. * @param name defines the block name
  64332. */
  64333. constructor(name: string);
  64334. /**
  64335. * Gets the current class name
  64336. * @returns the class name
  64337. */
  64338. getClassName(): string;
  64339. /**
  64340. * Gets the left operand input component
  64341. */
  64342. get left(): NodeMaterialConnectionPoint;
  64343. /**
  64344. * Gets the right operand input component
  64345. */
  64346. get right(): NodeMaterialConnectionPoint;
  64347. /**
  64348. * Gets the output component
  64349. */
  64350. get output(): NodeMaterialConnectionPoint;
  64351. protected _buildBlock(state: NodeMaterialBuildState): this;
  64352. }
  64353. }
  64354. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64358. /**
  64359. * Block used to normalize a vector
  64360. */
  64361. export class NormalizeBlock extends NodeMaterialBlock {
  64362. /**
  64363. * Creates a new NormalizeBlock
  64364. * @param name defines the block name
  64365. */
  64366. constructor(name: string);
  64367. /**
  64368. * Gets the current class name
  64369. * @returns the class name
  64370. */
  64371. getClassName(): string;
  64372. /**
  64373. * Gets the input component
  64374. */
  64375. get input(): NodeMaterialConnectionPoint;
  64376. /**
  64377. * Gets the output component
  64378. */
  64379. get output(): NodeMaterialConnectionPoint;
  64380. protected _buildBlock(state: NodeMaterialBuildState): this;
  64381. }
  64382. }
  64383. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64384. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64385. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64386. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64387. import { Scene } from "babylonjs/scene";
  64388. /**
  64389. * Operations supported by the Trigonometry block
  64390. */
  64391. export enum TrigonometryBlockOperations {
  64392. /** Cos */
  64393. Cos = 0,
  64394. /** Sin */
  64395. Sin = 1,
  64396. /** Abs */
  64397. Abs = 2,
  64398. /** Exp */
  64399. Exp = 3,
  64400. /** Exp2 */
  64401. Exp2 = 4,
  64402. /** Round */
  64403. Round = 5,
  64404. /** Floor */
  64405. Floor = 6,
  64406. /** Ceiling */
  64407. Ceiling = 7,
  64408. /** Square root */
  64409. Sqrt = 8,
  64410. /** Log */
  64411. Log = 9,
  64412. /** Tangent */
  64413. Tan = 10,
  64414. /** Arc tangent */
  64415. ArcTan = 11,
  64416. /** Arc cosinus */
  64417. ArcCos = 12,
  64418. /** Arc sinus */
  64419. ArcSin = 13,
  64420. /** Fraction */
  64421. Fract = 14,
  64422. /** Sign */
  64423. Sign = 15,
  64424. /** To radians (from degrees) */
  64425. Radians = 16,
  64426. /** To degrees (from radians) */
  64427. Degrees = 17
  64428. }
  64429. /**
  64430. * Block used to apply trigonometry operation to floats
  64431. */
  64432. export class TrigonometryBlock extends NodeMaterialBlock {
  64433. /**
  64434. * Gets or sets the operation applied by the block
  64435. */
  64436. operation: TrigonometryBlockOperations;
  64437. /**
  64438. * Creates a new TrigonometryBlock
  64439. * @param name defines the block name
  64440. */
  64441. constructor(name: string);
  64442. /**
  64443. * Gets the current class name
  64444. * @returns the class name
  64445. */
  64446. getClassName(): string;
  64447. /**
  64448. * Gets the input component
  64449. */
  64450. get input(): NodeMaterialConnectionPoint;
  64451. /**
  64452. * Gets the output component
  64453. */
  64454. get output(): NodeMaterialConnectionPoint;
  64455. protected _buildBlock(state: NodeMaterialBuildState): this;
  64456. serialize(): any;
  64457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64458. protected _dumpPropertiesCode(): string;
  64459. }
  64460. }
  64461. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64465. /**
  64466. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64467. */
  64468. export class ColorMergerBlock extends NodeMaterialBlock {
  64469. /**
  64470. * Create a new ColorMergerBlock
  64471. * @param name defines the block name
  64472. */
  64473. constructor(name: string);
  64474. /**
  64475. * Gets the current class name
  64476. * @returns the class name
  64477. */
  64478. getClassName(): string;
  64479. /**
  64480. * Gets the rgb component (input)
  64481. */
  64482. get rgbIn(): NodeMaterialConnectionPoint;
  64483. /**
  64484. * Gets the r component (input)
  64485. */
  64486. get r(): NodeMaterialConnectionPoint;
  64487. /**
  64488. * Gets the g component (input)
  64489. */
  64490. get g(): NodeMaterialConnectionPoint;
  64491. /**
  64492. * Gets the b component (input)
  64493. */
  64494. get b(): NodeMaterialConnectionPoint;
  64495. /**
  64496. * Gets the a component (input)
  64497. */
  64498. get a(): NodeMaterialConnectionPoint;
  64499. /**
  64500. * Gets the rgba component (output)
  64501. */
  64502. get rgba(): NodeMaterialConnectionPoint;
  64503. /**
  64504. * Gets the rgb component (output)
  64505. */
  64506. get rgbOut(): NodeMaterialConnectionPoint;
  64507. /**
  64508. * Gets the rgb component (output)
  64509. * @deprecated Please use rgbOut instead.
  64510. */
  64511. get rgb(): NodeMaterialConnectionPoint;
  64512. protected _buildBlock(state: NodeMaterialBuildState): this;
  64513. }
  64514. }
  64515. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  64516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64519. /**
  64520. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64521. */
  64522. export class VectorSplitterBlock extends NodeMaterialBlock {
  64523. /**
  64524. * Create a new VectorSplitterBlock
  64525. * @param name defines the block name
  64526. */
  64527. constructor(name: string);
  64528. /**
  64529. * Gets the current class name
  64530. * @returns the class name
  64531. */
  64532. getClassName(): string;
  64533. /**
  64534. * Gets the xyzw component (input)
  64535. */
  64536. get xyzw(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the xyz component (input)
  64539. */
  64540. get xyzIn(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the xy component (input)
  64543. */
  64544. get xyIn(): NodeMaterialConnectionPoint;
  64545. /**
  64546. * Gets the xyz component (output)
  64547. */
  64548. get xyzOut(): NodeMaterialConnectionPoint;
  64549. /**
  64550. * Gets the xy component (output)
  64551. */
  64552. get xyOut(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the x component (output)
  64555. */
  64556. get x(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the y component (output)
  64559. */
  64560. get y(): NodeMaterialConnectionPoint;
  64561. /**
  64562. * Gets the z component (output)
  64563. */
  64564. get z(): NodeMaterialConnectionPoint;
  64565. /**
  64566. * Gets the w component (output)
  64567. */
  64568. get w(): NodeMaterialConnectionPoint;
  64569. protected _inputRename(name: string): string;
  64570. protected _outputRename(name: string): string;
  64571. protected _buildBlock(state: NodeMaterialBuildState): this;
  64572. }
  64573. }
  64574. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  64575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64578. /**
  64579. * Block used to lerp between 2 values
  64580. */
  64581. export class LerpBlock extends NodeMaterialBlock {
  64582. /**
  64583. * Creates a new LerpBlock
  64584. * @param name defines the block name
  64585. */
  64586. constructor(name: string);
  64587. /**
  64588. * Gets the current class name
  64589. * @returns the class name
  64590. */
  64591. getClassName(): string;
  64592. /**
  64593. * Gets the left operand input component
  64594. */
  64595. get left(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the right operand input component
  64598. */
  64599. get right(): NodeMaterialConnectionPoint;
  64600. /**
  64601. * Gets the gradient operand input component
  64602. */
  64603. get gradient(): NodeMaterialConnectionPoint;
  64604. /**
  64605. * Gets the output component
  64606. */
  64607. get output(): NodeMaterialConnectionPoint;
  64608. protected _buildBlock(state: NodeMaterialBuildState): this;
  64609. }
  64610. }
  64611. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  64612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64615. /**
  64616. * Block used to divide 2 vectors
  64617. */
  64618. export class DivideBlock extends NodeMaterialBlock {
  64619. /**
  64620. * Creates a new DivideBlock
  64621. * @param name defines the block name
  64622. */
  64623. constructor(name: string);
  64624. /**
  64625. * Gets the current class name
  64626. * @returns the class name
  64627. */
  64628. getClassName(): string;
  64629. /**
  64630. * Gets the left operand input component
  64631. */
  64632. get left(): NodeMaterialConnectionPoint;
  64633. /**
  64634. * Gets the right operand input component
  64635. */
  64636. get right(): NodeMaterialConnectionPoint;
  64637. /**
  64638. * Gets the output component
  64639. */
  64640. get output(): NodeMaterialConnectionPoint;
  64641. protected _buildBlock(state: NodeMaterialBuildState): this;
  64642. }
  64643. }
  64644. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  64645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64648. /**
  64649. * Block used to subtract 2 vectors
  64650. */
  64651. export class SubtractBlock extends NodeMaterialBlock {
  64652. /**
  64653. * Creates a new SubtractBlock
  64654. * @param name defines the block name
  64655. */
  64656. constructor(name: string);
  64657. /**
  64658. * Gets the current class name
  64659. * @returns the class name
  64660. */
  64661. getClassName(): string;
  64662. /**
  64663. * Gets the left operand input component
  64664. */
  64665. get left(): NodeMaterialConnectionPoint;
  64666. /**
  64667. * Gets the right operand input component
  64668. */
  64669. get right(): NodeMaterialConnectionPoint;
  64670. /**
  64671. * Gets the output component
  64672. */
  64673. get output(): NodeMaterialConnectionPoint;
  64674. protected _buildBlock(state: NodeMaterialBuildState): this;
  64675. }
  64676. }
  64677. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  64678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64681. /**
  64682. * Block used to step a value
  64683. */
  64684. export class StepBlock extends NodeMaterialBlock {
  64685. /**
  64686. * Creates a new StepBlock
  64687. * @param name defines the block name
  64688. */
  64689. constructor(name: string);
  64690. /**
  64691. * Gets the current class name
  64692. * @returns the class name
  64693. */
  64694. getClassName(): string;
  64695. /**
  64696. * Gets the value operand input component
  64697. */
  64698. get value(): NodeMaterialConnectionPoint;
  64699. /**
  64700. * Gets the edge operand input component
  64701. */
  64702. get edge(): NodeMaterialConnectionPoint;
  64703. /**
  64704. * Gets the output component
  64705. */
  64706. get output(): NodeMaterialConnectionPoint;
  64707. protected _buildBlock(state: NodeMaterialBuildState): this;
  64708. }
  64709. }
  64710. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  64711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64714. /**
  64715. * Block used to get the opposite (1 - x) of a value
  64716. */
  64717. export class OneMinusBlock extends NodeMaterialBlock {
  64718. /**
  64719. * Creates a new OneMinusBlock
  64720. * @param name defines the block name
  64721. */
  64722. constructor(name: string);
  64723. /**
  64724. * Gets the current class name
  64725. * @returns the class name
  64726. */
  64727. getClassName(): string;
  64728. /**
  64729. * Gets the input component
  64730. */
  64731. get input(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the output component
  64734. */
  64735. get output(): NodeMaterialConnectionPoint;
  64736. protected _buildBlock(state: NodeMaterialBuildState): this;
  64737. }
  64738. }
  64739. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  64740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64743. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64744. /**
  64745. * Block used to get the view direction
  64746. */
  64747. export class ViewDirectionBlock extends NodeMaterialBlock {
  64748. /**
  64749. * Creates a new ViewDirectionBlock
  64750. * @param name defines the block name
  64751. */
  64752. constructor(name: string);
  64753. /**
  64754. * Gets the current class name
  64755. * @returns the class name
  64756. */
  64757. getClassName(): string;
  64758. /**
  64759. * Gets the world position component
  64760. */
  64761. get worldPosition(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the camera position component
  64764. */
  64765. get cameraPosition(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the output component
  64768. */
  64769. get output(): NodeMaterialConnectionPoint;
  64770. autoConfigure(material: NodeMaterial): void;
  64771. protected _buildBlock(state: NodeMaterialBuildState): this;
  64772. }
  64773. }
  64774. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  64775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64778. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64779. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  64780. /**
  64781. * Block used to compute fresnel value
  64782. */
  64783. export class FresnelBlock extends NodeMaterialBlock {
  64784. /**
  64785. * Create a new FresnelBlock
  64786. * @param name defines the block name
  64787. */
  64788. constructor(name: string);
  64789. /**
  64790. * Gets the current class name
  64791. * @returns the class name
  64792. */
  64793. getClassName(): string;
  64794. /**
  64795. * Gets the world normal input component
  64796. */
  64797. get worldNormal(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the view direction input component
  64800. */
  64801. get viewDirection(): NodeMaterialConnectionPoint;
  64802. /**
  64803. * Gets the bias input component
  64804. */
  64805. get bias(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the camera (or eye) position component
  64808. */
  64809. get power(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the fresnel output component
  64812. */
  64813. get fresnel(): NodeMaterialConnectionPoint;
  64814. autoConfigure(material: NodeMaterial): void;
  64815. protected _buildBlock(state: NodeMaterialBuildState): this;
  64816. }
  64817. }
  64818. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  64819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64822. /**
  64823. * Block used to get the max of 2 values
  64824. */
  64825. export class MaxBlock extends NodeMaterialBlock {
  64826. /**
  64827. * Creates a new MaxBlock
  64828. * @param name defines the block name
  64829. */
  64830. constructor(name: string);
  64831. /**
  64832. * Gets the current class name
  64833. * @returns the class name
  64834. */
  64835. getClassName(): string;
  64836. /**
  64837. * Gets the left operand input component
  64838. */
  64839. get left(): NodeMaterialConnectionPoint;
  64840. /**
  64841. * Gets the right operand input component
  64842. */
  64843. get right(): NodeMaterialConnectionPoint;
  64844. /**
  64845. * Gets the output component
  64846. */
  64847. get output(): NodeMaterialConnectionPoint;
  64848. protected _buildBlock(state: NodeMaterialBuildState): this;
  64849. }
  64850. }
  64851. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  64852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64855. /**
  64856. * Block used to get the min of 2 values
  64857. */
  64858. export class MinBlock extends NodeMaterialBlock {
  64859. /**
  64860. * Creates a new MinBlock
  64861. * @param name defines the block name
  64862. */
  64863. constructor(name: string);
  64864. /**
  64865. * Gets the current class name
  64866. * @returns the class name
  64867. */
  64868. getClassName(): string;
  64869. /**
  64870. * Gets the left operand input component
  64871. */
  64872. get left(): NodeMaterialConnectionPoint;
  64873. /**
  64874. * Gets the right operand input component
  64875. */
  64876. get right(): NodeMaterialConnectionPoint;
  64877. /**
  64878. * Gets the output component
  64879. */
  64880. get output(): NodeMaterialConnectionPoint;
  64881. protected _buildBlock(state: NodeMaterialBuildState): this;
  64882. }
  64883. }
  64884. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  64885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64888. /**
  64889. * Block used to get the distance between 2 values
  64890. */
  64891. export class DistanceBlock extends NodeMaterialBlock {
  64892. /**
  64893. * Creates a new DistanceBlock
  64894. * @param name defines the block name
  64895. */
  64896. constructor(name: string);
  64897. /**
  64898. * Gets the current class name
  64899. * @returns the class name
  64900. */
  64901. getClassName(): string;
  64902. /**
  64903. * Gets the left operand input component
  64904. */
  64905. get left(): NodeMaterialConnectionPoint;
  64906. /**
  64907. * Gets the right operand input component
  64908. */
  64909. get right(): NodeMaterialConnectionPoint;
  64910. /**
  64911. * Gets the output component
  64912. */
  64913. get output(): NodeMaterialConnectionPoint;
  64914. protected _buildBlock(state: NodeMaterialBuildState): this;
  64915. }
  64916. }
  64917. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  64918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64921. /**
  64922. * Block used to get the length of a vector
  64923. */
  64924. export class LengthBlock extends NodeMaterialBlock {
  64925. /**
  64926. * Creates a new LengthBlock
  64927. * @param name defines the block name
  64928. */
  64929. constructor(name: string);
  64930. /**
  64931. * Gets the current class name
  64932. * @returns the class name
  64933. */
  64934. getClassName(): string;
  64935. /**
  64936. * Gets the value input component
  64937. */
  64938. get value(): NodeMaterialConnectionPoint;
  64939. /**
  64940. * Gets the output component
  64941. */
  64942. get output(): NodeMaterialConnectionPoint;
  64943. protected _buildBlock(state: NodeMaterialBuildState): this;
  64944. }
  64945. }
  64946. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  64947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64950. /**
  64951. * Block used to get negative version of a value (i.e. x * -1)
  64952. */
  64953. export class NegateBlock extends NodeMaterialBlock {
  64954. /**
  64955. * Creates a new NegateBlock
  64956. * @param name defines the block name
  64957. */
  64958. constructor(name: string);
  64959. /**
  64960. * Gets the current class name
  64961. * @returns the class name
  64962. */
  64963. getClassName(): string;
  64964. /**
  64965. * Gets the value input component
  64966. */
  64967. get value(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the output component
  64970. */
  64971. get output(): NodeMaterialConnectionPoint;
  64972. protected _buildBlock(state: NodeMaterialBuildState): this;
  64973. }
  64974. }
  64975. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  64976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64979. /**
  64980. * Block used to get the value of the first parameter raised to the power of the second
  64981. */
  64982. export class PowBlock extends NodeMaterialBlock {
  64983. /**
  64984. * Creates a new PowBlock
  64985. * @param name defines the block name
  64986. */
  64987. constructor(name: string);
  64988. /**
  64989. * Gets the current class name
  64990. * @returns the class name
  64991. */
  64992. getClassName(): string;
  64993. /**
  64994. * Gets the value operand input component
  64995. */
  64996. get value(): NodeMaterialConnectionPoint;
  64997. /**
  64998. * Gets the power operand input component
  64999. */
  65000. get power(): NodeMaterialConnectionPoint;
  65001. /**
  65002. * Gets the output component
  65003. */
  65004. get output(): NodeMaterialConnectionPoint;
  65005. protected _buildBlock(state: NodeMaterialBuildState): this;
  65006. }
  65007. }
  65008. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65012. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65013. /**
  65014. * Block used to get a random number
  65015. */
  65016. export class RandomNumberBlock extends NodeMaterialBlock {
  65017. /**
  65018. * Creates a new RandomNumberBlock
  65019. * @param name defines the block name
  65020. */
  65021. constructor(name: string);
  65022. /**
  65023. * Gets the current class name
  65024. * @returns the class name
  65025. */
  65026. getClassName(): string;
  65027. /**
  65028. * Gets the seed input component
  65029. */
  65030. get seed(): NodeMaterialConnectionPoint;
  65031. /**
  65032. * Gets the output component
  65033. */
  65034. get output(): NodeMaterialConnectionPoint;
  65035. protected _buildBlock(state: NodeMaterialBuildState): this;
  65036. }
  65037. }
  65038. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65042. /**
  65043. * Block used to compute arc tangent of 2 values
  65044. */
  65045. export class ArcTan2Block extends NodeMaterialBlock {
  65046. /**
  65047. * Creates a new ArcTan2Block
  65048. * @param name defines the block name
  65049. */
  65050. constructor(name: string);
  65051. /**
  65052. * Gets the current class name
  65053. * @returns the class name
  65054. */
  65055. getClassName(): string;
  65056. /**
  65057. * Gets the x operand input component
  65058. */
  65059. get x(): NodeMaterialConnectionPoint;
  65060. /**
  65061. * Gets the y operand input component
  65062. */
  65063. get y(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the output component
  65066. */
  65067. get output(): NodeMaterialConnectionPoint;
  65068. protected _buildBlock(state: NodeMaterialBuildState): this;
  65069. }
  65070. }
  65071. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65075. /**
  65076. * Block used to smooth step a value
  65077. */
  65078. export class SmoothStepBlock extends NodeMaterialBlock {
  65079. /**
  65080. * Creates a new SmoothStepBlock
  65081. * @param name defines the block name
  65082. */
  65083. constructor(name: string);
  65084. /**
  65085. * Gets the current class name
  65086. * @returns the class name
  65087. */
  65088. getClassName(): string;
  65089. /**
  65090. * Gets the value operand input component
  65091. */
  65092. get value(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the first edge operand input component
  65095. */
  65096. get edge0(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the second edge operand input component
  65099. */
  65100. get edge1(): NodeMaterialConnectionPoint;
  65101. /**
  65102. * Gets the output component
  65103. */
  65104. get output(): NodeMaterialConnectionPoint;
  65105. protected _buildBlock(state: NodeMaterialBuildState): this;
  65106. }
  65107. }
  65108. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65112. /**
  65113. * Block used to get the reciprocal (1 / x) of a value
  65114. */
  65115. export class ReciprocalBlock extends NodeMaterialBlock {
  65116. /**
  65117. * Creates a new ReciprocalBlock
  65118. * @param name defines the block name
  65119. */
  65120. constructor(name: string);
  65121. /**
  65122. * Gets the current class name
  65123. * @returns the class name
  65124. */
  65125. getClassName(): string;
  65126. /**
  65127. * Gets the input component
  65128. */
  65129. get input(): NodeMaterialConnectionPoint;
  65130. /**
  65131. * Gets the output component
  65132. */
  65133. get output(): NodeMaterialConnectionPoint;
  65134. protected _buildBlock(state: NodeMaterialBuildState): this;
  65135. }
  65136. }
  65137. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65141. /**
  65142. * Block used to replace a color by another one
  65143. */
  65144. export class ReplaceColorBlock extends NodeMaterialBlock {
  65145. /**
  65146. * Creates a new ReplaceColorBlock
  65147. * @param name defines the block name
  65148. */
  65149. constructor(name: string);
  65150. /**
  65151. * Gets the current class name
  65152. * @returns the class name
  65153. */
  65154. getClassName(): string;
  65155. /**
  65156. * Gets the value input component
  65157. */
  65158. get value(): NodeMaterialConnectionPoint;
  65159. /**
  65160. * Gets the reference input component
  65161. */
  65162. get reference(): NodeMaterialConnectionPoint;
  65163. /**
  65164. * Gets the distance input component
  65165. */
  65166. get distance(): NodeMaterialConnectionPoint;
  65167. /**
  65168. * Gets the replacement input component
  65169. */
  65170. get replacement(): NodeMaterialConnectionPoint;
  65171. /**
  65172. * Gets the output component
  65173. */
  65174. get output(): NodeMaterialConnectionPoint;
  65175. protected _buildBlock(state: NodeMaterialBuildState): this;
  65176. }
  65177. }
  65178. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65182. /**
  65183. * Block used to posterize a value
  65184. * @see https://en.wikipedia.org/wiki/Posterization
  65185. */
  65186. export class PosterizeBlock extends NodeMaterialBlock {
  65187. /**
  65188. * Creates a new PosterizeBlock
  65189. * @param name defines the block name
  65190. */
  65191. constructor(name: string);
  65192. /**
  65193. * Gets the current class name
  65194. * @returns the class name
  65195. */
  65196. getClassName(): string;
  65197. /**
  65198. * Gets the value input component
  65199. */
  65200. get value(): NodeMaterialConnectionPoint;
  65201. /**
  65202. * Gets the steps input component
  65203. */
  65204. get steps(): NodeMaterialConnectionPoint;
  65205. /**
  65206. * Gets the output component
  65207. */
  65208. get output(): NodeMaterialConnectionPoint;
  65209. protected _buildBlock(state: NodeMaterialBuildState): this;
  65210. }
  65211. }
  65212. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65216. import { Scene } from "babylonjs/scene";
  65217. /**
  65218. * Operations supported by the Wave block
  65219. */
  65220. export enum WaveBlockKind {
  65221. /** SawTooth */
  65222. SawTooth = 0,
  65223. /** Square */
  65224. Square = 1,
  65225. /** Triangle */
  65226. Triangle = 2
  65227. }
  65228. /**
  65229. * Block used to apply wave operation to floats
  65230. */
  65231. export class WaveBlock extends NodeMaterialBlock {
  65232. /**
  65233. * Gets or sets the kibnd of wave to be applied by the block
  65234. */
  65235. kind: WaveBlockKind;
  65236. /**
  65237. * Creates a new WaveBlock
  65238. * @param name defines the block name
  65239. */
  65240. constructor(name: string);
  65241. /**
  65242. * Gets the current class name
  65243. * @returns the class name
  65244. */
  65245. getClassName(): string;
  65246. /**
  65247. * Gets the input component
  65248. */
  65249. get input(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the output component
  65252. */
  65253. get output(): NodeMaterialConnectionPoint;
  65254. protected _buildBlock(state: NodeMaterialBuildState): this;
  65255. serialize(): any;
  65256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65257. }
  65258. }
  65259. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65260. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65261. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65262. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65263. import { Color3 } from "babylonjs/Maths/math.color";
  65264. import { Scene } from "babylonjs/scene";
  65265. /**
  65266. * Class used to store a color step for the GradientBlock
  65267. */
  65268. export class GradientBlockColorStep {
  65269. /**
  65270. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65271. */
  65272. step: number;
  65273. /**
  65274. * Gets or sets the color associated with this step
  65275. */
  65276. color: Color3;
  65277. /**
  65278. * Creates a new GradientBlockColorStep
  65279. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65280. * @param color defines the color associated with this step
  65281. */
  65282. constructor(
  65283. /**
  65284. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65285. */
  65286. step: number,
  65287. /**
  65288. * Gets or sets the color associated with this step
  65289. */
  65290. color: Color3);
  65291. }
  65292. /**
  65293. * Block used to return a color from a gradient based on an input value between 0 and 1
  65294. */
  65295. export class GradientBlock extends NodeMaterialBlock {
  65296. /**
  65297. * Gets or sets the list of color steps
  65298. */
  65299. colorSteps: GradientBlockColorStep[];
  65300. /**
  65301. * Creates a new GradientBlock
  65302. * @param name defines the block name
  65303. */
  65304. constructor(name: string);
  65305. /**
  65306. * Gets the current class name
  65307. * @returns the class name
  65308. */
  65309. getClassName(): string;
  65310. /**
  65311. * Gets the gradient input component
  65312. */
  65313. get gradient(): NodeMaterialConnectionPoint;
  65314. /**
  65315. * Gets the output component
  65316. */
  65317. get output(): NodeMaterialConnectionPoint;
  65318. private _writeColorConstant;
  65319. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65320. serialize(): any;
  65321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65322. protected _dumpPropertiesCode(): string;
  65323. }
  65324. }
  65325. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65329. /**
  65330. * Block used to normalize lerp between 2 values
  65331. */
  65332. export class NLerpBlock extends NodeMaterialBlock {
  65333. /**
  65334. * Creates a new NLerpBlock
  65335. * @param name defines the block name
  65336. */
  65337. constructor(name: string);
  65338. /**
  65339. * Gets the current class name
  65340. * @returns the class name
  65341. */
  65342. getClassName(): string;
  65343. /**
  65344. * Gets the left operand input component
  65345. */
  65346. get left(): NodeMaterialConnectionPoint;
  65347. /**
  65348. * Gets the right operand input component
  65349. */
  65350. get right(): NodeMaterialConnectionPoint;
  65351. /**
  65352. * Gets the gradient operand input component
  65353. */
  65354. get gradient(): NodeMaterialConnectionPoint;
  65355. /**
  65356. * Gets the output component
  65357. */
  65358. get output(): NodeMaterialConnectionPoint;
  65359. protected _buildBlock(state: NodeMaterialBuildState): this;
  65360. }
  65361. }
  65362. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65366. import { Scene } from "babylonjs/scene";
  65367. /**
  65368. * block used to Generate a Worley Noise 3D Noise Pattern
  65369. */
  65370. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65371. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65372. manhattanDistance: boolean;
  65373. /**
  65374. * Creates a new WorleyNoise3DBlock
  65375. * @param name defines the block name
  65376. */
  65377. constructor(name: string);
  65378. /**
  65379. * Gets the current class name
  65380. * @returns the class name
  65381. */
  65382. getClassName(): string;
  65383. /**
  65384. * Gets the seed input component
  65385. */
  65386. get seed(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the jitter input component
  65389. */
  65390. get jitter(): NodeMaterialConnectionPoint;
  65391. /**
  65392. * Gets the output component
  65393. */
  65394. get output(): NodeMaterialConnectionPoint;
  65395. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65396. /**
  65397. * Exposes the properties to the UI?
  65398. */
  65399. protected _dumpPropertiesCode(): string;
  65400. /**
  65401. * Exposes the properties to the Seralize?
  65402. */
  65403. serialize(): any;
  65404. /**
  65405. * Exposes the properties to the deseralize?
  65406. */
  65407. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65408. }
  65409. }
  65410. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65414. /**
  65415. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65416. */
  65417. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65418. /**
  65419. * Creates a new SimplexPerlin3DBlock
  65420. * @param name defines the block name
  65421. */
  65422. constructor(name: string);
  65423. /**
  65424. * Gets the current class name
  65425. * @returns the class name
  65426. */
  65427. getClassName(): string;
  65428. /**
  65429. * Gets the seed operand input component
  65430. */
  65431. get seed(): NodeMaterialConnectionPoint;
  65432. /**
  65433. * Gets the output component
  65434. */
  65435. get output(): NodeMaterialConnectionPoint;
  65436. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65437. }
  65438. }
  65439. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65443. /**
  65444. * Block used to blend normals
  65445. */
  65446. export class NormalBlendBlock extends NodeMaterialBlock {
  65447. /**
  65448. * Creates a new NormalBlendBlock
  65449. * @param name defines the block name
  65450. */
  65451. constructor(name: string);
  65452. /**
  65453. * Gets the current class name
  65454. * @returns the class name
  65455. */
  65456. getClassName(): string;
  65457. /**
  65458. * Gets the first input component
  65459. */
  65460. get normalMap0(): NodeMaterialConnectionPoint;
  65461. /**
  65462. * Gets the second input component
  65463. */
  65464. get normalMap1(): NodeMaterialConnectionPoint;
  65465. /**
  65466. * Gets the output component
  65467. */
  65468. get output(): NodeMaterialConnectionPoint;
  65469. protected _buildBlock(state: NodeMaterialBuildState): this;
  65470. }
  65471. }
  65472. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65476. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65477. /**
  65478. * Block used to rotate a 2d vector by a given angle
  65479. */
  65480. export class Rotate2dBlock extends NodeMaterialBlock {
  65481. /**
  65482. * Creates a new Rotate2dBlock
  65483. * @param name defines the block name
  65484. */
  65485. constructor(name: string);
  65486. /**
  65487. * Gets the current class name
  65488. * @returns the class name
  65489. */
  65490. getClassName(): string;
  65491. /**
  65492. * Gets the input vector
  65493. */
  65494. get input(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the input angle
  65497. */
  65498. get angle(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the output component
  65501. */
  65502. get output(): NodeMaterialConnectionPoint;
  65503. autoConfigure(material: NodeMaterial): void;
  65504. protected _buildBlock(state: NodeMaterialBuildState): this;
  65505. }
  65506. }
  65507. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  65508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65511. /**
  65512. * Block used to get the reflected vector from a direction and a normal
  65513. */
  65514. export class ReflectBlock extends NodeMaterialBlock {
  65515. /**
  65516. * Creates a new ReflectBlock
  65517. * @param name defines the block name
  65518. */
  65519. constructor(name: string);
  65520. /**
  65521. * Gets the current class name
  65522. * @returns the class name
  65523. */
  65524. getClassName(): string;
  65525. /**
  65526. * Gets the incident component
  65527. */
  65528. get incident(): NodeMaterialConnectionPoint;
  65529. /**
  65530. * Gets the normal component
  65531. */
  65532. get normal(): NodeMaterialConnectionPoint;
  65533. /**
  65534. * Gets the output component
  65535. */
  65536. get output(): NodeMaterialConnectionPoint;
  65537. protected _buildBlock(state: NodeMaterialBuildState): this;
  65538. }
  65539. }
  65540. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  65541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65544. /**
  65545. * Block used to get the refracted vector from a direction and a normal
  65546. */
  65547. export class RefractBlock extends NodeMaterialBlock {
  65548. /**
  65549. * Creates a new RefractBlock
  65550. * @param name defines the block name
  65551. */
  65552. constructor(name: string);
  65553. /**
  65554. * Gets the current class name
  65555. * @returns the class name
  65556. */
  65557. getClassName(): string;
  65558. /**
  65559. * Gets the incident component
  65560. */
  65561. get incident(): NodeMaterialConnectionPoint;
  65562. /**
  65563. * Gets the normal component
  65564. */
  65565. get normal(): NodeMaterialConnectionPoint;
  65566. /**
  65567. * Gets the index of refraction component
  65568. */
  65569. get ior(): NodeMaterialConnectionPoint;
  65570. /**
  65571. * Gets the output component
  65572. */
  65573. get output(): NodeMaterialConnectionPoint;
  65574. protected _buildBlock(state: NodeMaterialBuildState): this;
  65575. }
  65576. }
  65577. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  65578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65581. /**
  65582. * Block used to desaturate a color
  65583. */
  65584. export class DesaturateBlock extends NodeMaterialBlock {
  65585. /**
  65586. * Creates a new DesaturateBlock
  65587. * @param name defines the block name
  65588. */
  65589. constructor(name: string);
  65590. /**
  65591. * Gets the current class name
  65592. * @returns the class name
  65593. */
  65594. getClassName(): string;
  65595. /**
  65596. * Gets the color operand input component
  65597. */
  65598. get color(): NodeMaterialConnectionPoint;
  65599. /**
  65600. * Gets the level operand input component
  65601. */
  65602. get level(): NodeMaterialConnectionPoint;
  65603. /**
  65604. * Gets the output component
  65605. */
  65606. get output(): NodeMaterialConnectionPoint;
  65607. protected _buildBlock(state: NodeMaterialBuildState): this;
  65608. }
  65609. }
  65610. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  65611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65614. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65615. import { Nullable } from "babylonjs/types";
  65616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65617. import { Scene } from "babylonjs/scene";
  65618. /**
  65619. * Block used to implement the ambient occlusion module of the PBR material
  65620. */
  65621. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65622. /**
  65623. * Create a new AmbientOcclusionBlock
  65624. * @param name defines the block name
  65625. */
  65626. constructor(name: string);
  65627. /**
  65628. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65629. */
  65630. useAmbientInGrayScale: boolean;
  65631. /**
  65632. * Initialize the block and prepare the context for build
  65633. * @param state defines the state that will be used for the build
  65634. */
  65635. initialize(state: NodeMaterialBuildState): void;
  65636. /**
  65637. * Gets the current class name
  65638. * @returns the class name
  65639. */
  65640. getClassName(): string;
  65641. /**
  65642. * Gets the texture input component
  65643. */
  65644. get texture(): NodeMaterialConnectionPoint;
  65645. /**
  65646. * Gets the texture intensity component
  65647. */
  65648. get intensity(): NodeMaterialConnectionPoint;
  65649. /**
  65650. * Gets the direct light intensity input component
  65651. */
  65652. get directLightIntensity(): NodeMaterialConnectionPoint;
  65653. /**
  65654. * Gets the ambient occlusion object output component
  65655. */
  65656. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65657. /**
  65658. * Gets the main code of the block (fragment side)
  65659. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65660. * @returns the shader code
  65661. */
  65662. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65664. protected _buildBlock(state: NodeMaterialBuildState): this;
  65665. protected _dumpPropertiesCode(): string;
  65666. serialize(): any;
  65667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65668. }
  65669. }
  65670. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  65671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65673. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65674. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65676. import { Nullable } from "babylonjs/types";
  65677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65678. import { Mesh } from "babylonjs/Meshes/mesh";
  65679. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65680. import { Effect } from "babylonjs/Materials/effect";
  65681. import { Scene } from "babylonjs/scene";
  65682. /**
  65683. * Block used to implement the reflection module of the PBR material
  65684. */
  65685. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65686. /** @hidden */
  65687. _defineLODReflectionAlpha: string;
  65688. /** @hidden */
  65689. _defineLinearSpecularReflection: string;
  65690. private _vEnvironmentIrradianceName;
  65691. /** @hidden */
  65692. _vReflectionMicrosurfaceInfosName: string;
  65693. /** @hidden */
  65694. _vReflectionInfosName: string;
  65695. private _scene;
  65696. /**
  65697. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65698. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65699. * It's less burden on the user side in the editor part.
  65700. */
  65701. /** @hidden */
  65702. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65703. /** @hidden */
  65704. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65705. /** @hidden */
  65706. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65707. /**
  65708. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65709. * diffuse part of the IBL.
  65710. */
  65711. useSphericalHarmonics: boolean;
  65712. /**
  65713. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65714. */
  65715. forceIrradianceInFragment: boolean;
  65716. /**
  65717. * Create a new ReflectionBlock
  65718. * @param name defines the block name
  65719. */
  65720. constructor(name: string);
  65721. /**
  65722. * Gets the current class name
  65723. * @returns the class name
  65724. */
  65725. getClassName(): string;
  65726. /**
  65727. * Gets the position input component
  65728. */
  65729. get position(): NodeMaterialConnectionPoint;
  65730. /**
  65731. * Gets the world position input component
  65732. */
  65733. get worldPosition(): NodeMaterialConnectionPoint;
  65734. /**
  65735. * Gets the world normal input component
  65736. */
  65737. get worldNormal(): NodeMaterialConnectionPoint;
  65738. /**
  65739. * Gets the world input component
  65740. */
  65741. get world(): NodeMaterialConnectionPoint;
  65742. /**
  65743. * Gets the camera (or eye) position component
  65744. */
  65745. get cameraPosition(): NodeMaterialConnectionPoint;
  65746. /**
  65747. * Gets the view input component
  65748. */
  65749. get view(): NodeMaterialConnectionPoint;
  65750. /**
  65751. * Gets the color input component
  65752. */
  65753. get color(): NodeMaterialConnectionPoint;
  65754. /**
  65755. * Gets the reflection object output component
  65756. */
  65757. get reflection(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65760. */
  65761. get hasTexture(): boolean;
  65762. /**
  65763. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65764. */
  65765. get reflectionColor(): string;
  65766. protected _getTexture(): Nullable<BaseTexture>;
  65767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65769. /**
  65770. * Gets the code to inject in the vertex shader
  65771. * @param state current state of the node material building
  65772. * @returns the shader code
  65773. */
  65774. handleVertexSide(state: NodeMaterialBuildState): string;
  65775. /**
  65776. * Gets the main code of the block (fragment side)
  65777. * @param state current state of the node material building
  65778. * @param normalVarName name of the existing variable corresponding to the normal
  65779. * @returns the shader code
  65780. */
  65781. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65782. protected _buildBlock(state: NodeMaterialBuildState): this;
  65783. protected _dumpPropertiesCode(): string;
  65784. serialize(): any;
  65785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65786. }
  65787. }
  65788. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  65789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65792. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65794. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65795. import { Scene } from "babylonjs/scene";
  65796. import { Nullable } from "babylonjs/types";
  65797. /**
  65798. * Block used to implement the sheen module of the PBR material
  65799. */
  65800. export class SheenBlock extends NodeMaterialBlock {
  65801. /**
  65802. * Create a new SheenBlock
  65803. * @param name defines the block name
  65804. */
  65805. constructor(name: string);
  65806. /**
  65807. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65808. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65809. * making it easier to setup and tweak the effect
  65810. */
  65811. albedoScaling: boolean;
  65812. /**
  65813. * Defines if the sheen is linked to the sheen color.
  65814. */
  65815. linkSheenWithAlbedo: boolean;
  65816. /**
  65817. * Initialize the block and prepare the context for build
  65818. * @param state defines the state that will be used for the build
  65819. */
  65820. initialize(state: NodeMaterialBuildState): void;
  65821. /**
  65822. * Gets the current class name
  65823. * @returns the class name
  65824. */
  65825. getClassName(): string;
  65826. /**
  65827. * Gets the intensity input component
  65828. */
  65829. get intensity(): NodeMaterialConnectionPoint;
  65830. /**
  65831. * Gets the color input component
  65832. */
  65833. get color(): NodeMaterialConnectionPoint;
  65834. /**
  65835. * Gets the roughness input component
  65836. */
  65837. get roughness(): NodeMaterialConnectionPoint;
  65838. /**
  65839. * Gets the texture input component
  65840. */
  65841. get texture(): NodeMaterialConnectionPoint;
  65842. /**
  65843. * Gets the sheen object output component
  65844. */
  65845. get sheen(): NodeMaterialConnectionPoint;
  65846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65847. /**
  65848. * Gets the main code of the block (fragment side)
  65849. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65850. * @returns the shader code
  65851. */
  65852. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65853. protected _buildBlock(state: NodeMaterialBuildState): this;
  65854. protected _dumpPropertiesCode(): string;
  65855. serialize(): any;
  65856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65857. }
  65858. }
  65859. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  65860. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65864. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65865. import { Scene } from "babylonjs/scene";
  65866. /**
  65867. * Block used to implement the reflectivity module of the PBR material
  65868. */
  65869. export class ReflectivityBlock extends NodeMaterialBlock {
  65870. /**
  65871. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65872. */
  65873. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65874. /**
  65875. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65876. */
  65877. useMetallnessFromMetallicTextureBlue: boolean;
  65878. /**
  65879. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65880. */
  65881. useRoughnessFromMetallicTextureAlpha: boolean;
  65882. /**
  65883. * Specifies if the metallic texture contains the roughness information in its green channel.
  65884. */
  65885. useRoughnessFromMetallicTextureGreen: boolean;
  65886. /**
  65887. * Create a new ReflectivityBlock
  65888. * @param name defines the block name
  65889. */
  65890. constructor(name: string);
  65891. /**
  65892. * Initialize the block and prepare the context for build
  65893. * @param state defines the state that will be used for the build
  65894. */
  65895. initialize(state: NodeMaterialBuildState): void;
  65896. /**
  65897. * Gets the current class name
  65898. * @returns the class name
  65899. */
  65900. getClassName(): string;
  65901. /**
  65902. * Gets the metallic input component
  65903. */
  65904. get metallic(): NodeMaterialConnectionPoint;
  65905. /**
  65906. * Gets the roughness input component
  65907. */
  65908. get roughness(): NodeMaterialConnectionPoint;
  65909. /**
  65910. * Gets the texture input component
  65911. */
  65912. get texture(): NodeMaterialConnectionPoint;
  65913. /**
  65914. * Gets the reflectivity object output component
  65915. */
  65916. get reflectivity(): NodeMaterialConnectionPoint;
  65917. /**
  65918. * Gets the main code of the block (fragment side)
  65919. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65920. * @returns the shader code
  65921. */
  65922. getCode(aoIntensityVarName: string): string;
  65923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65924. protected _buildBlock(state: NodeMaterialBuildState): this;
  65925. protected _dumpPropertiesCode(): string;
  65926. serialize(): any;
  65927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65928. }
  65929. }
  65930. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  65931. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65936. /**
  65937. * Block used to implement the anisotropy module of the PBR material
  65938. */
  65939. export class AnisotropyBlock extends NodeMaterialBlock {
  65940. /**
  65941. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65942. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65943. * It's less burden on the user side in the editor part.
  65944. */
  65945. /** @hidden */
  65946. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65947. /** @hidden */
  65948. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65949. /**
  65950. * Create a new AnisotropyBlock
  65951. * @param name defines the block name
  65952. */
  65953. constructor(name: string);
  65954. /**
  65955. * Initialize the block and prepare the context for build
  65956. * @param state defines the state that will be used for the build
  65957. */
  65958. initialize(state: NodeMaterialBuildState): void;
  65959. /**
  65960. * Gets the current class name
  65961. * @returns the class name
  65962. */
  65963. getClassName(): string;
  65964. /**
  65965. * Gets the intensity input component
  65966. */
  65967. get intensity(): NodeMaterialConnectionPoint;
  65968. /**
  65969. * Gets the direction input component
  65970. */
  65971. get direction(): NodeMaterialConnectionPoint;
  65972. /**
  65973. * Gets the texture input component
  65974. */
  65975. get texture(): NodeMaterialConnectionPoint;
  65976. /**
  65977. * Gets the uv input component
  65978. */
  65979. get uv(): NodeMaterialConnectionPoint;
  65980. /**
  65981. * Gets the worldTangent input component
  65982. */
  65983. get worldTangent(): NodeMaterialConnectionPoint;
  65984. /**
  65985. * Gets the anisotropy object output component
  65986. */
  65987. get anisotropy(): NodeMaterialConnectionPoint;
  65988. private _generateTBNSpace;
  65989. /**
  65990. * Gets the main code of the block (fragment side)
  65991. * @param state current state of the node material building
  65992. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65993. * @returns the shader code
  65994. */
  65995. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65997. protected _buildBlock(state: NodeMaterialBuildState): this;
  65998. }
  65999. }
  66000. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66004. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66006. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66007. import { Nullable } from "babylonjs/types";
  66008. import { Mesh } from "babylonjs/Meshes/mesh";
  66009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66010. import { Effect } from "babylonjs/Materials/effect";
  66011. /**
  66012. * Block used to implement the clear coat module of the PBR material
  66013. */
  66014. export class ClearCoatBlock extends NodeMaterialBlock {
  66015. private _scene;
  66016. /**
  66017. * Create a new ClearCoatBlock
  66018. * @param name defines the block name
  66019. */
  66020. constructor(name: string);
  66021. /**
  66022. * Initialize the block and prepare the context for build
  66023. * @param state defines the state that will be used for the build
  66024. */
  66025. initialize(state: NodeMaterialBuildState): void;
  66026. /**
  66027. * Gets the current class name
  66028. * @returns the class name
  66029. */
  66030. getClassName(): string;
  66031. /**
  66032. * Gets the intensity input component
  66033. */
  66034. get intensity(): NodeMaterialConnectionPoint;
  66035. /**
  66036. * Gets the roughness input component
  66037. */
  66038. get roughness(): NodeMaterialConnectionPoint;
  66039. /**
  66040. * Gets the ior input component
  66041. */
  66042. get ior(): NodeMaterialConnectionPoint;
  66043. /**
  66044. * Gets the texture input component
  66045. */
  66046. get texture(): NodeMaterialConnectionPoint;
  66047. /**
  66048. * Gets the bump texture input component
  66049. */
  66050. get bumpTexture(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the uv input component
  66053. */
  66054. get uv(): NodeMaterialConnectionPoint;
  66055. /**
  66056. * Gets the tint color input component
  66057. */
  66058. get tintColor(): NodeMaterialConnectionPoint;
  66059. /**
  66060. * Gets the tint "at distance" input component
  66061. */
  66062. get tintAtDistance(): NodeMaterialConnectionPoint;
  66063. /**
  66064. * Gets the tint thickness input component
  66065. */
  66066. get tintThickness(): NodeMaterialConnectionPoint;
  66067. /**
  66068. * Gets the tint texture input component
  66069. */
  66070. get tintTexture(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the world tangent input component
  66073. */
  66074. get worldTangent(): NodeMaterialConnectionPoint;
  66075. /**
  66076. * Gets the clear coat object output component
  66077. */
  66078. get clearcoat(): NodeMaterialConnectionPoint;
  66079. autoConfigure(material: NodeMaterial): void;
  66080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66081. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66082. private _generateTBNSpace;
  66083. /**
  66084. * Gets the main code of the block (fragment side)
  66085. * @param state current state of the node material building
  66086. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66087. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66088. * @param worldPosVarName name of the variable holding the world position
  66089. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66090. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66091. * @param worldNormalVarName name of the variable holding the world normal
  66092. * @returns the shader code
  66093. */
  66094. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66095. protected _buildBlock(state: NodeMaterialBuildState): this;
  66096. }
  66097. }
  66098. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66102. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66104. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66105. import { Nullable } from "babylonjs/types";
  66106. /**
  66107. * Block used to implement the sub surface module of the PBR material
  66108. */
  66109. export class SubSurfaceBlock extends NodeMaterialBlock {
  66110. /**
  66111. * Create a new SubSurfaceBlock
  66112. * @param name defines the block name
  66113. */
  66114. constructor(name: string);
  66115. /**
  66116. * Stores the intensity of the different subsurface effects in the thickness texture.
  66117. * * the green channel is the translucency intensity.
  66118. * * the blue channel is the scattering intensity.
  66119. * * the alpha channel is the refraction intensity.
  66120. */
  66121. useMaskFromThicknessTexture: boolean;
  66122. /**
  66123. * Initialize the block and prepare the context for build
  66124. * @param state defines the state that will be used for the build
  66125. */
  66126. initialize(state: NodeMaterialBuildState): void;
  66127. /**
  66128. * Gets the current class name
  66129. * @returns the class name
  66130. */
  66131. getClassName(): string;
  66132. /**
  66133. * Gets the min thickness input component
  66134. */
  66135. get minThickness(): NodeMaterialConnectionPoint;
  66136. /**
  66137. * Gets the max thickness input component
  66138. */
  66139. get maxThickness(): NodeMaterialConnectionPoint;
  66140. /**
  66141. * Gets the thickness texture component
  66142. */
  66143. get thicknessTexture(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the tint color input component
  66146. */
  66147. get tintColor(): NodeMaterialConnectionPoint;
  66148. /**
  66149. * Gets the translucency intensity input component
  66150. */
  66151. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66152. /**
  66153. * Gets the translucency diffusion distance input component
  66154. */
  66155. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66156. /**
  66157. * Gets the refraction object parameters
  66158. */
  66159. get refraction(): NodeMaterialConnectionPoint;
  66160. /**
  66161. * Gets the sub surface object output component
  66162. */
  66163. get subsurface(): NodeMaterialConnectionPoint;
  66164. autoConfigure(material: NodeMaterial): void;
  66165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66166. /**
  66167. * Gets the main code of the block (fragment side)
  66168. * @param state current state of the node material building
  66169. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66170. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66171. * @param worldPosVarName name of the variable holding the world position
  66172. * @returns the shader code
  66173. */
  66174. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66175. protected _buildBlock(state: NodeMaterialBuildState): this;
  66176. }
  66177. }
  66178. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66182. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66183. import { Light } from "babylonjs/Lights/light";
  66184. import { Nullable } from "babylonjs/types";
  66185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66186. import { Effect } from "babylonjs/Materials/effect";
  66187. import { Mesh } from "babylonjs/Meshes/mesh";
  66188. import { Scene } from "babylonjs/scene";
  66189. /**
  66190. * Block used to implement the PBR metallic/roughness model
  66191. */
  66192. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66193. /**
  66194. * Gets or sets the light associated with this block
  66195. */
  66196. light: Nullable<Light>;
  66197. private _lightId;
  66198. private _scene;
  66199. private _environmentBRDFTexture;
  66200. private _environmentBrdfSamplerName;
  66201. private _vNormalWName;
  66202. private _invertNormalName;
  66203. /**
  66204. * Create a new ReflectionBlock
  66205. * @param name defines the block name
  66206. */
  66207. constructor(name: string);
  66208. /**
  66209. * Intensity of the direct lights e.g. the four lights available in your scene.
  66210. * This impacts both the direct diffuse and specular highlights.
  66211. */
  66212. directIntensity: number;
  66213. /**
  66214. * Intensity of the environment e.g. how much the environment will light the object
  66215. * either through harmonics for rough material or through the refelction for shiny ones.
  66216. */
  66217. environmentIntensity: number;
  66218. /**
  66219. * This is a special control allowing the reduction of the specular highlights coming from the
  66220. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66221. */
  66222. specularIntensity: number;
  66223. /**
  66224. * Defines the falloff type used in this material.
  66225. * It by default is Physical.
  66226. */
  66227. lightFalloff: number;
  66228. /**
  66229. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66230. */
  66231. useAlphaFromAlbedoTexture: boolean;
  66232. /**
  66233. * Specifies that alpha test should be used
  66234. */
  66235. useAlphaTest: boolean;
  66236. /**
  66237. * Defines the alpha limits in alpha test mode.
  66238. */
  66239. alphaTestCutoff: number;
  66240. /**
  66241. * Specifies that alpha blending should be used
  66242. */
  66243. useAlphaBlending: boolean;
  66244. /**
  66245. * Defines if the alpha value should be determined via the rgb values.
  66246. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66247. */
  66248. opacityRGB: boolean;
  66249. /**
  66250. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66251. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66252. */
  66253. useRadianceOverAlpha: boolean;
  66254. /**
  66255. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66256. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66257. */
  66258. useSpecularOverAlpha: boolean;
  66259. /**
  66260. * Enables specular anti aliasing in the PBR shader.
  66261. * It will both interacts on the Geometry for analytical and IBL lighting.
  66262. * It also prefilter the roughness map based on the bump values.
  66263. */
  66264. enableSpecularAntiAliasing: boolean;
  66265. /**
  66266. * Defines if the material uses energy conservation.
  66267. */
  66268. useEnergyConservation: boolean;
  66269. /**
  66270. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66271. * too much the area relying on ambient texture to define their ambient occlusion.
  66272. */
  66273. useRadianceOcclusion: boolean;
  66274. /**
  66275. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66276. * makes the reflect vector face the model (under horizon).
  66277. */
  66278. useHorizonOcclusion: boolean;
  66279. /**
  66280. * If set to true, no lighting calculations will be applied.
  66281. */
  66282. unlit: boolean;
  66283. /**
  66284. * Force normal to face away from face.
  66285. */
  66286. forceNormalForward: boolean;
  66287. /**
  66288. * Defines the material debug mode.
  66289. * It helps seeing only some components of the material while troubleshooting.
  66290. */
  66291. debugMode: number;
  66292. /**
  66293. * Specify from where on screen the debug mode should start.
  66294. * The value goes from -1 (full screen) to 1 (not visible)
  66295. * It helps with side by side comparison against the final render
  66296. * This defaults to 0
  66297. */
  66298. debugLimit: number;
  66299. /**
  66300. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66301. * You can use the factor to better multiply the final value.
  66302. */
  66303. debugFactor: number;
  66304. /**
  66305. * Initialize the block and prepare the context for build
  66306. * @param state defines the state that will be used for the build
  66307. */
  66308. initialize(state: NodeMaterialBuildState): void;
  66309. /**
  66310. * Gets the current class name
  66311. * @returns the class name
  66312. */
  66313. getClassName(): string;
  66314. /**
  66315. * Gets the world position input component
  66316. */
  66317. get worldPosition(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the world normal input component
  66320. */
  66321. get worldNormal(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the perturbed normal input component
  66324. */
  66325. get perturbedNormal(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the camera position input component
  66328. */
  66329. get cameraPosition(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the base color input component
  66332. */
  66333. get baseColor(): NodeMaterialConnectionPoint;
  66334. /**
  66335. * Gets the base texture input component
  66336. */
  66337. get baseTexture(): NodeMaterialConnectionPoint;
  66338. /**
  66339. * Gets the opacity texture input component
  66340. */
  66341. get opacityTexture(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the ambient color input component
  66344. */
  66345. get ambientColor(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the reflectivity object parameters
  66348. */
  66349. get reflectivity(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the ambient occlusion object parameters
  66352. */
  66353. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66354. /**
  66355. * Gets the reflection object parameters
  66356. */
  66357. get reflection(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the sheen object parameters
  66360. */
  66361. get sheen(): NodeMaterialConnectionPoint;
  66362. /**
  66363. * Gets the clear coat object parameters
  66364. */
  66365. get clearcoat(): NodeMaterialConnectionPoint;
  66366. /**
  66367. * Gets the sub surface object parameters
  66368. */
  66369. get subsurface(): NodeMaterialConnectionPoint;
  66370. /**
  66371. * Gets the anisotropy object parameters
  66372. */
  66373. get anisotropy(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the ambient output component
  66376. */
  66377. get ambient(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the diffuse output component
  66380. */
  66381. get diffuse(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the specular output component
  66384. */
  66385. get specular(): NodeMaterialConnectionPoint;
  66386. /**
  66387. * Gets the sheen output component
  66388. */
  66389. get sheenDir(): NodeMaterialConnectionPoint;
  66390. /**
  66391. * Gets the clear coat output component
  66392. */
  66393. get clearcoatDir(): NodeMaterialConnectionPoint;
  66394. /**
  66395. * Gets the indirect diffuse output component
  66396. */
  66397. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66398. /**
  66399. * Gets the indirect specular output component
  66400. */
  66401. get specularIndirect(): NodeMaterialConnectionPoint;
  66402. /**
  66403. * Gets the indirect sheen output component
  66404. */
  66405. get sheenIndirect(): NodeMaterialConnectionPoint;
  66406. /**
  66407. * Gets the indirect clear coat output component
  66408. */
  66409. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66410. /**
  66411. * Gets the refraction output component
  66412. */
  66413. get refraction(): NodeMaterialConnectionPoint;
  66414. /**
  66415. * Gets the global lighting output component
  66416. */
  66417. get lighting(): NodeMaterialConnectionPoint;
  66418. /**
  66419. * Gets the shadow output component
  66420. */
  66421. get shadow(): NodeMaterialConnectionPoint;
  66422. /**
  66423. * Gets the alpha output component
  66424. */
  66425. get alpha(): NodeMaterialConnectionPoint;
  66426. autoConfigure(material: NodeMaterial): void;
  66427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66428. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66430. private _injectVertexCode;
  66431. /**
  66432. * Gets the code corresponding to the albedo/opacity module
  66433. * @returns the shader code
  66434. */
  66435. getAlbedoOpacityCode(): string;
  66436. protected _buildBlock(state: NodeMaterialBuildState): this;
  66437. protected _dumpPropertiesCode(): string;
  66438. serialize(): any;
  66439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66440. }
  66441. }
  66442. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66443. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66444. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66445. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66446. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66447. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66448. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66449. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66450. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66451. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66452. }
  66453. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66454. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66455. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66456. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66457. }
  66458. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66462. /**
  66463. * Block used to compute value of one parameter modulo another
  66464. */
  66465. export class ModBlock extends NodeMaterialBlock {
  66466. /**
  66467. * Creates a new ModBlock
  66468. * @param name defines the block name
  66469. */
  66470. constructor(name: string);
  66471. /**
  66472. * Gets the current class name
  66473. * @returns the class name
  66474. */
  66475. getClassName(): string;
  66476. /**
  66477. * Gets the left operand input component
  66478. */
  66479. get left(): NodeMaterialConnectionPoint;
  66480. /**
  66481. * Gets the right operand input component
  66482. */
  66483. get right(): NodeMaterialConnectionPoint;
  66484. /**
  66485. * Gets the output component
  66486. */
  66487. get output(): NodeMaterialConnectionPoint;
  66488. protected _buildBlock(state: NodeMaterialBuildState): this;
  66489. }
  66490. }
  66491. declare module "babylonjs/Materials/Node/Blocks/index" {
  66492. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  66493. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  66494. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  66495. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  66496. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  66497. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  66498. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  66499. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  66500. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  66501. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  66502. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  66503. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  66504. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  66505. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  66506. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  66507. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  66508. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  66509. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  66510. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  66511. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  66512. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  66513. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  66514. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  66515. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  66516. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  66517. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  66518. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  66519. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  66520. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  66521. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  66522. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  66523. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  66524. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  66525. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  66526. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  66527. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  66528. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  66529. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  66530. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  66531. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  66532. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  66533. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  66534. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  66535. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  66536. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  66537. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  66538. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  66539. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  66540. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  66541. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  66542. }
  66543. declare module "babylonjs/Materials/Node/Optimizers/index" {
  66544. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  66545. }
  66546. declare module "babylonjs/Materials/Node/index" {
  66547. export * from "babylonjs/Materials/Node/Enums/index";
  66548. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66549. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  66550. export * from "babylonjs/Materials/Node/nodeMaterial";
  66551. export * from "babylonjs/Materials/Node/Blocks/index";
  66552. export * from "babylonjs/Materials/Node/Optimizers/index";
  66553. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  66554. }
  66555. declare module "babylonjs/Materials/index" {
  66556. export * from "babylonjs/Materials/Background/index";
  66557. export * from "babylonjs/Materials/colorCurves";
  66558. export * from "babylonjs/Materials/iEffectFallbacks";
  66559. export * from "babylonjs/Materials/effectFallbacks";
  66560. export * from "babylonjs/Materials/effect";
  66561. export * from "babylonjs/Materials/fresnelParameters";
  66562. export * from "babylonjs/Materials/imageProcessingConfiguration";
  66563. export * from "babylonjs/Materials/material";
  66564. export * from "babylonjs/Materials/materialDefines";
  66565. export * from "babylonjs/Materials/materialHelper";
  66566. export * from "babylonjs/Materials/multiMaterial";
  66567. export * from "babylonjs/Materials/PBR/index";
  66568. export * from "babylonjs/Materials/pushMaterial";
  66569. export * from "babylonjs/Materials/shaderMaterial";
  66570. export * from "babylonjs/Materials/standardMaterial";
  66571. export * from "babylonjs/Materials/Textures/index";
  66572. export * from "babylonjs/Materials/uniformBuffer";
  66573. export * from "babylonjs/Materials/materialFlags";
  66574. export * from "babylonjs/Materials/Node/index";
  66575. export * from "babylonjs/Materials/effectRenderer";
  66576. export * from "babylonjs/Materials/shadowDepthWrapper";
  66577. }
  66578. declare module "babylonjs/Maths/index" {
  66579. export * from "babylonjs/Maths/math.scalar";
  66580. export * from "babylonjs/Maths/math";
  66581. export * from "babylonjs/Maths/sphericalPolynomial";
  66582. }
  66583. declare module "babylonjs/Misc/workerPool" {
  66584. import { IDisposable } from "babylonjs/scene";
  66585. /**
  66586. * Helper class to push actions to a pool of workers.
  66587. */
  66588. export class WorkerPool implements IDisposable {
  66589. private _workerInfos;
  66590. private _pendingActions;
  66591. /**
  66592. * Constructor
  66593. * @param workers Array of workers to use for actions
  66594. */
  66595. constructor(workers: Array<Worker>);
  66596. /**
  66597. * Terminates all workers and clears any pending actions.
  66598. */
  66599. dispose(): void;
  66600. /**
  66601. * Pushes an action to the worker pool. If all the workers are active, the action will be
  66602. * pended until a worker has completed its action.
  66603. * @param action The action to perform. Call onComplete when the action is complete.
  66604. */
  66605. push(action: (worker: Worker, onComplete: () => void) => void): void;
  66606. private _execute;
  66607. }
  66608. }
  66609. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  66610. import { IDisposable } from "babylonjs/scene";
  66611. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66612. /**
  66613. * Configuration for Draco compression
  66614. */
  66615. export interface IDracoCompressionConfiguration {
  66616. /**
  66617. * Configuration for the decoder.
  66618. */
  66619. decoder: {
  66620. /**
  66621. * The url to the WebAssembly module.
  66622. */
  66623. wasmUrl?: string;
  66624. /**
  66625. * The url to the WebAssembly binary.
  66626. */
  66627. wasmBinaryUrl?: string;
  66628. /**
  66629. * The url to the fallback JavaScript module.
  66630. */
  66631. fallbackUrl?: string;
  66632. };
  66633. }
  66634. /**
  66635. * Draco compression (https://google.github.io/draco/)
  66636. *
  66637. * This class wraps the Draco module.
  66638. *
  66639. * **Encoder**
  66640. *
  66641. * The encoder is not currently implemented.
  66642. *
  66643. * **Decoder**
  66644. *
  66645. * 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.
  66646. *
  66647. * To update the configuration, use the following code:
  66648. * ```javascript
  66649. * DracoCompression.Configuration = {
  66650. * decoder: {
  66651. * wasmUrl: "<url to the WebAssembly library>",
  66652. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66653. * fallbackUrl: "<url to the fallback JavaScript library>",
  66654. * }
  66655. * };
  66656. * ```
  66657. *
  66658. * 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.
  66659. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66660. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66661. *
  66662. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66663. * ```javascript
  66664. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66665. * ```
  66666. *
  66667. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66668. */
  66669. export class DracoCompression implements IDisposable {
  66670. private _workerPoolPromise?;
  66671. private _decoderModulePromise?;
  66672. /**
  66673. * The configuration. Defaults to the following urls:
  66674. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66675. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66676. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66677. */
  66678. static Configuration: IDracoCompressionConfiguration;
  66679. /**
  66680. * Returns true if the decoder configuration is available.
  66681. */
  66682. static get DecoderAvailable(): boolean;
  66683. /**
  66684. * Default number of workers to create when creating the draco compression object.
  66685. */
  66686. static DefaultNumWorkers: number;
  66687. private static GetDefaultNumWorkers;
  66688. private static _Default;
  66689. /**
  66690. * Default instance for the draco compression object.
  66691. */
  66692. static get Default(): DracoCompression;
  66693. /**
  66694. * Constructor
  66695. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66696. */
  66697. constructor(numWorkers?: number);
  66698. /**
  66699. * Stop all async operations and release resources.
  66700. */
  66701. dispose(): void;
  66702. /**
  66703. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66704. * @returns a promise that resolves when ready
  66705. */
  66706. whenReadyAsync(): Promise<void>;
  66707. /**
  66708. * Decode Draco compressed mesh data to vertex data.
  66709. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66710. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66711. * @returns A promise that resolves with the decoded vertex data
  66712. */
  66713. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66714. [kind: string]: number;
  66715. }): Promise<VertexData>;
  66716. }
  66717. }
  66718. declare module "babylonjs/Meshes/Compression/index" {
  66719. export * from "babylonjs/Meshes/Compression/dracoCompression";
  66720. }
  66721. declare module "babylonjs/Meshes/csg" {
  66722. import { Nullable } from "babylonjs/types";
  66723. import { Scene } from "babylonjs/scene";
  66724. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66725. import { Mesh } from "babylonjs/Meshes/mesh";
  66726. import { Material } from "babylonjs/Materials/material";
  66727. /**
  66728. * Class for building Constructive Solid Geometry
  66729. */
  66730. export class CSG {
  66731. private polygons;
  66732. /**
  66733. * The world matrix
  66734. */
  66735. matrix: Matrix;
  66736. /**
  66737. * Stores the position
  66738. */
  66739. position: Vector3;
  66740. /**
  66741. * Stores the rotation
  66742. */
  66743. rotation: Vector3;
  66744. /**
  66745. * Stores the rotation quaternion
  66746. */
  66747. rotationQuaternion: Nullable<Quaternion>;
  66748. /**
  66749. * Stores the scaling vector
  66750. */
  66751. scaling: Vector3;
  66752. /**
  66753. * Convert the Mesh to CSG
  66754. * @param mesh The Mesh to convert to CSG
  66755. * @returns A new CSG from the Mesh
  66756. */
  66757. static FromMesh(mesh: Mesh): CSG;
  66758. /**
  66759. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66760. * @param polygons Polygons used to construct a CSG solid
  66761. */
  66762. private static FromPolygons;
  66763. /**
  66764. * Clones, or makes a deep copy, of the CSG
  66765. * @returns A new CSG
  66766. */
  66767. clone(): CSG;
  66768. /**
  66769. * Unions this CSG with another CSG
  66770. * @param csg The CSG to union against this CSG
  66771. * @returns The unioned CSG
  66772. */
  66773. union(csg: CSG): CSG;
  66774. /**
  66775. * Unions this CSG with another CSG in place
  66776. * @param csg The CSG to union against this CSG
  66777. */
  66778. unionInPlace(csg: CSG): void;
  66779. /**
  66780. * Subtracts this CSG with another CSG
  66781. * @param csg The CSG to subtract against this CSG
  66782. * @returns A new CSG
  66783. */
  66784. subtract(csg: CSG): CSG;
  66785. /**
  66786. * Subtracts this CSG with another CSG in place
  66787. * @param csg The CSG to subtact against this CSG
  66788. */
  66789. subtractInPlace(csg: CSG): void;
  66790. /**
  66791. * Intersect this CSG with another CSG
  66792. * @param csg The CSG to intersect against this CSG
  66793. * @returns A new CSG
  66794. */
  66795. intersect(csg: CSG): CSG;
  66796. /**
  66797. * Intersects this CSG with another CSG in place
  66798. * @param csg The CSG to intersect against this CSG
  66799. */
  66800. intersectInPlace(csg: CSG): void;
  66801. /**
  66802. * Return a new CSG solid with solid and empty space switched. This solid is
  66803. * not modified.
  66804. * @returns A new CSG solid with solid and empty space switched
  66805. */
  66806. inverse(): CSG;
  66807. /**
  66808. * Inverses the CSG in place
  66809. */
  66810. inverseInPlace(): void;
  66811. /**
  66812. * This is used to keep meshes transformations so they can be restored
  66813. * when we build back a Babylon Mesh
  66814. * NB : All CSG operations are performed in world coordinates
  66815. * @param csg The CSG to copy the transform attributes from
  66816. * @returns This CSG
  66817. */
  66818. copyTransformAttributes(csg: CSG): CSG;
  66819. /**
  66820. * Build Raw mesh from CSG
  66821. * Coordinates here are in world space
  66822. * @param name The name of the mesh geometry
  66823. * @param scene The Scene
  66824. * @param keepSubMeshes Specifies if the submeshes should be kept
  66825. * @returns A new Mesh
  66826. */
  66827. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66828. /**
  66829. * Build Mesh from CSG taking material and transforms into account
  66830. * @param name The name of the Mesh
  66831. * @param material The material of the Mesh
  66832. * @param scene The Scene
  66833. * @param keepSubMeshes Specifies if submeshes should be kept
  66834. * @returns The new Mesh
  66835. */
  66836. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66837. }
  66838. }
  66839. declare module "babylonjs/Meshes/trailMesh" {
  66840. import { Mesh } from "babylonjs/Meshes/mesh";
  66841. import { Scene } from "babylonjs/scene";
  66842. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66843. /**
  66844. * Class used to create a trail following a mesh
  66845. */
  66846. export class TrailMesh extends Mesh {
  66847. private _generator;
  66848. private _autoStart;
  66849. private _running;
  66850. private _diameter;
  66851. private _length;
  66852. private _sectionPolygonPointsCount;
  66853. private _sectionVectors;
  66854. private _sectionNormalVectors;
  66855. private _beforeRenderObserver;
  66856. /**
  66857. * @constructor
  66858. * @param name The value used by scene.getMeshByName() to do a lookup.
  66859. * @param generator The mesh or transform node to generate a trail.
  66860. * @param scene The scene to add this mesh to.
  66861. * @param diameter Diameter of trailing mesh. Default is 1.
  66862. * @param length Length of trailing mesh. Default is 60.
  66863. * @param autoStart Automatically start trailing mesh. Default true.
  66864. */
  66865. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66866. /**
  66867. * "TrailMesh"
  66868. * @returns "TrailMesh"
  66869. */
  66870. getClassName(): string;
  66871. private _createMesh;
  66872. /**
  66873. * Start trailing mesh.
  66874. */
  66875. start(): void;
  66876. /**
  66877. * Stop trailing mesh.
  66878. */
  66879. stop(): void;
  66880. /**
  66881. * Update trailing mesh geometry.
  66882. */
  66883. update(): void;
  66884. /**
  66885. * Returns a new TrailMesh object.
  66886. * @param name is a string, the name given to the new mesh
  66887. * @param newGenerator use new generator object for cloned trail mesh
  66888. * @returns a new mesh
  66889. */
  66890. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66891. /**
  66892. * Serializes this trail mesh
  66893. * @param serializationObject object to write serialization to
  66894. */
  66895. serialize(serializationObject: any): void;
  66896. /**
  66897. * Parses a serialized trail mesh
  66898. * @param parsedMesh the serialized mesh
  66899. * @param scene the scene to create the trail mesh in
  66900. * @returns the created trail mesh
  66901. */
  66902. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66903. }
  66904. }
  66905. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  66906. import { Nullable } from "babylonjs/types";
  66907. import { Scene } from "babylonjs/scene";
  66908. import { Vector4 } from "babylonjs/Maths/math.vector";
  66909. import { Color4 } from "babylonjs/Maths/math.color";
  66910. import { Mesh } from "babylonjs/Meshes/mesh";
  66911. /**
  66912. * Class containing static functions to help procedurally build meshes
  66913. */
  66914. export class TiledBoxBuilder {
  66915. /**
  66916. * Creates a box mesh
  66917. * 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)
  66918. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66922. * @param name defines the name of the mesh
  66923. * @param options defines the options used to create the mesh
  66924. * @param scene defines the hosting scene
  66925. * @returns the box mesh
  66926. */
  66927. static CreateTiledBox(name: string, options: {
  66928. pattern?: number;
  66929. width?: number;
  66930. height?: number;
  66931. depth?: number;
  66932. tileSize?: number;
  66933. tileWidth?: number;
  66934. tileHeight?: number;
  66935. alignHorizontal?: number;
  66936. alignVertical?: number;
  66937. faceUV?: Vector4[];
  66938. faceColors?: Color4[];
  66939. sideOrientation?: number;
  66940. updatable?: boolean;
  66941. }, scene?: Nullable<Scene>): Mesh;
  66942. }
  66943. }
  66944. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  66945. import { Vector4 } from "babylonjs/Maths/math.vector";
  66946. import { Mesh } from "babylonjs/Meshes/mesh";
  66947. /**
  66948. * Class containing static functions to help procedurally build meshes
  66949. */
  66950. export class TorusKnotBuilder {
  66951. /**
  66952. * Creates a torus knot mesh
  66953. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66954. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66955. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66956. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66960. * @param name defines the name of the mesh
  66961. * @param options defines the options used to create the mesh
  66962. * @param scene defines the hosting scene
  66963. * @returns the torus knot mesh
  66964. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66965. */
  66966. static CreateTorusKnot(name: string, options: {
  66967. radius?: number;
  66968. tube?: number;
  66969. radialSegments?: number;
  66970. tubularSegments?: number;
  66971. p?: number;
  66972. q?: number;
  66973. updatable?: boolean;
  66974. sideOrientation?: number;
  66975. frontUVs?: Vector4;
  66976. backUVs?: Vector4;
  66977. }, scene: any): Mesh;
  66978. }
  66979. }
  66980. declare module "babylonjs/Meshes/polygonMesh" {
  66981. import { Scene } from "babylonjs/scene";
  66982. import { Vector2 } from "babylonjs/Maths/math.vector";
  66983. import { Mesh } from "babylonjs/Meshes/mesh";
  66984. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66985. import { Path2 } from "babylonjs/Maths/math.path";
  66986. /**
  66987. * Polygon
  66988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66989. */
  66990. export class Polygon {
  66991. /**
  66992. * Creates a rectangle
  66993. * @param xmin bottom X coord
  66994. * @param ymin bottom Y coord
  66995. * @param xmax top X coord
  66996. * @param ymax top Y coord
  66997. * @returns points that make the resulting rectation
  66998. */
  66999. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67000. /**
  67001. * Creates a circle
  67002. * @param radius radius of circle
  67003. * @param cx scale in x
  67004. * @param cy scale in y
  67005. * @param numberOfSides number of sides that make up the circle
  67006. * @returns points that make the resulting circle
  67007. */
  67008. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67009. /**
  67010. * Creates a polygon from input string
  67011. * @param input Input polygon data
  67012. * @returns the parsed points
  67013. */
  67014. static Parse(input: string): Vector2[];
  67015. /**
  67016. * Starts building a polygon from x and y coordinates
  67017. * @param x x coordinate
  67018. * @param y y coordinate
  67019. * @returns the started path2
  67020. */
  67021. static StartingAt(x: number, y: number): Path2;
  67022. }
  67023. /**
  67024. * Builds a polygon
  67025. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67026. */
  67027. export class PolygonMeshBuilder {
  67028. private _points;
  67029. private _outlinepoints;
  67030. private _holes;
  67031. private _name;
  67032. private _scene;
  67033. private _epoints;
  67034. private _eholes;
  67035. private _addToepoint;
  67036. /**
  67037. * Babylon reference to the earcut plugin.
  67038. */
  67039. bjsEarcut: any;
  67040. /**
  67041. * Creates a PolygonMeshBuilder
  67042. * @param name name of the builder
  67043. * @param contours Path of the polygon
  67044. * @param scene scene to add to when creating the mesh
  67045. * @param earcutInjection can be used to inject your own earcut reference
  67046. */
  67047. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67048. /**
  67049. * Adds a whole within the polygon
  67050. * @param hole Array of points defining the hole
  67051. * @returns this
  67052. */
  67053. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67054. /**
  67055. * Creates the polygon
  67056. * @param updatable If the mesh should be updatable
  67057. * @param depth The depth of the mesh created
  67058. * @returns the created mesh
  67059. */
  67060. build(updatable?: boolean, depth?: number): Mesh;
  67061. /**
  67062. * Creates the polygon
  67063. * @param depth The depth of the mesh created
  67064. * @returns the created VertexData
  67065. */
  67066. buildVertexData(depth?: number): VertexData;
  67067. /**
  67068. * Adds a side to the polygon
  67069. * @param positions points that make the polygon
  67070. * @param normals normals of the polygon
  67071. * @param uvs uvs of the polygon
  67072. * @param indices indices of the polygon
  67073. * @param bounds bounds of the polygon
  67074. * @param points points of the polygon
  67075. * @param depth depth of the polygon
  67076. * @param flip flip of the polygon
  67077. */
  67078. private addSide;
  67079. }
  67080. }
  67081. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67082. import { Scene } from "babylonjs/scene";
  67083. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67084. import { Color4 } from "babylonjs/Maths/math.color";
  67085. import { Mesh } from "babylonjs/Meshes/mesh";
  67086. import { Nullable } from "babylonjs/types";
  67087. /**
  67088. * Class containing static functions to help procedurally build meshes
  67089. */
  67090. export class PolygonBuilder {
  67091. /**
  67092. * Creates a polygon mesh
  67093. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67094. * * 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
  67095. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67098. * * Remember you can only change the shape positions, not their number when updating a polygon
  67099. * @param name defines the name of the mesh
  67100. * @param options defines the options used to create the mesh
  67101. * @param scene defines the hosting scene
  67102. * @param earcutInjection can be used to inject your own earcut reference
  67103. * @returns the polygon mesh
  67104. */
  67105. static CreatePolygon(name: string, options: {
  67106. shape: Vector3[];
  67107. holes?: Vector3[][];
  67108. depth?: number;
  67109. faceUV?: Vector4[];
  67110. faceColors?: Color4[];
  67111. updatable?: boolean;
  67112. sideOrientation?: number;
  67113. frontUVs?: Vector4;
  67114. backUVs?: Vector4;
  67115. wrap?: boolean;
  67116. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67117. /**
  67118. * Creates an extruded polygon mesh, with depth in the Y direction.
  67119. * * 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)
  67120. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67121. * @param name defines the name of the mesh
  67122. * @param options defines the options used to create the mesh
  67123. * @param scene defines the hosting scene
  67124. * @param earcutInjection can be used to inject your own earcut reference
  67125. * @returns the polygon mesh
  67126. */
  67127. static ExtrudePolygon(name: string, options: {
  67128. shape: Vector3[];
  67129. holes?: Vector3[][];
  67130. depth?: number;
  67131. faceUV?: Vector4[];
  67132. faceColors?: Color4[];
  67133. updatable?: boolean;
  67134. sideOrientation?: number;
  67135. frontUVs?: Vector4;
  67136. backUVs?: Vector4;
  67137. wrap?: boolean;
  67138. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67139. }
  67140. }
  67141. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67142. import { Scene } from "babylonjs/scene";
  67143. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67144. import { Mesh } from "babylonjs/Meshes/mesh";
  67145. import { Nullable } from "babylonjs/types";
  67146. /**
  67147. * Class containing static functions to help procedurally build meshes
  67148. */
  67149. export class LatheBuilder {
  67150. /**
  67151. * Creates lathe mesh.
  67152. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67153. * * 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
  67154. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67155. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67156. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67157. * * 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
  67158. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67159. * * 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
  67160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67164. * @param name defines the name of the mesh
  67165. * @param options defines the options used to create the mesh
  67166. * @param scene defines the hosting scene
  67167. * @returns the lathe mesh
  67168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67169. */
  67170. static CreateLathe(name: string, options: {
  67171. shape: Vector3[];
  67172. radius?: number;
  67173. tessellation?: number;
  67174. clip?: number;
  67175. arc?: number;
  67176. closed?: boolean;
  67177. updatable?: boolean;
  67178. sideOrientation?: number;
  67179. frontUVs?: Vector4;
  67180. backUVs?: Vector4;
  67181. cap?: number;
  67182. invertUV?: boolean;
  67183. }, scene?: Nullable<Scene>): Mesh;
  67184. }
  67185. }
  67186. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67187. import { Nullable } from "babylonjs/types";
  67188. import { Scene } from "babylonjs/scene";
  67189. import { Vector4 } from "babylonjs/Maths/math.vector";
  67190. import { Mesh } from "babylonjs/Meshes/mesh";
  67191. /**
  67192. * Class containing static functions to help procedurally build meshes
  67193. */
  67194. export class TiledPlaneBuilder {
  67195. /**
  67196. * Creates a tiled plane mesh
  67197. * * The parameter `pattern` will, depending on value, do nothing or
  67198. * * * flip (reflect about central vertical) alternate tiles across and up
  67199. * * * flip every tile on alternate rows
  67200. * * * rotate (180 degs) alternate tiles across and up
  67201. * * * rotate every tile on alternate rows
  67202. * * * flip and rotate alternate tiles across and up
  67203. * * * flip and rotate every tile on alternate rows
  67204. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67205. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67208. * * 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)
  67209. * * 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)
  67210. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67211. * @param name defines the name of the mesh
  67212. * @param options defines the options used to create the mesh
  67213. * @param scene defines the hosting scene
  67214. * @returns the box mesh
  67215. */
  67216. static CreateTiledPlane(name: string, options: {
  67217. pattern?: number;
  67218. tileSize?: number;
  67219. tileWidth?: number;
  67220. tileHeight?: number;
  67221. size?: number;
  67222. width?: number;
  67223. height?: number;
  67224. alignHorizontal?: number;
  67225. alignVertical?: number;
  67226. sideOrientation?: number;
  67227. frontUVs?: Vector4;
  67228. backUVs?: Vector4;
  67229. updatable?: boolean;
  67230. }, scene?: Nullable<Scene>): Mesh;
  67231. }
  67232. }
  67233. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67234. import { Nullable } from "babylonjs/types";
  67235. import { Scene } from "babylonjs/scene";
  67236. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67237. import { Mesh } from "babylonjs/Meshes/mesh";
  67238. /**
  67239. * Class containing static functions to help procedurally build meshes
  67240. */
  67241. export class TubeBuilder {
  67242. /**
  67243. * Creates a tube mesh.
  67244. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67245. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67246. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67247. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67248. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67249. * * 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)
  67250. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67251. * * 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
  67252. * * 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
  67253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67257. * @param name defines the name of the mesh
  67258. * @param options defines the options used to create the mesh
  67259. * @param scene defines the hosting scene
  67260. * @returns the tube mesh
  67261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67262. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67263. */
  67264. static CreateTube(name: string, options: {
  67265. path: Vector3[];
  67266. radius?: number;
  67267. tessellation?: number;
  67268. radiusFunction?: {
  67269. (i: number, distance: number): number;
  67270. };
  67271. cap?: number;
  67272. arc?: number;
  67273. updatable?: boolean;
  67274. sideOrientation?: number;
  67275. frontUVs?: Vector4;
  67276. backUVs?: Vector4;
  67277. instance?: Mesh;
  67278. invertUV?: boolean;
  67279. }, scene?: Nullable<Scene>): Mesh;
  67280. }
  67281. }
  67282. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67283. import { Scene } from "babylonjs/scene";
  67284. import { Vector4 } from "babylonjs/Maths/math.vector";
  67285. import { Mesh } from "babylonjs/Meshes/mesh";
  67286. import { Nullable } from "babylonjs/types";
  67287. /**
  67288. * Class containing static functions to help procedurally build meshes
  67289. */
  67290. export class IcoSphereBuilder {
  67291. /**
  67292. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67293. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67294. * * 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`)
  67295. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67296. * * 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
  67297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67300. * @param name defines the name of the mesh
  67301. * @param options defines the options used to create the mesh
  67302. * @param scene defines the hosting scene
  67303. * @returns the icosahedron mesh
  67304. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67305. */
  67306. static CreateIcoSphere(name: string, options: {
  67307. radius?: number;
  67308. radiusX?: number;
  67309. radiusY?: number;
  67310. radiusZ?: number;
  67311. flat?: boolean;
  67312. subdivisions?: number;
  67313. sideOrientation?: number;
  67314. frontUVs?: Vector4;
  67315. backUVs?: Vector4;
  67316. updatable?: boolean;
  67317. }, scene?: Nullable<Scene>): Mesh;
  67318. }
  67319. }
  67320. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67321. import { Vector3 } from "babylonjs/Maths/math.vector";
  67322. import { Mesh } from "babylonjs/Meshes/mesh";
  67323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67324. /**
  67325. * Class containing static functions to help procedurally build meshes
  67326. */
  67327. export class DecalBuilder {
  67328. /**
  67329. * Creates a decal mesh.
  67330. * 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
  67331. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67332. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67333. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67334. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67335. * @param name defines the name of the mesh
  67336. * @param sourceMesh defines the mesh where the decal must be applied
  67337. * @param options defines the options used to create the mesh
  67338. * @param scene defines the hosting scene
  67339. * @returns the decal mesh
  67340. * @see https://doc.babylonjs.com/how_to/decals
  67341. */
  67342. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67343. position?: Vector3;
  67344. normal?: Vector3;
  67345. size?: Vector3;
  67346. angle?: number;
  67347. }): Mesh;
  67348. }
  67349. }
  67350. declare module "babylonjs/Meshes/meshBuilder" {
  67351. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67352. import { Nullable } from "babylonjs/types";
  67353. import { Scene } from "babylonjs/scene";
  67354. import { Mesh } from "babylonjs/Meshes/mesh";
  67355. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67356. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67358. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67359. import { Plane } from "babylonjs/Maths/math.plane";
  67360. /**
  67361. * Class containing static functions to help procedurally build meshes
  67362. */
  67363. export class MeshBuilder {
  67364. /**
  67365. * Creates a box mesh
  67366. * * The parameter `size` sets the size (float) of each box side (default 1)
  67367. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67368. * * 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)
  67369. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67373. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67374. * @param name defines the name of the mesh
  67375. * @param options defines the options used to create the mesh
  67376. * @param scene defines the hosting scene
  67377. * @returns the box mesh
  67378. */
  67379. static CreateBox(name: string, options: {
  67380. size?: number;
  67381. width?: number;
  67382. height?: number;
  67383. depth?: number;
  67384. faceUV?: Vector4[];
  67385. faceColors?: Color4[];
  67386. sideOrientation?: number;
  67387. frontUVs?: Vector4;
  67388. backUVs?: Vector4;
  67389. wrap?: boolean;
  67390. topBaseAt?: number;
  67391. bottomBaseAt?: number;
  67392. updatable?: boolean;
  67393. }, scene?: Nullable<Scene>): Mesh;
  67394. /**
  67395. * Creates a tiled box mesh
  67396. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67398. * @param name defines the name of the mesh
  67399. * @param options defines the options used to create the mesh
  67400. * @param scene defines the hosting scene
  67401. * @returns the tiled box mesh
  67402. */
  67403. static CreateTiledBox(name: string, options: {
  67404. pattern?: number;
  67405. size?: number;
  67406. width?: number;
  67407. height?: number;
  67408. depth: number;
  67409. tileSize?: number;
  67410. tileWidth?: number;
  67411. tileHeight?: number;
  67412. faceUV?: Vector4[];
  67413. faceColors?: Color4[];
  67414. alignHorizontal?: number;
  67415. alignVertical?: number;
  67416. sideOrientation?: number;
  67417. updatable?: boolean;
  67418. }, scene?: Nullable<Scene>): Mesh;
  67419. /**
  67420. * Creates a sphere mesh
  67421. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67422. * * 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`)
  67423. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67424. * * 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
  67425. * * 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)
  67426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67429. * @param name defines the name of the mesh
  67430. * @param options defines the options used to create the mesh
  67431. * @param scene defines the hosting scene
  67432. * @returns the sphere mesh
  67433. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67434. */
  67435. static CreateSphere(name: string, options: {
  67436. segments?: number;
  67437. diameter?: number;
  67438. diameterX?: number;
  67439. diameterY?: number;
  67440. diameterZ?: number;
  67441. arc?: number;
  67442. slice?: number;
  67443. sideOrientation?: number;
  67444. frontUVs?: Vector4;
  67445. backUVs?: Vector4;
  67446. updatable?: boolean;
  67447. }, scene?: Nullable<Scene>): Mesh;
  67448. /**
  67449. * Creates a plane polygonal mesh. By default, this is a disc
  67450. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67451. * * 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
  67452. * * 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
  67453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67456. * @param name defines the name of the mesh
  67457. * @param options defines the options used to create the mesh
  67458. * @param scene defines the hosting scene
  67459. * @returns the plane polygonal mesh
  67460. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67461. */
  67462. static CreateDisc(name: string, options: {
  67463. radius?: number;
  67464. tessellation?: number;
  67465. arc?: number;
  67466. updatable?: boolean;
  67467. sideOrientation?: number;
  67468. frontUVs?: Vector4;
  67469. backUVs?: Vector4;
  67470. }, scene?: Nullable<Scene>): Mesh;
  67471. /**
  67472. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67473. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67474. * * 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`)
  67475. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67476. * * 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
  67477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67480. * @param name defines the name of the mesh
  67481. * @param options defines the options used to create the mesh
  67482. * @param scene defines the hosting scene
  67483. * @returns the icosahedron mesh
  67484. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67485. */
  67486. static CreateIcoSphere(name: string, options: {
  67487. radius?: number;
  67488. radiusX?: number;
  67489. radiusY?: number;
  67490. radiusZ?: number;
  67491. flat?: boolean;
  67492. subdivisions?: number;
  67493. sideOrientation?: number;
  67494. frontUVs?: Vector4;
  67495. backUVs?: Vector4;
  67496. updatable?: boolean;
  67497. }, scene?: Nullable<Scene>): Mesh;
  67498. /**
  67499. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67500. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67501. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67502. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67503. * * 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
  67504. * * 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
  67505. * * 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
  67506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67509. * * 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
  67510. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67511. * * 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
  67512. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67514. * @param name defines the name of the mesh
  67515. * @param options defines the options used to create the mesh
  67516. * @param scene defines the hosting scene
  67517. * @returns the ribbon mesh
  67518. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67520. */
  67521. static CreateRibbon(name: string, options: {
  67522. pathArray: Vector3[][];
  67523. closeArray?: boolean;
  67524. closePath?: boolean;
  67525. offset?: number;
  67526. updatable?: boolean;
  67527. sideOrientation?: number;
  67528. frontUVs?: Vector4;
  67529. backUVs?: Vector4;
  67530. instance?: Mesh;
  67531. invertUV?: boolean;
  67532. uvs?: Vector2[];
  67533. colors?: Color4[];
  67534. }, scene?: Nullable<Scene>): Mesh;
  67535. /**
  67536. * Creates a cylinder or a cone mesh
  67537. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67538. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67539. * * 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.
  67540. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67541. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67542. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67543. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67544. * * 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).
  67545. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67546. * * 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).
  67547. * * 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
  67548. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67549. * * 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
  67550. * * 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.
  67551. * * If `enclose` is false, a ring surface is one element.
  67552. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67553. * * 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
  67554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67557. * @param name defines the name of the mesh
  67558. * @param options defines the options used to create the mesh
  67559. * @param scene defines the hosting scene
  67560. * @returns the cylinder mesh
  67561. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67562. */
  67563. static CreateCylinder(name: string, options: {
  67564. height?: number;
  67565. diameterTop?: number;
  67566. diameterBottom?: number;
  67567. diameter?: number;
  67568. tessellation?: number;
  67569. subdivisions?: number;
  67570. arc?: number;
  67571. faceColors?: Color4[];
  67572. faceUV?: Vector4[];
  67573. updatable?: boolean;
  67574. hasRings?: boolean;
  67575. enclose?: boolean;
  67576. cap?: number;
  67577. sideOrientation?: number;
  67578. frontUVs?: Vector4;
  67579. backUVs?: Vector4;
  67580. }, scene?: Nullable<Scene>): Mesh;
  67581. /**
  67582. * Creates a torus mesh
  67583. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67584. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67585. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67589. * @param name defines the name of the mesh
  67590. * @param options defines the options used to create the mesh
  67591. * @param scene defines the hosting scene
  67592. * @returns the torus mesh
  67593. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67594. */
  67595. static CreateTorus(name: string, options: {
  67596. diameter?: number;
  67597. thickness?: number;
  67598. tessellation?: number;
  67599. updatable?: boolean;
  67600. sideOrientation?: number;
  67601. frontUVs?: Vector4;
  67602. backUVs?: Vector4;
  67603. }, scene?: Nullable<Scene>): Mesh;
  67604. /**
  67605. * Creates a torus knot mesh
  67606. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67607. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67608. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67609. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67613. * @param name defines the name of the mesh
  67614. * @param options defines the options used to create the mesh
  67615. * @param scene defines the hosting scene
  67616. * @returns the torus knot mesh
  67617. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67618. */
  67619. static CreateTorusKnot(name: string, options: {
  67620. radius?: number;
  67621. tube?: number;
  67622. radialSegments?: number;
  67623. tubularSegments?: number;
  67624. p?: number;
  67625. q?: number;
  67626. updatable?: boolean;
  67627. sideOrientation?: number;
  67628. frontUVs?: Vector4;
  67629. backUVs?: Vector4;
  67630. }, scene?: Nullable<Scene>): Mesh;
  67631. /**
  67632. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67633. * * 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
  67634. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67635. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67636. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67637. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67638. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67639. * * 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
  67640. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67643. * @param name defines the name of the new line system
  67644. * @param options defines the options used to create the line system
  67645. * @param scene defines the hosting scene
  67646. * @returns a new line system mesh
  67647. */
  67648. static CreateLineSystem(name: string, options: {
  67649. lines: Vector3[][];
  67650. updatable?: boolean;
  67651. instance?: Nullable<LinesMesh>;
  67652. colors?: Nullable<Color4[][]>;
  67653. useVertexAlpha?: boolean;
  67654. }, scene: Nullable<Scene>): LinesMesh;
  67655. /**
  67656. * Creates a line mesh
  67657. * 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
  67658. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67659. * * The parameter `points` is an array successive Vector3
  67660. * * 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
  67661. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67662. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67663. * * When updating an instance, remember that only point positions can change, not the number of points
  67664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67666. * @param name defines the name of the new line system
  67667. * @param options defines the options used to create the line system
  67668. * @param scene defines the hosting scene
  67669. * @returns a new line mesh
  67670. */
  67671. static CreateLines(name: string, options: {
  67672. points: Vector3[];
  67673. updatable?: boolean;
  67674. instance?: Nullable<LinesMesh>;
  67675. colors?: Color4[];
  67676. useVertexAlpha?: boolean;
  67677. }, scene?: Nullable<Scene>): LinesMesh;
  67678. /**
  67679. * Creates a dashed line mesh
  67680. * * 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
  67681. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67682. * * The parameter `points` is an array successive Vector3
  67683. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67684. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67685. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67686. * * 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
  67687. * * When updating an instance, remember that only point positions can change, not the number of points
  67688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67689. * @param name defines the name of the mesh
  67690. * @param options defines the options used to create the mesh
  67691. * @param scene defines the hosting scene
  67692. * @returns the dashed line mesh
  67693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67694. */
  67695. static CreateDashedLines(name: string, options: {
  67696. points: Vector3[];
  67697. dashSize?: number;
  67698. gapSize?: number;
  67699. dashNb?: number;
  67700. updatable?: boolean;
  67701. instance?: LinesMesh;
  67702. }, scene?: Nullable<Scene>): LinesMesh;
  67703. /**
  67704. * 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.
  67705. * * 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.
  67706. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67707. * * 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.
  67708. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67709. * * 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
  67710. * * 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
  67711. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67716. * @param name defines the name of the mesh
  67717. * @param options defines the options used to create the mesh
  67718. * @param scene defines the hosting scene
  67719. * @returns the extruded shape mesh
  67720. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67722. */
  67723. static ExtrudeShape(name: string, options: {
  67724. shape: Vector3[];
  67725. path: Vector3[];
  67726. scale?: number;
  67727. rotation?: number;
  67728. cap?: number;
  67729. updatable?: boolean;
  67730. sideOrientation?: number;
  67731. frontUVs?: Vector4;
  67732. backUVs?: Vector4;
  67733. instance?: Mesh;
  67734. invertUV?: boolean;
  67735. }, scene?: Nullable<Scene>): Mesh;
  67736. /**
  67737. * Creates an custom extruded shape mesh.
  67738. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67739. * * 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.
  67740. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67741. * * 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
  67742. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67743. * * 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
  67744. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67745. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67746. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67747. * * 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
  67748. * * 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
  67749. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67754. * @param name defines the name of the mesh
  67755. * @param options defines the options used to create the mesh
  67756. * @param scene defines the hosting scene
  67757. * @returns the custom extruded shape mesh
  67758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67761. */
  67762. static ExtrudeShapeCustom(name: string, options: {
  67763. shape: Vector3[];
  67764. path: Vector3[];
  67765. scaleFunction?: any;
  67766. rotationFunction?: any;
  67767. ribbonCloseArray?: boolean;
  67768. ribbonClosePath?: boolean;
  67769. cap?: number;
  67770. updatable?: boolean;
  67771. sideOrientation?: number;
  67772. frontUVs?: Vector4;
  67773. backUVs?: Vector4;
  67774. instance?: Mesh;
  67775. invertUV?: boolean;
  67776. }, scene?: Nullable<Scene>): Mesh;
  67777. /**
  67778. * Creates lathe mesh.
  67779. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67780. * * 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
  67781. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67782. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67783. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67784. * * 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
  67785. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67786. * * 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
  67787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67789. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67791. * @param name defines the name of the mesh
  67792. * @param options defines the options used to create the mesh
  67793. * @param scene defines the hosting scene
  67794. * @returns the lathe mesh
  67795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67796. */
  67797. static CreateLathe(name: string, options: {
  67798. shape: Vector3[];
  67799. radius?: number;
  67800. tessellation?: number;
  67801. clip?: number;
  67802. arc?: number;
  67803. closed?: boolean;
  67804. updatable?: boolean;
  67805. sideOrientation?: number;
  67806. frontUVs?: Vector4;
  67807. backUVs?: Vector4;
  67808. cap?: number;
  67809. invertUV?: boolean;
  67810. }, scene?: Nullable<Scene>): Mesh;
  67811. /**
  67812. * Creates a tiled plane mesh
  67813. * * You can set a limited pattern arrangement with the tiles
  67814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67817. * @param name defines the name of the mesh
  67818. * @param options defines the options used to create the mesh
  67819. * @param scene defines the hosting scene
  67820. * @returns the plane mesh
  67821. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67822. */
  67823. static CreateTiledPlane(name: string, options: {
  67824. pattern?: number;
  67825. tileSize?: number;
  67826. tileWidth?: number;
  67827. tileHeight?: number;
  67828. size?: number;
  67829. width?: number;
  67830. height?: number;
  67831. alignHorizontal?: number;
  67832. alignVertical?: number;
  67833. sideOrientation?: number;
  67834. frontUVs?: Vector4;
  67835. backUVs?: Vector4;
  67836. updatable?: boolean;
  67837. }, scene?: Nullable<Scene>): Mesh;
  67838. /**
  67839. * Creates a plane mesh
  67840. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67841. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67842. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67846. * @param name defines the name of the mesh
  67847. * @param options defines the options used to create the mesh
  67848. * @param scene defines the hosting scene
  67849. * @returns the plane mesh
  67850. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67851. */
  67852. static CreatePlane(name: string, options: {
  67853. size?: number;
  67854. width?: number;
  67855. height?: number;
  67856. sideOrientation?: number;
  67857. frontUVs?: Vector4;
  67858. backUVs?: Vector4;
  67859. updatable?: boolean;
  67860. sourcePlane?: Plane;
  67861. }, scene?: Nullable<Scene>): Mesh;
  67862. /**
  67863. * Creates a ground mesh
  67864. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67865. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67867. * @param name defines the name of the mesh
  67868. * @param options defines the options used to create the mesh
  67869. * @param scene defines the hosting scene
  67870. * @returns the ground mesh
  67871. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67872. */
  67873. static CreateGround(name: string, options: {
  67874. width?: number;
  67875. height?: number;
  67876. subdivisions?: number;
  67877. subdivisionsX?: number;
  67878. subdivisionsY?: number;
  67879. updatable?: boolean;
  67880. }, scene?: Nullable<Scene>): Mesh;
  67881. /**
  67882. * Creates a tiled ground mesh
  67883. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67884. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67885. * * 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
  67886. * * 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
  67887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67888. * @param name defines the name of the mesh
  67889. * @param options defines the options used to create the mesh
  67890. * @param scene defines the hosting scene
  67891. * @returns the tiled ground mesh
  67892. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67893. */
  67894. static CreateTiledGround(name: string, options: {
  67895. xmin: number;
  67896. zmin: number;
  67897. xmax: number;
  67898. zmax: number;
  67899. subdivisions?: {
  67900. w: number;
  67901. h: number;
  67902. };
  67903. precision?: {
  67904. w: number;
  67905. h: number;
  67906. };
  67907. updatable?: boolean;
  67908. }, scene?: Nullable<Scene>): Mesh;
  67909. /**
  67910. * Creates a ground mesh from a height map
  67911. * * The parameter `url` sets the URL of the height map image resource.
  67912. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67913. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67914. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67915. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67916. * * 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.
  67917. * * 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).
  67918. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67920. * @param name defines the name of the mesh
  67921. * @param url defines the url to the height map
  67922. * @param options defines the options used to create the mesh
  67923. * @param scene defines the hosting scene
  67924. * @returns the ground mesh
  67925. * @see https://doc.babylonjs.com/babylon101/height_map
  67926. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67927. */
  67928. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67929. width?: number;
  67930. height?: number;
  67931. subdivisions?: number;
  67932. minHeight?: number;
  67933. maxHeight?: number;
  67934. colorFilter?: Color3;
  67935. alphaFilter?: number;
  67936. updatable?: boolean;
  67937. onReady?: (mesh: GroundMesh) => void;
  67938. }, scene?: Nullable<Scene>): GroundMesh;
  67939. /**
  67940. * Creates a polygon mesh
  67941. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67942. * * 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
  67943. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67946. * * Remember you can only change the shape positions, not their number when updating a polygon
  67947. * @param name defines the name of the mesh
  67948. * @param options defines the options used to create the mesh
  67949. * @param scene defines the hosting scene
  67950. * @param earcutInjection can be used to inject your own earcut reference
  67951. * @returns the polygon mesh
  67952. */
  67953. static CreatePolygon(name: string, options: {
  67954. shape: Vector3[];
  67955. holes?: Vector3[][];
  67956. depth?: number;
  67957. faceUV?: Vector4[];
  67958. faceColors?: Color4[];
  67959. updatable?: boolean;
  67960. sideOrientation?: number;
  67961. frontUVs?: Vector4;
  67962. backUVs?: Vector4;
  67963. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67964. /**
  67965. * Creates an extruded polygon mesh, with depth in the Y direction.
  67966. * * 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)
  67967. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67968. * @param name defines the name of the mesh
  67969. * @param options defines the options used to create the mesh
  67970. * @param scene defines the hosting scene
  67971. * @param earcutInjection can be used to inject your own earcut reference
  67972. * @returns the polygon mesh
  67973. */
  67974. static ExtrudePolygon(name: string, options: {
  67975. shape: Vector3[];
  67976. holes?: Vector3[][];
  67977. depth?: number;
  67978. faceUV?: Vector4[];
  67979. faceColors?: Color4[];
  67980. updatable?: boolean;
  67981. sideOrientation?: number;
  67982. frontUVs?: Vector4;
  67983. backUVs?: Vector4;
  67984. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67985. /**
  67986. * Creates a tube mesh.
  67987. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67988. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67989. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67990. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67991. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67992. * * 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)
  67993. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67994. * * 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
  67995. * * 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
  67996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68000. * @param name defines the name of the mesh
  68001. * @param options defines the options used to create the mesh
  68002. * @param scene defines the hosting scene
  68003. * @returns the tube mesh
  68004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68005. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68006. */
  68007. static CreateTube(name: string, options: {
  68008. path: Vector3[];
  68009. radius?: number;
  68010. tessellation?: number;
  68011. radiusFunction?: {
  68012. (i: number, distance: number): number;
  68013. };
  68014. cap?: number;
  68015. arc?: number;
  68016. updatable?: boolean;
  68017. sideOrientation?: number;
  68018. frontUVs?: Vector4;
  68019. backUVs?: Vector4;
  68020. instance?: Mesh;
  68021. invertUV?: boolean;
  68022. }, scene?: Nullable<Scene>): Mesh;
  68023. /**
  68024. * Creates a polyhedron mesh
  68025. * * 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
  68026. * * The parameter `size` (positive float, default 1) sets the polygon size
  68027. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68028. * * 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`
  68029. * * 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
  68030. * * 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)`)
  68031. * * 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
  68032. * * 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
  68033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68036. * @param name defines the name of the mesh
  68037. * @param options defines the options used to create the mesh
  68038. * @param scene defines the hosting scene
  68039. * @returns the polyhedron mesh
  68040. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68041. */
  68042. static CreatePolyhedron(name: string, options: {
  68043. type?: number;
  68044. size?: number;
  68045. sizeX?: number;
  68046. sizeY?: number;
  68047. sizeZ?: number;
  68048. custom?: any;
  68049. faceUV?: Vector4[];
  68050. faceColors?: Color4[];
  68051. flat?: boolean;
  68052. updatable?: boolean;
  68053. sideOrientation?: number;
  68054. frontUVs?: Vector4;
  68055. backUVs?: Vector4;
  68056. }, scene?: Nullable<Scene>): Mesh;
  68057. /**
  68058. * Creates a decal mesh.
  68059. * 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
  68060. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68061. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68062. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68063. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68064. * @param name defines the name of the mesh
  68065. * @param sourceMesh defines the mesh where the decal must be applied
  68066. * @param options defines the options used to create the mesh
  68067. * @param scene defines the hosting scene
  68068. * @returns the decal mesh
  68069. * @see https://doc.babylonjs.com/how_to/decals
  68070. */
  68071. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68072. position?: Vector3;
  68073. normal?: Vector3;
  68074. size?: Vector3;
  68075. angle?: number;
  68076. }): Mesh;
  68077. }
  68078. }
  68079. declare module "babylonjs/Meshes/meshSimplification" {
  68080. import { Mesh } from "babylonjs/Meshes/mesh";
  68081. /**
  68082. * A simplifier interface for future simplification implementations
  68083. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68084. */
  68085. export interface ISimplifier {
  68086. /**
  68087. * Simplification of a given mesh according to the given settings.
  68088. * Since this requires computation, it is assumed that the function runs async.
  68089. * @param settings The settings of the simplification, including quality and distance
  68090. * @param successCallback A callback that will be called after the mesh was simplified.
  68091. * @param errorCallback in case of an error, this callback will be called. optional.
  68092. */
  68093. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68094. }
  68095. /**
  68096. * Expected simplification settings.
  68097. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68098. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68099. */
  68100. export interface ISimplificationSettings {
  68101. /**
  68102. * Gets or sets the expected quality
  68103. */
  68104. quality: number;
  68105. /**
  68106. * Gets or sets the distance when this optimized version should be used
  68107. */
  68108. distance: number;
  68109. /**
  68110. * Gets an already optimized mesh
  68111. */
  68112. optimizeMesh?: boolean;
  68113. }
  68114. /**
  68115. * Class used to specify simplification options
  68116. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68117. */
  68118. export class SimplificationSettings implements ISimplificationSettings {
  68119. /** expected quality */
  68120. quality: number;
  68121. /** distance when this optimized version should be used */
  68122. distance: number;
  68123. /** already optimized mesh */
  68124. optimizeMesh?: boolean | undefined;
  68125. /**
  68126. * Creates a SimplificationSettings
  68127. * @param quality expected quality
  68128. * @param distance distance when this optimized version should be used
  68129. * @param optimizeMesh already optimized mesh
  68130. */
  68131. constructor(
  68132. /** expected quality */
  68133. quality: number,
  68134. /** distance when this optimized version should be used */
  68135. distance: number,
  68136. /** already optimized mesh */
  68137. optimizeMesh?: boolean | undefined);
  68138. }
  68139. /**
  68140. * Interface used to define a simplification task
  68141. */
  68142. export interface ISimplificationTask {
  68143. /**
  68144. * Array of settings
  68145. */
  68146. settings: Array<ISimplificationSettings>;
  68147. /**
  68148. * Simplification type
  68149. */
  68150. simplificationType: SimplificationType;
  68151. /**
  68152. * Mesh to simplify
  68153. */
  68154. mesh: Mesh;
  68155. /**
  68156. * Callback called on success
  68157. */
  68158. successCallback?: () => void;
  68159. /**
  68160. * Defines if parallel processing can be used
  68161. */
  68162. parallelProcessing: boolean;
  68163. }
  68164. /**
  68165. * Queue used to order the simplification tasks
  68166. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68167. */
  68168. export class SimplificationQueue {
  68169. private _simplificationArray;
  68170. /**
  68171. * Gets a boolean indicating that the process is still running
  68172. */
  68173. running: boolean;
  68174. /**
  68175. * Creates a new queue
  68176. */
  68177. constructor();
  68178. /**
  68179. * Adds a new simplification task
  68180. * @param task defines a task to add
  68181. */
  68182. addTask(task: ISimplificationTask): void;
  68183. /**
  68184. * Execute next task
  68185. */
  68186. executeNext(): void;
  68187. /**
  68188. * Execute a simplification task
  68189. * @param task defines the task to run
  68190. */
  68191. runSimplification(task: ISimplificationTask): void;
  68192. private getSimplifier;
  68193. }
  68194. /**
  68195. * The implemented types of simplification
  68196. * At the moment only Quadratic Error Decimation is implemented
  68197. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68198. */
  68199. export enum SimplificationType {
  68200. /** Quadratic error decimation */
  68201. QUADRATIC = 0
  68202. }
  68203. /**
  68204. * An implementation of the Quadratic Error simplification algorithm.
  68205. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68206. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68207. * @author RaananW
  68208. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68209. */
  68210. export class QuadraticErrorSimplification implements ISimplifier {
  68211. private _mesh;
  68212. private triangles;
  68213. private vertices;
  68214. private references;
  68215. private _reconstructedMesh;
  68216. /** Gets or sets the number pf sync interations */
  68217. syncIterations: number;
  68218. /** Gets or sets the aggressiveness of the simplifier */
  68219. aggressiveness: number;
  68220. /** Gets or sets the number of allowed iterations for decimation */
  68221. decimationIterations: number;
  68222. /** Gets or sets the espilon to use for bounding box computation */
  68223. boundingBoxEpsilon: number;
  68224. /**
  68225. * Creates a new QuadraticErrorSimplification
  68226. * @param _mesh defines the target mesh
  68227. */
  68228. constructor(_mesh: Mesh);
  68229. /**
  68230. * Simplification of a given mesh according to the given settings.
  68231. * Since this requires computation, it is assumed that the function runs async.
  68232. * @param settings The settings of the simplification, including quality and distance
  68233. * @param successCallback A callback that will be called after the mesh was simplified.
  68234. */
  68235. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68236. private runDecimation;
  68237. private initWithMesh;
  68238. private init;
  68239. private reconstructMesh;
  68240. private initDecimatedMesh;
  68241. private isFlipped;
  68242. private updateTriangles;
  68243. private identifyBorder;
  68244. private updateMesh;
  68245. private vertexError;
  68246. private calculateError;
  68247. }
  68248. }
  68249. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68250. import { Scene } from "babylonjs/scene";
  68251. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68252. import { ISceneComponent } from "babylonjs/sceneComponent";
  68253. module "babylonjs/scene" {
  68254. interface Scene {
  68255. /** @hidden (Backing field) */
  68256. _simplificationQueue: SimplificationQueue;
  68257. /**
  68258. * Gets or sets the simplification queue attached to the scene
  68259. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68260. */
  68261. simplificationQueue: SimplificationQueue;
  68262. }
  68263. }
  68264. module "babylonjs/Meshes/mesh" {
  68265. interface Mesh {
  68266. /**
  68267. * Simplify the mesh according to the given array of settings.
  68268. * Function will return immediately and will simplify async
  68269. * @param settings a collection of simplification settings
  68270. * @param parallelProcessing should all levels calculate parallel or one after the other
  68271. * @param simplificationType the type of simplification to run
  68272. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68273. * @returns the current mesh
  68274. */
  68275. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68276. }
  68277. }
  68278. /**
  68279. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68280. * created in a scene
  68281. */
  68282. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68283. /**
  68284. * The component name helpfull to identify the component in the list of scene components.
  68285. */
  68286. readonly name: string;
  68287. /**
  68288. * The scene the component belongs to.
  68289. */
  68290. scene: Scene;
  68291. /**
  68292. * Creates a new instance of the component for the given scene
  68293. * @param scene Defines the scene to register the component in
  68294. */
  68295. constructor(scene: Scene);
  68296. /**
  68297. * Registers the component in a given scene
  68298. */
  68299. register(): void;
  68300. /**
  68301. * Rebuilds the elements related to this component in case of
  68302. * context lost for instance.
  68303. */
  68304. rebuild(): void;
  68305. /**
  68306. * Disposes the component and the associated ressources
  68307. */
  68308. dispose(): void;
  68309. private _beforeCameraUpdate;
  68310. }
  68311. }
  68312. declare module "babylonjs/Meshes/Builders/index" {
  68313. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68314. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68315. export * from "babylonjs/Meshes/Builders/discBuilder";
  68316. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68317. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68318. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68319. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68320. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68321. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68322. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68323. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68324. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68325. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68326. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68327. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68328. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68329. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68330. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68331. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68332. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68333. }
  68334. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68335. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68336. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68337. import { Matrix } from "babylonjs/Maths/math.vector";
  68338. module "babylonjs/Meshes/mesh" {
  68339. interface Mesh {
  68340. /**
  68341. * Creates a new thin instance
  68342. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68343. * @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
  68344. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68345. */
  68346. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68347. /**
  68348. * Adds the transformation (matrix) of the current mesh as a thin instance
  68349. * @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
  68350. * @returns the thin instance index number
  68351. */
  68352. thinInstanceAddSelf(refresh: boolean): number;
  68353. /**
  68354. * Registers a custom attribute to be used with thin instances
  68355. * @param kind name of the attribute
  68356. * @param stride size in floats of the attribute
  68357. */
  68358. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68359. /**
  68360. * Sets the matrix of a thin instance
  68361. * @param index index of the thin instance
  68362. * @param matrix matrix to set
  68363. * @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
  68364. */
  68365. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68366. /**
  68367. * Sets the value of a custom attribute for a thin instance
  68368. * @param kind name of the attribute
  68369. * @param index index of the thin instance
  68370. * @param value value to set
  68371. * @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
  68372. */
  68373. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68374. /**
  68375. * 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.
  68376. */
  68377. thinInstanceCount: number;
  68378. /**
  68379. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68380. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68381. * @param buffer buffer to set
  68382. * @param stride size in floats of each value of the buffer
  68383. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68384. */
  68385. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68386. /**
  68387. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68388. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68389. */
  68390. thinInstanceBufferUpdated(kind: string): void;
  68391. /**
  68392. * Refreshes the bounding info, taking into account all the thin instances defined
  68393. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68394. */
  68395. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68396. /** @hidden */
  68397. _thinInstanceInitializeUserStorage(): void;
  68398. /** @hidden */
  68399. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68400. /** @hidden */
  68401. _userThinInstanceBuffersStorage: {
  68402. data: {
  68403. [key: string]: Float32Array;
  68404. };
  68405. sizes: {
  68406. [key: string]: number;
  68407. };
  68408. vertexBuffers: {
  68409. [key: string]: Nullable<VertexBuffer>;
  68410. };
  68411. strides: {
  68412. [key: string]: number;
  68413. };
  68414. };
  68415. }
  68416. }
  68417. }
  68418. declare module "babylonjs/Meshes/index" {
  68419. export * from "babylonjs/Meshes/abstractMesh";
  68420. export * from "babylonjs/Meshes/buffer";
  68421. export * from "babylonjs/Meshes/Compression/index";
  68422. export * from "babylonjs/Meshes/csg";
  68423. export * from "babylonjs/Meshes/geometry";
  68424. export * from "babylonjs/Meshes/groundMesh";
  68425. export * from "babylonjs/Meshes/trailMesh";
  68426. export * from "babylonjs/Meshes/instancedMesh";
  68427. export * from "babylonjs/Meshes/linesMesh";
  68428. export * from "babylonjs/Meshes/mesh";
  68429. export * from "babylonjs/Meshes/mesh.vertexData";
  68430. export * from "babylonjs/Meshes/meshBuilder";
  68431. export * from "babylonjs/Meshes/meshSimplification";
  68432. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68433. export * from "babylonjs/Meshes/polygonMesh";
  68434. export * from "babylonjs/Meshes/subMesh";
  68435. export * from "babylonjs/Meshes/meshLODLevel";
  68436. export * from "babylonjs/Meshes/transformNode";
  68437. export * from "babylonjs/Meshes/Builders/index";
  68438. export * from "babylonjs/Meshes/dataBuffer";
  68439. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68440. import "babylonjs/Meshes/thinInstanceMesh";
  68441. export * from "babylonjs/Meshes/thinInstanceMesh";
  68442. }
  68443. declare module "babylonjs/Morph/index" {
  68444. export * from "babylonjs/Morph/morphTarget";
  68445. export * from "babylonjs/Morph/morphTargetManager";
  68446. }
  68447. declare module "babylonjs/Navigation/INavigationEngine" {
  68448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68449. import { Vector3 } from "babylonjs/Maths/math";
  68450. import { Mesh } from "babylonjs/Meshes/mesh";
  68451. import { Scene } from "babylonjs/scene";
  68452. /**
  68453. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68454. */
  68455. export interface INavigationEnginePlugin {
  68456. /**
  68457. * plugin name
  68458. */
  68459. name: string;
  68460. /**
  68461. * Creates a navigation mesh
  68462. * @param meshes array of all the geometry used to compute the navigatio mesh
  68463. * @param parameters bunch of parameters used to filter geometry
  68464. */
  68465. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68466. /**
  68467. * Create a navigation mesh debug mesh
  68468. * @param scene is where the mesh will be added
  68469. * @returns debug display mesh
  68470. */
  68471. createDebugNavMesh(scene: Scene): Mesh;
  68472. /**
  68473. * Get a navigation mesh constrained position, closest to the parameter position
  68474. * @param position world position
  68475. * @returns the closest point to position constrained by the navigation mesh
  68476. */
  68477. getClosestPoint(position: Vector3): Vector3;
  68478. /**
  68479. * Get a navigation mesh constrained position, closest to the parameter position
  68480. * @param position world position
  68481. * @param result output the closest point to position constrained by the navigation mesh
  68482. */
  68483. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68484. /**
  68485. * Get a navigation mesh constrained position, within a particular radius
  68486. * @param position world position
  68487. * @param maxRadius the maximum distance to the constrained world position
  68488. * @returns the closest point to position constrained by the navigation mesh
  68489. */
  68490. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68491. /**
  68492. * Get a navigation mesh constrained position, within a particular radius
  68493. * @param position world position
  68494. * @param maxRadius the maximum distance to the constrained world position
  68495. * @param result output the closest point to position constrained by the navigation mesh
  68496. */
  68497. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68498. /**
  68499. * Compute the final position from a segment made of destination-position
  68500. * @param position world position
  68501. * @param destination world position
  68502. * @returns the resulting point along the navmesh
  68503. */
  68504. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68505. /**
  68506. * Compute the final position from a segment made of destination-position
  68507. * @param position world position
  68508. * @param destination world position
  68509. * @param result output the resulting point along the navmesh
  68510. */
  68511. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68512. /**
  68513. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68514. * @param start world position
  68515. * @param end world position
  68516. * @returns array containing world position composing the path
  68517. */
  68518. computePath(start: Vector3, end: Vector3): Vector3[];
  68519. /**
  68520. * If this plugin is supported
  68521. * @returns true if plugin is supported
  68522. */
  68523. isSupported(): boolean;
  68524. /**
  68525. * Create a new Crowd so you can add agents
  68526. * @param maxAgents the maximum agent count in the crowd
  68527. * @param maxAgentRadius the maximum radius an agent can have
  68528. * @param scene to attach the crowd to
  68529. * @returns the crowd you can add agents to
  68530. */
  68531. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68532. /**
  68533. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68534. * The queries will try to find a solution within those bounds
  68535. * default is (1,1,1)
  68536. * @param extent x,y,z value that define the extent around the queries point of reference
  68537. */
  68538. setDefaultQueryExtent(extent: Vector3): void;
  68539. /**
  68540. * Get the Bounding box extent specified by setDefaultQueryExtent
  68541. * @returns the box extent values
  68542. */
  68543. getDefaultQueryExtent(): Vector3;
  68544. /**
  68545. * build the navmesh from a previously saved state using getNavmeshData
  68546. * @param data the Uint8Array returned by getNavmeshData
  68547. */
  68548. buildFromNavmeshData(data: Uint8Array): void;
  68549. /**
  68550. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68551. * @returns data the Uint8Array that can be saved and reused
  68552. */
  68553. getNavmeshData(): Uint8Array;
  68554. /**
  68555. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68556. * @param result output the box extent values
  68557. */
  68558. getDefaultQueryExtentToRef(result: Vector3): void;
  68559. /**
  68560. * Release all resources
  68561. */
  68562. dispose(): void;
  68563. }
  68564. /**
  68565. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68566. */
  68567. export interface ICrowd {
  68568. /**
  68569. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68570. * You can attach anything to that node. The node position is updated in the scene update tick.
  68571. * @param pos world position that will be constrained by the navigation mesh
  68572. * @param parameters agent parameters
  68573. * @param transform hooked to the agent that will be update by the scene
  68574. * @returns agent index
  68575. */
  68576. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68577. /**
  68578. * Returns the agent position in world space
  68579. * @param index agent index returned by addAgent
  68580. * @returns world space position
  68581. */
  68582. getAgentPosition(index: number): Vector3;
  68583. /**
  68584. * Gets the agent position result in world space
  68585. * @param index agent index returned by addAgent
  68586. * @param result output world space position
  68587. */
  68588. getAgentPositionToRef(index: number, result: Vector3): void;
  68589. /**
  68590. * Gets the agent velocity in world space
  68591. * @param index agent index returned by addAgent
  68592. * @returns world space velocity
  68593. */
  68594. getAgentVelocity(index: number): Vector3;
  68595. /**
  68596. * Gets the agent velocity result in world space
  68597. * @param index agent index returned by addAgent
  68598. * @param result output world space velocity
  68599. */
  68600. getAgentVelocityToRef(index: number, result: Vector3): void;
  68601. /**
  68602. * remove a particular agent previously created
  68603. * @param index agent index returned by addAgent
  68604. */
  68605. removeAgent(index: number): void;
  68606. /**
  68607. * get the list of all agents attached to this crowd
  68608. * @returns list of agent indices
  68609. */
  68610. getAgents(): number[];
  68611. /**
  68612. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68613. * @param deltaTime in seconds
  68614. */
  68615. update(deltaTime: number): void;
  68616. /**
  68617. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68618. * @param index agent index returned by addAgent
  68619. * @param destination targeted world position
  68620. */
  68621. agentGoto(index: number, destination: Vector3): void;
  68622. /**
  68623. * Teleport the agent to a new position
  68624. * @param index agent index returned by addAgent
  68625. * @param destination targeted world position
  68626. */
  68627. agentTeleport(index: number, destination: Vector3): void;
  68628. /**
  68629. * Update agent parameters
  68630. * @param index agent index returned by addAgent
  68631. * @param parameters agent parameters
  68632. */
  68633. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68634. /**
  68635. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68636. * The queries will try to find a solution within those bounds
  68637. * default is (1,1,1)
  68638. * @param extent x,y,z value that define the extent around the queries point of reference
  68639. */
  68640. setDefaultQueryExtent(extent: Vector3): void;
  68641. /**
  68642. * Get the Bounding box extent specified by setDefaultQueryExtent
  68643. * @returns the box extent values
  68644. */
  68645. getDefaultQueryExtent(): Vector3;
  68646. /**
  68647. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68648. * @param result output the box extent values
  68649. */
  68650. getDefaultQueryExtentToRef(result: Vector3): void;
  68651. /**
  68652. * Release all resources
  68653. */
  68654. dispose(): void;
  68655. }
  68656. /**
  68657. * Configures an agent
  68658. */
  68659. export interface IAgentParameters {
  68660. /**
  68661. * Agent radius. [Limit: >= 0]
  68662. */
  68663. radius: number;
  68664. /**
  68665. * Agent height. [Limit: > 0]
  68666. */
  68667. height: number;
  68668. /**
  68669. * Maximum allowed acceleration. [Limit: >= 0]
  68670. */
  68671. maxAcceleration: number;
  68672. /**
  68673. * Maximum allowed speed. [Limit: >= 0]
  68674. */
  68675. maxSpeed: number;
  68676. /**
  68677. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68678. */
  68679. collisionQueryRange: number;
  68680. /**
  68681. * The path visibility optimization range. [Limit: > 0]
  68682. */
  68683. pathOptimizationRange: number;
  68684. /**
  68685. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68686. */
  68687. separationWeight: number;
  68688. }
  68689. /**
  68690. * Configures the navigation mesh creation
  68691. */
  68692. export interface INavMeshParameters {
  68693. /**
  68694. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68695. */
  68696. cs: number;
  68697. /**
  68698. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68699. */
  68700. ch: number;
  68701. /**
  68702. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68703. */
  68704. walkableSlopeAngle: number;
  68705. /**
  68706. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68707. * be considered walkable. [Limit: >= 3] [Units: vx]
  68708. */
  68709. walkableHeight: number;
  68710. /**
  68711. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68712. */
  68713. walkableClimb: number;
  68714. /**
  68715. * The distance to erode/shrink the walkable area of the heightfield away from
  68716. * obstructions. [Limit: >=0] [Units: vx]
  68717. */
  68718. walkableRadius: number;
  68719. /**
  68720. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68721. */
  68722. maxEdgeLen: number;
  68723. /**
  68724. * The maximum distance a simplfied contour's border edges should deviate
  68725. * the original raw contour. [Limit: >=0] [Units: vx]
  68726. */
  68727. maxSimplificationError: number;
  68728. /**
  68729. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68730. */
  68731. minRegionArea: number;
  68732. /**
  68733. * Any regions with a span count smaller than this value will, if possible,
  68734. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68735. */
  68736. mergeRegionArea: number;
  68737. /**
  68738. * The maximum number of vertices allowed for polygons generated during the
  68739. * contour to polygon conversion process. [Limit: >= 3]
  68740. */
  68741. maxVertsPerPoly: number;
  68742. /**
  68743. * Sets the sampling distance to use when generating the detail mesh.
  68744. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68745. */
  68746. detailSampleDist: number;
  68747. /**
  68748. * The maximum distance the detail mesh surface should deviate from heightfield
  68749. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68750. */
  68751. detailSampleMaxError: number;
  68752. }
  68753. }
  68754. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  68755. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  68756. import { Mesh } from "babylonjs/Meshes/mesh";
  68757. import { Scene } from "babylonjs/scene";
  68758. import { Vector3 } from "babylonjs/Maths/math";
  68759. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68760. /**
  68761. * RecastJS navigation plugin
  68762. */
  68763. export class RecastJSPlugin implements INavigationEnginePlugin {
  68764. /**
  68765. * Reference to the Recast library
  68766. */
  68767. bjsRECAST: any;
  68768. /**
  68769. * plugin name
  68770. */
  68771. name: string;
  68772. /**
  68773. * the first navmesh created. We might extend this to support multiple navmeshes
  68774. */
  68775. navMesh: any;
  68776. /**
  68777. * Initializes the recastJS plugin
  68778. * @param recastInjection can be used to inject your own recast reference
  68779. */
  68780. constructor(recastInjection?: any);
  68781. /**
  68782. * Creates a navigation mesh
  68783. * @param meshes array of all the geometry used to compute the navigatio mesh
  68784. * @param parameters bunch of parameters used to filter geometry
  68785. */
  68786. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68787. /**
  68788. * Create a navigation mesh debug mesh
  68789. * @param scene is where the mesh will be added
  68790. * @returns debug display mesh
  68791. */
  68792. createDebugNavMesh(scene: Scene): Mesh;
  68793. /**
  68794. * Get a navigation mesh constrained position, closest to the parameter position
  68795. * @param position world position
  68796. * @returns the closest point to position constrained by the navigation mesh
  68797. */
  68798. getClosestPoint(position: Vector3): Vector3;
  68799. /**
  68800. * Get a navigation mesh constrained position, closest to the parameter position
  68801. * @param position world position
  68802. * @param result output the closest point to position constrained by the navigation mesh
  68803. */
  68804. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68805. /**
  68806. * Get a navigation mesh constrained position, within a particular radius
  68807. * @param position world position
  68808. * @param maxRadius the maximum distance to the constrained world position
  68809. * @returns the closest point to position constrained by the navigation mesh
  68810. */
  68811. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68812. /**
  68813. * Get a navigation mesh constrained position, within a particular radius
  68814. * @param position world position
  68815. * @param maxRadius the maximum distance to the constrained world position
  68816. * @param result output the closest point to position constrained by the navigation mesh
  68817. */
  68818. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68819. /**
  68820. * Compute the final position from a segment made of destination-position
  68821. * @param position world position
  68822. * @param destination world position
  68823. * @returns the resulting point along the navmesh
  68824. */
  68825. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68826. /**
  68827. * Compute the final position from a segment made of destination-position
  68828. * @param position world position
  68829. * @param destination world position
  68830. * @param result output the resulting point along the navmesh
  68831. */
  68832. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68833. /**
  68834. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68835. * @param start world position
  68836. * @param end world position
  68837. * @returns array containing world position composing the path
  68838. */
  68839. computePath(start: Vector3, end: Vector3): Vector3[];
  68840. /**
  68841. * Create a new Crowd so you can add agents
  68842. * @param maxAgents the maximum agent count in the crowd
  68843. * @param maxAgentRadius the maximum radius an agent can have
  68844. * @param scene to attach the crowd to
  68845. * @returns the crowd you can add agents to
  68846. */
  68847. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68848. /**
  68849. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68850. * The queries will try to find a solution within those bounds
  68851. * default is (1,1,1)
  68852. * @param extent x,y,z value that define the extent around the queries point of reference
  68853. */
  68854. setDefaultQueryExtent(extent: Vector3): void;
  68855. /**
  68856. * Get the Bounding box extent specified by setDefaultQueryExtent
  68857. * @returns the box extent values
  68858. */
  68859. getDefaultQueryExtent(): Vector3;
  68860. /**
  68861. * build the navmesh from a previously saved state using getNavmeshData
  68862. * @param data the Uint8Array returned by getNavmeshData
  68863. */
  68864. buildFromNavmeshData(data: Uint8Array): void;
  68865. /**
  68866. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68867. * @returns data the Uint8Array that can be saved and reused
  68868. */
  68869. getNavmeshData(): Uint8Array;
  68870. /**
  68871. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68872. * @param result output the box extent values
  68873. */
  68874. getDefaultQueryExtentToRef(result: Vector3): void;
  68875. /**
  68876. * Disposes
  68877. */
  68878. dispose(): void;
  68879. /**
  68880. * If this plugin is supported
  68881. * @returns true if plugin is supported
  68882. */
  68883. isSupported(): boolean;
  68884. }
  68885. /**
  68886. * Recast detour crowd implementation
  68887. */
  68888. export class RecastJSCrowd implements ICrowd {
  68889. /**
  68890. * Recast/detour plugin
  68891. */
  68892. bjsRECASTPlugin: RecastJSPlugin;
  68893. /**
  68894. * Link to the detour crowd
  68895. */
  68896. recastCrowd: any;
  68897. /**
  68898. * One transform per agent
  68899. */
  68900. transforms: TransformNode[];
  68901. /**
  68902. * All agents created
  68903. */
  68904. agents: number[];
  68905. /**
  68906. * Link to the scene is kept to unregister the crowd from the scene
  68907. */
  68908. private _scene;
  68909. /**
  68910. * Observer for crowd updates
  68911. */
  68912. private _onBeforeAnimationsObserver;
  68913. /**
  68914. * Constructor
  68915. * @param plugin recastJS plugin
  68916. * @param maxAgents the maximum agent count in the crowd
  68917. * @param maxAgentRadius the maximum radius an agent can have
  68918. * @param scene to attach the crowd to
  68919. * @returns the crowd you can add agents to
  68920. */
  68921. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68922. /**
  68923. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68924. * You can attach anything to that node. The node position is updated in the scene update tick.
  68925. * @param pos world position that will be constrained by the navigation mesh
  68926. * @param parameters agent parameters
  68927. * @param transform hooked to the agent that will be update by the scene
  68928. * @returns agent index
  68929. */
  68930. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68931. /**
  68932. * Returns the agent position in world space
  68933. * @param index agent index returned by addAgent
  68934. * @returns world space position
  68935. */
  68936. getAgentPosition(index: number): Vector3;
  68937. /**
  68938. * Returns the agent position result in world space
  68939. * @param index agent index returned by addAgent
  68940. * @param result output world space position
  68941. */
  68942. getAgentPositionToRef(index: number, result: Vector3): void;
  68943. /**
  68944. * Returns the agent velocity in world space
  68945. * @param index agent index returned by addAgent
  68946. * @returns world space velocity
  68947. */
  68948. getAgentVelocity(index: number): Vector3;
  68949. /**
  68950. * Returns the agent velocity result in world space
  68951. * @param index agent index returned by addAgent
  68952. * @param result output world space velocity
  68953. */
  68954. getAgentVelocityToRef(index: number, result: Vector3): void;
  68955. /**
  68956. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68957. * @param index agent index returned by addAgent
  68958. * @param destination targeted world position
  68959. */
  68960. agentGoto(index: number, destination: Vector3): void;
  68961. /**
  68962. * Teleport the agent to a new position
  68963. * @param index agent index returned by addAgent
  68964. * @param destination targeted world position
  68965. */
  68966. agentTeleport(index: number, destination: Vector3): void;
  68967. /**
  68968. * Update agent parameters
  68969. * @param index agent index returned by addAgent
  68970. * @param parameters agent parameters
  68971. */
  68972. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68973. /**
  68974. * remove a particular agent previously created
  68975. * @param index agent index returned by addAgent
  68976. */
  68977. removeAgent(index: number): void;
  68978. /**
  68979. * get the list of all agents attached to this crowd
  68980. * @returns list of agent indices
  68981. */
  68982. getAgents(): number[];
  68983. /**
  68984. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68985. * @param deltaTime in seconds
  68986. */
  68987. update(deltaTime: number): void;
  68988. /**
  68989. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68990. * The queries will try to find a solution within those bounds
  68991. * default is (1,1,1)
  68992. * @param extent x,y,z value that define the extent around the queries point of reference
  68993. */
  68994. setDefaultQueryExtent(extent: Vector3): void;
  68995. /**
  68996. * Get the Bounding box extent specified by setDefaultQueryExtent
  68997. * @returns the box extent values
  68998. */
  68999. getDefaultQueryExtent(): Vector3;
  69000. /**
  69001. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69002. * @param result output the box extent values
  69003. */
  69004. getDefaultQueryExtentToRef(result: Vector3): void;
  69005. /**
  69006. * Release all resources
  69007. */
  69008. dispose(): void;
  69009. }
  69010. }
  69011. declare module "babylonjs/Navigation/Plugins/index" {
  69012. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69013. }
  69014. declare module "babylonjs/Navigation/index" {
  69015. export * from "babylonjs/Navigation/INavigationEngine";
  69016. export * from "babylonjs/Navigation/Plugins/index";
  69017. }
  69018. declare module "babylonjs/Offline/database" {
  69019. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69020. /**
  69021. * Class used to enable access to IndexedDB
  69022. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69023. */
  69024. export class Database implements IOfflineProvider {
  69025. private _callbackManifestChecked;
  69026. private _currentSceneUrl;
  69027. private _db;
  69028. private _enableSceneOffline;
  69029. private _enableTexturesOffline;
  69030. private _manifestVersionFound;
  69031. private _mustUpdateRessources;
  69032. private _hasReachedQuota;
  69033. private _isSupported;
  69034. private _idbFactory;
  69035. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69036. private static IsUASupportingBlobStorage;
  69037. /**
  69038. * Gets a boolean indicating if Database storate is enabled (off by default)
  69039. */
  69040. static IDBStorageEnabled: boolean;
  69041. /**
  69042. * Gets a boolean indicating if scene must be saved in the database
  69043. */
  69044. get enableSceneOffline(): boolean;
  69045. /**
  69046. * Gets a boolean indicating if textures must be saved in the database
  69047. */
  69048. get enableTexturesOffline(): boolean;
  69049. /**
  69050. * Creates a new Database
  69051. * @param urlToScene defines the url to load the scene
  69052. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69053. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69054. */
  69055. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69056. private static _ParseURL;
  69057. private static _ReturnFullUrlLocation;
  69058. private _checkManifestFile;
  69059. /**
  69060. * Open the database and make it available
  69061. * @param successCallback defines the callback to call on success
  69062. * @param errorCallback defines the callback to call on error
  69063. */
  69064. open(successCallback: () => void, errorCallback: () => void): void;
  69065. /**
  69066. * Loads an image from the database
  69067. * @param url defines the url to load from
  69068. * @param image defines the target DOM image
  69069. */
  69070. loadImage(url: string, image: HTMLImageElement): void;
  69071. private _loadImageFromDBAsync;
  69072. private _saveImageIntoDBAsync;
  69073. private _checkVersionFromDB;
  69074. private _loadVersionFromDBAsync;
  69075. private _saveVersionIntoDBAsync;
  69076. /**
  69077. * Loads a file from database
  69078. * @param url defines the URL to load from
  69079. * @param sceneLoaded defines a callback to call on success
  69080. * @param progressCallBack defines a callback to call when progress changed
  69081. * @param errorCallback defines a callback to call on error
  69082. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69083. */
  69084. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69085. private _loadFileAsync;
  69086. private _saveFileAsync;
  69087. /**
  69088. * Validates if xhr data is correct
  69089. * @param xhr defines the request to validate
  69090. * @param dataType defines the expected data type
  69091. * @returns true if data is correct
  69092. */
  69093. private static _ValidateXHRData;
  69094. }
  69095. }
  69096. declare module "babylonjs/Offline/index" {
  69097. export * from "babylonjs/Offline/database";
  69098. export * from "babylonjs/Offline/IOfflineProvider";
  69099. }
  69100. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69101. /** @hidden */
  69102. export var gpuUpdateParticlesPixelShader: {
  69103. name: string;
  69104. shader: string;
  69105. };
  69106. }
  69107. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69108. /** @hidden */
  69109. export var gpuUpdateParticlesVertexShader: {
  69110. name: string;
  69111. shader: string;
  69112. };
  69113. }
  69114. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69115. /** @hidden */
  69116. export var clipPlaneFragmentDeclaration2: {
  69117. name: string;
  69118. shader: string;
  69119. };
  69120. }
  69121. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69122. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69123. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69124. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69125. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69126. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69127. /** @hidden */
  69128. export var gpuRenderParticlesPixelShader: {
  69129. name: string;
  69130. shader: string;
  69131. };
  69132. }
  69133. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69134. /** @hidden */
  69135. export var clipPlaneVertexDeclaration2: {
  69136. name: string;
  69137. shader: string;
  69138. };
  69139. }
  69140. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69141. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69142. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69143. /** @hidden */
  69144. export var gpuRenderParticlesVertexShader: {
  69145. name: string;
  69146. shader: string;
  69147. };
  69148. }
  69149. declare module "babylonjs/Particles/gpuParticleSystem" {
  69150. import { Nullable } from "babylonjs/types";
  69151. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69152. import { Observable } from "babylonjs/Misc/observable";
  69153. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69154. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69155. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69156. import { Scene, IDisposable } from "babylonjs/scene";
  69157. import { Effect } from "babylonjs/Materials/effect";
  69158. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69159. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69160. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69161. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69162. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69163. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69164. /**
  69165. * This represents a GPU particle system in Babylon
  69166. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69167. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69168. */
  69169. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69170. /**
  69171. * The layer mask we are rendering the particles through.
  69172. */
  69173. layerMask: number;
  69174. private _capacity;
  69175. private _activeCount;
  69176. private _currentActiveCount;
  69177. private _accumulatedCount;
  69178. private _renderEffect;
  69179. private _updateEffect;
  69180. private _buffer0;
  69181. private _buffer1;
  69182. private _spriteBuffer;
  69183. private _updateVAO;
  69184. private _renderVAO;
  69185. private _targetIndex;
  69186. private _sourceBuffer;
  69187. private _targetBuffer;
  69188. private _engine;
  69189. private _currentRenderId;
  69190. private _started;
  69191. private _stopped;
  69192. private _timeDelta;
  69193. private _randomTexture;
  69194. private _randomTexture2;
  69195. private _attributesStrideSize;
  69196. private _updateEffectOptions;
  69197. private _randomTextureSize;
  69198. private _actualFrame;
  69199. private _customEffect;
  69200. private readonly _rawTextureWidth;
  69201. /**
  69202. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69203. */
  69204. static get IsSupported(): boolean;
  69205. /**
  69206. * An event triggered when the system is disposed.
  69207. */
  69208. onDisposeObservable: Observable<IParticleSystem>;
  69209. /**
  69210. * Gets the maximum number of particles active at the same time.
  69211. * @returns The max number of active particles.
  69212. */
  69213. getCapacity(): number;
  69214. /**
  69215. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69216. * to override the particles.
  69217. */
  69218. forceDepthWrite: boolean;
  69219. /**
  69220. * Gets or set the number of active particles
  69221. */
  69222. get activeParticleCount(): number;
  69223. set activeParticleCount(value: number);
  69224. private _preWarmDone;
  69225. /**
  69226. * Specifies if the particles are updated in emitter local space or world space.
  69227. */
  69228. isLocal: boolean;
  69229. /**
  69230. * Is this system ready to be used/rendered
  69231. * @return true if the system is ready
  69232. */
  69233. isReady(): boolean;
  69234. /**
  69235. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69236. * @returns True if it has been started, otherwise false.
  69237. */
  69238. isStarted(): boolean;
  69239. /**
  69240. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69241. * @returns True if it has been stopped, otherwise false.
  69242. */
  69243. isStopped(): boolean;
  69244. /**
  69245. * Gets a boolean indicating that the system is stopping
  69246. * @returns true if the system is currently stopping
  69247. */
  69248. isStopping(): boolean;
  69249. /**
  69250. * Gets the number of particles active at the same time.
  69251. * @returns The number of active particles.
  69252. */
  69253. getActiveCount(): number;
  69254. /**
  69255. * Starts the particle system and begins to emit
  69256. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69257. */
  69258. start(delay?: number): void;
  69259. /**
  69260. * Stops the particle system.
  69261. */
  69262. stop(): void;
  69263. /**
  69264. * Remove all active particles
  69265. */
  69266. reset(): void;
  69267. /**
  69268. * Returns the string "GPUParticleSystem"
  69269. * @returns a string containing the class name
  69270. */
  69271. getClassName(): string;
  69272. /**
  69273. * Gets the custom effect used to render the particles
  69274. * @param blendMode Blend mode for which the effect should be retrieved
  69275. * @returns The effect
  69276. */
  69277. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69278. /**
  69279. * Sets the custom effect used to render the particles
  69280. * @param effect The effect to set
  69281. * @param blendMode Blend mode for which the effect should be set
  69282. */
  69283. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69284. /** @hidden */
  69285. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69286. /**
  69287. * Observable that will be called just before the particles are drawn
  69288. */
  69289. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69290. /**
  69291. * Gets the name of the particle vertex shader
  69292. */
  69293. get vertexShaderName(): string;
  69294. private _colorGradientsTexture;
  69295. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69296. /**
  69297. * Adds a new color gradient
  69298. * @param gradient defines the gradient to use (between 0 and 1)
  69299. * @param color1 defines the color to affect to the specified gradient
  69300. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69301. * @returns the current particle system
  69302. */
  69303. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69304. private _refreshColorGradient;
  69305. /** Force the system to rebuild all gradients that need to be resync */
  69306. forceRefreshGradients(): void;
  69307. /**
  69308. * Remove a specific color gradient
  69309. * @param gradient defines the gradient to remove
  69310. * @returns the current particle system
  69311. */
  69312. removeColorGradient(gradient: number): GPUParticleSystem;
  69313. private _angularSpeedGradientsTexture;
  69314. private _sizeGradientsTexture;
  69315. private _velocityGradientsTexture;
  69316. private _limitVelocityGradientsTexture;
  69317. private _dragGradientsTexture;
  69318. private _addFactorGradient;
  69319. /**
  69320. * Adds a new size gradient
  69321. * @param gradient defines the gradient to use (between 0 and 1)
  69322. * @param factor defines the size factor to affect to the specified gradient
  69323. * @returns the current particle system
  69324. */
  69325. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69326. /**
  69327. * Remove a specific size gradient
  69328. * @param gradient defines the gradient to remove
  69329. * @returns the current particle system
  69330. */
  69331. removeSizeGradient(gradient: number): GPUParticleSystem;
  69332. private _refreshFactorGradient;
  69333. /**
  69334. * Adds a new angular speed gradient
  69335. * @param gradient defines the gradient to use (between 0 and 1)
  69336. * @param factor defines the angular speed to affect to the specified gradient
  69337. * @returns the current particle system
  69338. */
  69339. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69340. /**
  69341. * Remove a specific angular speed gradient
  69342. * @param gradient defines the gradient to remove
  69343. * @returns the current particle system
  69344. */
  69345. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69346. /**
  69347. * Adds a new velocity gradient
  69348. * @param gradient defines the gradient to use (between 0 and 1)
  69349. * @param factor defines the velocity to affect to the specified gradient
  69350. * @returns the current particle system
  69351. */
  69352. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69353. /**
  69354. * Remove a specific velocity gradient
  69355. * @param gradient defines the gradient to remove
  69356. * @returns the current particle system
  69357. */
  69358. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69359. /**
  69360. * Adds a new limit velocity gradient
  69361. * @param gradient defines the gradient to use (between 0 and 1)
  69362. * @param factor defines the limit velocity value to affect to the specified gradient
  69363. * @returns the current particle system
  69364. */
  69365. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69366. /**
  69367. * Remove a specific limit velocity gradient
  69368. * @param gradient defines the gradient to remove
  69369. * @returns the current particle system
  69370. */
  69371. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69372. /**
  69373. * Adds a new drag gradient
  69374. * @param gradient defines the gradient to use (between 0 and 1)
  69375. * @param factor defines the drag value to affect to the specified gradient
  69376. * @returns the current particle system
  69377. */
  69378. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69379. /**
  69380. * Remove a specific drag gradient
  69381. * @param gradient defines the gradient to remove
  69382. * @returns the current particle system
  69383. */
  69384. removeDragGradient(gradient: number): GPUParticleSystem;
  69385. /**
  69386. * Not supported by GPUParticleSystem
  69387. * @param gradient defines the gradient to use (between 0 and 1)
  69388. * @param factor defines the emit rate value to affect to the specified gradient
  69389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69390. * @returns the current particle system
  69391. */
  69392. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69393. /**
  69394. * Not supported by GPUParticleSystem
  69395. * @param gradient defines the gradient to remove
  69396. * @returns the current particle system
  69397. */
  69398. removeEmitRateGradient(gradient: number): IParticleSystem;
  69399. /**
  69400. * Not supported by GPUParticleSystem
  69401. * @param gradient defines the gradient to use (between 0 and 1)
  69402. * @param factor defines the start size value to affect to the specified gradient
  69403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69404. * @returns the current particle system
  69405. */
  69406. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69407. /**
  69408. * Not supported by GPUParticleSystem
  69409. * @param gradient defines the gradient to remove
  69410. * @returns the current particle system
  69411. */
  69412. removeStartSizeGradient(gradient: number): IParticleSystem;
  69413. /**
  69414. * Not supported by GPUParticleSystem
  69415. * @param gradient defines the gradient to use (between 0 and 1)
  69416. * @param min defines the color remap minimal range
  69417. * @param max defines the color remap maximal range
  69418. * @returns the current particle system
  69419. */
  69420. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69421. /**
  69422. * Not supported by GPUParticleSystem
  69423. * @param gradient defines the gradient to remove
  69424. * @returns the current particle system
  69425. */
  69426. removeColorRemapGradient(): IParticleSystem;
  69427. /**
  69428. * Not supported by GPUParticleSystem
  69429. * @param gradient defines the gradient to use (between 0 and 1)
  69430. * @param min defines the alpha remap minimal range
  69431. * @param max defines the alpha remap maximal range
  69432. * @returns the current particle system
  69433. */
  69434. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69435. /**
  69436. * Not supported by GPUParticleSystem
  69437. * @param gradient defines the gradient to remove
  69438. * @returns the current particle system
  69439. */
  69440. removeAlphaRemapGradient(): IParticleSystem;
  69441. /**
  69442. * Not supported by GPUParticleSystem
  69443. * @param gradient defines the gradient to use (between 0 and 1)
  69444. * @param color defines the color to affect to the specified gradient
  69445. * @returns the current particle system
  69446. */
  69447. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69448. /**
  69449. * Not supported by GPUParticleSystem
  69450. * @param gradient defines the gradient to remove
  69451. * @returns the current particle system
  69452. */
  69453. removeRampGradient(): IParticleSystem;
  69454. /**
  69455. * Not supported by GPUParticleSystem
  69456. * @returns the list of ramp gradients
  69457. */
  69458. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69459. /**
  69460. * Not supported by GPUParticleSystem
  69461. * Gets or sets a boolean indicating that ramp gradients must be used
  69462. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69463. */
  69464. get useRampGradients(): boolean;
  69465. set useRampGradients(value: boolean);
  69466. /**
  69467. * Not supported by GPUParticleSystem
  69468. * @param gradient defines the gradient to use (between 0 and 1)
  69469. * @param factor defines the life time factor to affect to the specified gradient
  69470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69471. * @returns the current particle system
  69472. */
  69473. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69474. /**
  69475. * Not supported by GPUParticleSystem
  69476. * @param gradient defines the gradient to remove
  69477. * @returns the current particle system
  69478. */
  69479. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69480. /**
  69481. * Instantiates a GPU particle system.
  69482. * 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.
  69483. * @param name The name of the particle system
  69484. * @param options The options used to create the system
  69485. * @param scene The scene the particle system belongs to
  69486. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69487. * @param customEffect a custom effect used to change the way particles are rendered by default
  69488. */
  69489. constructor(name: string, options: Partial<{
  69490. capacity: number;
  69491. randomTextureSize: number;
  69492. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69493. protected _reset(): void;
  69494. private _createUpdateVAO;
  69495. private _createRenderVAO;
  69496. private _initialize;
  69497. /** @hidden */
  69498. _recreateUpdateEffect(): void;
  69499. private _getEffect;
  69500. /**
  69501. * Fill the defines array according to the current settings of the particle system
  69502. * @param defines Array to be updated
  69503. * @param blendMode blend mode to take into account when updating the array
  69504. */
  69505. fillDefines(defines: Array<string>, blendMode?: number): void;
  69506. /**
  69507. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69508. * @param uniforms Uniforms array to fill
  69509. * @param attributes Attributes array to fill
  69510. * @param samplers Samplers array to fill
  69511. */
  69512. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69513. /** @hidden */
  69514. _recreateRenderEffect(): Effect;
  69515. /**
  69516. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69517. * @param preWarm defines if we are in the pre-warmimg phase
  69518. */
  69519. animate(preWarm?: boolean): void;
  69520. private _createFactorGradientTexture;
  69521. private _createSizeGradientTexture;
  69522. private _createAngularSpeedGradientTexture;
  69523. private _createVelocityGradientTexture;
  69524. private _createLimitVelocityGradientTexture;
  69525. private _createDragGradientTexture;
  69526. private _createColorGradientTexture;
  69527. /**
  69528. * Renders the particle system in its current state
  69529. * @param preWarm defines if the system should only update the particles but not render them
  69530. * @returns the current number of particles
  69531. */
  69532. render(preWarm?: boolean): number;
  69533. /**
  69534. * Rebuilds the particle system
  69535. */
  69536. rebuild(): void;
  69537. private _releaseBuffers;
  69538. private _releaseVAOs;
  69539. /**
  69540. * Disposes the particle system and free the associated resources
  69541. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69542. */
  69543. dispose(disposeTexture?: boolean): void;
  69544. /**
  69545. * Clones the particle system.
  69546. * @param name The name of the cloned object
  69547. * @param newEmitter The new emitter to use
  69548. * @returns the cloned particle system
  69549. */
  69550. clone(name: string, newEmitter: any): GPUParticleSystem;
  69551. /**
  69552. * Serializes the particle system to a JSON object
  69553. * @param serializeTexture defines if the texture must be serialized as well
  69554. * @returns the JSON object
  69555. */
  69556. serialize(serializeTexture?: boolean): any;
  69557. /**
  69558. * Parses a JSON object to create a GPU particle system.
  69559. * @param parsedParticleSystem The JSON object to parse
  69560. * @param scene The scene to create the particle system in
  69561. * @param rootUrl The root url to use to load external dependencies like texture
  69562. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69563. * @returns the parsed GPU particle system
  69564. */
  69565. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69566. }
  69567. }
  69568. declare module "babylonjs/Particles/particleSystemSet" {
  69569. import { Nullable } from "babylonjs/types";
  69570. import { Color3 } from "babylonjs/Maths/math.color";
  69571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69573. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69574. import { Scene, IDisposable } from "babylonjs/scene";
  69575. /**
  69576. * Represents a set of particle systems working together to create a specific effect
  69577. */
  69578. export class ParticleSystemSet implements IDisposable {
  69579. /**
  69580. * Gets or sets base Assets URL
  69581. */
  69582. static BaseAssetsUrl: string;
  69583. private _emitterCreationOptions;
  69584. private _emitterNode;
  69585. /**
  69586. * Gets the particle system list
  69587. */
  69588. systems: IParticleSystem[];
  69589. /**
  69590. * Gets the emitter node used with this set
  69591. */
  69592. get emitterNode(): Nullable<TransformNode>;
  69593. /**
  69594. * Creates a new emitter mesh as a sphere
  69595. * @param options defines the options used to create the sphere
  69596. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69597. * @param scene defines the hosting scene
  69598. */
  69599. setEmitterAsSphere(options: {
  69600. diameter: number;
  69601. segments: number;
  69602. color: Color3;
  69603. }, renderingGroupId: number, scene: Scene): void;
  69604. /**
  69605. * Starts all particle systems of the set
  69606. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69607. */
  69608. start(emitter?: AbstractMesh): void;
  69609. /**
  69610. * Release all associated resources
  69611. */
  69612. dispose(): void;
  69613. /**
  69614. * Serialize the set into a JSON compatible object
  69615. * @param serializeTexture defines if the texture must be serialized as well
  69616. * @returns a JSON compatible representation of the set
  69617. */
  69618. serialize(serializeTexture?: boolean): any;
  69619. /**
  69620. * Parse a new ParticleSystemSet from a serialized source
  69621. * @param data defines a JSON compatible representation of the set
  69622. * @param scene defines the hosting scene
  69623. * @param gpu defines if we want GPU particles or CPU particles
  69624. * @returns a new ParticleSystemSet
  69625. */
  69626. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69627. }
  69628. }
  69629. declare module "babylonjs/Particles/particleHelper" {
  69630. import { Nullable } from "babylonjs/types";
  69631. import { Scene } from "babylonjs/scene";
  69632. import { Vector3 } from "babylonjs/Maths/math.vector";
  69633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69634. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69635. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  69636. /**
  69637. * This class is made for on one-liner static method to help creating particle system set.
  69638. */
  69639. export class ParticleHelper {
  69640. /**
  69641. * Gets or sets base Assets URL
  69642. */
  69643. static BaseAssetsUrl: string;
  69644. /** Define the Url to load snippets */
  69645. static SnippetUrl: string;
  69646. /**
  69647. * Create a default particle system that you can tweak
  69648. * @param emitter defines the emitter to use
  69649. * @param capacity defines the system capacity (default is 500 particles)
  69650. * @param scene defines the hosting scene
  69651. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69652. * @returns the new Particle system
  69653. */
  69654. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69655. /**
  69656. * This is the main static method (one-liner) of this helper to create different particle systems
  69657. * @param type This string represents the type to the particle system to create
  69658. * @param scene The scene where the particle system should live
  69659. * @param gpu If the system will use gpu
  69660. * @returns the ParticleSystemSet created
  69661. */
  69662. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69663. /**
  69664. * Static function used to export a particle system to a ParticleSystemSet variable.
  69665. * Please note that the emitter shape is not exported
  69666. * @param systems defines the particle systems to export
  69667. * @returns the created particle system set
  69668. */
  69669. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69670. /**
  69671. * Creates a particle system from a snippet saved in a remote file
  69672. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69673. * @param url defines the url to load from
  69674. * @param scene defines the hosting scene
  69675. * @param gpu If the system will use gpu
  69676. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69677. * @returns a promise that will resolve to the new particle system
  69678. */
  69679. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69680. /**
  69681. * Creates a particle system from a snippet saved by the particle system editor
  69682. * @param snippetId defines the snippet to load
  69683. * @param scene defines the hosting scene
  69684. * @param gpu If the system will use gpu
  69685. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69686. * @returns a promise that will resolve to the new particle system
  69687. */
  69688. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69689. }
  69690. }
  69691. declare module "babylonjs/Particles/particleSystemComponent" {
  69692. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69693. import { Effect } from "babylonjs/Materials/effect";
  69694. import "babylonjs/Shaders/particles.vertex";
  69695. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69696. module "babylonjs/Engines/engine" {
  69697. interface Engine {
  69698. /**
  69699. * Create an effect to use with particle systems.
  69700. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69701. * the particle system for which you want to create a custom effect in the last parameter
  69702. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69703. * @param uniformsNames defines a list of attribute names
  69704. * @param samplers defines an array of string used to represent textures
  69705. * @param defines defines the string containing the defines to use to compile the shaders
  69706. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69707. * @param onCompiled defines a function to call when the effect creation is successful
  69708. * @param onError defines a function to call when the effect creation has failed
  69709. * @param particleSystem the particle system you want to create the effect for
  69710. * @returns the new Effect
  69711. */
  69712. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69713. }
  69714. }
  69715. module "babylonjs/Meshes/mesh" {
  69716. interface Mesh {
  69717. /**
  69718. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69719. * @returns an array of IParticleSystem
  69720. */
  69721. getEmittedParticleSystems(): IParticleSystem[];
  69722. /**
  69723. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69724. * @returns an array of IParticleSystem
  69725. */
  69726. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69727. }
  69728. }
  69729. }
  69730. declare module "babylonjs/Particles/pointsCloudSystem" {
  69731. import { Color4 } from "babylonjs/Maths/math";
  69732. import { Mesh } from "babylonjs/Meshes/mesh";
  69733. import { Scene, IDisposable } from "babylonjs/scene";
  69734. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  69735. /** Defines the 4 color options */
  69736. export enum PointColor {
  69737. /** color value */
  69738. Color = 2,
  69739. /** uv value */
  69740. UV = 1,
  69741. /** random value */
  69742. Random = 0,
  69743. /** stated value */
  69744. Stated = 3
  69745. }
  69746. /**
  69747. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69748. * 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.
  69749. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69750. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69751. *
  69752. * Full documentation here : TO BE ENTERED
  69753. */
  69754. export class PointsCloudSystem implements IDisposable {
  69755. /**
  69756. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69757. * Example : var p = SPS.particles[i];
  69758. */
  69759. particles: CloudPoint[];
  69760. /**
  69761. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69762. */
  69763. nbParticles: number;
  69764. /**
  69765. * This a counter for your own usage. It's not set by any SPS functions.
  69766. */
  69767. counter: number;
  69768. /**
  69769. * The PCS name. This name is also given to the underlying mesh.
  69770. */
  69771. name: string;
  69772. /**
  69773. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69774. */
  69775. mesh: Mesh;
  69776. /**
  69777. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69778. * Please read :
  69779. */
  69780. vars: any;
  69781. /**
  69782. * @hidden
  69783. */
  69784. _size: number;
  69785. private _scene;
  69786. private _promises;
  69787. private _positions;
  69788. private _indices;
  69789. private _normals;
  69790. private _colors;
  69791. private _uvs;
  69792. private _indices32;
  69793. private _positions32;
  69794. private _colors32;
  69795. private _uvs32;
  69796. private _updatable;
  69797. private _isVisibilityBoxLocked;
  69798. private _alwaysVisible;
  69799. private _groups;
  69800. private _groupCounter;
  69801. private _computeParticleColor;
  69802. private _computeParticleTexture;
  69803. private _computeParticleRotation;
  69804. private _computeBoundingBox;
  69805. private _isReady;
  69806. /**
  69807. * Creates a PCS (Points Cloud System) object
  69808. * @param name (String) is the PCS name, this will be the underlying mesh name
  69809. * @param pointSize (number) is the size for each point
  69810. * @param scene (Scene) is the scene in which the PCS is added
  69811. * @param options defines the options of the PCS e.g.
  69812. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69813. */
  69814. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69815. updatable?: boolean;
  69816. });
  69817. /**
  69818. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69819. * If no points were added to the PCS, the returned mesh is just a single point.
  69820. * @returns a promise for the created mesh
  69821. */
  69822. buildMeshAsync(): Promise<Mesh>;
  69823. /**
  69824. * @hidden
  69825. */
  69826. private _buildMesh;
  69827. private _addParticle;
  69828. private _randomUnitVector;
  69829. private _getColorIndicesForCoord;
  69830. private _setPointsColorOrUV;
  69831. private _colorFromTexture;
  69832. private _calculateDensity;
  69833. /**
  69834. * Adds points to the PCS in random positions within a unit sphere
  69835. * @param nb (positive integer) the number of particles to be created from this model
  69836. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69837. * @returns the number of groups in the system
  69838. */
  69839. addPoints(nb: number, pointFunction?: any): number;
  69840. /**
  69841. * Adds points to the PCS from the surface of the model shape
  69842. * @param mesh is any Mesh object that will be used as a surface model for the points
  69843. * @param nb (positive integer) the number of particles to be created from this model
  69844. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69845. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69846. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69847. * @returns the number of groups in the system
  69848. */
  69849. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69850. /**
  69851. * Adds points to the PCS inside the model shape
  69852. * @param mesh is any Mesh object that will be used as a surface model for the points
  69853. * @param nb (positive integer) the number of particles to be created from this model
  69854. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69855. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69856. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69857. * @returns the number of groups in the system
  69858. */
  69859. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69860. /**
  69861. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69862. * This method calls `updateParticle()` for each particle of the SPS.
  69863. * For an animated SPS, it is usually called within the render loop.
  69864. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69865. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69866. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69867. * @returns the PCS.
  69868. */
  69869. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69870. /**
  69871. * Disposes the PCS.
  69872. */
  69873. dispose(): void;
  69874. /**
  69875. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69876. * doc :
  69877. * @returns the PCS.
  69878. */
  69879. refreshVisibleSize(): PointsCloudSystem;
  69880. /**
  69881. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69882. * @param size the size (float) of the visibility box
  69883. * note : this doesn't lock the PCS mesh bounding box.
  69884. * doc :
  69885. */
  69886. setVisibilityBox(size: number): void;
  69887. /**
  69888. * Gets whether the PCS is always visible or not
  69889. * doc :
  69890. */
  69891. get isAlwaysVisible(): boolean;
  69892. /**
  69893. * Sets the PCS as always visible or not
  69894. * doc :
  69895. */
  69896. set isAlwaysVisible(val: boolean);
  69897. /**
  69898. * Tells to `setParticles()` to compute the particle rotations or not
  69899. * Default value : false. The PCS is faster when it's set to false
  69900. * Note : particle rotations are only applied to parent particles
  69901. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69902. */
  69903. set computeParticleRotation(val: boolean);
  69904. /**
  69905. * Tells to `setParticles()` to compute the particle colors or not.
  69906. * Default value : true. The PCS is faster when it's set to false.
  69907. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69908. */
  69909. set computeParticleColor(val: boolean);
  69910. set computeParticleTexture(val: boolean);
  69911. /**
  69912. * Gets if `setParticles()` computes the particle colors or not.
  69913. * Default value : false. The PCS is faster when it's set to false.
  69914. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69915. */
  69916. get computeParticleColor(): boolean;
  69917. /**
  69918. * Gets if `setParticles()` computes the particle textures or not.
  69919. * Default value : false. The PCS is faster when it's set to false.
  69920. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69921. */
  69922. get computeParticleTexture(): boolean;
  69923. /**
  69924. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69925. */
  69926. set computeBoundingBox(val: boolean);
  69927. /**
  69928. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69929. */
  69930. get computeBoundingBox(): boolean;
  69931. /**
  69932. * This function does nothing. It may be overwritten to set all the particle first values.
  69933. * The PCS doesn't call this function, you may have to call it by your own.
  69934. * doc :
  69935. */
  69936. initParticles(): void;
  69937. /**
  69938. * This function does nothing. It may be overwritten to recycle a particle
  69939. * The PCS doesn't call this function, you can to call it
  69940. * doc :
  69941. * @param particle The particle to recycle
  69942. * @returns the recycled particle
  69943. */
  69944. recycleParticle(particle: CloudPoint): CloudPoint;
  69945. /**
  69946. * Updates a particle : this function should be overwritten by the user.
  69947. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69948. * doc :
  69949. * @example : just set a particle position or velocity and recycle conditions
  69950. * @param particle The particle to update
  69951. * @returns the updated particle
  69952. */
  69953. updateParticle(particle: CloudPoint): CloudPoint;
  69954. /**
  69955. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69956. * This does nothing and may be overwritten by the user.
  69957. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69958. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69959. * @param update the boolean update value actually passed to setParticles()
  69960. */
  69961. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69962. /**
  69963. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69964. * This will be passed three parameters.
  69965. * This does nothing and may be overwritten by the user.
  69966. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69968. * @param update the boolean update value actually passed to setParticles()
  69969. */
  69970. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69971. }
  69972. }
  69973. declare module "babylonjs/Particles/cloudPoint" {
  69974. import { Nullable } from "babylonjs/types";
  69975. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  69976. import { Mesh } from "babylonjs/Meshes/mesh";
  69977. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  69978. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  69979. /**
  69980. * Represents one particle of a points cloud system.
  69981. */
  69982. export class CloudPoint {
  69983. /**
  69984. * particle global index
  69985. */
  69986. idx: number;
  69987. /**
  69988. * The color of the particle
  69989. */
  69990. color: Nullable<Color4>;
  69991. /**
  69992. * The world space position of the particle.
  69993. */
  69994. position: Vector3;
  69995. /**
  69996. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69997. */
  69998. rotation: Vector3;
  69999. /**
  70000. * The world space rotation quaternion of the particle.
  70001. */
  70002. rotationQuaternion: Nullable<Quaternion>;
  70003. /**
  70004. * The uv of the particle.
  70005. */
  70006. uv: Nullable<Vector2>;
  70007. /**
  70008. * The current speed of the particle.
  70009. */
  70010. velocity: Vector3;
  70011. /**
  70012. * The pivot point in the particle local space.
  70013. */
  70014. pivot: Vector3;
  70015. /**
  70016. * Must the particle be translated from its pivot point in its local space ?
  70017. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70018. * Default : false
  70019. */
  70020. translateFromPivot: boolean;
  70021. /**
  70022. * Index of this particle in the global "positions" array (Internal use)
  70023. * @hidden
  70024. */
  70025. _pos: number;
  70026. /**
  70027. * @hidden Index of this particle in the global "indices" array (Internal use)
  70028. */
  70029. _ind: number;
  70030. /**
  70031. * Group this particle belongs to
  70032. */
  70033. _group: PointsGroup;
  70034. /**
  70035. * Group id of this particle
  70036. */
  70037. groupId: number;
  70038. /**
  70039. * Index of the particle in its group id (Internal use)
  70040. */
  70041. idxInGroup: number;
  70042. /**
  70043. * @hidden Particle BoundingInfo object (Internal use)
  70044. */
  70045. _boundingInfo: BoundingInfo;
  70046. /**
  70047. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70048. */
  70049. _pcs: PointsCloudSystem;
  70050. /**
  70051. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70052. */
  70053. _stillInvisible: boolean;
  70054. /**
  70055. * @hidden Last computed particle rotation matrix
  70056. */
  70057. _rotationMatrix: number[];
  70058. /**
  70059. * Parent particle Id, if any.
  70060. * Default null.
  70061. */
  70062. parentId: Nullable<number>;
  70063. /**
  70064. * @hidden Internal global position in the PCS.
  70065. */
  70066. _globalPosition: Vector3;
  70067. /**
  70068. * Creates a Point Cloud object.
  70069. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70070. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70071. * @param group (PointsGroup) is the group the particle belongs to
  70072. * @param groupId (integer) is the group identifier in the PCS.
  70073. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70074. * @param pcs defines the PCS it is associated to
  70075. */
  70076. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70077. /**
  70078. * get point size
  70079. */
  70080. get size(): Vector3;
  70081. /**
  70082. * Set point size
  70083. */
  70084. set size(scale: Vector3);
  70085. /**
  70086. * Legacy support, changed quaternion to rotationQuaternion
  70087. */
  70088. get quaternion(): Nullable<Quaternion>;
  70089. /**
  70090. * Legacy support, changed quaternion to rotationQuaternion
  70091. */
  70092. set quaternion(q: Nullable<Quaternion>);
  70093. /**
  70094. * Returns a boolean. True if the particle intersects a mesh, else false
  70095. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70096. * @param target is the object (point or mesh) what the intersection is computed against
  70097. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70098. * @returns true if it intersects
  70099. */
  70100. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70101. /**
  70102. * get the rotation matrix of the particle
  70103. * @hidden
  70104. */
  70105. getRotationMatrix(m: Matrix): void;
  70106. }
  70107. /**
  70108. * Represents a group of points in a points cloud system
  70109. * * PCS internal tool, don't use it manually.
  70110. */
  70111. export class PointsGroup {
  70112. /**
  70113. * The group id
  70114. * @hidden
  70115. */
  70116. groupID: number;
  70117. /**
  70118. * image data for group (internal use)
  70119. * @hidden
  70120. */
  70121. _groupImageData: Nullable<ArrayBufferView>;
  70122. /**
  70123. * Image Width (internal use)
  70124. * @hidden
  70125. */
  70126. _groupImgWidth: number;
  70127. /**
  70128. * Image Height (internal use)
  70129. * @hidden
  70130. */
  70131. _groupImgHeight: number;
  70132. /**
  70133. * Custom position function (internal use)
  70134. * @hidden
  70135. */
  70136. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70137. /**
  70138. * density per facet for surface points
  70139. * @hidden
  70140. */
  70141. _groupDensity: number[];
  70142. /**
  70143. * Only when points are colored by texture carries pointer to texture list array
  70144. * @hidden
  70145. */
  70146. _textureNb: number;
  70147. /**
  70148. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70149. * PCS internal tool, don't use it manually.
  70150. * @hidden
  70151. */
  70152. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70153. }
  70154. }
  70155. declare module "babylonjs/Particles/index" {
  70156. export * from "babylonjs/Particles/baseParticleSystem";
  70157. export * from "babylonjs/Particles/EmitterTypes/index";
  70158. export * from "babylonjs/Particles/gpuParticleSystem";
  70159. export * from "babylonjs/Particles/IParticleSystem";
  70160. export * from "babylonjs/Particles/particle";
  70161. export * from "babylonjs/Particles/particleHelper";
  70162. export * from "babylonjs/Particles/particleSystem";
  70163. import "babylonjs/Particles/particleSystemComponent";
  70164. export * from "babylonjs/Particles/particleSystemComponent";
  70165. export * from "babylonjs/Particles/particleSystemSet";
  70166. export * from "babylonjs/Particles/solidParticle";
  70167. export * from "babylonjs/Particles/solidParticleSystem";
  70168. export * from "babylonjs/Particles/cloudPoint";
  70169. export * from "babylonjs/Particles/pointsCloudSystem";
  70170. export * from "babylonjs/Particles/subEmitter";
  70171. }
  70172. declare module "babylonjs/Physics/physicsEngineComponent" {
  70173. import { Nullable } from "babylonjs/types";
  70174. import { Observable, Observer } from "babylonjs/Misc/observable";
  70175. import { Vector3 } from "babylonjs/Maths/math.vector";
  70176. import { Mesh } from "babylonjs/Meshes/mesh";
  70177. import { ISceneComponent } from "babylonjs/sceneComponent";
  70178. import { Scene } from "babylonjs/scene";
  70179. import { Node } from "babylonjs/node";
  70180. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70181. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70182. module "babylonjs/scene" {
  70183. interface Scene {
  70184. /** @hidden (Backing field) */
  70185. _physicsEngine: Nullable<IPhysicsEngine>;
  70186. /** @hidden */
  70187. _physicsTimeAccumulator: number;
  70188. /**
  70189. * Gets the current physics engine
  70190. * @returns a IPhysicsEngine or null if none attached
  70191. */
  70192. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70193. /**
  70194. * Enables physics to the current scene
  70195. * @param gravity defines the scene's gravity for the physics engine
  70196. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70197. * @return a boolean indicating if the physics engine was initialized
  70198. */
  70199. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70200. /**
  70201. * Disables and disposes the physics engine associated with the scene
  70202. */
  70203. disablePhysicsEngine(): void;
  70204. /**
  70205. * Gets a boolean indicating if there is an active physics engine
  70206. * @returns a boolean indicating if there is an active physics engine
  70207. */
  70208. isPhysicsEnabled(): boolean;
  70209. /**
  70210. * Deletes a physics compound impostor
  70211. * @param compound defines the compound to delete
  70212. */
  70213. deleteCompoundImpostor(compound: any): void;
  70214. /**
  70215. * An event triggered when physic simulation is about to be run
  70216. */
  70217. onBeforePhysicsObservable: Observable<Scene>;
  70218. /**
  70219. * An event triggered when physic simulation has been done
  70220. */
  70221. onAfterPhysicsObservable: Observable<Scene>;
  70222. }
  70223. }
  70224. module "babylonjs/Meshes/abstractMesh" {
  70225. interface AbstractMesh {
  70226. /** @hidden */
  70227. _physicsImpostor: Nullable<PhysicsImpostor>;
  70228. /**
  70229. * Gets or sets impostor used for physic simulation
  70230. * @see http://doc.babylonjs.com/features/physics_engine
  70231. */
  70232. physicsImpostor: Nullable<PhysicsImpostor>;
  70233. /**
  70234. * Gets the current physics impostor
  70235. * @see http://doc.babylonjs.com/features/physics_engine
  70236. * @returns a physics impostor or null
  70237. */
  70238. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70239. /** Apply a physic impulse to the mesh
  70240. * @param force defines the force to apply
  70241. * @param contactPoint defines where to apply the force
  70242. * @returns the current mesh
  70243. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70244. */
  70245. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70246. /**
  70247. * Creates a physic joint between two meshes
  70248. * @param otherMesh defines the other mesh to use
  70249. * @param pivot1 defines the pivot to use on this mesh
  70250. * @param pivot2 defines the pivot to use on the other mesh
  70251. * @param options defines additional options (can be plugin dependent)
  70252. * @returns the current mesh
  70253. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70254. */
  70255. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70256. /** @hidden */
  70257. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70258. }
  70259. }
  70260. /**
  70261. * Defines the physics engine scene component responsible to manage a physics engine
  70262. */
  70263. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70264. /**
  70265. * The component name helpful to identify the component in the list of scene components.
  70266. */
  70267. readonly name: string;
  70268. /**
  70269. * The scene the component belongs to.
  70270. */
  70271. scene: Scene;
  70272. /**
  70273. * Creates a new instance of the component for the given scene
  70274. * @param scene Defines the scene to register the component in
  70275. */
  70276. constructor(scene: Scene);
  70277. /**
  70278. * Registers the component in a given scene
  70279. */
  70280. register(): void;
  70281. /**
  70282. * Rebuilds the elements related to this component in case of
  70283. * context lost for instance.
  70284. */
  70285. rebuild(): void;
  70286. /**
  70287. * Disposes the component and the associated ressources
  70288. */
  70289. dispose(): void;
  70290. }
  70291. }
  70292. declare module "babylonjs/Physics/physicsHelper" {
  70293. import { Nullable } from "babylonjs/types";
  70294. import { Vector3 } from "babylonjs/Maths/math.vector";
  70295. import { Mesh } from "babylonjs/Meshes/mesh";
  70296. import { Scene } from "babylonjs/scene";
  70297. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70298. /**
  70299. * A helper for physics simulations
  70300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70301. */
  70302. export class PhysicsHelper {
  70303. private _scene;
  70304. private _physicsEngine;
  70305. /**
  70306. * Initializes the Physics helper
  70307. * @param scene Babylon.js scene
  70308. */
  70309. constructor(scene: Scene);
  70310. /**
  70311. * Applies a radial explosion impulse
  70312. * @param origin the origin of the explosion
  70313. * @param radiusOrEventOptions the radius or the options of radial explosion
  70314. * @param strength the explosion strength
  70315. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70316. * @returns A physics radial explosion event, or null
  70317. */
  70318. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70319. /**
  70320. * Applies a radial explosion force
  70321. * @param origin the origin of the explosion
  70322. * @param radiusOrEventOptions the radius or the options of radial explosion
  70323. * @param strength the explosion strength
  70324. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70325. * @returns A physics radial explosion event, or null
  70326. */
  70327. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70328. /**
  70329. * Creates a gravitational field
  70330. * @param origin the origin of the explosion
  70331. * @param radiusOrEventOptions the radius or the options of radial explosion
  70332. * @param strength the explosion strength
  70333. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70334. * @returns A physics gravitational field event, or null
  70335. */
  70336. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70337. /**
  70338. * Creates a physics updraft event
  70339. * @param origin the origin of the updraft
  70340. * @param radiusOrEventOptions the radius or the options of the updraft
  70341. * @param strength the strength of the updraft
  70342. * @param height the height of the updraft
  70343. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70344. * @returns A physics updraft event, or null
  70345. */
  70346. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70347. /**
  70348. * Creates a physics vortex event
  70349. * @param origin the of the vortex
  70350. * @param radiusOrEventOptions the radius or the options of the vortex
  70351. * @param strength the strength of the vortex
  70352. * @param height the height of the vortex
  70353. * @returns a Physics vortex event, or null
  70354. * A physics vortex event or null
  70355. */
  70356. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70357. }
  70358. /**
  70359. * Represents a physics radial explosion event
  70360. */
  70361. class PhysicsRadialExplosionEvent {
  70362. private _scene;
  70363. private _options;
  70364. private _sphere;
  70365. private _dataFetched;
  70366. /**
  70367. * Initializes a radial explosioin event
  70368. * @param _scene BabylonJS scene
  70369. * @param _options The options for the vortex event
  70370. */
  70371. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70372. /**
  70373. * Returns the data related to the radial explosion event (sphere).
  70374. * @returns The radial explosion event data
  70375. */
  70376. getData(): PhysicsRadialExplosionEventData;
  70377. /**
  70378. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70379. * @param impostor A physics imposter
  70380. * @param origin the origin of the explosion
  70381. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70382. */
  70383. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70384. /**
  70385. * Triggers affecterd impostors callbacks
  70386. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70387. */
  70388. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70389. /**
  70390. * Disposes the sphere.
  70391. * @param force Specifies if the sphere should be disposed by force
  70392. */
  70393. dispose(force?: boolean): void;
  70394. /*** Helpers ***/
  70395. private _prepareSphere;
  70396. private _intersectsWithSphere;
  70397. }
  70398. /**
  70399. * Represents a gravitational field event
  70400. */
  70401. class PhysicsGravitationalFieldEvent {
  70402. private _physicsHelper;
  70403. private _scene;
  70404. private _origin;
  70405. private _options;
  70406. private _tickCallback;
  70407. private _sphere;
  70408. private _dataFetched;
  70409. /**
  70410. * Initializes the physics gravitational field event
  70411. * @param _physicsHelper A physics helper
  70412. * @param _scene BabylonJS scene
  70413. * @param _origin The origin position of the gravitational field event
  70414. * @param _options The options for the vortex event
  70415. */
  70416. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70417. /**
  70418. * Returns the data related to the gravitational field event (sphere).
  70419. * @returns A gravitational field event
  70420. */
  70421. getData(): PhysicsGravitationalFieldEventData;
  70422. /**
  70423. * Enables the gravitational field.
  70424. */
  70425. enable(): void;
  70426. /**
  70427. * Disables the gravitational field.
  70428. */
  70429. disable(): void;
  70430. /**
  70431. * Disposes the sphere.
  70432. * @param force The force to dispose from the gravitational field event
  70433. */
  70434. dispose(force?: boolean): void;
  70435. private _tick;
  70436. }
  70437. /**
  70438. * Represents a physics updraft event
  70439. */
  70440. class PhysicsUpdraftEvent {
  70441. private _scene;
  70442. private _origin;
  70443. private _options;
  70444. private _physicsEngine;
  70445. private _originTop;
  70446. private _originDirection;
  70447. private _tickCallback;
  70448. private _cylinder;
  70449. private _cylinderPosition;
  70450. private _dataFetched;
  70451. /**
  70452. * Initializes the physics updraft event
  70453. * @param _scene BabylonJS scene
  70454. * @param _origin The origin position of the updraft
  70455. * @param _options The options for the updraft event
  70456. */
  70457. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70458. /**
  70459. * Returns the data related to the updraft event (cylinder).
  70460. * @returns A physics updraft event
  70461. */
  70462. getData(): PhysicsUpdraftEventData;
  70463. /**
  70464. * Enables the updraft.
  70465. */
  70466. enable(): void;
  70467. /**
  70468. * Disables the updraft.
  70469. */
  70470. disable(): void;
  70471. /**
  70472. * Disposes the cylinder.
  70473. * @param force Specifies if the updraft should be disposed by force
  70474. */
  70475. dispose(force?: boolean): void;
  70476. private getImpostorHitData;
  70477. private _tick;
  70478. /*** Helpers ***/
  70479. private _prepareCylinder;
  70480. private _intersectsWithCylinder;
  70481. }
  70482. /**
  70483. * Represents a physics vortex event
  70484. */
  70485. class PhysicsVortexEvent {
  70486. private _scene;
  70487. private _origin;
  70488. private _options;
  70489. private _physicsEngine;
  70490. private _originTop;
  70491. private _tickCallback;
  70492. private _cylinder;
  70493. private _cylinderPosition;
  70494. private _dataFetched;
  70495. /**
  70496. * Initializes the physics vortex event
  70497. * @param _scene The BabylonJS scene
  70498. * @param _origin The origin position of the vortex
  70499. * @param _options The options for the vortex event
  70500. */
  70501. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70502. /**
  70503. * Returns the data related to the vortex event (cylinder).
  70504. * @returns The physics vortex event data
  70505. */
  70506. getData(): PhysicsVortexEventData;
  70507. /**
  70508. * Enables the vortex.
  70509. */
  70510. enable(): void;
  70511. /**
  70512. * Disables the cortex.
  70513. */
  70514. disable(): void;
  70515. /**
  70516. * Disposes the sphere.
  70517. * @param force
  70518. */
  70519. dispose(force?: boolean): void;
  70520. private getImpostorHitData;
  70521. private _tick;
  70522. /*** Helpers ***/
  70523. private _prepareCylinder;
  70524. private _intersectsWithCylinder;
  70525. }
  70526. /**
  70527. * Options fot the radial explosion event
  70528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70529. */
  70530. export class PhysicsRadialExplosionEventOptions {
  70531. /**
  70532. * The radius of the sphere for the radial explosion.
  70533. */
  70534. radius: number;
  70535. /**
  70536. * The strenth of the explosion.
  70537. */
  70538. strength: number;
  70539. /**
  70540. * The strenght of the force in correspondence to the distance of the affected object
  70541. */
  70542. falloff: PhysicsRadialImpulseFalloff;
  70543. /**
  70544. * Sphere options for the radial explosion.
  70545. */
  70546. sphere: {
  70547. segments: number;
  70548. diameter: number;
  70549. };
  70550. /**
  70551. * Sphere options for the radial explosion.
  70552. */
  70553. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70554. }
  70555. /**
  70556. * Options fot the updraft event
  70557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70558. */
  70559. export class PhysicsUpdraftEventOptions {
  70560. /**
  70561. * The radius of the cylinder for the vortex
  70562. */
  70563. radius: number;
  70564. /**
  70565. * The strenth of the updraft.
  70566. */
  70567. strength: number;
  70568. /**
  70569. * The height of the cylinder for the updraft.
  70570. */
  70571. height: number;
  70572. /**
  70573. * The mode for the the updraft.
  70574. */
  70575. updraftMode: PhysicsUpdraftMode;
  70576. }
  70577. /**
  70578. * Options fot the vortex event
  70579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70580. */
  70581. export class PhysicsVortexEventOptions {
  70582. /**
  70583. * The radius of the cylinder for the vortex
  70584. */
  70585. radius: number;
  70586. /**
  70587. * The strenth of the vortex.
  70588. */
  70589. strength: number;
  70590. /**
  70591. * The height of the cylinder for the vortex.
  70592. */
  70593. height: number;
  70594. /**
  70595. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70596. */
  70597. centripetalForceThreshold: number;
  70598. /**
  70599. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70600. */
  70601. centripetalForceMultiplier: number;
  70602. /**
  70603. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70604. */
  70605. centrifugalForceMultiplier: number;
  70606. /**
  70607. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70608. */
  70609. updraftForceMultiplier: number;
  70610. }
  70611. /**
  70612. * The strenght of the force in correspondence to the distance of the affected object
  70613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70614. */
  70615. export enum PhysicsRadialImpulseFalloff {
  70616. /** Defines that impulse is constant in strength across it's whole radius */
  70617. Constant = 0,
  70618. /** Defines that impulse gets weaker if it's further from the origin */
  70619. Linear = 1
  70620. }
  70621. /**
  70622. * The strength of the force in correspondence to the distance of the affected object
  70623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70624. */
  70625. export enum PhysicsUpdraftMode {
  70626. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70627. Center = 0,
  70628. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70629. Perpendicular = 1
  70630. }
  70631. /**
  70632. * Interface for a physics hit data
  70633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70634. */
  70635. export interface PhysicsHitData {
  70636. /**
  70637. * The force applied at the contact point
  70638. */
  70639. force: Vector3;
  70640. /**
  70641. * The contact point
  70642. */
  70643. contactPoint: Vector3;
  70644. /**
  70645. * The distance from the origin to the contact point
  70646. */
  70647. distanceFromOrigin: number;
  70648. }
  70649. /**
  70650. * Interface for radial explosion event data
  70651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70652. */
  70653. export interface PhysicsRadialExplosionEventData {
  70654. /**
  70655. * A sphere used for the radial explosion event
  70656. */
  70657. sphere: Mesh;
  70658. }
  70659. /**
  70660. * Interface for gravitational field event data
  70661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70662. */
  70663. export interface PhysicsGravitationalFieldEventData {
  70664. /**
  70665. * A sphere mesh used for the gravitational field event
  70666. */
  70667. sphere: Mesh;
  70668. }
  70669. /**
  70670. * Interface for updraft event data
  70671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70672. */
  70673. export interface PhysicsUpdraftEventData {
  70674. /**
  70675. * A cylinder used for the updraft event
  70676. */
  70677. cylinder: Mesh;
  70678. }
  70679. /**
  70680. * Interface for vortex event data
  70681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70682. */
  70683. export interface PhysicsVortexEventData {
  70684. /**
  70685. * A cylinder used for the vortex event
  70686. */
  70687. cylinder: Mesh;
  70688. }
  70689. /**
  70690. * Interface for an affected physics impostor
  70691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70692. */
  70693. export interface PhysicsAffectedImpostorWithData {
  70694. /**
  70695. * The impostor affected by the effect
  70696. */
  70697. impostor: PhysicsImpostor;
  70698. /**
  70699. * The data about the hit/horce from the explosion
  70700. */
  70701. hitData: PhysicsHitData;
  70702. }
  70703. }
  70704. declare module "babylonjs/Physics/Plugins/index" {
  70705. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  70706. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  70707. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  70708. }
  70709. declare module "babylonjs/Physics/index" {
  70710. export * from "babylonjs/Physics/IPhysicsEngine";
  70711. export * from "babylonjs/Physics/physicsEngine";
  70712. export * from "babylonjs/Physics/physicsEngineComponent";
  70713. export * from "babylonjs/Physics/physicsHelper";
  70714. export * from "babylonjs/Physics/physicsImpostor";
  70715. export * from "babylonjs/Physics/physicsJoint";
  70716. export * from "babylonjs/Physics/Plugins/index";
  70717. }
  70718. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  70719. /** @hidden */
  70720. export var blackAndWhitePixelShader: {
  70721. name: string;
  70722. shader: string;
  70723. };
  70724. }
  70725. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  70726. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70727. import { Camera } from "babylonjs/Cameras/camera";
  70728. import { Engine } from "babylonjs/Engines/engine";
  70729. import "babylonjs/Shaders/blackAndWhite.fragment";
  70730. /**
  70731. * Post process used to render in black and white
  70732. */
  70733. export class BlackAndWhitePostProcess extends PostProcess {
  70734. /**
  70735. * Linear about to convert he result to black and white (default: 1)
  70736. */
  70737. degree: number;
  70738. /**
  70739. * Creates a black and white post process
  70740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70741. * @param name The name of the effect.
  70742. * @param options The required width/height ratio to downsize to before computing the render pass.
  70743. * @param camera The camera to apply the render pass to.
  70744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70745. * @param engine The engine which the post process will be applied. (default: current engine)
  70746. * @param reusable If the post process can be reused on the same frame. (default: false)
  70747. */
  70748. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70749. }
  70750. }
  70751. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  70752. import { Nullable } from "babylonjs/types";
  70753. import { Camera } from "babylonjs/Cameras/camera";
  70754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70755. import { Engine } from "babylonjs/Engines/engine";
  70756. /**
  70757. * This represents a set of one or more post processes in Babylon.
  70758. * A post process can be used to apply a shader to a texture after it is rendered.
  70759. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70760. */
  70761. export class PostProcessRenderEffect {
  70762. private _postProcesses;
  70763. private _getPostProcesses;
  70764. private _singleInstance;
  70765. private _cameras;
  70766. private _indicesForCamera;
  70767. /**
  70768. * Name of the effect
  70769. * @hidden
  70770. */
  70771. _name: string;
  70772. /**
  70773. * Instantiates a post process render effect.
  70774. * A post process can be used to apply a shader to a texture after it is rendered.
  70775. * @param engine The engine the effect is tied to
  70776. * @param name The name of the effect
  70777. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70778. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70779. */
  70780. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70781. /**
  70782. * Checks if all the post processes in the effect are supported.
  70783. */
  70784. get isSupported(): boolean;
  70785. /**
  70786. * Updates the current state of the effect
  70787. * @hidden
  70788. */
  70789. _update(): void;
  70790. /**
  70791. * Attaches the effect on cameras
  70792. * @param cameras The camera to attach to.
  70793. * @hidden
  70794. */
  70795. _attachCameras(cameras: Camera): void;
  70796. /**
  70797. * Attaches the effect on cameras
  70798. * @param cameras The camera to attach to.
  70799. * @hidden
  70800. */
  70801. _attachCameras(cameras: Camera[]): void;
  70802. /**
  70803. * Detaches the effect on cameras
  70804. * @param cameras The camera to detatch from.
  70805. * @hidden
  70806. */
  70807. _detachCameras(cameras: Camera): void;
  70808. /**
  70809. * Detatches the effect on cameras
  70810. * @param cameras The camera to detatch from.
  70811. * @hidden
  70812. */
  70813. _detachCameras(cameras: Camera[]): void;
  70814. /**
  70815. * Enables the effect on given cameras
  70816. * @param cameras The camera to enable.
  70817. * @hidden
  70818. */
  70819. _enable(cameras: Camera): void;
  70820. /**
  70821. * Enables the effect on given cameras
  70822. * @param cameras The camera to enable.
  70823. * @hidden
  70824. */
  70825. _enable(cameras: Nullable<Camera[]>): void;
  70826. /**
  70827. * Disables the effect on the given cameras
  70828. * @param cameras The camera to disable.
  70829. * @hidden
  70830. */
  70831. _disable(cameras: Camera): void;
  70832. /**
  70833. * Disables the effect on the given cameras
  70834. * @param cameras The camera to disable.
  70835. * @hidden
  70836. */
  70837. _disable(cameras: Nullable<Camera[]>): void;
  70838. /**
  70839. * Gets a list of the post processes contained in the effect.
  70840. * @param camera The camera to get the post processes on.
  70841. * @returns The list of the post processes in the effect.
  70842. */
  70843. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70844. }
  70845. }
  70846. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  70847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70848. /** @hidden */
  70849. export var extractHighlightsPixelShader: {
  70850. name: string;
  70851. shader: string;
  70852. };
  70853. }
  70854. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  70855. import { Nullable } from "babylonjs/types";
  70856. import { Camera } from "babylonjs/Cameras/camera";
  70857. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70858. import { Engine } from "babylonjs/Engines/engine";
  70859. import "babylonjs/Shaders/extractHighlights.fragment";
  70860. /**
  70861. * 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.
  70862. */
  70863. export class ExtractHighlightsPostProcess extends PostProcess {
  70864. /**
  70865. * The luminance threshold, pixels below this value will be set to black.
  70866. */
  70867. threshold: number;
  70868. /** @hidden */
  70869. _exposure: number;
  70870. /**
  70871. * Post process which has the input texture to be used when performing highlight extraction
  70872. * @hidden
  70873. */
  70874. _inputPostProcess: Nullable<PostProcess>;
  70875. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70876. }
  70877. }
  70878. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  70879. /** @hidden */
  70880. export var bloomMergePixelShader: {
  70881. name: string;
  70882. shader: string;
  70883. };
  70884. }
  70885. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  70886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70887. import { Nullable } from "babylonjs/types";
  70888. import { Engine } from "babylonjs/Engines/engine";
  70889. import { Camera } from "babylonjs/Cameras/camera";
  70890. import "babylonjs/Shaders/bloomMerge.fragment";
  70891. /**
  70892. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70893. */
  70894. export class BloomMergePostProcess extends PostProcess {
  70895. /** Weight of the bloom to be added to the original input. */
  70896. weight: number;
  70897. /**
  70898. * Creates a new instance of @see BloomMergePostProcess
  70899. * @param name The name of the effect.
  70900. * @param originalFromInput Post process which's input will be used for the merge.
  70901. * @param blurred Blurred highlights post process which's output will be used.
  70902. * @param weight Weight of the bloom to be added to the original input.
  70903. * @param options The required width/height ratio to downsize to before computing the render pass.
  70904. * @param camera The camera to apply the render pass to.
  70905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70906. * @param engine The engine which the post process will be applied. (default: current engine)
  70907. * @param reusable If the post process can be reused on the same frame. (default: false)
  70908. * @param textureType Type of textures used when performing the post process. (default: 0)
  70909. * @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)
  70910. */
  70911. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70912. /** Weight of the bloom to be added to the original input. */
  70913. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70914. }
  70915. }
  70916. declare module "babylonjs/PostProcesses/bloomEffect" {
  70917. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70918. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70919. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70920. import { Camera } from "babylonjs/Cameras/camera";
  70921. import { Scene } from "babylonjs/scene";
  70922. /**
  70923. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70924. */
  70925. export class BloomEffect extends PostProcessRenderEffect {
  70926. private bloomScale;
  70927. /**
  70928. * @hidden Internal
  70929. */
  70930. _effects: Array<PostProcess>;
  70931. /**
  70932. * @hidden Internal
  70933. */
  70934. _downscale: ExtractHighlightsPostProcess;
  70935. private _blurX;
  70936. private _blurY;
  70937. private _merge;
  70938. /**
  70939. * The luminance threshold to find bright areas of the image to bloom.
  70940. */
  70941. get threshold(): number;
  70942. set threshold(value: number);
  70943. /**
  70944. * The strength of the bloom.
  70945. */
  70946. get weight(): number;
  70947. set weight(value: number);
  70948. /**
  70949. * Specifies the size of the bloom blur kernel, relative to the final output size
  70950. */
  70951. get kernel(): number;
  70952. set kernel(value: number);
  70953. /**
  70954. * Creates a new instance of @see BloomEffect
  70955. * @param scene The scene the effect belongs to.
  70956. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70957. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70958. * @param bloomWeight The the strength of bloom.
  70959. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70960. * @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)
  70961. */
  70962. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70963. /**
  70964. * Disposes each of the internal effects for a given camera.
  70965. * @param camera The camera to dispose the effect on.
  70966. */
  70967. disposeEffects(camera: Camera): void;
  70968. /**
  70969. * @hidden Internal
  70970. */
  70971. _updateEffects(): void;
  70972. /**
  70973. * Internal
  70974. * @returns if all the contained post processes are ready.
  70975. * @hidden
  70976. */
  70977. _isReady(): boolean;
  70978. }
  70979. }
  70980. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  70981. /** @hidden */
  70982. export var chromaticAberrationPixelShader: {
  70983. name: string;
  70984. shader: string;
  70985. };
  70986. }
  70987. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  70988. import { Vector2 } from "babylonjs/Maths/math.vector";
  70989. import { Nullable } from "babylonjs/types";
  70990. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70991. import { Camera } from "babylonjs/Cameras/camera";
  70992. import { Engine } from "babylonjs/Engines/engine";
  70993. import "babylonjs/Shaders/chromaticAberration.fragment";
  70994. /**
  70995. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70996. */
  70997. export class ChromaticAberrationPostProcess extends PostProcess {
  70998. /**
  70999. * The amount of seperation of rgb channels (default: 30)
  71000. */
  71001. aberrationAmount: number;
  71002. /**
  71003. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71004. */
  71005. radialIntensity: number;
  71006. /**
  71007. * 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))
  71008. */
  71009. direction: Vector2;
  71010. /**
  71011. * 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))
  71012. */
  71013. centerPosition: Vector2;
  71014. /**
  71015. * Creates a new instance ChromaticAberrationPostProcess
  71016. * @param name The name of the effect.
  71017. * @param screenWidth The width of the screen to apply the effect on.
  71018. * @param screenHeight The height of the screen to apply the effect on.
  71019. * @param options The required width/height ratio to downsize to before computing the render pass.
  71020. * @param camera The camera to apply the render pass to.
  71021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71022. * @param engine The engine which the post process will be applied. (default: current engine)
  71023. * @param reusable If the post process can be reused on the same frame. (default: false)
  71024. * @param textureType Type of textures used when performing the post process. (default: 0)
  71025. * @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)
  71026. */
  71027. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71028. }
  71029. }
  71030. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71031. /** @hidden */
  71032. export var circleOfConfusionPixelShader: {
  71033. name: string;
  71034. shader: string;
  71035. };
  71036. }
  71037. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71038. import { Nullable } from "babylonjs/types";
  71039. import { Engine } from "babylonjs/Engines/engine";
  71040. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71042. import { Camera } from "babylonjs/Cameras/camera";
  71043. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71044. /**
  71045. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71046. */
  71047. export class CircleOfConfusionPostProcess extends PostProcess {
  71048. /**
  71049. * 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.
  71050. */
  71051. lensSize: number;
  71052. /**
  71053. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71054. */
  71055. fStop: number;
  71056. /**
  71057. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71058. */
  71059. focusDistance: number;
  71060. /**
  71061. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71062. */
  71063. focalLength: number;
  71064. private _depthTexture;
  71065. /**
  71066. * Creates a new instance CircleOfConfusionPostProcess
  71067. * @param name The name of the effect.
  71068. * @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.
  71069. * @param options The required width/height ratio to downsize to before computing the render pass.
  71070. * @param camera The camera to apply the render pass to.
  71071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71072. * @param engine The engine which the post process will be applied. (default: current engine)
  71073. * @param reusable If the post process can be reused on the same frame. (default: false)
  71074. * @param textureType Type of textures used when performing the post process. (default: 0)
  71075. * @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)
  71076. */
  71077. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71078. /**
  71079. * 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.
  71080. */
  71081. set depthTexture(value: RenderTargetTexture);
  71082. }
  71083. }
  71084. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71085. /** @hidden */
  71086. export var colorCorrectionPixelShader: {
  71087. name: string;
  71088. shader: string;
  71089. };
  71090. }
  71091. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71092. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71093. import { Engine } from "babylonjs/Engines/engine";
  71094. import { Camera } from "babylonjs/Cameras/camera";
  71095. import "babylonjs/Shaders/colorCorrection.fragment";
  71096. /**
  71097. *
  71098. * This post-process allows the modification of rendered colors by using
  71099. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71100. *
  71101. * The object needs to be provided an url to a texture containing the color
  71102. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71103. * Use an image editing software to tweak the LUT to match your needs.
  71104. *
  71105. * For an example of a color LUT, see here:
  71106. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71107. * For explanations on color grading, see here:
  71108. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71109. *
  71110. */
  71111. export class ColorCorrectionPostProcess extends PostProcess {
  71112. private _colorTableTexture;
  71113. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71114. }
  71115. }
  71116. declare module "babylonjs/Shaders/convolution.fragment" {
  71117. /** @hidden */
  71118. export var convolutionPixelShader: {
  71119. name: string;
  71120. shader: string;
  71121. };
  71122. }
  71123. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71124. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71125. import { Nullable } from "babylonjs/types";
  71126. import { Camera } from "babylonjs/Cameras/camera";
  71127. import { Engine } from "babylonjs/Engines/engine";
  71128. import "babylonjs/Shaders/convolution.fragment";
  71129. /**
  71130. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71131. * input texture to perform effects such as edge detection or sharpening
  71132. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71133. */
  71134. export class ConvolutionPostProcess extends PostProcess {
  71135. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71136. kernel: number[];
  71137. /**
  71138. * Creates a new instance ConvolutionPostProcess
  71139. * @param name The name of the effect.
  71140. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71141. * @param options The required width/height ratio to downsize to before computing the render pass.
  71142. * @param camera The camera to apply the render pass to.
  71143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71144. * @param engine The engine which the post process will be applied. (default: current engine)
  71145. * @param reusable If the post process can be reused on the same frame. (default: false)
  71146. * @param textureType Type of textures used when performing the post process. (default: 0)
  71147. */
  71148. constructor(name: string,
  71149. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71150. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71151. /**
  71152. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71153. */
  71154. static EdgeDetect0Kernel: number[];
  71155. /**
  71156. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71157. */
  71158. static EdgeDetect1Kernel: number[];
  71159. /**
  71160. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71161. */
  71162. static EdgeDetect2Kernel: number[];
  71163. /**
  71164. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71165. */
  71166. static SharpenKernel: number[];
  71167. /**
  71168. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71169. */
  71170. static EmbossKernel: number[];
  71171. /**
  71172. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71173. */
  71174. static GaussianKernel: number[];
  71175. }
  71176. }
  71177. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71178. import { Nullable } from "babylonjs/types";
  71179. import { Vector2 } from "babylonjs/Maths/math.vector";
  71180. import { Camera } from "babylonjs/Cameras/camera";
  71181. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71182. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71183. import { Engine } from "babylonjs/Engines/engine";
  71184. import { Scene } from "babylonjs/scene";
  71185. /**
  71186. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71187. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71188. * based on samples that have a large difference in distance than the center pixel.
  71189. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71190. */
  71191. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71192. direction: Vector2;
  71193. /**
  71194. * Creates a new instance CircleOfConfusionPostProcess
  71195. * @param name The name of the effect.
  71196. * @param scene The scene the effect belongs to.
  71197. * @param direction The direction the blur should be applied.
  71198. * @param kernel The size of the kernel used to blur.
  71199. * @param options The required width/height ratio to downsize to before computing the render pass.
  71200. * @param camera The camera to apply the render pass to.
  71201. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71202. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71204. * @param engine The engine which the post process will be applied. (default: current engine)
  71205. * @param reusable If the post process can be reused on the same frame. (default: false)
  71206. * @param textureType Type of textures used when performing the post process. (default: 0)
  71207. * @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)
  71208. */
  71209. 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);
  71210. }
  71211. }
  71212. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71213. /** @hidden */
  71214. export var depthOfFieldMergePixelShader: {
  71215. name: string;
  71216. shader: string;
  71217. };
  71218. }
  71219. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71220. import { Nullable } from "babylonjs/types";
  71221. import { Camera } from "babylonjs/Cameras/camera";
  71222. import { Effect } from "babylonjs/Materials/effect";
  71223. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71224. import { Engine } from "babylonjs/Engines/engine";
  71225. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71226. /**
  71227. * Options to be set when merging outputs from the default pipeline.
  71228. */
  71229. export class DepthOfFieldMergePostProcessOptions {
  71230. /**
  71231. * The original image to merge on top of
  71232. */
  71233. originalFromInput: PostProcess;
  71234. /**
  71235. * Parameters to perform the merge of the depth of field effect
  71236. */
  71237. depthOfField?: {
  71238. circleOfConfusion: PostProcess;
  71239. blurSteps: Array<PostProcess>;
  71240. };
  71241. /**
  71242. * Parameters to perform the merge of bloom effect
  71243. */
  71244. bloom?: {
  71245. blurred: PostProcess;
  71246. weight: number;
  71247. };
  71248. }
  71249. /**
  71250. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71251. */
  71252. export class DepthOfFieldMergePostProcess extends PostProcess {
  71253. private blurSteps;
  71254. /**
  71255. * Creates a new instance of DepthOfFieldMergePostProcess
  71256. * @param name The name of the effect.
  71257. * @param originalFromInput Post process which's input will be used for the merge.
  71258. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71259. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71260. * @param options The required width/height ratio to downsize to before computing the render pass.
  71261. * @param camera The camera to apply the render pass to.
  71262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71263. * @param engine The engine which the post process will be applied. (default: current engine)
  71264. * @param reusable If the post process can be reused on the same frame. (default: false)
  71265. * @param textureType Type of textures used when performing the post process. (default: 0)
  71266. * @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)
  71267. */
  71268. 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);
  71269. /**
  71270. * Updates the effect with the current post process compile time values and recompiles the shader.
  71271. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71272. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71273. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71274. * @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
  71275. * @param onCompiled Called when the shader has been compiled.
  71276. * @param onError Called if there is an error when compiling a shader.
  71277. */
  71278. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71279. }
  71280. }
  71281. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71282. import { Nullable } from "babylonjs/types";
  71283. import { Camera } from "babylonjs/Cameras/camera";
  71284. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71285. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71286. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71287. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71288. import { Scene } from "babylonjs/scene";
  71289. /**
  71290. * Specifies the level of max blur that should be applied when using the depth of field effect
  71291. */
  71292. export enum DepthOfFieldEffectBlurLevel {
  71293. /**
  71294. * Subtle blur
  71295. */
  71296. Low = 0,
  71297. /**
  71298. * Medium blur
  71299. */
  71300. Medium = 1,
  71301. /**
  71302. * Large blur
  71303. */
  71304. High = 2
  71305. }
  71306. /**
  71307. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71308. */
  71309. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71310. private _circleOfConfusion;
  71311. /**
  71312. * @hidden Internal, blurs from high to low
  71313. */
  71314. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71315. private _depthOfFieldBlurY;
  71316. private _dofMerge;
  71317. /**
  71318. * @hidden Internal post processes in depth of field effect
  71319. */
  71320. _effects: Array<PostProcess>;
  71321. /**
  71322. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71323. */
  71324. set focalLength(value: number);
  71325. get focalLength(): number;
  71326. /**
  71327. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71328. */
  71329. set fStop(value: number);
  71330. get fStop(): number;
  71331. /**
  71332. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71333. */
  71334. set focusDistance(value: number);
  71335. get focusDistance(): number;
  71336. /**
  71337. * 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.
  71338. */
  71339. set lensSize(value: number);
  71340. get lensSize(): number;
  71341. /**
  71342. * Creates a new instance DepthOfFieldEffect
  71343. * @param scene The scene the effect belongs to.
  71344. * @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.
  71345. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71346. * @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)
  71347. */
  71348. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71349. /**
  71350. * Get the current class name of the current effet
  71351. * @returns "DepthOfFieldEffect"
  71352. */
  71353. getClassName(): string;
  71354. /**
  71355. * 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.
  71356. */
  71357. set depthTexture(value: RenderTargetTexture);
  71358. /**
  71359. * Disposes each of the internal effects for a given camera.
  71360. * @param camera The camera to dispose the effect on.
  71361. */
  71362. disposeEffects(camera: Camera): void;
  71363. /**
  71364. * @hidden Internal
  71365. */
  71366. _updateEffects(): void;
  71367. /**
  71368. * Internal
  71369. * @returns if all the contained post processes are ready.
  71370. * @hidden
  71371. */
  71372. _isReady(): boolean;
  71373. }
  71374. }
  71375. declare module "babylonjs/Shaders/displayPass.fragment" {
  71376. /** @hidden */
  71377. export var displayPassPixelShader: {
  71378. name: string;
  71379. shader: string;
  71380. };
  71381. }
  71382. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  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/displayPass.fragment";
  71388. /**
  71389. * DisplayPassPostProcess which produces an output the same as it's input
  71390. */
  71391. export class DisplayPassPostProcess extends PostProcess {
  71392. /**
  71393. * Creates the DisplayPassPostProcess
  71394. * @param name The name of the effect.
  71395. * @param options The required width/height ratio to downsize to before computing the render pass.
  71396. * @param camera The camera to apply the render pass to.
  71397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71398. * @param engine The engine which the post process will be applied. (default: current engine)
  71399. * @param reusable If the post process can be reused on the same frame. (default: false)
  71400. */
  71401. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71402. }
  71403. }
  71404. declare module "babylonjs/Shaders/filter.fragment" {
  71405. /** @hidden */
  71406. export var filterPixelShader: {
  71407. name: string;
  71408. shader: string;
  71409. };
  71410. }
  71411. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71412. import { Nullable } from "babylonjs/types";
  71413. import { Matrix } from "babylonjs/Maths/math.vector";
  71414. import { Camera } from "babylonjs/Cameras/camera";
  71415. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71416. import { Engine } from "babylonjs/Engines/engine";
  71417. import "babylonjs/Shaders/filter.fragment";
  71418. /**
  71419. * Applies a kernel filter to the image
  71420. */
  71421. export class FilterPostProcess extends PostProcess {
  71422. /** The matrix to be applied to the image */
  71423. kernelMatrix: Matrix;
  71424. /**
  71425. *
  71426. * @param name The name of the effect.
  71427. * @param kernelMatrix The matrix to be applied to the image
  71428. * @param options The required width/height ratio to downsize to before computing the render pass.
  71429. * @param camera The camera to apply the render pass to.
  71430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71431. * @param engine The engine which the post process will be applied. (default: current engine)
  71432. * @param reusable If the post process can be reused on the same frame. (default: false)
  71433. */
  71434. constructor(name: string,
  71435. /** The matrix to be applied to the image */
  71436. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71437. }
  71438. }
  71439. declare module "babylonjs/Shaders/fxaa.fragment" {
  71440. /** @hidden */
  71441. export var fxaaPixelShader: {
  71442. name: string;
  71443. shader: string;
  71444. };
  71445. }
  71446. declare module "babylonjs/Shaders/fxaa.vertex" {
  71447. /** @hidden */
  71448. export var fxaaVertexShader: {
  71449. name: string;
  71450. shader: string;
  71451. };
  71452. }
  71453. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71454. import { Nullable } from "babylonjs/types";
  71455. import { Camera } from "babylonjs/Cameras/camera";
  71456. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71457. import { Engine } from "babylonjs/Engines/engine";
  71458. import "babylonjs/Shaders/fxaa.fragment";
  71459. import "babylonjs/Shaders/fxaa.vertex";
  71460. /**
  71461. * Fxaa post process
  71462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71463. */
  71464. export class FxaaPostProcess extends PostProcess {
  71465. /** @hidden */
  71466. texelWidth: number;
  71467. /** @hidden */
  71468. texelHeight: number;
  71469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71470. private _getDefines;
  71471. }
  71472. }
  71473. declare module "babylonjs/Shaders/grain.fragment" {
  71474. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71475. /** @hidden */
  71476. export var grainPixelShader: {
  71477. name: string;
  71478. shader: string;
  71479. };
  71480. }
  71481. declare module "babylonjs/PostProcesses/grainPostProcess" {
  71482. import { Nullable } from "babylonjs/types";
  71483. import { Camera } from "babylonjs/Cameras/camera";
  71484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71485. import { Engine } from "babylonjs/Engines/engine";
  71486. import "babylonjs/Shaders/grain.fragment";
  71487. /**
  71488. * The GrainPostProcess adds noise to the image at mid luminance levels
  71489. */
  71490. export class GrainPostProcess extends PostProcess {
  71491. /**
  71492. * The intensity of the grain added (default: 30)
  71493. */
  71494. intensity: number;
  71495. /**
  71496. * If the grain should be randomized on every frame
  71497. */
  71498. animated: boolean;
  71499. /**
  71500. * Creates a new instance of @see GrainPostProcess
  71501. * @param name The name of the effect.
  71502. * @param options The required width/height ratio to downsize to before computing the render pass.
  71503. * @param camera The camera to apply the render pass to.
  71504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71505. * @param engine The engine which the post process will be applied. (default: current engine)
  71506. * @param reusable If the post process can be reused on the same frame. (default: false)
  71507. * @param textureType Type of textures used when performing the post process. (default: 0)
  71508. * @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)
  71509. */
  71510. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71511. }
  71512. }
  71513. declare module "babylonjs/Shaders/highlights.fragment" {
  71514. /** @hidden */
  71515. export var highlightsPixelShader: {
  71516. name: string;
  71517. shader: string;
  71518. };
  71519. }
  71520. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  71521. import { Nullable } from "babylonjs/types";
  71522. import { Camera } from "babylonjs/Cameras/camera";
  71523. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71524. import { Engine } from "babylonjs/Engines/engine";
  71525. import "babylonjs/Shaders/highlights.fragment";
  71526. /**
  71527. * Extracts highlights from the image
  71528. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71529. */
  71530. export class HighlightsPostProcess extends PostProcess {
  71531. /**
  71532. * Extracts highlights from the image
  71533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71534. * @param name The name of the effect.
  71535. * @param options The required width/height ratio to downsize to before computing the render pass.
  71536. * @param camera The camera to apply the render pass to.
  71537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71538. * @param engine The engine which the post process will be applied. (default: current engine)
  71539. * @param reusable If the post process can be reused on the same frame. (default: false)
  71540. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71541. */
  71542. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71543. }
  71544. }
  71545. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  71546. /** @hidden */
  71547. export var mrtFragmentDeclaration: {
  71548. name: string;
  71549. shader: string;
  71550. };
  71551. }
  71552. declare module "babylonjs/Shaders/geometry.fragment" {
  71553. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  71554. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  71555. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  71556. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  71557. /** @hidden */
  71558. export var geometryPixelShader: {
  71559. name: string;
  71560. shader: string;
  71561. };
  71562. }
  71563. declare module "babylonjs/Shaders/geometry.vertex" {
  71564. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71565. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71566. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71567. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71569. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71570. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71571. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  71572. /** @hidden */
  71573. export var geometryVertexShader: {
  71574. name: string;
  71575. shader: string;
  71576. };
  71577. }
  71578. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  71579. import { Matrix } from "babylonjs/Maths/math.vector";
  71580. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71581. import { Mesh } from "babylonjs/Meshes/mesh";
  71582. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  71583. import { Effect } from "babylonjs/Materials/effect";
  71584. import { Scene } from "babylonjs/scene";
  71585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71586. import "babylonjs/Shaders/geometry.fragment";
  71587. import "babylonjs/Shaders/geometry.vertex";
  71588. /** @hidden */
  71589. interface ISavedTransformationMatrix {
  71590. world: Matrix;
  71591. viewProjection: Matrix;
  71592. }
  71593. /**
  71594. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  71595. */
  71596. export class GeometryBufferRenderer {
  71597. /**
  71598. * Constant used to retrieve the position texture index in the G-Buffer textures array
  71599. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  71600. */
  71601. static readonly POSITION_TEXTURE_TYPE: number;
  71602. /**
  71603. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  71604. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  71605. */
  71606. static readonly VELOCITY_TEXTURE_TYPE: number;
  71607. /**
  71608. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  71609. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  71610. */
  71611. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  71612. /**
  71613. * Dictionary used to store the previous transformation matrices of each rendered mesh
  71614. * in order to compute objects velocities when enableVelocity is set to "true"
  71615. * @hidden
  71616. */
  71617. _previousTransformationMatrices: {
  71618. [index: number]: ISavedTransformationMatrix;
  71619. };
  71620. /**
  71621. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  71622. * in order to compute objects velocities when enableVelocity is set to "true"
  71623. * @hidden
  71624. */
  71625. _previousBonesTransformationMatrices: {
  71626. [index: number]: Float32Array;
  71627. };
  71628. /**
  71629. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  71630. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  71631. */
  71632. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  71633. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  71634. renderTransparentMeshes: boolean;
  71635. private _scene;
  71636. private _multiRenderTarget;
  71637. private _ratio;
  71638. private _enablePosition;
  71639. private _enableVelocity;
  71640. private _enableReflectivity;
  71641. private _positionIndex;
  71642. private _velocityIndex;
  71643. private _reflectivityIndex;
  71644. protected _effect: Effect;
  71645. protected _cachedDefines: string;
  71646. /**
  71647. * Set the render list (meshes to be rendered) used in the G buffer.
  71648. */
  71649. set renderList(meshes: Mesh[]);
  71650. /**
  71651. * Gets wether or not G buffer are supported by the running hardware.
  71652. * This requires draw buffer supports
  71653. */
  71654. get isSupported(): boolean;
  71655. /**
  71656. * Returns the index of the given texture type in the G-Buffer textures array
  71657. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  71658. * @returns the index of the given texture type in the G-Buffer textures array
  71659. */
  71660. getTextureIndex(textureType: number): number;
  71661. /**
  71662. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  71663. */
  71664. get enablePosition(): boolean;
  71665. /**
  71666. * Sets whether or not objects positions are enabled for the G buffer.
  71667. */
  71668. set enablePosition(enable: boolean);
  71669. /**
  71670. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  71671. */
  71672. get enableVelocity(): boolean;
  71673. /**
  71674. * Sets wether or not objects velocities are enabled for the G buffer.
  71675. */
  71676. set enableVelocity(enable: boolean);
  71677. /**
  71678. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  71679. */
  71680. get enableReflectivity(): boolean;
  71681. /**
  71682. * Sets wether or not objects roughness are enabled for the G buffer.
  71683. */
  71684. set enableReflectivity(enable: boolean);
  71685. /**
  71686. * Gets the scene associated with the buffer.
  71687. */
  71688. get scene(): Scene;
  71689. /**
  71690. * Gets the ratio used by the buffer during its creation.
  71691. * How big is the buffer related to the main canvas.
  71692. */
  71693. get ratio(): number;
  71694. /** @hidden */
  71695. static _SceneComponentInitialization: (scene: Scene) => void;
  71696. /**
  71697. * Creates a new G Buffer for the scene
  71698. * @param scene The scene the buffer belongs to
  71699. * @param ratio How big is the buffer related to the main canvas.
  71700. */
  71701. constructor(scene: Scene, ratio?: number);
  71702. /**
  71703. * Checks wether everything is ready to render a submesh to the G buffer.
  71704. * @param subMesh the submesh to check readiness for
  71705. * @param useInstances is the mesh drawn using instance or not
  71706. * @returns true if ready otherwise false
  71707. */
  71708. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71709. /**
  71710. * Gets the current underlying G Buffer.
  71711. * @returns the buffer
  71712. */
  71713. getGBuffer(): MultiRenderTarget;
  71714. /**
  71715. * Gets the number of samples used to render the buffer (anti aliasing).
  71716. */
  71717. get samples(): number;
  71718. /**
  71719. * Sets the number of samples used to render the buffer (anti aliasing).
  71720. */
  71721. set samples(value: number);
  71722. /**
  71723. * Disposes the renderer and frees up associated resources.
  71724. */
  71725. dispose(): void;
  71726. protected _createRenderTargets(): void;
  71727. private _copyBonesTransformationMatrices;
  71728. }
  71729. }
  71730. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  71731. import { Nullable } from "babylonjs/types";
  71732. import { Scene } from "babylonjs/scene";
  71733. import { ISceneComponent } from "babylonjs/sceneComponent";
  71734. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  71735. module "babylonjs/scene" {
  71736. interface Scene {
  71737. /** @hidden (Backing field) */
  71738. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71739. /**
  71740. * Gets or Sets the current geometry buffer associated to the scene.
  71741. */
  71742. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71743. /**
  71744. * Enables a GeometryBufferRender and associates it with the scene
  71745. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71746. * @returns the GeometryBufferRenderer
  71747. */
  71748. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71749. /**
  71750. * Disables the GeometryBufferRender associated with the scene
  71751. */
  71752. disableGeometryBufferRenderer(): void;
  71753. }
  71754. }
  71755. /**
  71756. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71757. * in several rendering techniques.
  71758. */
  71759. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71760. /**
  71761. * The component name helpful to identify the component in the list of scene components.
  71762. */
  71763. readonly name: string;
  71764. /**
  71765. * The scene the component belongs to.
  71766. */
  71767. scene: Scene;
  71768. /**
  71769. * Creates a new instance of the component for the given scene
  71770. * @param scene Defines the scene to register the component in
  71771. */
  71772. constructor(scene: Scene);
  71773. /**
  71774. * Registers the component in a given scene
  71775. */
  71776. register(): void;
  71777. /**
  71778. * Rebuilds the elements related to this component in case of
  71779. * context lost for instance.
  71780. */
  71781. rebuild(): void;
  71782. /**
  71783. * Disposes the component and the associated ressources
  71784. */
  71785. dispose(): void;
  71786. private _gatherRenderTargets;
  71787. }
  71788. }
  71789. declare module "babylonjs/Shaders/motionBlur.fragment" {
  71790. /** @hidden */
  71791. export var motionBlurPixelShader: {
  71792. name: string;
  71793. shader: string;
  71794. };
  71795. }
  71796. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  71797. import { Nullable } from "babylonjs/types";
  71798. import { Camera } from "babylonjs/Cameras/camera";
  71799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71800. import { Scene } from "babylonjs/scene";
  71801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71802. import "babylonjs/Animations/animatable";
  71803. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71804. import "babylonjs/Shaders/motionBlur.fragment";
  71805. import { Engine } from "babylonjs/Engines/engine";
  71806. /**
  71807. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71808. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71809. * As an example, all you have to do is to create the post-process:
  71810. * var mb = new BABYLON.MotionBlurPostProcess(
  71811. * 'mb', // The name of the effect.
  71812. * scene, // The scene containing the objects to blur according to their velocity.
  71813. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71814. * camera // The camera to apply the render pass to.
  71815. * );
  71816. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71817. */
  71818. export class MotionBlurPostProcess extends PostProcess {
  71819. /**
  71820. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71821. */
  71822. motionStrength: number;
  71823. /**
  71824. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71825. */
  71826. get motionBlurSamples(): number;
  71827. /**
  71828. * Sets the number of iterations to be used for motion blur quality
  71829. */
  71830. set motionBlurSamples(samples: number);
  71831. private _motionBlurSamples;
  71832. private _geometryBufferRenderer;
  71833. /**
  71834. * Creates a new instance MotionBlurPostProcess
  71835. * @param name The name of the effect.
  71836. * @param scene The scene containing the objects to blur according to their velocity.
  71837. * @param options The required width/height ratio to downsize to before computing the render pass.
  71838. * @param camera The camera to apply the render pass to.
  71839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71840. * @param engine The engine which the post process will be applied. (default: current engine)
  71841. * @param reusable If the post process can be reused on the same frame. (default: false)
  71842. * @param textureType Type of textures used when performing the post process. (default: 0)
  71843. * @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)
  71844. */
  71845. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71846. /**
  71847. * Excludes the given skinned mesh from computing bones velocities.
  71848. * 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.
  71849. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71850. */
  71851. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71852. /**
  71853. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71854. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71855. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71856. */
  71857. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71858. /**
  71859. * Disposes the post process.
  71860. * @param camera The camera to dispose the post process on.
  71861. */
  71862. dispose(camera?: Camera): void;
  71863. }
  71864. }
  71865. declare module "babylonjs/Shaders/refraction.fragment" {
  71866. /** @hidden */
  71867. export var refractionPixelShader: {
  71868. name: string;
  71869. shader: string;
  71870. };
  71871. }
  71872. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  71873. import { Color3 } from "babylonjs/Maths/math.color";
  71874. import { Camera } from "babylonjs/Cameras/camera";
  71875. import { Texture } from "babylonjs/Materials/Textures/texture";
  71876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71877. import { Engine } from "babylonjs/Engines/engine";
  71878. import "babylonjs/Shaders/refraction.fragment";
  71879. /**
  71880. * Post process which applies a refractin texture
  71881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71882. */
  71883. export class RefractionPostProcess extends PostProcess {
  71884. /** the base color of the refraction (used to taint the rendering) */
  71885. color: Color3;
  71886. /** simulated refraction depth */
  71887. depth: number;
  71888. /** the coefficient of the base color (0 to remove base color tainting) */
  71889. colorLevel: number;
  71890. private _refTexture;
  71891. private _ownRefractionTexture;
  71892. /**
  71893. * Gets or sets the refraction texture
  71894. * Please note that you are responsible for disposing the texture if you set it manually
  71895. */
  71896. get refractionTexture(): Texture;
  71897. set refractionTexture(value: Texture);
  71898. /**
  71899. * Initializes the RefractionPostProcess
  71900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71901. * @param name The name of the effect.
  71902. * @param refractionTextureUrl Url of the refraction texture to use
  71903. * @param color the base color of the refraction (used to taint the rendering)
  71904. * @param depth simulated refraction depth
  71905. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71906. * @param camera The camera to apply the render pass to.
  71907. * @param options The required width/height ratio to downsize to before computing the render pass.
  71908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71909. * @param engine The engine which the post process will be applied. (default: current engine)
  71910. * @param reusable If the post process can be reused on the same frame. (default: false)
  71911. */
  71912. constructor(name: string, refractionTextureUrl: string,
  71913. /** the base color of the refraction (used to taint the rendering) */
  71914. color: Color3,
  71915. /** simulated refraction depth */
  71916. depth: number,
  71917. /** the coefficient of the base color (0 to remove base color tainting) */
  71918. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71919. /**
  71920. * Disposes of the post process
  71921. * @param camera Camera to dispose post process on
  71922. */
  71923. dispose(camera: Camera): void;
  71924. }
  71925. }
  71926. declare module "babylonjs/Shaders/sharpen.fragment" {
  71927. /** @hidden */
  71928. export var sharpenPixelShader: {
  71929. name: string;
  71930. shader: string;
  71931. };
  71932. }
  71933. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  71934. import { Nullable } from "babylonjs/types";
  71935. import { Camera } from "babylonjs/Cameras/camera";
  71936. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71937. import "babylonjs/Shaders/sharpen.fragment";
  71938. import { Engine } from "babylonjs/Engines/engine";
  71939. /**
  71940. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71941. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71942. */
  71943. export class SharpenPostProcess extends PostProcess {
  71944. /**
  71945. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71946. */
  71947. colorAmount: number;
  71948. /**
  71949. * How much sharpness should be applied (default: 0.3)
  71950. */
  71951. edgeAmount: number;
  71952. /**
  71953. * Creates a new instance ConvolutionPostProcess
  71954. * @param name The name of the effect.
  71955. * @param options The required width/height ratio to downsize to before computing the render pass.
  71956. * @param camera The camera to apply the render pass to.
  71957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71958. * @param engine The engine which the post process will be applied. (default: current engine)
  71959. * @param reusable If the post process can be reused on the same frame. (default: false)
  71960. * @param textureType Type of textures used when performing the post process. (default: 0)
  71961. * @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)
  71962. */
  71963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71964. }
  71965. }
  71966. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  71967. import { Nullable } from "babylonjs/types";
  71968. import { Camera } from "babylonjs/Cameras/camera";
  71969. import { Engine } from "babylonjs/Engines/engine";
  71970. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71971. import { IInspectable } from "babylonjs/Misc/iInspectable";
  71972. /**
  71973. * PostProcessRenderPipeline
  71974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71975. */
  71976. export class PostProcessRenderPipeline {
  71977. private engine;
  71978. private _renderEffects;
  71979. private _renderEffectsForIsolatedPass;
  71980. /**
  71981. * List of inspectable custom properties (used by the Inspector)
  71982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71983. */
  71984. inspectableCustomProperties: IInspectable[];
  71985. /**
  71986. * @hidden
  71987. */
  71988. protected _cameras: Camera[];
  71989. /** @hidden */
  71990. _name: string;
  71991. /**
  71992. * Gets pipeline name
  71993. */
  71994. get name(): string;
  71995. /** Gets the list of attached cameras */
  71996. get cameras(): Camera[];
  71997. /**
  71998. * Initializes a PostProcessRenderPipeline
  71999. * @param engine engine to add the pipeline to
  72000. * @param name name of the pipeline
  72001. */
  72002. constructor(engine: Engine, name: string);
  72003. /**
  72004. * Gets the class name
  72005. * @returns "PostProcessRenderPipeline"
  72006. */
  72007. getClassName(): string;
  72008. /**
  72009. * If all the render effects in the pipeline are supported
  72010. */
  72011. get isSupported(): boolean;
  72012. /**
  72013. * Adds an effect to the pipeline
  72014. * @param renderEffect the effect to add
  72015. */
  72016. addEffect(renderEffect: PostProcessRenderEffect): void;
  72017. /** @hidden */
  72018. _rebuild(): void;
  72019. /** @hidden */
  72020. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72021. /** @hidden */
  72022. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72023. /** @hidden */
  72024. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72025. /** @hidden */
  72026. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72027. /** @hidden */
  72028. _attachCameras(cameras: Camera, unique: boolean): void;
  72029. /** @hidden */
  72030. _attachCameras(cameras: Camera[], unique: boolean): void;
  72031. /** @hidden */
  72032. _detachCameras(cameras: Camera): void;
  72033. /** @hidden */
  72034. _detachCameras(cameras: Nullable<Camera[]>): void;
  72035. /** @hidden */
  72036. _update(): void;
  72037. /** @hidden */
  72038. _reset(): void;
  72039. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72040. /**
  72041. * Disposes of the pipeline
  72042. */
  72043. dispose(): void;
  72044. }
  72045. }
  72046. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72047. import { Camera } from "babylonjs/Cameras/camera";
  72048. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72049. /**
  72050. * PostProcessRenderPipelineManager class
  72051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72052. */
  72053. export class PostProcessRenderPipelineManager {
  72054. private _renderPipelines;
  72055. /**
  72056. * Initializes a PostProcessRenderPipelineManager
  72057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72058. */
  72059. constructor();
  72060. /**
  72061. * Gets the list of supported render pipelines
  72062. */
  72063. get supportedPipelines(): PostProcessRenderPipeline[];
  72064. /**
  72065. * Adds a pipeline to the manager
  72066. * @param renderPipeline The pipeline to add
  72067. */
  72068. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72069. /**
  72070. * Attaches a camera to the pipeline
  72071. * @param renderPipelineName The name of the pipeline to attach to
  72072. * @param cameras the camera to attach
  72073. * @param unique if the camera can be attached multiple times to the pipeline
  72074. */
  72075. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72076. /**
  72077. * Detaches a camera from the pipeline
  72078. * @param renderPipelineName The name of the pipeline to detach from
  72079. * @param cameras the camera to detach
  72080. */
  72081. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72082. /**
  72083. * Enables an effect by name on a pipeline
  72084. * @param renderPipelineName the name of the pipeline to enable the effect in
  72085. * @param renderEffectName the name of the effect to enable
  72086. * @param cameras the cameras that the effect should be enabled on
  72087. */
  72088. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72089. /**
  72090. * Disables an effect by name on a pipeline
  72091. * @param renderPipelineName the name of the pipeline to disable the effect in
  72092. * @param renderEffectName the name of the effect to disable
  72093. * @param cameras the cameras that the effect should be disabled on
  72094. */
  72095. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72096. /**
  72097. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72098. */
  72099. update(): void;
  72100. /** @hidden */
  72101. _rebuild(): void;
  72102. /**
  72103. * Disposes of the manager and pipelines
  72104. */
  72105. dispose(): void;
  72106. }
  72107. }
  72108. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72109. import { ISceneComponent } from "babylonjs/sceneComponent";
  72110. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72111. import { Scene } from "babylonjs/scene";
  72112. module "babylonjs/scene" {
  72113. interface Scene {
  72114. /** @hidden (Backing field) */
  72115. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72116. /**
  72117. * Gets the postprocess render pipeline manager
  72118. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72119. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72120. */
  72121. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72122. }
  72123. }
  72124. /**
  72125. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72126. */
  72127. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72128. /**
  72129. * The component name helpfull to identify the component in the list of scene components.
  72130. */
  72131. readonly name: string;
  72132. /**
  72133. * The scene the component belongs to.
  72134. */
  72135. scene: Scene;
  72136. /**
  72137. * Creates a new instance of the component for the given scene
  72138. * @param scene Defines the scene to register the component in
  72139. */
  72140. constructor(scene: Scene);
  72141. /**
  72142. * Registers the component in a given scene
  72143. */
  72144. register(): void;
  72145. /**
  72146. * Rebuilds the elements related to this component in case of
  72147. * context lost for instance.
  72148. */
  72149. rebuild(): void;
  72150. /**
  72151. * Disposes the component and the associated ressources
  72152. */
  72153. dispose(): void;
  72154. private _gatherRenderTargets;
  72155. }
  72156. }
  72157. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72158. import { Nullable } from "babylonjs/types";
  72159. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72160. import { Camera } from "babylonjs/Cameras/camera";
  72161. import { IDisposable } from "babylonjs/scene";
  72162. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72163. import { Scene } from "babylonjs/scene";
  72164. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72165. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72166. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72167. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72168. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72169. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72170. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72171. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72172. import { Animation } from "babylonjs/Animations/animation";
  72173. /**
  72174. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72175. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72176. */
  72177. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72178. private _scene;
  72179. private _camerasToBeAttached;
  72180. /**
  72181. * ID of the sharpen post process,
  72182. */
  72183. private readonly SharpenPostProcessId;
  72184. /**
  72185. * @ignore
  72186. * ID of the image processing post process;
  72187. */
  72188. readonly ImageProcessingPostProcessId: string;
  72189. /**
  72190. * @ignore
  72191. * ID of the Fast Approximate Anti-Aliasing post process;
  72192. */
  72193. readonly FxaaPostProcessId: string;
  72194. /**
  72195. * ID of the chromatic aberration post process,
  72196. */
  72197. private readonly ChromaticAberrationPostProcessId;
  72198. /**
  72199. * ID of the grain post process
  72200. */
  72201. private readonly GrainPostProcessId;
  72202. /**
  72203. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72204. */
  72205. sharpen: SharpenPostProcess;
  72206. private _sharpenEffect;
  72207. private bloom;
  72208. /**
  72209. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72210. */
  72211. depthOfField: DepthOfFieldEffect;
  72212. /**
  72213. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72214. */
  72215. fxaa: FxaaPostProcess;
  72216. /**
  72217. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72218. */
  72219. imageProcessing: ImageProcessingPostProcess;
  72220. /**
  72221. * Chromatic aberration post process which will shift rgb colors in the image
  72222. */
  72223. chromaticAberration: ChromaticAberrationPostProcess;
  72224. private _chromaticAberrationEffect;
  72225. /**
  72226. * Grain post process which add noise to the image
  72227. */
  72228. grain: GrainPostProcess;
  72229. private _grainEffect;
  72230. /**
  72231. * Glow post process which adds a glow to emissive areas of the image
  72232. */
  72233. private _glowLayer;
  72234. /**
  72235. * Animations which can be used to tweak settings over a period of time
  72236. */
  72237. animations: Animation[];
  72238. private _imageProcessingConfigurationObserver;
  72239. private _sharpenEnabled;
  72240. private _bloomEnabled;
  72241. private _depthOfFieldEnabled;
  72242. private _depthOfFieldBlurLevel;
  72243. private _fxaaEnabled;
  72244. private _imageProcessingEnabled;
  72245. private _defaultPipelineTextureType;
  72246. private _bloomScale;
  72247. private _chromaticAberrationEnabled;
  72248. private _grainEnabled;
  72249. private _buildAllowed;
  72250. /**
  72251. * Gets active scene
  72252. */
  72253. get scene(): Scene;
  72254. /**
  72255. * Enable or disable the sharpen process from the pipeline
  72256. */
  72257. set sharpenEnabled(enabled: boolean);
  72258. get sharpenEnabled(): boolean;
  72259. private _resizeObserver;
  72260. private _hardwareScaleLevel;
  72261. private _bloomKernel;
  72262. /**
  72263. * Specifies the size of the bloom blur kernel, relative to the final output size
  72264. */
  72265. get bloomKernel(): number;
  72266. set bloomKernel(value: number);
  72267. /**
  72268. * Specifies the weight of the bloom in the final rendering
  72269. */
  72270. private _bloomWeight;
  72271. /**
  72272. * Specifies the luma threshold for the area that will be blurred by the bloom
  72273. */
  72274. private _bloomThreshold;
  72275. private _hdr;
  72276. /**
  72277. * The strength of the bloom.
  72278. */
  72279. set bloomWeight(value: number);
  72280. get bloomWeight(): number;
  72281. /**
  72282. * The strength of the bloom.
  72283. */
  72284. set bloomThreshold(value: number);
  72285. get bloomThreshold(): number;
  72286. /**
  72287. * The scale of the bloom, lower value will provide better performance.
  72288. */
  72289. set bloomScale(value: number);
  72290. get bloomScale(): number;
  72291. /**
  72292. * Enable or disable the bloom from the pipeline
  72293. */
  72294. set bloomEnabled(enabled: boolean);
  72295. get bloomEnabled(): boolean;
  72296. private _rebuildBloom;
  72297. /**
  72298. * If the depth of field is enabled.
  72299. */
  72300. get depthOfFieldEnabled(): boolean;
  72301. set depthOfFieldEnabled(enabled: boolean);
  72302. /**
  72303. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72304. */
  72305. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72306. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72307. /**
  72308. * If the anti aliasing is enabled.
  72309. */
  72310. set fxaaEnabled(enabled: boolean);
  72311. get fxaaEnabled(): boolean;
  72312. private _samples;
  72313. /**
  72314. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72315. */
  72316. set samples(sampleCount: number);
  72317. get samples(): number;
  72318. /**
  72319. * If image processing is enabled.
  72320. */
  72321. set imageProcessingEnabled(enabled: boolean);
  72322. get imageProcessingEnabled(): boolean;
  72323. /**
  72324. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72325. */
  72326. set glowLayerEnabled(enabled: boolean);
  72327. get glowLayerEnabled(): boolean;
  72328. /**
  72329. * Gets the glow layer (or null if not defined)
  72330. */
  72331. get glowLayer(): Nullable<GlowLayer>;
  72332. /**
  72333. * Enable or disable the chromaticAberration process from the pipeline
  72334. */
  72335. set chromaticAberrationEnabled(enabled: boolean);
  72336. get chromaticAberrationEnabled(): boolean;
  72337. /**
  72338. * Enable or disable the grain process from the pipeline
  72339. */
  72340. set grainEnabled(enabled: boolean);
  72341. get grainEnabled(): boolean;
  72342. /**
  72343. * @constructor
  72344. * @param name - The rendering pipeline name (default: "")
  72345. * @param hdr - If high dynamic range textures should be used (default: true)
  72346. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72347. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72348. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72349. */
  72350. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72351. /**
  72352. * Get the class name
  72353. * @returns "DefaultRenderingPipeline"
  72354. */
  72355. getClassName(): string;
  72356. /**
  72357. * Force the compilation of the entire pipeline.
  72358. */
  72359. prepare(): void;
  72360. private _hasCleared;
  72361. private _prevPostProcess;
  72362. private _prevPrevPostProcess;
  72363. private _setAutoClearAndTextureSharing;
  72364. private _depthOfFieldSceneObserver;
  72365. private _buildPipeline;
  72366. private _disposePostProcesses;
  72367. /**
  72368. * Adds a camera to the pipeline
  72369. * @param camera the camera to be added
  72370. */
  72371. addCamera(camera: Camera): void;
  72372. /**
  72373. * Removes a camera from the pipeline
  72374. * @param camera the camera to remove
  72375. */
  72376. removeCamera(camera: Camera): void;
  72377. /**
  72378. * Dispose of the pipeline and stop all post processes
  72379. */
  72380. dispose(): void;
  72381. /**
  72382. * Serialize the rendering pipeline (Used when exporting)
  72383. * @returns the serialized object
  72384. */
  72385. serialize(): any;
  72386. /**
  72387. * Parse the serialized pipeline
  72388. * @param source Source pipeline.
  72389. * @param scene The scene to load the pipeline to.
  72390. * @param rootUrl The URL of the serialized pipeline.
  72391. * @returns An instantiated pipeline from the serialized object.
  72392. */
  72393. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72394. }
  72395. }
  72396. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72397. /** @hidden */
  72398. export var lensHighlightsPixelShader: {
  72399. name: string;
  72400. shader: string;
  72401. };
  72402. }
  72403. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72404. /** @hidden */
  72405. export var depthOfFieldPixelShader: {
  72406. name: string;
  72407. shader: string;
  72408. };
  72409. }
  72410. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72411. import { Camera } from "babylonjs/Cameras/camera";
  72412. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72413. import { Scene } from "babylonjs/scene";
  72414. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72415. import "babylonjs/Shaders/chromaticAberration.fragment";
  72416. import "babylonjs/Shaders/lensHighlights.fragment";
  72417. import "babylonjs/Shaders/depthOfField.fragment";
  72418. /**
  72419. * BABYLON.JS Chromatic Aberration GLSL Shader
  72420. * Author: Olivier Guyot
  72421. * Separates very slightly R, G and B colors on the edges of the screen
  72422. * Inspired by Francois Tarlier & Martins Upitis
  72423. */
  72424. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72425. /**
  72426. * @ignore
  72427. * The chromatic aberration PostProcess id in the pipeline
  72428. */
  72429. LensChromaticAberrationEffect: string;
  72430. /**
  72431. * @ignore
  72432. * The highlights enhancing PostProcess id in the pipeline
  72433. */
  72434. HighlightsEnhancingEffect: string;
  72435. /**
  72436. * @ignore
  72437. * The depth-of-field PostProcess id in the pipeline
  72438. */
  72439. LensDepthOfFieldEffect: string;
  72440. private _scene;
  72441. private _depthTexture;
  72442. private _grainTexture;
  72443. private _chromaticAberrationPostProcess;
  72444. private _highlightsPostProcess;
  72445. private _depthOfFieldPostProcess;
  72446. private _edgeBlur;
  72447. private _grainAmount;
  72448. private _chromaticAberration;
  72449. private _distortion;
  72450. private _highlightsGain;
  72451. private _highlightsThreshold;
  72452. private _dofDistance;
  72453. private _dofAperture;
  72454. private _dofDarken;
  72455. private _dofPentagon;
  72456. private _blurNoise;
  72457. /**
  72458. * @constructor
  72459. *
  72460. * Effect parameters are as follow:
  72461. * {
  72462. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72463. * edge_blur: number; // from 0 to x (1 for realism)
  72464. * distortion: number; // from 0 to x (1 for realism)
  72465. * grain_amount: number; // from 0 to 1
  72466. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72467. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72468. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72469. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72470. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72471. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72472. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72473. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72474. * }
  72475. * Note: if an effect parameter is unset, effect is disabled
  72476. *
  72477. * @param name The rendering pipeline name
  72478. * @param parameters - An object containing all parameters (see above)
  72479. * @param scene The scene linked to this pipeline
  72480. * @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)
  72481. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72482. */
  72483. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72484. /**
  72485. * Get the class name
  72486. * @returns "LensRenderingPipeline"
  72487. */
  72488. getClassName(): string;
  72489. /**
  72490. * Gets associated scene
  72491. */
  72492. get scene(): Scene;
  72493. /**
  72494. * Gets or sets the edge blur
  72495. */
  72496. get edgeBlur(): number;
  72497. set edgeBlur(value: number);
  72498. /**
  72499. * Gets or sets the grain amount
  72500. */
  72501. get grainAmount(): number;
  72502. set grainAmount(value: number);
  72503. /**
  72504. * Gets or sets the chromatic aberration amount
  72505. */
  72506. get chromaticAberration(): number;
  72507. set chromaticAberration(value: number);
  72508. /**
  72509. * Gets or sets the depth of field aperture
  72510. */
  72511. get dofAperture(): number;
  72512. set dofAperture(value: number);
  72513. /**
  72514. * Gets or sets the edge distortion
  72515. */
  72516. get edgeDistortion(): number;
  72517. set edgeDistortion(value: number);
  72518. /**
  72519. * Gets or sets the depth of field distortion
  72520. */
  72521. get dofDistortion(): number;
  72522. set dofDistortion(value: number);
  72523. /**
  72524. * Gets or sets the darken out of focus amount
  72525. */
  72526. get darkenOutOfFocus(): number;
  72527. set darkenOutOfFocus(value: number);
  72528. /**
  72529. * Gets or sets a boolean indicating if blur noise is enabled
  72530. */
  72531. get blurNoise(): boolean;
  72532. set blurNoise(value: boolean);
  72533. /**
  72534. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72535. */
  72536. get pentagonBokeh(): boolean;
  72537. set pentagonBokeh(value: boolean);
  72538. /**
  72539. * Gets or sets the highlight grain amount
  72540. */
  72541. get highlightsGain(): number;
  72542. set highlightsGain(value: number);
  72543. /**
  72544. * Gets or sets the highlight threshold
  72545. */
  72546. get highlightsThreshold(): number;
  72547. set highlightsThreshold(value: number);
  72548. /**
  72549. * Sets the amount of blur at the edges
  72550. * @param amount blur amount
  72551. */
  72552. setEdgeBlur(amount: number): void;
  72553. /**
  72554. * Sets edge blur to 0
  72555. */
  72556. disableEdgeBlur(): void;
  72557. /**
  72558. * Sets the amout of grain
  72559. * @param amount Amount of grain
  72560. */
  72561. setGrainAmount(amount: number): void;
  72562. /**
  72563. * Set grain amount to 0
  72564. */
  72565. disableGrain(): void;
  72566. /**
  72567. * Sets the chromatic aberration amount
  72568. * @param amount amount of chromatic aberration
  72569. */
  72570. setChromaticAberration(amount: number): void;
  72571. /**
  72572. * Sets chromatic aberration amount to 0
  72573. */
  72574. disableChromaticAberration(): void;
  72575. /**
  72576. * Sets the EdgeDistortion amount
  72577. * @param amount amount of EdgeDistortion
  72578. */
  72579. setEdgeDistortion(amount: number): void;
  72580. /**
  72581. * Sets edge distortion to 0
  72582. */
  72583. disableEdgeDistortion(): void;
  72584. /**
  72585. * Sets the FocusDistance amount
  72586. * @param amount amount of FocusDistance
  72587. */
  72588. setFocusDistance(amount: number): void;
  72589. /**
  72590. * Disables depth of field
  72591. */
  72592. disableDepthOfField(): void;
  72593. /**
  72594. * Sets the Aperture amount
  72595. * @param amount amount of Aperture
  72596. */
  72597. setAperture(amount: number): void;
  72598. /**
  72599. * Sets the DarkenOutOfFocus amount
  72600. * @param amount amount of DarkenOutOfFocus
  72601. */
  72602. setDarkenOutOfFocus(amount: number): void;
  72603. private _pentagonBokehIsEnabled;
  72604. /**
  72605. * Creates a pentagon bokeh effect
  72606. */
  72607. enablePentagonBokeh(): void;
  72608. /**
  72609. * Disables the pentagon bokeh effect
  72610. */
  72611. disablePentagonBokeh(): void;
  72612. /**
  72613. * Enables noise blur
  72614. */
  72615. enableNoiseBlur(): void;
  72616. /**
  72617. * Disables noise blur
  72618. */
  72619. disableNoiseBlur(): void;
  72620. /**
  72621. * Sets the HighlightsGain amount
  72622. * @param amount amount of HighlightsGain
  72623. */
  72624. setHighlightsGain(amount: number): void;
  72625. /**
  72626. * Sets the HighlightsThreshold amount
  72627. * @param amount amount of HighlightsThreshold
  72628. */
  72629. setHighlightsThreshold(amount: number): void;
  72630. /**
  72631. * Disables highlights
  72632. */
  72633. disableHighlights(): void;
  72634. /**
  72635. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72636. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72637. */
  72638. dispose(disableDepthRender?: boolean): void;
  72639. private _createChromaticAberrationPostProcess;
  72640. private _createHighlightsPostProcess;
  72641. private _createDepthOfFieldPostProcess;
  72642. private _createGrainTexture;
  72643. }
  72644. }
  72645. declare module "babylonjs/Shaders/ssao2.fragment" {
  72646. /** @hidden */
  72647. export var ssao2PixelShader: {
  72648. name: string;
  72649. shader: string;
  72650. };
  72651. }
  72652. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  72653. /** @hidden */
  72654. export var ssaoCombinePixelShader: {
  72655. name: string;
  72656. shader: string;
  72657. };
  72658. }
  72659. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  72660. import { Camera } from "babylonjs/Cameras/camera";
  72661. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72662. import { Scene } from "babylonjs/scene";
  72663. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72664. import "babylonjs/Shaders/ssao2.fragment";
  72665. import "babylonjs/Shaders/ssaoCombine.fragment";
  72666. /**
  72667. * Render pipeline to produce ssao effect
  72668. */
  72669. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72670. /**
  72671. * @ignore
  72672. * The PassPostProcess id in the pipeline that contains the original scene color
  72673. */
  72674. SSAOOriginalSceneColorEffect: string;
  72675. /**
  72676. * @ignore
  72677. * The SSAO PostProcess id in the pipeline
  72678. */
  72679. SSAORenderEffect: string;
  72680. /**
  72681. * @ignore
  72682. * The horizontal blur PostProcess id in the pipeline
  72683. */
  72684. SSAOBlurHRenderEffect: string;
  72685. /**
  72686. * @ignore
  72687. * The vertical blur PostProcess id in the pipeline
  72688. */
  72689. SSAOBlurVRenderEffect: string;
  72690. /**
  72691. * @ignore
  72692. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72693. */
  72694. SSAOCombineRenderEffect: string;
  72695. /**
  72696. * The output strength of the SSAO post-process. Default value is 1.0.
  72697. */
  72698. totalStrength: number;
  72699. /**
  72700. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72701. */
  72702. maxZ: number;
  72703. /**
  72704. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72705. */
  72706. minZAspect: number;
  72707. private _samples;
  72708. /**
  72709. * Number of samples used for the SSAO calculations. Default value is 8
  72710. */
  72711. set samples(n: number);
  72712. get samples(): number;
  72713. private _textureSamples;
  72714. /**
  72715. * Number of samples to use for antialiasing
  72716. */
  72717. set textureSamples(n: number);
  72718. get textureSamples(): number;
  72719. /**
  72720. * Ratio object used for SSAO ratio and blur ratio
  72721. */
  72722. private _ratio;
  72723. /**
  72724. * Dynamically generated sphere sampler.
  72725. */
  72726. private _sampleSphere;
  72727. /**
  72728. * Blur filter offsets
  72729. */
  72730. private _samplerOffsets;
  72731. private _expensiveBlur;
  72732. /**
  72733. * If bilateral blur should be used
  72734. */
  72735. set expensiveBlur(b: boolean);
  72736. get expensiveBlur(): boolean;
  72737. /**
  72738. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72739. */
  72740. radius: number;
  72741. /**
  72742. * The base color of the SSAO post-process
  72743. * The final result is "base + ssao" between [0, 1]
  72744. */
  72745. base: number;
  72746. /**
  72747. * Support test.
  72748. */
  72749. static get IsSupported(): boolean;
  72750. private _scene;
  72751. private _depthTexture;
  72752. private _normalTexture;
  72753. private _randomTexture;
  72754. private _originalColorPostProcess;
  72755. private _ssaoPostProcess;
  72756. private _blurHPostProcess;
  72757. private _blurVPostProcess;
  72758. private _ssaoCombinePostProcess;
  72759. /**
  72760. * Gets active scene
  72761. */
  72762. get scene(): Scene;
  72763. /**
  72764. * @constructor
  72765. * @param name The rendering pipeline name
  72766. * @param scene The scene linked to this pipeline
  72767. * @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 }
  72768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72769. */
  72770. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72771. /**
  72772. * Get the class name
  72773. * @returns "SSAO2RenderingPipeline"
  72774. */
  72775. getClassName(): string;
  72776. /**
  72777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72778. */
  72779. dispose(disableGeometryBufferRenderer?: boolean): void;
  72780. private _createBlurPostProcess;
  72781. /** @hidden */
  72782. _rebuild(): void;
  72783. private _bits;
  72784. private _radicalInverse_VdC;
  72785. private _hammersley;
  72786. private _hemisphereSample_uniform;
  72787. private _generateHemisphere;
  72788. private _createSSAOPostProcess;
  72789. private _createSSAOCombinePostProcess;
  72790. private _createRandomTexture;
  72791. /**
  72792. * Serialize the rendering pipeline (Used when exporting)
  72793. * @returns the serialized object
  72794. */
  72795. serialize(): any;
  72796. /**
  72797. * Parse the serialized pipeline
  72798. * @param source Source pipeline.
  72799. * @param scene The scene to load the pipeline to.
  72800. * @param rootUrl The URL of the serialized pipeline.
  72801. * @returns An instantiated pipeline from the serialized object.
  72802. */
  72803. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72804. }
  72805. }
  72806. declare module "babylonjs/Shaders/ssao.fragment" {
  72807. /** @hidden */
  72808. export var ssaoPixelShader: {
  72809. name: string;
  72810. shader: string;
  72811. };
  72812. }
  72813. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  72814. import { Camera } from "babylonjs/Cameras/camera";
  72815. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72816. import { Scene } from "babylonjs/scene";
  72817. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72818. import "babylonjs/Shaders/ssao.fragment";
  72819. import "babylonjs/Shaders/ssaoCombine.fragment";
  72820. /**
  72821. * Render pipeline to produce ssao effect
  72822. */
  72823. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72824. /**
  72825. * @ignore
  72826. * The PassPostProcess id in the pipeline that contains the original scene color
  72827. */
  72828. SSAOOriginalSceneColorEffect: string;
  72829. /**
  72830. * @ignore
  72831. * The SSAO PostProcess id in the pipeline
  72832. */
  72833. SSAORenderEffect: string;
  72834. /**
  72835. * @ignore
  72836. * The horizontal blur PostProcess id in the pipeline
  72837. */
  72838. SSAOBlurHRenderEffect: string;
  72839. /**
  72840. * @ignore
  72841. * The vertical blur PostProcess id in the pipeline
  72842. */
  72843. SSAOBlurVRenderEffect: string;
  72844. /**
  72845. * @ignore
  72846. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72847. */
  72848. SSAOCombineRenderEffect: string;
  72849. /**
  72850. * The output strength of the SSAO post-process. Default value is 1.0.
  72851. */
  72852. totalStrength: number;
  72853. /**
  72854. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72855. */
  72856. radius: number;
  72857. /**
  72858. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72859. * Must not be equal to fallOff and superior to fallOff.
  72860. * Default value is 0.0075
  72861. */
  72862. area: number;
  72863. /**
  72864. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72865. * Must not be equal to area and inferior to area.
  72866. * Default value is 0.000001
  72867. */
  72868. fallOff: number;
  72869. /**
  72870. * The base color of the SSAO post-process
  72871. * The final result is "base + ssao" between [0, 1]
  72872. */
  72873. base: number;
  72874. private _scene;
  72875. private _depthTexture;
  72876. private _randomTexture;
  72877. private _originalColorPostProcess;
  72878. private _ssaoPostProcess;
  72879. private _blurHPostProcess;
  72880. private _blurVPostProcess;
  72881. private _ssaoCombinePostProcess;
  72882. private _firstUpdate;
  72883. /**
  72884. * Gets active scene
  72885. */
  72886. get scene(): Scene;
  72887. /**
  72888. * @constructor
  72889. * @param name - The rendering pipeline name
  72890. * @param scene - The scene linked to this pipeline
  72891. * @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 }
  72892. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72893. */
  72894. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72895. /**
  72896. * Get the class name
  72897. * @returns "SSAORenderingPipeline"
  72898. */
  72899. getClassName(): string;
  72900. /**
  72901. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72902. */
  72903. dispose(disableDepthRender?: boolean): void;
  72904. private _createBlurPostProcess;
  72905. /** @hidden */
  72906. _rebuild(): void;
  72907. private _createSSAOPostProcess;
  72908. private _createSSAOCombinePostProcess;
  72909. private _createRandomTexture;
  72910. }
  72911. }
  72912. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  72913. /** @hidden */
  72914. export var screenSpaceReflectionPixelShader: {
  72915. name: string;
  72916. shader: string;
  72917. };
  72918. }
  72919. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  72920. import { Nullable } from "babylonjs/types";
  72921. import { Camera } from "babylonjs/Cameras/camera";
  72922. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72923. import { Scene } from "babylonjs/scene";
  72924. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  72925. import { Engine } from "babylonjs/Engines/engine";
  72926. /**
  72927. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72928. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72929. */
  72930. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72931. /**
  72932. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72933. */
  72934. threshold: number;
  72935. /**
  72936. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72937. */
  72938. strength: number;
  72939. /**
  72940. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72941. */
  72942. reflectionSpecularFalloffExponent: number;
  72943. /**
  72944. * 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]
  72945. */
  72946. step: number;
  72947. /**
  72948. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72949. */
  72950. roughnessFactor: number;
  72951. private _geometryBufferRenderer;
  72952. private _enableSmoothReflections;
  72953. private _reflectionSamples;
  72954. private _smoothSteps;
  72955. /**
  72956. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72957. * @param name The name of the effect.
  72958. * @param scene The scene containing the objects to calculate reflections.
  72959. * @param options The required width/height ratio to downsize to before computing the render pass.
  72960. * @param camera The camera to apply the render pass to.
  72961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72962. * @param engine The engine which the post process will be applied. (default: current engine)
  72963. * @param reusable If the post process can be reused on the same frame. (default: false)
  72964. * @param textureType Type of textures used when performing the post process. (default: 0)
  72965. * @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)
  72966. */
  72967. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72968. /**
  72969. * Gets wether or not smoothing reflections is enabled.
  72970. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72971. */
  72972. get enableSmoothReflections(): boolean;
  72973. /**
  72974. * Sets wether or not smoothing reflections is enabled.
  72975. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72976. */
  72977. set enableSmoothReflections(enabled: boolean);
  72978. /**
  72979. * Gets the number of samples taken while computing reflections. More samples count is high,
  72980. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72981. */
  72982. get reflectionSamples(): number;
  72983. /**
  72984. * Sets the number of samples taken while computing reflections. More samples count is high,
  72985. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72986. */
  72987. set reflectionSamples(samples: number);
  72988. /**
  72989. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72990. * more the post-process will require GPU power and can generate a drop in FPS.
  72991. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72992. */
  72993. get smoothSteps(): number;
  72994. set smoothSteps(steps: number);
  72995. private _updateEffectDefines;
  72996. }
  72997. }
  72998. declare module "babylonjs/Shaders/standard.fragment" {
  72999. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73000. /** @hidden */
  73001. export var standardPixelShader: {
  73002. name: string;
  73003. shader: string;
  73004. };
  73005. }
  73006. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73007. import { Nullable } from "babylonjs/types";
  73008. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73009. import { Camera } from "babylonjs/Cameras/camera";
  73010. import { Texture } from "babylonjs/Materials/Textures/texture";
  73011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73012. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73013. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73014. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73015. import { IDisposable } from "babylonjs/scene";
  73016. import { SpotLight } from "babylonjs/Lights/spotLight";
  73017. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73018. import { Scene } from "babylonjs/scene";
  73019. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73020. import { Animation } from "babylonjs/Animations/animation";
  73021. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73022. import "babylonjs/Shaders/standard.fragment";
  73023. /**
  73024. * Standard rendering pipeline
  73025. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73026. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73027. */
  73028. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73029. /**
  73030. * Public members
  73031. */
  73032. /**
  73033. * Post-process which contains the original scene color before the pipeline applies all the effects
  73034. */
  73035. originalPostProcess: Nullable<PostProcess>;
  73036. /**
  73037. * Post-process used to down scale an image x4
  73038. */
  73039. downSampleX4PostProcess: Nullable<PostProcess>;
  73040. /**
  73041. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73042. */
  73043. brightPassPostProcess: Nullable<PostProcess>;
  73044. /**
  73045. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73046. */
  73047. blurHPostProcesses: PostProcess[];
  73048. /**
  73049. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73050. */
  73051. blurVPostProcesses: PostProcess[];
  73052. /**
  73053. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73054. */
  73055. textureAdderPostProcess: Nullable<PostProcess>;
  73056. /**
  73057. * Post-process used to create volumetric lighting effect
  73058. */
  73059. volumetricLightPostProcess: Nullable<PostProcess>;
  73060. /**
  73061. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73062. */
  73063. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73064. /**
  73065. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73066. */
  73067. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73068. /**
  73069. * Post-process used to merge the volumetric light effect and the real scene color
  73070. */
  73071. volumetricLightMergePostProces: Nullable<PostProcess>;
  73072. /**
  73073. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73074. */
  73075. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73076. /**
  73077. * Base post-process used to calculate the average luminance of the final image for HDR
  73078. */
  73079. luminancePostProcess: Nullable<PostProcess>;
  73080. /**
  73081. * Post-processes used to create down sample post-processes in order to get
  73082. * the average luminance of the final image for HDR
  73083. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73084. */
  73085. luminanceDownSamplePostProcesses: PostProcess[];
  73086. /**
  73087. * Post-process used to create a HDR effect (light adaptation)
  73088. */
  73089. hdrPostProcess: Nullable<PostProcess>;
  73090. /**
  73091. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73092. */
  73093. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73094. /**
  73095. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73096. */
  73097. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73098. /**
  73099. * Post-process used to merge the final HDR post-process and the real scene color
  73100. */
  73101. hdrFinalPostProcess: Nullable<PostProcess>;
  73102. /**
  73103. * Post-process used to create a lens flare effect
  73104. */
  73105. lensFlarePostProcess: Nullable<PostProcess>;
  73106. /**
  73107. * Post-process that merges the result of the lens flare post-process and the real scene color
  73108. */
  73109. lensFlareComposePostProcess: Nullable<PostProcess>;
  73110. /**
  73111. * Post-process used to create a motion blur effect
  73112. */
  73113. motionBlurPostProcess: Nullable<PostProcess>;
  73114. /**
  73115. * Post-process used to create a depth of field effect
  73116. */
  73117. depthOfFieldPostProcess: Nullable<PostProcess>;
  73118. /**
  73119. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73120. */
  73121. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73122. /**
  73123. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73124. */
  73125. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73126. /**
  73127. * Represents the brightness threshold in order to configure the illuminated surfaces
  73128. */
  73129. brightThreshold: number;
  73130. /**
  73131. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73132. */
  73133. blurWidth: number;
  73134. /**
  73135. * Sets if the blur for highlighted surfaces must be only horizontal
  73136. */
  73137. horizontalBlur: boolean;
  73138. /**
  73139. * Gets the overall exposure used by the pipeline
  73140. */
  73141. get exposure(): number;
  73142. /**
  73143. * Sets the overall exposure used by the pipeline
  73144. */
  73145. set exposure(value: number);
  73146. /**
  73147. * Texture used typically to simulate "dirty" on camera lens
  73148. */
  73149. lensTexture: Nullable<Texture>;
  73150. /**
  73151. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73152. */
  73153. volumetricLightCoefficient: number;
  73154. /**
  73155. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73156. */
  73157. volumetricLightPower: number;
  73158. /**
  73159. * Used the set the blur intensity to smooth the volumetric lights
  73160. */
  73161. volumetricLightBlurScale: number;
  73162. /**
  73163. * Light (spot or directional) used to generate the volumetric lights rays
  73164. * The source light must have a shadow generate so the pipeline can get its
  73165. * depth map
  73166. */
  73167. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73168. /**
  73169. * For eye adaptation, represents the minimum luminance the eye can see
  73170. */
  73171. hdrMinimumLuminance: number;
  73172. /**
  73173. * For eye adaptation, represents the decrease luminance speed
  73174. */
  73175. hdrDecreaseRate: number;
  73176. /**
  73177. * For eye adaptation, represents the increase luminance speed
  73178. */
  73179. hdrIncreaseRate: number;
  73180. /**
  73181. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73182. */
  73183. get hdrAutoExposure(): boolean;
  73184. /**
  73185. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73186. */
  73187. set hdrAutoExposure(value: boolean);
  73188. /**
  73189. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73190. */
  73191. lensColorTexture: Nullable<Texture>;
  73192. /**
  73193. * The overall strengh for the lens flare effect
  73194. */
  73195. lensFlareStrength: number;
  73196. /**
  73197. * Dispersion coefficient for lens flare ghosts
  73198. */
  73199. lensFlareGhostDispersal: number;
  73200. /**
  73201. * Main lens flare halo width
  73202. */
  73203. lensFlareHaloWidth: number;
  73204. /**
  73205. * Based on the lens distortion effect, defines how much the lens flare result
  73206. * is distorted
  73207. */
  73208. lensFlareDistortionStrength: number;
  73209. /**
  73210. * Configures the blur intensity used for for lens flare (halo)
  73211. */
  73212. lensFlareBlurWidth: number;
  73213. /**
  73214. * Lens star texture must be used to simulate rays on the flares and is available
  73215. * in the documentation
  73216. */
  73217. lensStarTexture: Nullable<Texture>;
  73218. /**
  73219. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73220. * flare effect by taking account of the dirt texture
  73221. */
  73222. lensFlareDirtTexture: Nullable<Texture>;
  73223. /**
  73224. * Represents the focal length for the depth of field effect
  73225. */
  73226. depthOfFieldDistance: number;
  73227. /**
  73228. * Represents the blur intensity for the blurred part of the depth of field effect
  73229. */
  73230. depthOfFieldBlurWidth: number;
  73231. /**
  73232. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73233. */
  73234. get motionStrength(): number;
  73235. /**
  73236. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73237. */
  73238. set motionStrength(strength: number);
  73239. /**
  73240. * Gets wether or not the motion blur post-process is object based or screen based.
  73241. */
  73242. get objectBasedMotionBlur(): boolean;
  73243. /**
  73244. * Sets wether or not the motion blur post-process should be object based or screen based
  73245. */
  73246. set objectBasedMotionBlur(value: boolean);
  73247. /**
  73248. * List of animations for the pipeline (IAnimatable implementation)
  73249. */
  73250. animations: Animation[];
  73251. /**
  73252. * Private members
  73253. */
  73254. private _scene;
  73255. private _currentDepthOfFieldSource;
  73256. private _basePostProcess;
  73257. private _fixedExposure;
  73258. private _currentExposure;
  73259. private _hdrAutoExposure;
  73260. private _hdrCurrentLuminance;
  73261. private _motionStrength;
  73262. private _isObjectBasedMotionBlur;
  73263. private _floatTextureType;
  73264. private _camerasToBeAttached;
  73265. private _ratio;
  73266. private _bloomEnabled;
  73267. private _depthOfFieldEnabled;
  73268. private _vlsEnabled;
  73269. private _lensFlareEnabled;
  73270. private _hdrEnabled;
  73271. private _motionBlurEnabled;
  73272. private _fxaaEnabled;
  73273. private _screenSpaceReflectionsEnabled;
  73274. private _motionBlurSamples;
  73275. private _volumetricLightStepsCount;
  73276. private _samples;
  73277. /**
  73278. * @ignore
  73279. * Specifies if the bloom pipeline is enabled
  73280. */
  73281. get BloomEnabled(): boolean;
  73282. set BloomEnabled(enabled: boolean);
  73283. /**
  73284. * @ignore
  73285. * Specifies if the depth of field pipeline is enabed
  73286. */
  73287. get DepthOfFieldEnabled(): boolean;
  73288. set DepthOfFieldEnabled(enabled: boolean);
  73289. /**
  73290. * @ignore
  73291. * Specifies if the lens flare pipeline is enabed
  73292. */
  73293. get LensFlareEnabled(): boolean;
  73294. set LensFlareEnabled(enabled: boolean);
  73295. /**
  73296. * @ignore
  73297. * Specifies if the HDR pipeline is enabled
  73298. */
  73299. get HDREnabled(): boolean;
  73300. set HDREnabled(enabled: boolean);
  73301. /**
  73302. * @ignore
  73303. * Specifies if the volumetric lights scattering effect is enabled
  73304. */
  73305. get VLSEnabled(): boolean;
  73306. set VLSEnabled(enabled: boolean);
  73307. /**
  73308. * @ignore
  73309. * Specifies if the motion blur effect is enabled
  73310. */
  73311. get MotionBlurEnabled(): boolean;
  73312. set MotionBlurEnabled(enabled: boolean);
  73313. /**
  73314. * Specifies if anti-aliasing is enabled
  73315. */
  73316. get fxaaEnabled(): boolean;
  73317. set fxaaEnabled(enabled: boolean);
  73318. /**
  73319. * Specifies if screen space reflections are enabled.
  73320. */
  73321. get screenSpaceReflectionsEnabled(): boolean;
  73322. set screenSpaceReflectionsEnabled(enabled: boolean);
  73323. /**
  73324. * Specifies the number of steps used to calculate the volumetric lights
  73325. * Typically in interval [50, 200]
  73326. */
  73327. get volumetricLightStepsCount(): number;
  73328. set volumetricLightStepsCount(count: number);
  73329. /**
  73330. * Specifies the number of samples used for the motion blur effect
  73331. * Typically in interval [16, 64]
  73332. */
  73333. get motionBlurSamples(): number;
  73334. set motionBlurSamples(samples: number);
  73335. /**
  73336. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73337. */
  73338. get samples(): number;
  73339. set samples(sampleCount: number);
  73340. /**
  73341. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73342. * @constructor
  73343. * @param name The rendering pipeline name
  73344. * @param scene The scene linked to this pipeline
  73345. * @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)
  73346. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73347. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73348. */
  73349. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73350. private _buildPipeline;
  73351. private _createDownSampleX4PostProcess;
  73352. private _createBrightPassPostProcess;
  73353. private _createBlurPostProcesses;
  73354. private _createTextureAdderPostProcess;
  73355. private _createVolumetricLightPostProcess;
  73356. private _createLuminancePostProcesses;
  73357. private _createHdrPostProcess;
  73358. private _createLensFlarePostProcess;
  73359. private _createDepthOfFieldPostProcess;
  73360. private _createMotionBlurPostProcess;
  73361. private _getDepthTexture;
  73362. private _disposePostProcesses;
  73363. /**
  73364. * Dispose of the pipeline and stop all post processes
  73365. */
  73366. dispose(): void;
  73367. /**
  73368. * Serialize the rendering pipeline (Used when exporting)
  73369. * @returns the serialized object
  73370. */
  73371. serialize(): any;
  73372. /**
  73373. * Parse the serialized pipeline
  73374. * @param source Source pipeline.
  73375. * @param scene The scene to load the pipeline to.
  73376. * @param rootUrl The URL of the serialized pipeline.
  73377. * @returns An instantiated pipeline from the serialized object.
  73378. */
  73379. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73380. /**
  73381. * Luminance steps
  73382. */
  73383. static LuminanceSteps: number;
  73384. }
  73385. }
  73386. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73387. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73388. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73389. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73390. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73391. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73392. }
  73393. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73394. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73395. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73396. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73397. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73398. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73399. }
  73400. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73401. /** @hidden */
  73402. export var stereoscopicInterlacePixelShader: {
  73403. name: string;
  73404. shader: string;
  73405. };
  73406. }
  73407. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73408. import { Camera } from "babylonjs/Cameras/camera";
  73409. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73410. import { Engine } from "babylonjs/Engines/engine";
  73411. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73412. /**
  73413. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73414. */
  73415. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73416. private _stepSize;
  73417. private _passedProcess;
  73418. /**
  73419. * Initializes a StereoscopicInterlacePostProcessI
  73420. * @param name The name of the effect.
  73421. * @param rigCameras The rig cameras to be appled to the post process
  73422. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73423. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73425. * @param engine The engine which the post process will be applied. (default: current engine)
  73426. * @param reusable If the post process can be reused on the same frame. (default: false)
  73427. */
  73428. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73429. }
  73430. /**
  73431. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73432. */
  73433. export class StereoscopicInterlacePostProcess extends PostProcess {
  73434. private _stepSize;
  73435. private _passedProcess;
  73436. /**
  73437. * Initializes a StereoscopicInterlacePostProcess
  73438. * @param name The name of the effect.
  73439. * @param rigCameras The rig cameras to be appled to the post process
  73440. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73442. * @param engine The engine which the post process will be applied. (default: current engine)
  73443. * @param reusable If the post process can be reused on the same frame. (default: false)
  73444. */
  73445. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73446. }
  73447. }
  73448. declare module "babylonjs/Shaders/tonemap.fragment" {
  73449. /** @hidden */
  73450. export var tonemapPixelShader: {
  73451. name: string;
  73452. shader: string;
  73453. };
  73454. }
  73455. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73456. import { Camera } from "babylonjs/Cameras/camera";
  73457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73458. import "babylonjs/Shaders/tonemap.fragment";
  73459. import { Engine } from "babylonjs/Engines/engine";
  73460. /** Defines operator used for tonemapping */
  73461. export enum TonemappingOperator {
  73462. /** Hable */
  73463. Hable = 0,
  73464. /** Reinhard */
  73465. Reinhard = 1,
  73466. /** HejiDawson */
  73467. HejiDawson = 2,
  73468. /** Photographic */
  73469. Photographic = 3
  73470. }
  73471. /**
  73472. * Defines a post process to apply tone mapping
  73473. */
  73474. export class TonemapPostProcess extends PostProcess {
  73475. private _operator;
  73476. /** Defines the required exposure adjustement */
  73477. exposureAdjustment: number;
  73478. /**
  73479. * Creates a new TonemapPostProcess
  73480. * @param name defines the name of the postprocess
  73481. * @param _operator defines the operator to use
  73482. * @param exposureAdjustment defines the required exposure adjustement
  73483. * @param camera defines the camera to use (can be null)
  73484. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73485. * @param engine defines the hosting engine (can be ignore if camera is set)
  73486. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73487. */
  73488. constructor(name: string, _operator: TonemappingOperator,
  73489. /** Defines the required exposure adjustement */
  73490. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73491. }
  73492. }
  73493. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  73494. /** @hidden */
  73495. export var volumetricLightScatteringPixelShader: {
  73496. name: string;
  73497. shader: string;
  73498. };
  73499. }
  73500. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  73501. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73504. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73506. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73507. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73508. /** @hidden */
  73509. export var volumetricLightScatteringPassVertexShader: {
  73510. name: string;
  73511. shader: string;
  73512. };
  73513. }
  73514. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  73515. /** @hidden */
  73516. export var volumetricLightScatteringPassPixelShader: {
  73517. name: string;
  73518. shader: string;
  73519. };
  73520. }
  73521. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  73522. import { Vector3 } from "babylonjs/Maths/math.vector";
  73523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73524. import { Mesh } from "babylonjs/Meshes/mesh";
  73525. import { Camera } from "babylonjs/Cameras/camera";
  73526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73527. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73528. import { Scene } from "babylonjs/scene";
  73529. import "babylonjs/Meshes/Builders/planeBuilder";
  73530. import "babylonjs/Shaders/depth.vertex";
  73531. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  73532. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  73533. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  73534. import { Engine } from "babylonjs/Engines/engine";
  73535. /**
  73536. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73537. */
  73538. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73539. private _volumetricLightScatteringPass;
  73540. private _volumetricLightScatteringRTT;
  73541. private _viewPort;
  73542. private _screenCoordinates;
  73543. private _cachedDefines;
  73544. /**
  73545. * If not undefined, the mesh position is computed from the attached node position
  73546. */
  73547. attachedNode: {
  73548. position: Vector3;
  73549. };
  73550. /**
  73551. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73552. */
  73553. customMeshPosition: Vector3;
  73554. /**
  73555. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73556. */
  73557. useCustomMeshPosition: boolean;
  73558. /**
  73559. * If the post-process should inverse the light scattering direction
  73560. */
  73561. invert: boolean;
  73562. /**
  73563. * The internal mesh used by the post-process
  73564. */
  73565. mesh: Mesh;
  73566. /**
  73567. * @hidden
  73568. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73569. */
  73570. get useDiffuseColor(): boolean;
  73571. set useDiffuseColor(useDiffuseColor: boolean);
  73572. /**
  73573. * Array containing the excluded meshes not rendered in the internal pass
  73574. */
  73575. excludedMeshes: AbstractMesh[];
  73576. /**
  73577. * Controls the overall intensity of the post-process
  73578. */
  73579. exposure: number;
  73580. /**
  73581. * Dissipates each sample's contribution in range [0, 1]
  73582. */
  73583. decay: number;
  73584. /**
  73585. * Controls the overall intensity of each sample
  73586. */
  73587. weight: number;
  73588. /**
  73589. * Controls the density of each sample
  73590. */
  73591. density: number;
  73592. /**
  73593. * @constructor
  73594. * @param name The post-process name
  73595. * @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)
  73596. * @param camera The camera that the post-process will be attached to
  73597. * @param mesh The mesh used to create the light scattering
  73598. * @param samples The post-process quality, default 100
  73599. * @param samplingModeThe post-process filtering mode
  73600. * @param engine The babylon engine
  73601. * @param reusable If the post-process is reusable
  73602. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73603. */
  73604. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73605. /**
  73606. * Returns the string "VolumetricLightScatteringPostProcess"
  73607. * @returns "VolumetricLightScatteringPostProcess"
  73608. */
  73609. getClassName(): string;
  73610. private _isReady;
  73611. /**
  73612. * Sets the new light position for light scattering effect
  73613. * @param position The new custom light position
  73614. */
  73615. setCustomMeshPosition(position: Vector3): void;
  73616. /**
  73617. * Returns the light position for light scattering effect
  73618. * @return Vector3 The custom light position
  73619. */
  73620. getCustomMeshPosition(): Vector3;
  73621. /**
  73622. * Disposes the internal assets and detaches the post-process from the camera
  73623. */
  73624. dispose(camera: Camera): void;
  73625. /**
  73626. * Returns the render target texture used by the post-process
  73627. * @return the render target texture used by the post-process
  73628. */
  73629. getPass(): RenderTargetTexture;
  73630. private _meshExcluded;
  73631. private _createPass;
  73632. private _updateMeshScreenCoordinates;
  73633. /**
  73634. * Creates a default mesh for the Volumeric Light Scattering post-process
  73635. * @param name The mesh name
  73636. * @param scene The scene where to create the mesh
  73637. * @return the default mesh
  73638. */
  73639. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73640. }
  73641. }
  73642. declare module "babylonjs/PostProcesses/index" {
  73643. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  73644. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  73645. export * from "babylonjs/PostProcesses/bloomEffect";
  73646. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  73647. export * from "babylonjs/PostProcesses/blurPostProcess";
  73648. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73649. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  73650. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  73651. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  73652. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73653. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  73654. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  73655. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  73656. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73657. export * from "babylonjs/PostProcesses/filterPostProcess";
  73658. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  73659. export * from "babylonjs/PostProcesses/grainPostProcess";
  73660. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  73661. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73662. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  73663. export * from "babylonjs/PostProcesses/passPostProcess";
  73664. export * from "babylonjs/PostProcesses/postProcess";
  73665. export * from "babylonjs/PostProcesses/postProcessManager";
  73666. export * from "babylonjs/PostProcesses/refractionPostProcess";
  73667. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  73668. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  73669. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  73670. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  73671. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  73672. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  73673. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  73674. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73675. }
  73676. declare module "babylonjs/Probes/index" {
  73677. export * from "babylonjs/Probes/reflectionProbe";
  73678. }
  73679. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  73680. import { Scene } from "babylonjs/scene";
  73681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73682. import { SmartArray } from "babylonjs/Misc/smartArray";
  73683. import { ISceneComponent } from "babylonjs/sceneComponent";
  73684. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  73685. import "babylonjs/Meshes/Builders/boxBuilder";
  73686. import "babylonjs/Shaders/color.fragment";
  73687. import "babylonjs/Shaders/color.vertex";
  73688. import { Color3 } from "babylonjs/Maths/math.color";
  73689. import { Observable } from "babylonjs/Misc/observable";
  73690. module "babylonjs/scene" {
  73691. interface Scene {
  73692. /** @hidden (Backing field) */
  73693. _boundingBoxRenderer: BoundingBoxRenderer;
  73694. /** @hidden (Backing field) */
  73695. _forceShowBoundingBoxes: boolean;
  73696. /**
  73697. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73698. */
  73699. forceShowBoundingBoxes: boolean;
  73700. /**
  73701. * Gets the bounding box renderer associated with the scene
  73702. * @returns a BoundingBoxRenderer
  73703. */
  73704. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73705. }
  73706. }
  73707. module "babylonjs/Meshes/abstractMesh" {
  73708. interface AbstractMesh {
  73709. /** @hidden (Backing field) */
  73710. _showBoundingBox: boolean;
  73711. /**
  73712. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73713. */
  73714. showBoundingBox: boolean;
  73715. }
  73716. }
  73717. /**
  73718. * Component responsible of rendering the bounding box of the meshes in a scene.
  73719. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73720. */
  73721. export class BoundingBoxRenderer implements ISceneComponent {
  73722. /**
  73723. * The component name helpfull to identify the component in the list of scene components.
  73724. */
  73725. readonly name: string;
  73726. /**
  73727. * The scene the component belongs to.
  73728. */
  73729. scene: Scene;
  73730. /**
  73731. * Color of the bounding box lines placed in front of an object
  73732. */
  73733. frontColor: Color3;
  73734. /**
  73735. * Color of the bounding box lines placed behind an object
  73736. */
  73737. backColor: Color3;
  73738. /**
  73739. * Defines if the renderer should show the back lines or not
  73740. */
  73741. showBackLines: boolean;
  73742. /**
  73743. * Observable raised before rendering a bounding box
  73744. */
  73745. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73746. /**
  73747. * Observable raised after rendering a bounding box
  73748. */
  73749. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73750. /**
  73751. * @hidden
  73752. */
  73753. renderList: SmartArray<BoundingBox>;
  73754. private _colorShader;
  73755. private _vertexBuffers;
  73756. private _indexBuffer;
  73757. private _fillIndexBuffer;
  73758. private _fillIndexData;
  73759. /**
  73760. * Instantiates a new bounding box renderer in a scene.
  73761. * @param scene the scene the renderer renders in
  73762. */
  73763. constructor(scene: Scene);
  73764. /**
  73765. * Registers the component in a given scene
  73766. */
  73767. register(): void;
  73768. private _evaluateSubMesh;
  73769. private _activeMesh;
  73770. private _prepareRessources;
  73771. private _createIndexBuffer;
  73772. /**
  73773. * Rebuilds the elements related to this component in case of
  73774. * context lost for instance.
  73775. */
  73776. rebuild(): void;
  73777. /**
  73778. * @hidden
  73779. */
  73780. reset(): void;
  73781. /**
  73782. * Render the bounding boxes of a specific rendering group
  73783. * @param renderingGroupId defines the rendering group to render
  73784. */
  73785. render(renderingGroupId: number): void;
  73786. /**
  73787. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73788. * @param mesh Define the mesh to render the occlusion bounding box for
  73789. */
  73790. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73791. /**
  73792. * Dispose and release the resources attached to this renderer.
  73793. */
  73794. dispose(): void;
  73795. }
  73796. }
  73797. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  73798. import { Nullable } from "babylonjs/types";
  73799. import { Scene } from "babylonjs/scene";
  73800. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  73801. import { Camera } from "babylonjs/Cameras/camera";
  73802. import { ISceneComponent } from "babylonjs/sceneComponent";
  73803. module "babylonjs/scene" {
  73804. interface Scene {
  73805. /** @hidden (Backing field) */
  73806. _depthRenderer: {
  73807. [id: string]: DepthRenderer;
  73808. };
  73809. /**
  73810. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73811. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73812. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73813. * @returns the created depth renderer
  73814. */
  73815. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  73816. /**
  73817. * Disables a depth renderer for a given camera
  73818. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73819. */
  73820. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73821. }
  73822. }
  73823. /**
  73824. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73825. * in several rendering techniques.
  73826. */
  73827. export class DepthRendererSceneComponent implements ISceneComponent {
  73828. /**
  73829. * The component name helpfull to identify the component in the list of scene components.
  73830. */
  73831. readonly name: string;
  73832. /**
  73833. * The scene the component belongs to.
  73834. */
  73835. scene: Scene;
  73836. /**
  73837. * Creates a new instance of the component for the given scene
  73838. * @param scene Defines the scene to register the component in
  73839. */
  73840. constructor(scene: Scene);
  73841. /**
  73842. * Registers the component in a given scene
  73843. */
  73844. register(): void;
  73845. /**
  73846. * Rebuilds the elements related to this component in case of
  73847. * context lost for instance.
  73848. */
  73849. rebuild(): void;
  73850. /**
  73851. * Disposes the component and the associated ressources
  73852. */
  73853. dispose(): void;
  73854. private _gatherRenderTargets;
  73855. private _gatherActiveCameraRenderTargets;
  73856. }
  73857. }
  73858. declare module "babylonjs/Shaders/outline.fragment" {
  73859. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73860. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  73861. /** @hidden */
  73862. export var outlinePixelShader: {
  73863. name: string;
  73864. shader: string;
  73865. };
  73866. }
  73867. declare module "babylonjs/Shaders/outline.vertex" {
  73868. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73869. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73870. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73871. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73872. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73873. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73874. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73875. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73876. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  73877. /** @hidden */
  73878. export var outlineVertexShader: {
  73879. name: string;
  73880. shader: string;
  73881. };
  73882. }
  73883. declare module "babylonjs/Rendering/outlineRenderer" {
  73884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73885. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  73886. import { Scene } from "babylonjs/scene";
  73887. import { ISceneComponent } from "babylonjs/sceneComponent";
  73888. import "babylonjs/Shaders/outline.fragment";
  73889. import "babylonjs/Shaders/outline.vertex";
  73890. module "babylonjs/scene" {
  73891. interface Scene {
  73892. /** @hidden */
  73893. _outlineRenderer: OutlineRenderer;
  73894. /**
  73895. * Gets the outline renderer associated with the scene
  73896. * @returns a OutlineRenderer
  73897. */
  73898. getOutlineRenderer(): OutlineRenderer;
  73899. }
  73900. }
  73901. module "babylonjs/Meshes/abstractMesh" {
  73902. interface AbstractMesh {
  73903. /** @hidden (Backing field) */
  73904. _renderOutline: boolean;
  73905. /**
  73906. * Gets or sets a boolean indicating if the outline must be rendered as well
  73907. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73908. */
  73909. renderOutline: boolean;
  73910. /** @hidden (Backing field) */
  73911. _renderOverlay: boolean;
  73912. /**
  73913. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73914. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73915. */
  73916. renderOverlay: boolean;
  73917. }
  73918. }
  73919. /**
  73920. * This class is responsible to draw bothe outline/overlay of meshes.
  73921. * It should not be used directly but through the available method on mesh.
  73922. */
  73923. export class OutlineRenderer implements ISceneComponent {
  73924. /**
  73925. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73926. */
  73927. private static _StencilReference;
  73928. /**
  73929. * The name of the component. Each component must have a unique name.
  73930. */
  73931. name: string;
  73932. /**
  73933. * The scene the component belongs to.
  73934. */
  73935. scene: Scene;
  73936. /**
  73937. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73938. */
  73939. zOffset: number;
  73940. private _engine;
  73941. private _effect;
  73942. private _cachedDefines;
  73943. private _savedDepthWrite;
  73944. /**
  73945. * Instantiates a new outline renderer. (There could be only one per scene).
  73946. * @param scene Defines the scene it belongs to
  73947. */
  73948. constructor(scene: Scene);
  73949. /**
  73950. * Register the component to one instance of a scene.
  73951. */
  73952. register(): void;
  73953. /**
  73954. * Rebuilds the elements related to this component in case of
  73955. * context lost for instance.
  73956. */
  73957. rebuild(): void;
  73958. /**
  73959. * Disposes the component and the associated ressources.
  73960. */
  73961. dispose(): void;
  73962. /**
  73963. * Renders the outline in the canvas.
  73964. * @param subMesh Defines the sumesh to render
  73965. * @param batch Defines the batch of meshes in case of instances
  73966. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73967. */
  73968. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73969. /**
  73970. * Returns whether or not the outline renderer is ready for a given submesh.
  73971. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73972. * @param subMesh Defines the submesh to check readyness for
  73973. * @param useInstances Defines wheter wee are trying to render instances or not
  73974. * @returns true if ready otherwise false
  73975. */
  73976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73977. private _beforeRenderingMesh;
  73978. private _afterRenderingMesh;
  73979. }
  73980. }
  73981. declare module "babylonjs/Rendering/index" {
  73982. export * from "babylonjs/Rendering/boundingBoxRenderer";
  73983. export * from "babylonjs/Rendering/depthRenderer";
  73984. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  73985. export * from "babylonjs/Rendering/edgesRenderer";
  73986. export * from "babylonjs/Rendering/geometryBufferRenderer";
  73987. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73988. export * from "babylonjs/Rendering/outlineRenderer";
  73989. export * from "babylonjs/Rendering/renderingGroup";
  73990. export * from "babylonjs/Rendering/renderingManager";
  73991. export * from "babylonjs/Rendering/utilityLayerRenderer";
  73992. }
  73993. declare module "babylonjs/Sprites/ISprites" {
  73994. /**
  73995. * Defines the basic options interface of a Sprite Frame Source Size.
  73996. */
  73997. export interface ISpriteJSONSpriteSourceSize {
  73998. /**
  73999. * number of the original width of the Frame
  74000. */
  74001. w: number;
  74002. /**
  74003. * number of the original height of the Frame
  74004. */
  74005. h: number;
  74006. }
  74007. /**
  74008. * Defines the basic options interface of a Sprite Frame Data.
  74009. */
  74010. export interface ISpriteJSONSpriteFrameData {
  74011. /**
  74012. * number of the x offset of the Frame
  74013. */
  74014. x: number;
  74015. /**
  74016. * number of the y offset of the Frame
  74017. */
  74018. y: number;
  74019. /**
  74020. * number of the width of the Frame
  74021. */
  74022. w: number;
  74023. /**
  74024. * number of the height of the Frame
  74025. */
  74026. h: number;
  74027. }
  74028. /**
  74029. * Defines the basic options interface of a JSON Sprite.
  74030. */
  74031. export interface ISpriteJSONSprite {
  74032. /**
  74033. * string name of the Frame
  74034. */
  74035. filename: string;
  74036. /**
  74037. * ISpriteJSONSpriteFrame basic object of the frame data
  74038. */
  74039. frame: ISpriteJSONSpriteFrameData;
  74040. /**
  74041. * boolean to flag is the frame was rotated.
  74042. */
  74043. rotated: boolean;
  74044. /**
  74045. * boolean to flag is the frame was trimmed.
  74046. */
  74047. trimmed: boolean;
  74048. /**
  74049. * ISpriteJSONSpriteFrame basic object of the source data
  74050. */
  74051. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74052. /**
  74053. * ISpriteJSONSpriteFrame basic object of the source data
  74054. */
  74055. sourceSize: ISpriteJSONSpriteSourceSize;
  74056. }
  74057. /**
  74058. * Defines the basic options interface of a JSON atlas.
  74059. */
  74060. export interface ISpriteJSONAtlas {
  74061. /**
  74062. * Array of objects that contain the frame data.
  74063. */
  74064. frames: Array<ISpriteJSONSprite>;
  74065. /**
  74066. * object basic object containing the sprite meta data.
  74067. */
  74068. meta?: object;
  74069. }
  74070. }
  74071. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74072. /** @hidden */
  74073. export var spriteMapPixelShader: {
  74074. name: string;
  74075. shader: string;
  74076. };
  74077. }
  74078. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74079. /** @hidden */
  74080. export var spriteMapVertexShader: {
  74081. name: string;
  74082. shader: string;
  74083. };
  74084. }
  74085. declare module "babylonjs/Sprites/spriteMap" {
  74086. import { IDisposable, Scene } from "babylonjs/scene";
  74087. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74088. import { Texture } from "babylonjs/Materials/Textures/texture";
  74089. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74090. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74091. import "babylonjs/Meshes/Builders/planeBuilder";
  74092. import "babylonjs/Shaders/spriteMap.fragment";
  74093. import "babylonjs/Shaders/spriteMap.vertex";
  74094. /**
  74095. * Defines the basic options interface of a SpriteMap
  74096. */
  74097. export interface ISpriteMapOptions {
  74098. /**
  74099. * Vector2 of the number of cells in the grid.
  74100. */
  74101. stageSize?: Vector2;
  74102. /**
  74103. * Vector2 of the size of the output plane in World Units.
  74104. */
  74105. outputSize?: Vector2;
  74106. /**
  74107. * Vector3 of the position of the output plane in World Units.
  74108. */
  74109. outputPosition?: Vector3;
  74110. /**
  74111. * Vector3 of the rotation of the output plane.
  74112. */
  74113. outputRotation?: Vector3;
  74114. /**
  74115. * number of layers that the system will reserve in resources.
  74116. */
  74117. layerCount?: number;
  74118. /**
  74119. * number of max animation frames a single cell will reserve in resources.
  74120. */
  74121. maxAnimationFrames?: number;
  74122. /**
  74123. * number cell index of the base tile when the system compiles.
  74124. */
  74125. baseTile?: number;
  74126. /**
  74127. * boolean flip the sprite after its been repositioned by the framing data.
  74128. */
  74129. flipU?: boolean;
  74130. /**
  74131. * Vector3 scalar of the global RGB values of the SpriteMap.
  74132. */
  74133. colorMultiply?: Vector3;
  74134. }
  74135. /**
  74136. * Defines the IDisposable interface in order to be cleanable from resources.
  74137. */
  74138. export interface ISpriteMap extends IDisposable {
  74139. /**
  74140. * String name of the SpriteMap.
  74141. */
  74142. name: string;
  74143. /**
  74144. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74145. */
  74146. atlasJSON: ISpriteJSONAtlas;
  74147. /**
  74148. * Texture of the SpriteMap.
  74149. */
  74150. spriteSheet: Texture;
  74151. /**
  74152. * The parameters to initialize the SpriteMap with.
  74153. */
  74154. options: ISpriteMapOptions;
  74155. }
  74156. /**
  74157. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74158. */
  74159. export class SpriteMap implements ISpriteMap {
  74160. /** The Name of the spriteMap */
  74161. name: string;
  74162. /** The JSON file with the frame and meta data */
  74163. atlasJSON: ISpriteJSONAtlas;
  74164. /** The systems Sprite Sheet Texture */
  74165. spriteSheet: Texture;
  74166. /** Arguments passed with the Constructor */
  74167. options: ISpriteMapOptions;
  74168. /** Public Sprite Storage array, parsed from atlasJSON */
  74169. sprites: Array<ISpriteJSONSprite>;
  74170. /** Returns the Number of Sprites in the System */
  74171. get spriteCount(): number;
  74172. /** Returns the Position of Output Plane*/
  74173. get position(): Vector3;
  74174. /** Returns the Position of Output Plane*/
  74175. set position(v: Vector3);
  74176. /** Returns the Rotation of Output Plane*/
  74177. get rotation(): Vector3;
  74178. /** Returns the Rotation of Output Plane*/
  74179. set rotation(v: Vector3);
  74180. /** Sets the AnimationMap*/
  74181. get animationMap(): RawTexture;
  74182. /** Sets the AnimationMap*/
  74183. set animationMap(v: RawTexture);
  74184. /** Scene that the SpriteMap was created in */
  74185. private _scene;
  74186. /** Texture Buffer of Float32 that holds tile frame data*/
  74187. private _frameMap;
  74188. /** Texture Buffers of Float32 that holds tileMap data*/
  74189. private _tileMaps;
  74190. /** Texture Buffer of Float32 that holds Animation Data*/
  74191. private _animationMap;
  74192. /** Custom ShaderMaterial Central to the System*/
  74193. private _material;
  74194. /** Custom ShaderMaterial Central to the System*/
  74195. private _output;
  74196. /** Systems Time Ticker*/
  74197. private _time;
  74198. /**
  74199. * Creates a new SpriteMap
  74200. * @param name defines the SpriteMaps Name
  74201. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74202. * @param spriteSheet is the Texture that the Sprites are on.
  74203. * @param options a basic deployment configuration
  74204. * @param scene The Scene that the map is deployed on
  74205. */
  74206. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74207. /**
  74208. * Returns tileID location
  74209. * @returns Vector2 the cell position ID
  74210. */
  74211. getTileID(): Vector2;
  74212. /**
  74213. * Gets the UV location of the mouse over the SpriteMap.
  74214. * @returns Vector2 the UV position of the mouse interaction
  74215. */
  74216. getMousePosition(): Vector2;
  74217. /**
  74218. * Creates the "frame" texture Buffer
  74219. * -------------------------------------
  74220. * Structure of frames
  74221. * "filename": "Falling-Water-2.png",
  74222. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74223. * "rotated": true,
  74224. * "trimmed": true,
  74225. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74226. * "sourceSize": {"w":32,"h":32}
  74227. * @returns RawTexture of the frameMap
  74228. */
  74229. private _createFrameBuffer;
  74230. /**
  74231. * Creates the tileMap texture Buffer
  74232. * @param buffer normally and array of numbers, or a false to generate from scratch
  74233. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74234. * @returns RawTexture of the tileMap
  74235. */
  74236. private _createTileBuffer;
  74237. /**
  74238. * Modifies the data of the tileMaps
  74239. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74240. * @param pos is the iVector2 Coordinates of the Tile
  74241. * @param tile The SpriteIndex of the new Tile
  74242. */
  74243. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74244. /**
  74245. * Creates the animationMap texture Buffer
  74246. * @param buffer normally and array of numbers, or a false to generate from scratch
  74247. * @returns RawTexture of the animationMap
  74248. */
  74249. private _createTileAnimationBuffer;
  74250. /**
  74251. * Modifies the data of the animationMap
  74252. * @param cellID is the Index of the Sprite
  74253. * @param _frame is the target Animation frame
  74254. * @param toCell is the Target Index of the next frame of the animation
  74255. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74256. * @param speed is a global scalar of the time variable on the map.
  74257. */
  74258. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74259. /**
  74260. * Exports the .tilemaps file
  74261. */
  74262. saveTileMaps(): void;
  74263. /**
  74264. * Imports the .tilemaps file
  74265. * @param url of the .tilemaps file
  74266. */
  74267. loadTileMaps(url: string): void;
  74268. /**
  74269. * Release associated resources
  74270. */
  74271. dispose(): void;
  74272. }
  74273. }
  74274. declare module "babylonjs/Sprites/spritePackedManager" {
  74275. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74276. import { Scene } from "babylonjs/scene";
  74277. /**
  74278. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74279. * @see http://doc.babylonjs.com/babylon101/sprites
  74280. */
  74281. export class SpritePackedManager extends SpriteManager {
  74282. /** defines the packed manager's name */
  74283. name: string;
  74284. /**
  74285. * Creates a new sprite manager from a packed sprite sheet
  74286. * @param name defines the manager's name
  74287. * @param imgUrl defines the sprite sheet url
  74288. * @param capacity defines the maximum allowed number of sprites
  74289. * @param scene defines the hosting scene
  74290. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74291. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74292. * @param samplingMode defines the smapling mode to use with spritesheet
  74293. * @param fromPacked set to true; do not alter
  74294. */
  74295. constructor(
  74296. /** defines the packed manager's name */
  74297. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74298. }
  74299. }
  74300. declare module "babylonjs/Sprites/index" {
  74301. export * from "babylonjs/Sprites/sprite";
  74302. export * from "babylonjs/Sprites/ISprites";
  74303. export * from "babylonjs/Sprites/spriteManager";
  74304. export * from "babylonjs/Sprites/spriteMap";
  74305. export * from "babylonjs/Sprites/spritePackedManager";
  74306. export * from "babylonjs/Sprites/spriteSceneComponent";
  74307. }
  74308. declare module "babylonjs/States/index" {
  74309. export * from "babylonjs/States/alphaCullingState";
  74310. export * from "babylonjs/States/depthCullingState";
  74311. export * from "babylonjs/States/stencilState";
  74312. }
  74313. declare module "babylonjs/Misc/assetsManager" {
  74314. import { Scene } from "babylonjs/scene";
  74315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74316. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74317. import { Skeleton } from "babylonjs/Bones/skeleton";
  74318. import { Observable } from "babylonjs/Misc/observable";
  74319. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74320. import { Texture } from "babylonjs/Materials/Textures/texture";
  74321. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74322. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74323. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74324. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74325. /**
  74326. * Defines the list of states available for a task inside a AssetsManager
  74327. */
  74328. export enum AssetTaskState {
  74329. /**
  74330. * Initialization
  74331. */
  74332. INIT = 0,
  74333. /**
  74334. * Running
  74335. */
  74336. RUNNING = 1,
  74337. /**
  74338. * Done
  74339. */
  74340. DONE = 2,
  74341. /**
  74342. * Error
  74343. */
  74344. ERROR = 3
  74345. }
  74346. /**
  74347. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74348. */
  74349. export abstract class AbstractAssetTask {
  74350. /**
  74351. * Task name
  74352. */ name: string;
  74353. /**
  74354. * Callback called when the task is successful
  74355. */
  74356. onSuccess: (task: any) => void;
  74357. /**
  74358. * Callback called when the task is not successful
  74359. */
  74360. onError: (task: any, message?: string, exception?: any) => void;
  74361. /**
  74362. * Creates a new AssetsManager
  74363. * @param name defines the name of the task
  74364. */
  74365. constructor(
  74366. /**
  74367. * Task name
  74368. */ name: string);
  74369. private _isCompleted;
  74370. private _taskState;
  74371. private _errorObject;
  74372. /**
  74373. * Get if the task is completed
  74374. */
  74375. get isCompleted(): boolean;
  74376. /**
  74377. * Gets the current state of the task
  74378. */
  74379. get taskState(): AssetTaskState;
  74380. /**
  74381. * Gets the current error object (if task is in error)
  74382. */
  74383. get errorObject(): {
  74384. message?: string;
  74385. exception?: any;
  74386. };
  74387. /**
  74388. * Internal only
  74389. * @hidden
  74390. */
  74391. _setErrorObject(message?: string, exception?: any): void;
  74392. /**
  74393. * Execute the current task
  74394. * @param scene defines the scene where you want your assets to be loaded
  74395. * @param onSuccess is a callback called when the task is successfully executed
  74396. * @param onError is a callback called if an error occurs
  74397. */
  74398. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74399. /**
  74400. * Execute the current task
  74401. * @param scene defines the scene where you want your assets to be loaded
  74402. * @param onSuccess is a callback called when the task is successfully executed
  74403. * @param onError is a callback called if an error occurs
  74404. */
  74405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74406. /**
  74407. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74408. * This can be used with failed tasks that have the reason for failure fixed.
  74409. */
  74410. reset(): void;
  74411. private onErrorCallback;
  74412. private onDoneCallback;
  74413. }
  74414. /**
  74415. * Define the interface used by progress events raised during assets loading
  74416. */
  74417. export interface IAssetsProgressEvent {
  74418. /**
  74419. * Defines the number of remaining tasks to process
  74420. */
  74421. remainingCount: number;
  74422. /**
  74423. * Defines the total number of tasks
  74424. */
  74425. totalCount: number;
  74426. /**
  74427. * Defines the task that was just processed
  74428. */
  74429. task: AbstractAssetTask;
  74430. }
  74431. /**
  74432. * Class used to share progress information about assets loading
  74433. */
  74434. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74435. /**
  74436. * Defines the number of remaining tasks to process
  74437. */
  74438. remainingCount: number;
  74439. /**
  74440. * Defines the total number of tasks
  74441. */
  74442. totalCount: number;
  74443. /**
  74444. * Defines the task that was just processed
  74445. */
  74446. task: AbstractAssetTask;
  74447. /**
  74448. * Creates a AssetsProgressEvent
  74449. * @param remainingCount defines the number of remaining tasks to process
  74450. * @param totalCount defines the total number of tasks
  74451. * @param task defines the task that was just processed
  74452. */
  74453. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74454. }
  74455. /**
  74456. * Define a task used by AssetsManager to load meshes
  74457. */
  74458. export class MeshAssetTask extends AbstractAssetTask {
  74459. /**
  74460. * Defines the name of the task
  74461. */
  74462. name: string;
  74463. /**
  74464. * Defines the list of mesh's names you want to load
  74465. */
  74466. meshesNames: any;
  74467. /**
  74468. * Defines the root url to use as a base to load your meshes and associated resources
  74469. */
  74470. rootUrl: string;
  74471. /**
  74472. * Defines the filename or File of the scene to load from
  74473. */
  74474. sceneFilename: string | File;
  74475. /**
  74476. * Gets the list of loaded meshes
  74477. */
  74478. loadedMeshes: Array<AbstractMesh>;
  74479. /**
  74480. * Gets the list of loaded particle systems
  74481. */
  74482. loadedParticleSystems: Array<IParticleSystem>;
  74483. /**
  74484. * Gets the list of loaded skeletons
  74485. */
  74486. loadedSkeletons: Array<Skeleton>;
  74487. /**
  74488. * Gets the list of loaded animation groups
  74489. */
  74490. loadedAnimationGroups: Array<AnimationGroup>;
  74491. /**
  74492. * Callback called when the task is successful
  74493. */
  74494. onSuccess: (task: MeshAssetTask) => void;
  74495. /**
  74496. * Callback called when the task is successful
  74497. */
  74498. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74499. /**
  74500. * Creates a new MeshAssetTask
  74501. * @param name defines the name of the task
  74502. * @param meshesNames defines the list of mesh's names you want to load
  74503. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74504. * @param sceneFilename defines the filename or File of the scene to load from
  74505. */
  74506. constructor(
  74507. /**
  74508. * Defines the name of the task
  74509. */
  74510. name: string,
  74511. /**
  74512. * Defines the list of mesh's names you want to load
  74513. */
  74514. meshesNames: any,
  74515. /**
  74516. * Defines the root url to use as a base to load your meshes and associated resources
  74517. */
  74518. rootUrl: string,
  74519. /**
  74520. * Defines the filename or File of the scene to load from
  74521. */
  74522. sceneFilename: string | File);
  74523. /**
  74524. * Execute the current task
  74525. * @param scene defines the scene where you want your assets to be loaded
  74526. * @param onSuccess is a callback called when the task is successfully executed
  74527. * @param onError is a callback called if an error occurs
  74528. */
  74529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74530. }
  74531. /**
  74532. * Define a task used by AssetsManager to load text content
  74533. */
  74534. export class TextFileAssetTask extends AbstractAssetTask {
  74535. /**
  74536. * Defines the name of the task
  74537. */
  74538. name: string;
  74539. /**
  74540. * Defines the location of the file to load
  74541. */
  74542. url: string;
  74543. /**
  74544. * Gets the loaded text string
  74545. */
  74546. text: string;
  74547. /**
  74548. * Callback called when the task is successful
  74549. */
  74550. onSuccess: (task: TextFileAssetTask) => void;
  74551. /**
  74552. * Callback called when the task is successful
  74553. */
  74554. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74555. /**
  74556. * Creates a new TextFileAssetTask object
  74557. * @param name defines the name of the task
  74558. * @param url defines the location of the file to load
  74559. */
  74560. constructor(
  74561. /**
  74562. * Defines the name of the task
  74563. */
  74564. name: string,
  74565. /**
  74566. * Defines the location of the file to load
  74567. */
  74568. url: string);
  74569. /**
  74570. * Execute the current task
  74571. * @param scene defines the scene where you want your assets to be loaded
  74572. * @param onSuccess is a callback called when the task is successfully executed
  74573. * @param onError is a callback called if an error occurs
  74574. */
  74575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74576. }
  74577. /**
  74578. * Define a task used by AssetsManager to load binary data
  74579. */
  74580. export class BinaryFileAssetTask extends AbstractAssetTask {
  74581. /**
  74582. * Defines the name of the task
  74583. */
  74584. name: string;
  74585. /**
  74586. * Defines the location of the file to load
  74587. */
  74588. url: string;
  74589. /**
  74590. * Gets the lodaded data (as an array buffer)
  74591. */
  74592. data: ArrayBuffer;
  74593. /**
  74594. * Callback called when the task is successful
  74595. */
  74596. onSuccess: (task: BinaryFileAssetTask) => void;
  74597. /**
  74598. * Callback called when the task is successful
  74599. */
  74600. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74601. /**
  74602. * Creates a new BinaryFileAssetTask object
  74603. * @param name defines the name of the new task
  74604. * @param url defines the location of the file to load
  74605. */
  74606. constructor(
  74607. /**
  74608. * Defines the name of the task
  74609. */
  74610. name: string,
  74611. /**
  74612. * Defines the location of the file to load
  74613. */
  74614. url: string);
  74615. /**
  74616. * Execute the current task
  74617. * @param scene defines the scene where you want your assets to be loaded
  74618. * @param onSuccess is a callback called when the task is successfully executed
  74619. * @param onError is a callback called if an error occurs
  74620. */
  74621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74622. }
  74623. /**
  74624. * Define a task used by AssetsManager to load images
  74625. */
  74626. export class ImageAssetTask extends AbstractAssetTask {
  74627. /**
  74628. * Defines the name of the task
  74629. */
  74630. name: string;
  74631. /**
  74632. * Defines the location of the image to load
  74633. */
  74634. url: string;
  74635. /**
  74636. * Gets the loaded images
  74637. */
  74638. image: HTMLImageElement;
  74639. /**
  74640. * Callback called when the task is successful
  74641. */
  74642. onSuccess: (task: ImageAssetTask) => void;
  74643. /**
  74644. * Callback called when the task is successful
  74645. */
  74646. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74647. /**
  74648. * Creates a new ImageAssetTask
  74649. * @param name defines the name of the task
  74650. * @param url defines the location of the image to load
  74651. */
  74652. constructor(
  74653. /**
  74654. * Defines the name of the task
  74655. */
  74656. name: string,
  74657. /**
  74658. * Defines the location of the image to load
  74659. */
  74660. url: string);
  74661. /**
  74662. * Execute the current task
  74663. * @param scene defines the scene where you want your assets to be loaded
  74664. * @param onSuccess is a callback called when the task is successfully executed
  74665. * @param onError is a callback called if an error occurs
  74666. */
  74667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74668. }
  74669. /**
  74670. * Defines the interface used by texture loading tasks
  74671. */
  74672. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74673. /**
  74674. * Gets the loaded texture
  74675. */
  74676. texture: TEX;
  74677. }
  74678. /**
  74679. * Define a task used by AssetsManager to load 2D textures
  74680. */
  74681. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74682. /**
  74683. * Defines the name of the task
  74684. */
  74685. name: string;
  74686. /**
  74687. * Defines the location of the file to load
  74688. */
  74689. url: string;
  74690. /**
  74691. * Defines if mipmap should not be generated (default is false)
  74692. */
  74693. noMipmap?: boolean | undefined;
  74694. /**
  74695. * Defines if texture must be inverted on Y axis (default is true)
  74696. */
  74697. invertY: boolean;
  74698. /**
  74699. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74700. */
  74701. samplingMode: number;
  74702. /**
  74703. * Gets the loaded texture
  74704. */
  74705. texture: Texture;
  74706. /**
  74707. * Callback called when the task is successful
  74708. */
  74709. onSuccess: (task: TextureAssetTask) => void;
  74710. /**
  74711. * Callback called when the task is successful
  74712. */
  74713. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74714. /**
  74715. * Creates a new TextureAssetTask object
  74716. * @param name defines the name of the task
  74717. * @param url defines the location of the file to load
  74718. * @param noMipmap defines if mipmap should not be generated (default is false)
  74719. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74720. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74721. */
  74722. constructor(
  74723. /**
  74724. * Defines the name of the task
  74725. */
  74726. name: string,
  74727. /**
  74728. * Defines the location of the file to load
  74729. */
  74730. url: string,
  74731. /**
  74732. * Defines if mipmap should not be generated (default is false)
  74733. */
  74734. noMipmap?: boolean | undefined,
  74735. /**
  74736. * Defines if texture must be inverted on Y axis (default is true)
  74737. */
  74738. invertY?: boolean,
  74739. /**
  74740. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74741. */
  74742. samplingMode?: number);
  74743. /**
  74744. * Execute the current task
  74745. * @param scene defines the scene where you want your assets to be loaded
  74746. * @param onSuccess is a callback called when the task is successfully executed
  74747. * @param onError is a callback called if an error occurs
  74748. */
  74749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74750. }
  74751. /**
  74752. * Define a task used by AssetsManager to load cube textures
  74753. */
  74754. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74755. /**
  74756. * Defines the name of the task
  74757. */
  74758. name: string;
  74759. /**
  74760. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74761. */
  74762. url: string;
  74763. /**
  74764. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74765. */
  74766. extensions?: string[] | undefined;
  74767. /**
  74768. * Defines if mipmaps should not be generated (default is false)
  74769. */
  74770. noMipmap?: boolean | undefined;
  74771. /**
  74772. * Defines the explicit list of files (undefined by default)
  74773. */
  74774. files?: string[] | undefined;
  74775. /**
  74776. * Gets the loaded texture
  74777. */
  74778. texture: CubeTexture;
  74779. /**
  74780. * Callback called when the task is successful
  74781. */
  74782. onSuccess: (task: CubeTextureAssetTask) => void;
  74783. /**
  74784. * Callback called when the task is successful
  74785. */
  74786. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74787. /**
  74788. * Creates a new CubeTextureAssetTask
  74789. * @param name defines the name of the task
  74790. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74791. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74792. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74793. * @param files defines the explicit list of files (undefined by default)
  74794. */
  74795. constructor(
  74796. /**
  74797. * Defines the name of the task
  74798. */
  74799. name: string,
  74800. /**
  74801. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74802. */
  74803. url: string,
  74804. /**
  74805. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74806. */
  74807. extensions?: string[] | undefined,
  74808. /**
  74809. * Defines if mipmaps should not be generated (default is false)
  74810. */
  74811. noMipmap?: boolean | undefined,
  74812. /**
  74813. * Defines the explicit list of files (undefined by default)
  74814. */
  74815. files?: string[] | undefined);
  74816. /**
  74817. * Execute the current task
  74818. * @param scene defines the scene where you want your assets to be loaded
  74819. * @param onSuccess is a callback called when the task is successfully executed
  74820. * @param onError is a callback called if an error occurs
  74821. */
  74822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74823. }
  74824. /**
  74825. * Define a task used by AssetsManager to load HDR cube textures
  74826. */
  74827. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74828. /**
  74829. * Defines the name of the task
  74830. */
  74831. name: string;
  74832. /**
  74833. * Defines the location of the file to load
  74834. */
  74835. url: string;
  74836. /**
  74837. * Defines the desired size (the more it increases the longer the generation will be)
  74838. */
  74839. size: number;
  74840. /**
  74841. * Defines if mipmaps should not be generated (default is false)
  74842. */
  74843. noMipmap: boolean;
  74844. /**
  74845. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74846. */
  74847. generateHarmonics: boolean;
  74848. /**
  74849. * 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)
  74850. */
  74851. gammaSpace: boolean;
  74852. /**
  74853. * Internal Use Only
  74854. */
  74855. reserved: boolean;
  74856. /**
  74857. * Gets the loaded texture
  74858. */
  74859. texture: HDRCubeTexture;
  74860. /**
  74861. * Callback called when the task is successful
  74862. */
  74863. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74864. /**
  74865. * Callback called when the task is successful
  74866. */
  74867. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74868. /**
  74869. * Creates a new HDRCubeTextureAssetTask object
  74870. * @param name defines the name of the task
  74871. * @param url defines the location of the file to load
  74872. * @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.
  74873. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74874. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74875. * @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)
  74876. * @param reserved Internal use only
  74877. */
  74878. constructor(
  74879. /**
  74880. * Defines the name of the task
  74881. */
  74882. name: string,
  74883. /**
  74884. * Defines the location of the file to load
  74885. */
  74886. url: string,
  74887. /**
  74888. * Defines the desired size (the more it increases the longer the generation will be)
  74889. */
  74890. size: number,
  74891. /**
  74892. * Defines if mipmaps should not be generated (default is false)
  74893. */
  74894. noMipmap?: boolean,
  74895. /**
  74896. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74897. */
  74898. generateHarmonics?: boolean,
  74899. /**
  74900. * 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)
  74901. */
  74902. gammaSpace?: boolean,
  74903. /**
  74904. * Internal Use Only
  74905. */
  74906. reserved?: boolean);
  74907. /**
  74908. * Execute the current task
  74909. * @param scene defines the scene where you want your assets to be loaded
  74910. * @param onSuccess is a callback called when the task is successfully executed
  74911. * @param onError is a callback called if an error occurs
  74912. */
  74913. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74914. }
  74915. /**
  74916. * Define a task used by AssetsManager to load Equirectangular cube textures
  74917. */
  74918. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74919. /**
  74920. * Defines the name of the task
  74921. */
  74922. name: string;
  74923. /**
  74924. * Defines the location of the file to load
  74925. */
  74926. url: string;
  74927. /**
  74928. * Defines the desired size (the more it increases the longer the generation will be)
  74929. */
  74930. size: number;
  74931. /**
  74932. * Defines if mipmaps should not be generated (default is false)
  74933. */
  74934. noMipmap: boolean;
  74935. /**
  74936. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74937. * but the standard material would require them in Gamma space) (default is true)
  74938. */
  74939. gammaSpace: boolean;
  74940. /**
  74941. * Gets the loaded texture
  74942. */
  74943. texture: EquiRectangularCubeTexture;
  74944. /**
  74945. * Callback called when the task is successful
  74946. */
  74947. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74948. /**
  74949. * Callback called when the task is successful
  74950. */
  74951. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74952. /**
  74953. * Creates a new EquiRectangularCubeTextureAssetTask object
  74954. * @param name defines the name of the task
  74955. * @param url defines the location of the file to load
  74956. * @param size defines the desired size (the more it increases the longer the generation will be)
  74957. * If the size is omitted this implies you are using a preprocessed cubemap.
  74958. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74959. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74960. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74961. * (default is true)
  74962. */
  74963. constructor(
  74964. /**
  74965. * Defines the name of the task
  74966. */
  74967. name: string,
  74968. /**
  74969. * Defines the location of the file to load
  74970. */
  74971. url: string,
  74972. /**
  74973. * Defines the desired size (the more it increases the longer the generation will be)
  74974. */
  74975. size: number,
  74976. /**
  74977. * Defines if mipmaps should not be generated (default is false)
  74978. */
  74979. noMipmap?: boolean,
  74980. /**
  74981. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74982. * but the standard material would require them in Gamma space) (default is true)
  74983. */
  74984. gammaSpace?: boolean);
  74985. /**
  74986. * Execute the current task
  74987. * @param scene defines the scene where you want your assets to be loaded
  74988. * @param onSuccess is a callback called when the task is successfully executed
  74989. * @param onError is a callback called if an error occurs
  74990. */
  74991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74992. }
  74993. /**
  74994. * This class can be used to easily import assets into a scene
  74995. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74996. */
  74997. export class AssetsManager {
  74998. private _scene;
  74999. private _isLoading;
  75000. protected _tasks: AbstractAssetTask[];
  75001. protected _waitingTasksCount: number;
  75002. protected _totalTasksCount: number;
  75003. /**
  75004. * Callback called when all tasks are processed
  75005. */
  75006. onFinish: (tasks: AbstractAssetTask[]) => void;
  75007. /**
  75008. * Callback called when a task is successful
  75009. */
  75010. onTaskSuccess: (task: AbstractAssetTask) => void;
  75011. /**
  75012. * Callback called when a task had an error
  75013. */
  75014. onTaskError: (task: AbstractAssetTask) => void;
  75015. /**
  75016. * Callback called when a task is done (whatever the result is)
  75017. */
  75018. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75019. /**
  75020. * Observable called when all tasks are processed
  75021. */
  75022. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75023. /**
  75024. * Observable called when a task had an error
  75025. */
  75026. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75027. /**
  75028. * Observable called when all tasks were executed
  75029. */
  75030. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75031. /**
  75032. * Observable called when a task is done (whatever the result is)
  75033. */
  75034. onProgressObservable: Observable<IAssetsProgressEvent>;
  75035. /**
  75036. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75037. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75038. */
  75039. useDefaultLoadingScreen: boolean;
  75040. /**
  75041. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75042. * when all assets have been downloaded.
  75043. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75044. */
  75045. autoHideLoadingUI: boolean;
  75046. /**
  75047. * Creates a new AssetsManager
  75048. * @param scene defines the scene to work on
  75049. */
  75050. constructor(scene: Scene);
  75051. /**
  75052. * Add a MeshAssetTask to the list of active tasks
  75053. * @param taskName defines the name of the new task
  75054. * @param meshesNames defines the name of meshes to load
  75055. * @param rootUrl defines the root url to use to locate files
  75056. * @param sceneFilename defines the filename of the scene file
  75057. * @returns a new MeshAssetTask object
  75058. */
  75059. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75060. /**
  75061. * Add a TextFileAssetTask to the list of active tasks
  75062. * @param taskName defines the name of the new task
  75063. * @param url defines the url of the file to load
  75064. * @returns a new TextFileAssetTask object
  75065. */
  75066. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75067. /**
  75068. * Add a BinaryFileAssetTask to the list of active tasks
  75069. * @param taskName defines the name of the new task
  75070. * @param url defines the url of the file to load
  75071. * @returns a new BinaryFileAssetTask object
  75072. */
  75073. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75074. /**
  75075. * Add a ImageAssetTask to the list of active tasks
  75076. * @param taskName defines the name of the new task
  75077. * @param url defines the url of the file to load
  75078. * @returns a new ImageAssetTask object
  75079. */
  75080. addImageTask(taskName: string, url: string): ImageAssetTask;
  75081. /**
  75082. * Add a TextureAssetTask to the list of active tasks
  75083. * @param taskName defines the name of the new task
  75084. * @param url defines the url of the file to load
  75085. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75086. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75087. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75088. * @returns a new TextureAssetTask object
  75089. */
  75090. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75091. /**
  75092. * Add a CubeTextureAssetTask to the list of active tasks
  75093. * @param taskName defines the name of the new task
  75094. * @param url defines the url of the file to load
  75095. * @param extensions defines the extension to use to load the cube map (can be null)
  75096. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75097. * @param files defines the list of files to load (can be null)
  75098. * @returns a new CubeTextureAssetTask object
  75099. */
  75100. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75101. /**
  75102. *
  75103. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75104. * @param taskName defines the name of the new task
  75105. * @param url defines the url of the file to load
  75106. * @param size defines the size you want for the cubemap (can be null)
  75107. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75108. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75109. * @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)
  75110. * @param reserved Internal use only
  75111. * @returns a new HDRCubeTextureAssetTask object
  75112. */
  75113. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75114. /**
  75115. *
  75116. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75117. * @param taskName defines the name of the new task
  75118. * @param url defines the url of the file to load
  75119. * @param size defines the size you want for the cubemap (can be null)
  75120. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75121. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75122. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75123. * @returns a new EquiRectangularCubeTextureAssetTask object
  75124. */
  75125. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75126. /**
  75127. * Remove a task from the assets manager.
  75128. * @param task the task to remove
  75129. */
  75130. removeTask(task: AbstractAssetTask): void;
  75131. private _decreaseWaitingTasksCount;
  75132. private _runTask;
  75133. /**
  75134. * Reset the AssetsManager and remove all tasks
  75135. * @return the current instance of the AssetsManager
  75136. */
  75137. reset(): AssetsManager;
  75138. /**
  75139. * Start the loading process
  75140. * @return the current instance of the AssetsManager
  75141. */
  75142. load(): AssetsManager;
  75143. /**
  75144. * Start the loading process as an async operation
  75145. * @return a promise returning the list of failed tasks
  75146. */
  75147. loadAsync(): Promise<void>;
  75148. }
  75149. }
  75150. declare module "babylonjs/Misc/deferred" {
  75151. /**
  75152. * Wrapper class for promise with external resolve and reject.
  75153. */
  75154. export class Deferred<T> {
  75155. /**
  75156. * The promise associated with this deferred object.
  75157. */
  75158. readonly promise: Promise<T>;
  75159. private _resolve;
  75160. private _reject;
  75161. /**
  75162. * The resolve method of the promise associated with this deferred object.
  75163. */
  75164. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75165. /**
  75166. * The reject method of the promise associated with this deferred object.
  75167. */
  75168. get reject(): (reason?: any) => void;
  75169. /**
  75170. * Constructor for this deferred object.
  75171. */
  75172. constructor();
  75173. }
  75174. }
  75175. declare module "babylonjs/Misc/meshExploder" {
  75176. import { Mesh } from "babylonjs/Meshes/mesh";
  75177. /**
  75178. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75179. */
  75180. export class MeshExploder {
  75181. private _centerMesh;
  75182. private _meshes;
  75183. private _meshesOrigins;
  75184. private _toCenterVectors;
  75185. private _scaledDirection;
  75186. private _newPosition;
  75187. private _centerPosition;
  75188. /**
  75189. * Explodes meshes from a center mesh.
  75190. * @param meshes The meshes to explode.
  75191. * @param centerMesh The mesh to be center of explosion.
  75192. */
  75193. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75194. private _setCenterMesh;
  75195. /**
  75196. * Get class name
  75197. * @returns "MeshExploder"
  75198. */
  75199. getClassName(): string;
  75200. /**
  75201. * "Exploded meshes"
  75202. * @returns Array of meshes with the centerMesh at index 0.
  75203. */
  75204. getMeshes(): Array<Mesh>;
  75205. /**
  75206. * Explodes meshes giving a specific direction
  75207. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75208. */
  75209. explode(direction?: number): void;
  75210. }
  75211. }
  75212. declare module "babylonjs/Misc/filesInput" {
  75213. import { Engine } from "babylonjs/Engines/engine";
  75214. import { Scene } from "babylonjs/scene";
  75215. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75216. /**
  75217. * Class used to help managing file picking and drag'n'drop
  75218. */
  75219. export class FilesInput {
  75220. /**
  75221. * List of files ready to be loaded
  75222. */
  75223. static get FilesToLoad(): {
  75224. [key: string]: File;
  75225. };
  75226. /**
  75227. * Callback called when a file is processed
  75228. */
  75229. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75230. private _engine;
  75231. private _currentScene;
  75232. private _sceneLoadedCallback;
  75233. private _progressCallback;
  75234. private _additionalRenderLoopLogicCallback;
  75235. private _textureLoadingCallback;
  75236. private _startingProcessingFilesCallback;
  75237. private _onReloadCallback;
  75238. private _errorCallback;
  75239. private _elementToMonitor;
  75240. private _sceneFileToLoad;
  75241. private _filesToLoad;
  75242. /**
  75243. * Creates a new FilesInput
  75244. * @param engine defines the rendering engine
  75245. * @param scene defines the hosting scene
  75246. * @param sceneLoadedCallback callback called when scene is loaded
  75247. * @param progressCallback callback called to track progress
  75248. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75249. * @param textureLoadingCallback callback called when a texture is loading
  75250. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75251. * @param onReloadCallback callback called when a reload is requested
  75252. * @param errorCallback callback call if an error occurs
  75253. */
  75254. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  75255. private _dragEnterHandler;
  75256. private _dragOverHandler;
  75257. private _dropHandler;
  75258. /**
  75259. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75260. * @param elementToMonitor defines the DOM element to track
  75261. */
  75262. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75263. /**
  75264. * Release all associated resources
  75265. */
  75266. dispose(): void;
  75267. private renderFunction;
  75268. private drag;
  75269. private drop;
  75270. private _traverseFolder;
  75271. private _processFiles;
  75272. /**
  75273. * Load files from a drop event
  75274. * @param event defines the drop event to use as source
  75275. */
  75276. loadFiles(event: any): void;
  75277. private _processReload;
  75278. /**
  75279. * Reload the current scene from the loaded files
  75280. */
  75281. reload(): void;
  75282. }
  75283. }
  75284. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75285. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75286. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75287. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75288. }
  75289. declare module "babylonjs/Misc/sceneOptimizer" {
  75290. import { Scene, IDisposable } from "babylonjs/scene";
  75291. import { Observable } from "babylonjs/Misc/observable";
  75292. /**
  75293. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75294. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75295. */
  75296. export class SceneOptimization {
  75297. /**
  75298. * Defines the priority of this optimization (0 by default which means first in the list)
  75299. */
  75300. priority: number;
  75301. /**
  75302. * Gets a string describing the action executed by the current optimization
  75303. * @returns description string
  75304. */
  75305. getDescription(): string;
  75306. /**
  75307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75308. * @param scene defines the current scene where to apply this optimization
  75309. * @param optimizer defines the current optimizer
  75310. * @returns true if everything that can be done was applied
  75311. */
  75312. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75313. /**
  75314. * Creates the SceneOptimization object
  75315. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75316. * @param desc defines the description associated with the optimization
  75317. */
  75318. constructor(
  75319. /**
  75320. * Defines the priority of this optimization (0 by default which means first in the list)
  75321. */
  75322. priority?: number);
  75323. }
  75324. /**
  75325. * Defines an optimization used to reduce the size of render target textures
  75326. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75327. */
  75328. export class TextureOptimization extends SceneOptimization {
  75329. /**
  75330. * Defines the priority of this optimization (0 by default which means first in the list)
  75331. */
  75332. priority: number;
  75333. /**
  75334. * 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
  75335. */
  75336. maximumSize: number;
  75337. /**
  75338. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75339. */
  75340. step: number;
  75341. /**
  75342. * Gets a string describing the action executed by the current optimization
  75343. * @returns description string
  75344. */
  75345. getDescription(): string;
  75346. /**
  75347. * Creates the TextureOptimization object
  75348. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75349. * @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
  75350. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75351. */
  75352. constructor(
  75353. /**
  75354. * Defines the priority of this optimization (0 by default which means first in the list)
  75355. */
  75356. priority?: number,
  75357. /**
  75358. * 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
  75359. */
  75360. maximumSize?: number,
  75361. /**
  75362. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75363. */
  75364. step?: number);
  75365. /**
  75366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75367. * @param scene defines the current scene where to apply this optimization
  75368. * @param optimizer defines the current optimizer
  75369. * @returns true if everything that can be done was applied
  75370. */
  75371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75372. }
  75373. /**
  75374. * Defines an optimization used to increase or decrease the rendering resolution
  75375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75376. */
  75377. export class HardwareScalingOptimization extends SceneOptimization {
  75378. /**
  75379. * Defines the priority of this optimization (0 by default which means first in the list)
  75380. */
  75381. priority: number;
  75382. /**
  75383. * Defines the maximum scale to use (2 by default)
  75384. */
  75385. maximumScale: number;
  75386. /**
  75387. * Defines the step to use between two passes (0.5 by default)
  75388. */
  75389. step: number;
  75390. private _currentScale;
  75391. private _directionOffset;
  75392. /**
  75393. * Gets a string describing the action executed by the current optimization
  75394. * @return description string
  75395. */
  75396. getDescription(): string;
  75397. /**
  75398. * Creates the HardwareScalingOptimization object
  75399. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75400. * @param maximumScale defines the maximum scale to use (2 by default)
  75401. * @param step defines the step to use between two passes (0.5 by default)
  75402. */
  75403. constructor(
  75404. /**
  75405. * Defines the priority of this optimization (0 by default which means first in the list)
  75406. */
  75407. priority?: number,
  75408. /**
  75409. * Defines the maximum scale to use (2 by default)
  75410. */
  75411. maximumScale?: number,
  75412. /**
  75413. * Defines the step to use between two passes (0.5 by default)
  75414. */
  75415. step?: number);
  75416. /**
  75417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75418. * @param scene defines the current scene where to apply this optimization
  75419. * @param optimizer defines the current optimizer
  75420. * @returns true if everything that can be done was applied
  75421. */
  75422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75423. }
  75424. /**
  75425. * Defines an optimization used to remove shadows
  75426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75427. */
  75428. export class ShadowsOptimization extends SceneOptimization {
  75429. /**
  75430. * Gets a string describing the action executed by the current optimization
  75431. * @return description string
  75432. */
  75433. getDescription(): string;
  75434. /**
  75435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75436. * @param scene defines the current scene where to apply this optimization
  75437. * @param optimizer defines the current optimizer
  75438. * @returns true if everything that can be done was applied
  75439. */
  75440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75441. }
  75442. /**
  75443. * Defines an optimization used to turn post-processes off
  75444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75445. */
  75446. export class PostProcessesOptimization extends SceneOptimization {
  75447. /**
  75448. * Gets a string describing the action executed by the current optimization
  75449. * @return description string
  75450. */
  75451. getDescription(): string;
  75452. /**
  75453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75454. * @param scene defines the current scene where to apply this optimization
  75455. * @param optimizer defines the current optimizer
  75456. * @returns true if everything that can be done was applied
  75457. */
  75458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75459. }
  75460. /**
  75461. * Defines an optimization used to turn lens flares off
  75462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75463. */
  75464. export class LensFlaresOptimization extends SceneOptimization {
  75465. /**
  75466. * Gets a string describing the action executed by the current optimization
  75467. * @return description string
  75468. */
  75469. getDescription(): string;
  75470. /**
  75471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75472. * @param scene defines the current scene where to apply this optimization
  75473. * @param optimizer defines the current optimizer
  75474. * @returns true if everything that can be done was applied
  75475. */
  75476. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75477. }
  75478. /**
  75479. * Defines an optimization based on user defined callback.
  75480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75481. */
  75482. export class CustomOptimization extends SceneOptimization {
  75483. /**
  75484. * Callback called to apply the custom optimization.
  75485. */
  75486. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75487. /**
  75488. * Callback called to get custom description
  75489. */
  75490. onGetDescription: () => string;
  75491. /**
  75492. * Gets a string describing the action executed by the current optimization
  75493. * @returns description string
  75494. */
  75495. getDescription(): string;
  75496. /**
  75497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75498. * @param scene defines the current scene where to apply this optimization
  75499. * @param optimizer defines the current optimizer
  75500. * @returns true if everything that can be done was applied
  75501. */
  75502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75503. }
  75504. /**
  75505. * Defines an optimization used to turn particles off
  75506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75507. */
  75508. export class ParticlesOptimization extends SceneOptimization {
  75509. /**
  75510. * Gets a string describing the action executed by the current optimization
  75511. * @return description string
  75512. */
  75513. getDescription(): string;
  75514. /**
  75515. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75516. * @param scene defines the current scene where to apply this optimization
  75517. * @param optimizer defines the current optimizer
  75518. * @returns true if everything that can be done was applied
  75519. */
  75520. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75521. }
  75522. /**
  75523. * Defines an optimization used to turn render targets off
  75524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75525. */
  75526. export class RenderTargetsOptimization extends SceneOptimization {
  75527. /**
  75528. * Gets a string describing the action executed by the current optimization
  75529. * @return description string
  75530. */
  75531. getDescription(): string;
  75532. /**
  75533. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75534. * @param scene defines the current scene where to apply this optimization
  75535. * @param optimizer defines the current optimizer
  75536. * @returns true if everything that can be done was applied
  75537. */
  75538. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75539. }
  75540. /**
  75541. * Defines an optimization used to merge meshes with compatible materials
  75542. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75543. */
  75544. export class MergeMeshesOptimization extends SceneOptimization {
  75545. private static _UpdateSelectionTree;
  75546. /**
  75547. * Gets or sets a boolean which defines if optimization octree has to be updated
  75548. */
  75549. static get UpdateSelectionTree(): boolean;
  75550. /**
  75551. * Gets or sets a boolean which defines if optimization octree has to be updated
  75552. */
  75553. static set UpdateSelectionTree(value: boolean);
  75554. /**
  75555. * Gets a string describing the action executed by the current optimization
  75556. * @return description string
  75557. */
  75558. getDescription(): string;
  75559. private _canBeMerged;
  75560. /**
  75561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75562. * @param scene defines the current scene where to apply this optimization
  75563. * @param optimizer defines the current optimizer
  75564. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75565. * @returns true if everything that can be done was applied
  75566. */
  75567. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75568. }
  75569. /**
  75570. * Defines a list of options used by SceneOptimizer
  75571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75572. */
  75573. export class SceneOptimizerOptions {
  75574. /**
  75575. * Defines the target frame rate to reach (60 by default)
  75576. */
  75577. targetFrameRate: number;
  75578. /**
  75579. * Defines the interval between two checkes (2000ms by default)
  75580. */
  75581. trackerDuration: number;
  75582. /**
  75583. * Gets the list of optimizations to apply
  75584. */
  75585. optimizations: SceneOptimization[];
  75586. /**
  75587. * Creates a new list of options used by SceneOptimizer
  75588. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75589. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75590. */
  75591. constructor(
  75592. /**
  75593. * Defines the target frame rate to reach (60 by default)
  75594. */
  75595. targetFrameRate?: number,
  75596. /**
  75597. * Defines the interval between two checkes (2000ms by default)
  75598. */
  75599. trackerDuration?: number);
  75600. /**
  75601. * Add a new optimization
  75602. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75603. * @returns the current SceneOptimizerOptions
  75604. */
  75605. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75606. /**
  75607. * Add a new custom optimization
  75608. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75609. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75610. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75611. * @returns the current SceneOptimizerOptions
  75612. */
  75613. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75614. /**
  75615. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75616. * @param targetFrameRate defines the target frame rate (60 by default)
  75617. * @returns a SceneOptimizerOptions object
  75618. */
  75619. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75620. /**
  75621. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75622. * @param targetFrameRate defines the target frame rate (60 by default)
  75623. * @returns a SceneOptimizerOptions object
  75624. */
  75625. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75626. /**
  75627. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75628. * @param targetFrameRate defines the target frame rate (60 by default)
  75629. * @returns a SceneOptimizerOptions object
  75630. */
  75631. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75632. }
  75633. /**
  75634. * Class used to run optimizations in order to reach a target frame rate
  75635. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75636. */
  75637. export class SceneOptimizer implements IDisposable {
  75638. private _isRunning;
  75639. private _options;
  75640. private _scene;
  75641. private _currentPriorityLevel;
  75642. private _targetFrameRate;
  75643. private _trackerDuration;
  75644. private _currentFrameRate;
  75645. private _sceneDisposeObserver;
  75646. private _improvementMode;
  75647. /**
  75648. * Defines an observable called when the optimizer reaches the target frame rate
  75649. */
  75650. onSuccessObservable: Observable<SceneOptimizer>;
  75651. /**
  75652. * Defines an observable called when the optimizer enables an optimization
  75653. */
  75654. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75655. /**
  75656. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75657. */
  75658. onFailureObservable: Observable<SceneOptimizer>;
  75659. /**
  75660. * Gets a boolean indicating if the optimizer is in improvement mode
  75661. */
  75662. get isInImprovementMode(): boolean;
  75663. /**
  75664. * Gets the current priority level (0 at start)
  75665. */
  75666. get currentPriorityLevel(): number;
  75667. /**
  75668. * Gets the current frame rate checked by the SceneOptimizer
  75669. */
  75670. get currentFrameRate(): number;
  75671. /**
  75672. * Gets or sets the current target frame rate (60 by default)
  75673. */
  75674. get targetFrameRate(): number;
  75675. /**
  75676. * Gets or sets the current target frame rate (60 by default)
  75677. */
  75678. set targetFrameRate(value: number);
  75679. /**
  75680. * Gets or sets the current interval between two checks (every 2000ms by default)
  75681. */
  75682. get trackerDuration(): number;
  75683. /**
  75684. * Gets or sets the current interval between two checks (every 2000ms by default)
  75685. */
  75686. set trackerDuration(value: number);
  75687. /**
  75688. * Gets the list of active optimizations
  75689. */
  75690. get optimizations(): SceneOptimization[];
  75691. /**
  75692. * Creates a new SceneOptimizer
  75693. * @param scene defines the scene to work on
  75694. * @param options defines the options to use with the SceneOptimizer
  75695. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75696. * @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)
  75697. */
  75698. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75699. /**
  75700. * Stops the current optimizer
  75701. */
  75702. stop(): void;
  75703. /**
  75704. * Reset the optimizer to initial step (current priority level = 0)
  75705. */
  75706. reset(): void;
  75707. /**
  75708. * Start the optimizer. By default it will try to reach a specific framerate
  75709. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75710. */
  75711. start(): void;
  75712. private _checkCurrentState;
  75713. /**
  75714. * Release all resources
  75715. */
  75716. dispose(): void;
  75717. /**
  75718. * Helper function to create a SceneOptimizer with one single line of code
  75719. * @param scene defines the scene to work on
  75720. * @param options defines the options to use with the SceneOptimizer
  75721. * @param onSuccess defines a callback to call on success
  75722. * @param onFailure defines a callback to call on failure
  75723. * @returns the new SceneOptimizer object
  75724. */
  75725. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75726. }
  75727. }
  75728. declare module "babylonjs/Misc/sceneSerializer" {
  75729. import { Scene } from "babylonjs/scene";
  75730. /**
  75731. * Class used to serialize a scene into a string
  75732. */
  75733. export class SceneSerializer {
  75734. /**
  75735. * Clear cache used by a previous serialization
  75736. */
  75737. static ClearCache(): void;
  75738. /**
  75739. * Serialize a scene into a JSON compatible object
  75740. * @param scene defines the scene to serialize
  75741. * @returns a JSON compatible object
  75742. */
  75743. static Serialize(scene: Scene): any;
  75744. /**
  75745. * Serialize a mesh into a JSON compatible object
  75746. * @param toSerialize defines the mesh to serialize
  75747. * @param withParents defines if parents must be serialized as well
  75748. * @param withChildren defines if children must be serialized as well
  75749. * @returns a JSON compatible object
  75750. */
  75751. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75752. }
  75753. }
  75754. declare module "babylonjs/Misc/textureTools" {
  75755. import { Texture } from "babylonjs/Materials/Textures/texture";
  75756. /**
  75757. * Class used to host texture specific utilities
  75758. */
  75759. export class TextureTools {
  75760. /**
  75761. * Uses the GPU to create a copy texture rescaled at a given size
  75762. * @param texture Texture to copy from
  75763. * @param width defines the desired width
  75764. * @param height defines the desired height
  75765. * @param useBilinearMode defines if bilinear mode has to be used
  75766. * @return the generated texture
  75767. */
  75768. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75769. }
  75770. }
  75771. declare module "babylonjs/Misc/videoRecorder" {
  75772. import { Nullable } from "babylonjs/types";
  75773. import { Engine } from "babylonjs/Engines/engine";
  75774. /**
  75775. * This represents the different options available for the video capture.
  75776. */
  75777. export interface VideoRecorderOptions {
  75778. /** Defines the mime type of the video. */
  75779. mimeType: string;
  75780. /** Defines the FPS the video should be recorded at. */
  75781. fps: number;
  75782. /** Defines the chunk size for the recording data. */
  75783. recordChunckSize: number;
  75784. /** The audio tracks to attach to the recording. */
  75785. audioTracks?: MediaStreamTrack[];
  75786. }
  75787. /**
  75788. * This can help with recording videos from BabylonJS.
  75789. * This is based on the available WebRTC functionalities of the browser.
  75790. *
  75791. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  75792. */
  75793. export class VideoRecorder {
  75794. private static readonly _defaultOptions;
  75795. /**
  75796. * Returns whether or not the VideoRecorder is available in your browser.
  75797. * @param engine Defines the Babylon Engine.
  75798. * @returns true if supported otherwise false.
  75799. */
  75800. static IsSupported(engine: Engine): boolean;
  75801. private readonly _options;
  75802. private _canvas;
  75803. private _mediaRecorder;
  75804. private _recordedChunks;
  75805. private _fileName;
  75806. private _resolve;
  75807. private _reject;
  75808. /**
  75809. * True when a recording is already in progress.
  75810. */
  75811. get isRecording(): boolean;
  75812. /**
  75813. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75814. * @param engine Defines the BabylonJS Engine you wish to record.
  75815. * @param options Defines options that can be used to customize the capture.
  75816. */
  75817. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75818. /**
  75819. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75820. */
  75821. stopRecording(): void;
  75822. /**
  75823. * Starts recording the canvas for a max duration specified in parameters.
  75824. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75825. * If null no automatic download will start and you can rely on the promise to get the data back.
  75826. * @param maxDuration Defines the maximum recording time in seconds.
  75827. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75828. * @return A promise callback at the end of the recording with the video data in Blob.
  75829. */
  75830. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75831. /**
  75832. * Releases internal resources used during the recording.
  75833. */
  75834. dispose(): void;
  75835. private _handleDataAvailable;
  75836. private _handleError;
  75837. private _handleStop;
  75838. }
  75839. }
  75840. declare module "babylonjs/Misc/screenshotTools" {
  75841. import { Camera } from "babylonjs/Cameras/camera";
  75842. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  75843. import { Engine } from "babylonjs/Engines/engine";
  75844. /**
  75845. * Class containing a set of static utilities functions for screenshots
  75846. */
  75847. export class ScreenshotTools {
  75848. /**
  75849. * Captures a screenshot of the current rendering
  75850. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75851. * @param engine defines the rendering engine
  75852. * @param camera defines the source camera
  75853. * @param size This parameter can be set to a single number or to an object with the
  75854. * following (optional) properties: precision, width, height. If a single number is passed,
  75855. * it will be used for both width and height. If an object is passed, the screenshot size
  75856. * will be derived from the parameters. The precision property is a multiplier allowing
  75857. * rendering at a higher or lower resolution
  75858. * @param successCallback defines the callback receives a single parameter which contains the
  75859. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75860. * src parameter of an <img> to display it
  75861. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75862. * Check your browser for supported MIME types
  75863. */
  75864. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75865. /**
  75866. * Captures a screenshot of the current rendering
  75867. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75868. * @param engine defines the rendering engine
  75869. * @param camera defines the source camera
  75870. * @param size This parameter can be set to a single number or to an object with the
  75871. * following (optional) properties: precision, width, height. If a single number is passed,
  75872. * it will be used for both width and height. If an object is passed, the screenshot size
  75873. * will be derived from the parameters. The precision property is a multiplier allowing
  75874. * rendering at a higher or lower resolution
  75875. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75876. * Check your browser for supported MIME types
  75877. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75878. * to the src parameter of an <img> to display it
  75879. */
  75880. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75881. /**
  75882. * Generates an image screenshot from the specified camera.
  75883. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75884. * @param engine The engine to use for rendering
  75885. * @param camera The camera to use for rendering
  75886. * @param size This parameter can be set to a single number or to an object with the
  75887. * following (optional) properties: precision, width, height. If a single number is passed,
  75888. * it will be used for both width and height. If an object is passed, the screenshot size
  75889. * will be derived from the parameters. The precision property is a multiplier allowing
  75890. * rendering at a higher or lower resolution
  75891. * @param successCallback The callback receives a single parameter which contains the
  75892. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75893. * src parameter of an <img> to display it
  75894. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75895. * Check your browser for supported MIME types
  75896. * @param samples Texture samples (default: 1)
  75897. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75898. * @param fileName A name for for the downloaded file.
  75899. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75900. */
  75901. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  75902. /**
  75903. * Generates an image screenshot from the specified camera.
  75904. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75905. * @param engine The engine to use for rendering
  75906. * @param camera The camera to use for rendering
  75907. * @param size This parameter can be set to a single number or to an object with the
  75908. * following (optional) properties: precision, width, height. If a single number is passed,
  75909. * it will be used for both width and height. If an object is passed, the screenshot size
  75910. * will be derived from the parameters. The precision property is a multiplier allowing
  75911. * rendering at a higher or lower resolution
  75912. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75913. * Check your browser for supported MIME types
  75914. * @param samples Texture samples (default: 1)
  75915. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75916. * @param fileName A name for for the downloaded file.
  75917. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75918. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75919. * to the src parameter of an <img> to display it
  75920. */
  75921. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75922. /**
  75923. * Gets height and width for screenshot size
  75924. * @private
  75925. */
  75926. private static _getScreenshotSize;
  75927. }
  75928. }
  75929. declare module "babylonjs/Misc/dataReader" {
  75930. /**
  75931. * Interface for a data buffer
  75932. */
  75933. export interface IDataBuffer {
  75934. /**
  75935. * Reads bytes from the data buffer.
  75936. * @param byteOffset The byte offset to read
  75937. * @param byteLength The byte length to read
  75938. * @returns A promise that resolves when the bytes are read
  75939. */
  75940. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75941. /**
  75942. * The byte length of the buffer.
  75943. */
  75944. readonly byteLength: number;
  75945. }
  75946. /**
  75947. * Utility class for reading from a data buffer
  75948. */
  75949. export class DataReader {
  75950. /**
  75951. * The data buffer associated with this data reader.
  75952. */
  75953. readonly buffer: IDataBuffer;
  75954. /**
  75955. * The current byte offset from the beginning of the data buffer.
  75956. */
  75957. byteOffset: number;
  75958. private _dataView;
  75959. private _dataByteOffset;
  75960. /**
  75961. * Constructor
  75962. * @param buffer The buffer to read
  75963. */
  75964. constructor(buffer: IDataBuffer);
  75965. /**
  75966. * Loads the given byte length.
  75967. * @param byteLength The byte length to load
  75968. * @returns A promise that resolves when the load is complete
  75969. */
  75970. loadAsync(byteLength: number): Promise<void>;
  75971. /**
  75972. * Read a unsigned 32-bit integer from the currently loaded data range.
  75973. * @returns The 32-bit integer read
  75974. */
  75975. readUint32(): number;
  75976. /**
  75977. * Read a byte array from the currently loaded data range.
  75978. * @param byteLength The byte length to read
  75979. * @returns The byte array read
  75980. */
  75981. readUint8Array(byteLength: number): Uint8Array;
  75982. /**
  75983. * Read a string from the currently loaded data range.
  75984. * @param byteLength The byte length to read
  75985. * @returns The string read
  75986. */
  75987. readString(byteLength: number): string;
  75988. /**
  75989. * Skips the given byte length the currently loaded data range.
  75990. * @param byteLength The byte length to skip
  75991. */
  75992. skipBytes(byteLength: number): void;
  75993. }
  75994. }
  75995. declare module "babylonjs/Misc/dataStorage" {
  75996. /**
  75997. * Class for storing data to local storage if available or in-memory storage otherwise
  75998. */
  75999. export class DataStorage {
  76000. private static _Storage;
  76001. private static _GetStorage;
  76002. /**
  76003. * Reads a string from the data storage
  76004. * @param key The key to read
  76005. * @param defaultValue The value if the key doesn't exist
  76006. * @returns The string value
  76007. */
  76008. static ReadString(key: string, defaultValue: string): string;
  76009. /**
  76010. * Writes a string to the data storage
  76011. * @param key The key to write
  76012. * @param value The value to write
  76013. */
  76014. static WriteString(key: string, value: string): void;
  76015. /**
  76016. * Reads a boolean from the data storage
  76017. * @param key The key to read
  76018. * @param defaultValue The value if the key doesn't exist
  76019. * @returns The boolean value
  76020. */
  76021. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76022. /**
  76023. * Writes a boolean to the data storage
  76024. * @param key The key to write
  76025. * @param value The value to write
  76026. */
  76027. static WriteBoolean(key: string, value: boolean): void;
  76028. /**
  76029. * Reads a number from the data storage
  76030. * @param key The key to read
  76031. * @param defaultValue The value if the key doesn't exist
  76032. * @returns The number value
  76033. */
  76034. static ReadNumber(key: string, defaultValue: number): number;
  76035. /**
  76036. * Writes a number to the data storage
  76037. * @param key The key to write
  76038. * @param value The value to write
  76039. */
  76040. static WriteNumber(key: string, value: number): void;
  76041. }
  76042. }
  76043. declare module "babylonjs/Misc/index" {
  76044. export * from "babylonjs/Misc/andOrNotEvaluator";
  76045. export * from "babylonjs/Misc/assetsManager";
  76046. export * from "babylonjs/Misc/basis";
  76047. export * from "babylonjs/Misc/dds";
  76048. export * from "babylonjs/Misc/decorators";
  76049. export * from "babylonjs/Misc/deferred";
  76050. export * from "babylonjs/Misc/environmentTextureTools";
  76051. export * from "babylonjs/Misc/meshExploder";
  76052. export * from "babylonjs/Misc/filesInput";
  76053. export * from "babylonjs/Misc/HighDynamicRange/index";
  76054. export * from "babylonjs/Misc/khronosTextureContainer";
  76055. export * from "babylonjs/Misc/observable";
  76056. export * from "babylonjs/Misc/performanceMonitor";
  76057. export * from "babylonjs/Misc/promise";
  76058. export * from "babylonjs/Misc/sceneOptimizer";
  76059. export * from "babylonjs/Misc/sceneSerializer";
  76060. export * from "babylonjs/Misc/smartArray";
  76061. export * from "babylonjs/Misc/stringDictionary";
  76062. export * from "babylonjs/Misc/tags";
  76063. export * from "babylonjs/Misc/textureTools";
  76064. export * from "babylonjs/Misc/tga";
  76065. export * from "babylonjs/Misc/tools";
  76066. export * from "babylonjs/Misc/videoRecorder";
  76067. export * from "babylonjs/Misc/virtualJoystick";
  76068. export * from "babylonjs/Misc/workerPool";
  76069. export * from "babylonjs/Misc/logger";
  76070. export * from "babylonjs/Misc/typeStore";
  76071. export * from "babylonjs/Misc/filesInputStore";
  76072. export * from "babylonjs/Misc/deepCopier";
  76073. export * from "babylonjs/Misc/pivotTools";
  76074. export * from "babylonjs/Misc/precisionDate";
  76075. export * from "babylonjs/Misc/screenshotTools";
  76076. export * from "babylonjs/Misc/typeStore";
  76077. export * from "babylonjs/Misc/webRequest";
  76078. export * from "babylonjs/Misc/iInspectable";
  76079. export * from "babylonjs/Misc/brdfTextureTools";
  76080. export * from "babylonjs/Misc/rgbdTextureTools";
  76081. export * from "babylonjs/Misc/gradients";
  76082. export * from "babylonjs/Misc/perfCounter";
  76083. export * from "babylonjs/Misc/fileRequest";
  76084. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76085. export * from "babylonjs/Misc/retryStrategy";
  76086. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76087. export * from "babylonjs/Misc/canvasGenerator";
  76088. export * from "babylonjs/Misc/fileTools";
  76089. export * from "babylonjs/Misc/stringTools";
  76090. export * from "babylonjs/Misc/dataReader";
  76091. export * from "babylonjs/Misc/minMaxReducer";
  76092. export * from "babylonjs/Misc/depthReducer";
  76093. export * from "babylonjs/Misc/dataStorage";
  76094. }
  76095. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76096. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76097. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76098. import { Observable } from "babylonjs/Misc/observable";
  76099. import { Matrix } from "babylonjs/Maths/math.vector";
  76100. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76101. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76102. /**
  76103. * An interface for all Hit test features
  76104. */
  76105. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76106. /**
  76107. * Triggered when new babylon (transformed) hit test results are available
  76108. */
  76109. onHitTestResultObservable: Observable<T[]>;
  76110. }
  76111. /**
  76112. * Options used for hit testing
  76113. */
  76114. export interface IWebXRLegacyHitTestOptions {
  76115. /**
  76116. * Only test when user interacted with the scene. Default - hit test every frame
  76117. */
  76118. testOnPointerDownOnly?: boolean;
  76119. /**
  76120. * The node to use to transform the local results to world coordinates
  76121. */
  76122. worldParentNode?: TransformNode;
  76123. }
  76124. /**
  76125. * Interface defining the babylon result of raycasting/hit-test
  76126. */
  76127. export interface IWebXRLegacyHitResult {
  76128. /**
  76129. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76130. */
  76131. transformationMatrix: Matrix;
  76132. /**
  76133. * The native hit test result
  76134. */
  76135. xrHitResult: XRHitResult | XRHitTestResult;
  76136. }
  76137. /**
  76138. * The currently-working hit-test module.
  76139. * Hit test (or Ray-casting) is used to interact with the real world.
  76140. * For further information read here - https://github.com/immersive-web/hit-test
  76141. */
  76142. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76143. /**
  76144. * options to use when constructing this feature
  76145. */
  76146. readonly options: IWebXRLegacyHitTestOptions;
  76147. private _direction;
  76148. private _mat;
  76149. private _onSelectEnabled;
  76150. private _origin;
  76151. /**
  76152. * The module's name
  76153. */
  76154. static readonly Name: string;
  76155. /**
  76156. * The (Babylon) version of this module.
  76157. * This is an integer representing the implementation version.
  76158. * This number does not correspond to the WebXR specs version
  76159. */
  76160. static readonly Version: number;
  76161. /**
  76162. * Populated with the last native XR Hit Results
  76163. */
  76164. lastNativeXRHitResults: XRHitResult[];
  76165. /**
  76166. * Triggered when new babylon (transformed) hit test results are available
  76167. */
  76168. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76169. /**
  76170. * Creates a new instance of the (legacy version) hit test feature
  76171. * @param _xrSessionManager an instance of WebXRSessionManager
  76172. * @param options options to use when constructing this feature
  76173. */
  76174. constructor(_xrSessionManager: WebXRSessionManager,
  76175. /**
  76176. * options to use when constructing this feature
  76177. */
  76178. options?: IWebXRLegacyHitTestOptions);
  76179. /**
  76180. * execute a hit test with an XR Ray
  76181. *
  76182. * @param xrSession a native xrSession that will execute this hit test
  76183. * @param xrRay the ray (position and direction) to use for ray-casting
  76184. * @param referenceSpace native XR reference space to use for the hit-test
  76185. * @param filter filter function that will filter the results
  76186. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76187. */
  76188. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76189. /**
  76190. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76191. * @param event the (select) event to use to select with
  76192. * @param referenceSpace the reference space to use for this hit test
  76193. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76194. */
  76195. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76196. /**
  76197. * attach this feature
  76198. * Will usually be called by the features manager
  76199. *
  76200. * @returns true if successful.
  76201. */
  76202. attach(): boolean;
  76203. /**
  76204. * detach this feature.
  76205. * Will usually be called by the features manager
  76206. *
  76207. * @returns true if successful.
  76208. */
  76209. detach(): boolean;
  76210. /**
  76211. * Dispose this feature and all of the resources attached
  76212. */
  76213. dispose(): void;
  76214. protected _onXRFrame(frame: XRFrame): void;
  76215. private _onHitTestResults;
  76216. private _onSelect;
  76217. }
  76218. }
  76219. declare module "babylonjs/XR/features/WebXRHitTest" {
  76220. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76221. import { Observable } from "babylonjs/Misc/observable";
  76222. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76223. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76224. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76225. /**
  76226. * Options used for hit testing (version 2)
  76227. */
  76228. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76229. /**
  76230. * Do not create a permanent hit test. Will usually be used when only
  76231. * transient inputs are needed.
  76232. */
  76233. disablePermanentHitTest?: boolean;
  76234. /**
  76235. * Enable transient (for example touch-based) hit test inspections
  76236. */
  76237. enableTransientHitTest?: boolean;
  76238. /**
  76239. * Offset ray for the permanent hit test
  76240. */
  76241. offsetRay?: Vector3;
  76242. /**
  76243. * Offset ray for the transient hit test
  76244. */
  76245. transientOffsetRay?: Vector3;
  76246. /**
  76247. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76248. */
  76249. useReferenceSpace?: boolean;
  76250. }
  76251. /**
  76252. * Interface defining the babylon result of hit-test
  76253. */
  76254. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76255. /**
  76256. * The input source that generated this hit test (if transient)
  76257. */
  76258. inputSource?: XRInputSource;
  76259. /**
  76260. * Is this a transient hit test
  76261. */
  76262. isTransient?: boolean;
  76263. /**
  76264. * Position of the hit test result
  76265. */
  76266. position: Vector3;
  76267. /**
  76268. * Rotation of the hit test result
  76269. */
  76270. rotationQuaternion: Quaternion;
  76271. /**
  76272. * The native hit test result
  76273. */
  76274. xrHitResult: XRHitTestResult;
  76275. }
  76276. /**
  76277. * The currently-working hit-test module.
  76278. * Hit test (or Ray-casting) is used to interact with the real world.
  76279. * For further information read here - https://github.com/immersive-web/hit-test
  76280. *
  76281. * Tested on chrome (mobile) 80.
  76282. */
  76283. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76284. /**
  76285. * options to use when constructing this feature
  76286. */
  76287. readonly options: IWebXRHitTestOptions;
  76288. private _tmpMat;
  76289. private _tmpPos;
  76290. private _tmpQuat;
  76291. private _transientXrHitTestSource;
  76292. private _xrHitTestSource;
  76293. private initHitTestSource;
  76294. /**
  76295. * The module's name
  76296. */
  76297. static readonly Name: string;
  76298. /**
  76299. * The (Babylon) version of this module.
  76300. * This is an integer representing the implementation version.
  76301. * This number does not correspond to the WebXR specs version
  76302. */
  76303. static readonly Version: number;
  76304. /**
  76305. * When set to true, each hit test will have its own position/rotation objects
  76306. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76307. * the developers will clone them or copy them as they see fit.
  76308. */
  76309. autoCloneTransformation: boolean;
  76310. /**
  76311. * Triggered when new babylon (transformed) hit test results are available
  76312. */
  76313. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76314. /**
  76315. * Use this to temporarily pause hit test checks.
  76316. */
  76317. paused: boolean;
  76318. /**
  76319. * Creates a new instance of the hit test feature
  76320. * @param _xrSessionManager an instance of WebXRSessionManager
  76321. * @param options options to use when constructing this feature
  76322. */
  76323. constructor(_xrSessionManager: WebXRSessionManager,
  76324. /**
  76325. * options to use when constructing this feature
  76326. */
  76327. options?: IWebXRHitTestOptions);
  76328. /**
  76329. * attach this feature
  76330. * Will usually be called by the features manager
  76331. *
  76332. * @returns true if successful.
  76333. */
  76334. attach(): boolean;
  76335. /**
  76336. * detach this feature.
  76337. * Will usually be called by the features manager
  76338. *
  76339. * @returns true if successful.
  76340. */
  76341. detach(): boolean;
  76342. /**
  76343. * Dispose this feature and all of the resources attached
  76344. */
  76345. dispose(): void;
  76346. protected _onXRFrame(frame: XRFrame): void;
  76347. private _processWebXRHitTestResult;
  76348. }
  76349. }
  76350. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76351. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76352. import { Observable } from "babylonjs/Misc/observable";
  76353. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76354. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76355. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76356. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76357. /**
  76358. * Configuration options of the anchor system
  76359. */
  76360. export interface IWebXRAnchorSystemOptions {
  76361. /**
  76362. * a node that will be used to convert local to world coordinates
  76363. */
  76364. worldParentNode?: TransformNode;
  76365. /**
  76366. * If set to true a reference of the created anchors will be kept until the next session starts
  76367. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76368. */
  76369. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76370. }
  76371. /**
  76372. * A babylon container for an XR Anchor
  76373. */
  76374. export interface IWebXRAnchor {
  76375. /**
  76376. * A babylon-assigned ID for this anchor
  76377. */
  76378. id: number;
  76379. /**
  76380. * Transformation matrix to apply to an object attached to this anchor
  76381. */
  76382. transformationMatrix: Matrix;
  76383. /**
  76384. * The native anchor object
  76385. */
  76386. xrAnchor: XRAnchor;
  76387. /**
  76388. * if defined, this object will be constantly updated by the anchor's position and rotation
  76389. */
  76390. attachedNode?: TransformNode;
  76391. }
  76392. /**
  76393. * An implementation of the anchor system for WebXR.
  76394. * For further information see https://github.com/immersive-web/anchors/
  76395. */
  76396. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76397. private _options;
  76398. private _lastFrameDetected;
  76399. private _trackedAnchors;
  76400. private _referenceSpaceForFrameAnchors;
  76401. private _futureAnchors;
  76402. /**
  76403. * The module's name
  76404. */
  76405. static readonly Name: string;
  76406. /**
  76407. * The (Babylon) version of this module.
  76408. * This is an integer representing the implementation version.
  76409. * This number does not correspond to the WebXR specs version
  76410. */
  76411. static readonly Version: number;
  76412. /**
  76413. * Observers registered here will be executed when a new anchor was added to the session
  76414. */
  76415. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76416. /**
  76417. * Observers registered here will be executed when an anchor was removed from the session
  76418. */
  76419. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76420. /**
  76421. * Observers registered here will be executed when an existing anchor updates
  76422. * This can execute N times every frame
  76423. */
  76424. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76425. /**
  76426. * Set the reference space to use for anchor creation, when not using a hit test.
  76427. * Will default to the session's reference space if not defined
  76428. */
  76429. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76430. /**
  76431. * constructs a new anchor system
  76432. * @param _xrSessionManager an instance of WebXRSessionManager
  76433. * @param _options configuration object for this feature
  76434. */
  76435. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76436. private _tmpVector;
  76437. private _tmpQuaternion;
  76438. private _populateTmpTransformation;
  76439. /**
  76440. * Create a new anchor point using a hit test result at a specific point in the scene
  76441. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76442. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76443. *
  76444. * @param hitTestResult The hit test result to use for this anchor creation
  76445. * @param position an optional position offset for this anchor
  76446. * @param rotationQuaternion an optional rotation offset for this anchor
  76447. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76448. */
  76449. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76450. /**
  76451. * Add a new anchor at a specific position and rotation
  76452. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76453. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76454. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76455. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76456. *
  76457. * @param position the position in which to add an anchor
  76458. * @param rotationQuaternion an optional rotation for the anchor transformation
  76459. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76460. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76461. */
  76462. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76463. /**
  76464. * detach this feature.
  76465. * Will usually be called by the features manager
  76466. *
  76467. * @returns true if successful.
  76468. */
  76469. detach(): boolean;
  76470. /**
  76471. * Dispose this feature and all of the resources attached
  76472. */
  76473. dispose(): void;
  76474. protected _onXRFrame(frame: XRFrame): void;
  76475. /**
  76476. * avoiding using Array.find for global support.
  76477. * @param xrAnchor the plane to find in the array
  76478. */
  76479. private _findIndexInAnchorArray;
  76480. private _updateAnchorWithXRFrame;
  76481. private _createAnchorAtTransformation;
  76482. }
  76483. }
  76484. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  76485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76486. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76487. import { Observable } from "babylonjs/Misc/observable";
  76488. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  76489. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76490. /**
  76491. * Options used in the plane detector module
  76492. */
  76493. export interface IWebXRPlaneDetectorOptions {
  76494. /**
  76495. * The node to use to transform the local results to world coordinates
  76496. */
  76497. worldParentNode?: TransformNode;
  76498. /**
  76499. * If set to true a reference of the created planes will be kept until the next session starts
  76500. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76501. */
  76502. doNotRemovePlanesOnSessionEnded?: boolean;
  76503. }
  76504. /**
  76505. * A babylon interface for a WebXR plane.
  76506. * A Plane is actually a polygon, built from N points in space
  76507. *
  76508. * Supported in chrome 79, not supported in canary 81 ATM
  76509. */
  76510. export interface IWebXRPlane {
  76511. /**
  76512. * a babylon-assigned ID for this polygon
  76513. */
  76514. id: number;
  76515. /**
  76516. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76517. */
  76518. polygonDefinition: Array<Vector3>;
  76519. /**
  76520. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76521. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76522. */
  76523. transformationMatrix: Matrix;
  76524. /**
  76525. * the native xr-plane object
  76526. */
  76527. xrPlane: XRPlane;
  76528. }
  76529. /**
  76530. * The plane detector is used to detect planes in the real world when in AR
  76531. * For more information see https://github.com/immersive-web/real-world-geometry/
  76532. */
  76533. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76534. private _options;
  76535. private _detectedPlanes;
  76536. private _enabled;
  76537. private _lastFrameDetected;
  76538. /**
  76539. * The module's name
  76540. */
  76541. static readonly Name: string;
  76542. /**
  76543. * The (Babylon) version of this module.
  76544. * This is an integer representing the implementation version.
  76545. * This number does not correspond to the WebXR specs version
  76546. */
  76547. static readonly Version: number;
  76548. /**
  76549. * Observers registered here will be executed when a new plane was added to the session
  76550. */
  76551. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76552. /**
  76553. * Observers registered here will be executed when a plane is no longer detected in the session
  76554. */
  76555. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76556. /**
  76557. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76558. * This can execute N times every frame
  76559. */
  76560. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76561. /**
  76562. * construct a new Plane Detector
  76563. * @param _xrSessionManager an instance of xr Session manager
  76564. * @param _options configuration to use when constructing this feature
  76565. */
  76566. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76567. /**
  76568. * detach this feature.
  76569. * Will usually be called by the features manager
  76570. *
  76571. * @returns true if successful.
  76572. */
  76573. detach(): boolean;
  76574. /**
  76575. * Dispose this feature and all of the resources attached
  76576. */
  76577. dispose(): void;
  76578. protected _onXRFrame(frame: XRFrame): void;
  76579. private _init;
  76580. private _updatePlaneWithXRPlane;
  76581. /**
  76582. * avoiding using Array.find for global support.
  76583. * @param xrPlane the plane to find in the array
  76584. */
  76585. private findIndexInPlaneArray;
  76586. }
  76587. }
  76588. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  76589. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76591. import { Observable } from "babylonjs/Misc/observable";
  76592. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76593. /**
  76594. * Options interface for the background remover plugin
  76595. */
  76596. export interface IWebXRBackgroundRemoverOptions {
  76597. /**
  76598. * Further background meshes to disable when entering AR
  76599. */
  76600. backgroundMeshes?: AbstractMesh[];
  76601. /**
  76602. * flags to configure the removal of the environment helper.
  76603. * If not set, the entire background will be removed. If set, flags should be set as well.
  76604. */
  76605. environmentHelperRemovalFlags?: {
  76606. /**
  76607. * Should the skybox be removed (default false)
  76608. */
  76609. skyBox?: boolean;
  76610. /**
  76611. * Should the ground be removed (default false)
  76612. */
  76613. ground?: boolean;
  76614. };
  76615. /**
  76616. * don't disable the environment helper
  76617. */
  76618. ignoreEnvironmentHelper?: boolean;
  76619. }
  76620. /**
  76621. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76622. */
  76623. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76624. /**
  76625. * read-only options to be used in this module
  76626. */
  76627. readonly options: IWebXRBackgroundRemoverOptions;
  76628. /**
  76629. * The module's name
  76630. */
  76631. static readonly Name: string;
  76632. /**
  76633. * The (Babylon) version of this module.
  76634. * This is an integer representing the implementation version.
  76635. * This number does not correspond to the WebXR specs version
  76636. */
  76637. static readonly Version: number;
  76638. /**
  76639. * registered observers will be triggered when the background state changes
  76640. */
  76641. onBackgroundStateChangedObservable: Observable<boolean>;
  76642. /**
  76643. * constructs a new background remover module
  76644. * @param _xrSessionManager the session manager for this module
  76645. * @param options read-only options to be used in this module
  76646. */
  76647. constructor(_xrSessionManager: WebXRSessionManager,
  76648. /**
  76649. * read-only options to be used in this module
  76650. */
  76651. options?: IWebXRBackgroundRemoverOptions);
  76652. /**
  76653. * attach this feature
  76654. * Will usually be called by the features manager
  76655. *
  76656. * @returns true if successful.
  76657. */
  76658. attach(): boolean;
  76659. /**
  76660. * detach this feature.
  76661. * Will usually be called by the features manager
  76662. *
  76663. * @returns true if successful.
  76664. */
  76665. detach(): boolean;
  76666. /**
  76667. * Dispose this feature and all of the resources attached
  76668. */
  76669. dispose(): void;
  76670. protected _onXRFrame(_xrFrame: XRFrame): void;
  76671. private _setBackgroundState;
  76672. }
  76673. }
  76674. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  76675. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76676. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  76677. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76678. import { WebXRInput } from "babylonjs/XR/webXRInput";
  76679. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76680. import { Nullable } from "babylonjs/types";
  76681. /**
  76682. * Options for the controller physics feature
  76683. */
  76684. export class IWebXRControllerPhysicsOptions {
  76685. /**
  76686. * Should the headset get its own impostor
  76687. */
  76688. enableHeadsetImpostor?: boolean;
  76689. /**
  76690. * Optional parameters for the headset impostor
  76691. */
  76692. headsetImpostorParams?: {
  76693. /**
  76694. * The type of impostor to create. Default is sphere
  76695. */
  76696. impostorType: number;
  76697. /**
  76698. * the size of the impostor. Defaults to 10cm
  76699. */
  76700. impostorSize?: number | {
  76701. width: number;
  76702. height: number;
  76703. depth: number;
  76704. };
  76705. /**
  76706. * Friction definitions
  76707. */
  76708. friction?: number;
  76709. /**
  76710. * Restitution
  76711. */
  76712. restitution?: number;
  76713. };
  76714. /**
  76715. * The physics properties of the future impostors
  76716. */
  76717. physicsProperties?: {
  76718. /**
  76719. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76720. * Note that this requires a physics engine that supports mesh impostors!
  76721. */
  76722. useControllerMesh?: boolean;
  76723. /**
  76724. * The type of impostor to create. Default is sphere
  76725. */
  76726. impostorType?: number;
  76727. /**
  76728. * the size of the impostor. Defaults to 10cm
  76729. */
  76730. impostorSize?: number | {
  76731. width: number;
  76732. height: number;
  76733. depth: number;
  76734. };
  76735. /**
  76736. * Friction definitions
  76737. */
  76738. friction?: number;
  76739. /**
  76740. * Restitution
  76741. */
  76742. restitution?: number;
  76743. };
  76744. /**
  76745. * the xr input to use with this pointer selection
  76746. */
  76747. xrInput: WebXRInput;
  76748. }
  76749. /**
  76750. * Add physics impostor to your webxr controllers,
  76751. * including naive calculation of their linear and angular velocity
  76752. */
  76753. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76754. private readonly _options;
  76755. private _attachController;
  76756. private _controllers;
  76757. private _debugMode;
  76758. private _delta;
  76759. private _headsetImpostor?;
  76760. private _headsetMesh?;
  76761. private _lastTimestamp;
  76762. private _tmpQuaternion;
  76763. private _tmpVector;
  76764. /**
  76765. * The module's name
  76766. */
  76767. static readonly Name: string;
  76768. /**
  76769. * The (Babylon) version of this module.
  76770. * This is an integer representing the implementation version.
  76771. * This number does not correspond to the webxr specs version
  76772. */
  76773. static readonly Version: number;
  76774. /**
  76775. * Construct a new Controller Physics Feature
  76776. * @param _xrSessionManager the corresponding xr session manager
  76777. * @param _options options to create this feature with
  76778. */
  76779. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76780. /**
  76781. * @hidden
  76782. * enable debugging - will show console outputs and the impostor mesh
  76783. */
  76784. _enablePhysicsDebug(): void;
  76785. /**
  76786. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76787. * @param xrController the controller to add
  76788. */
  76789. addController(xrController: WebXRInputSource): void;
  76790. /**
  76791. * attach this feature
  76792. * Will usually be called by the features manager
  76793. *
  76794. * @returns true if successful.
  76795. */
  76796. attach(): boolean;
  76797. /**
  76798. * detach this feature.
  76799. * Will usually be called by the features manager
  76800. *
  76801. * @returns true if successful.
  76802. */
  76803. detach(): boolean;
  76804. /**
  76805. * Get the headset impostor, if enabled
  76806. * @returns the impostor
  76807. */
  76808. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76809. /**
  76810. * Get the physics impostor of a specific controller.
  76811. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76812. * @param controller the controller or the controller id of which to get the impostor
  76813. * @returns the impostor or null
  76814. */
  76815. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76816. /**
  76817. * Update the physics properties provided in the constructor
  76818. * @param newProperties the new properties object
  76819. */
  76820. setPhysicsProperties(newProperties: {
  76821. impostorType?: number;
  76822. impostorSize?: number | {
  76823. width: number;
  76824. height: number;
  76825. depth: number;
  76826. };
  76827. friction?: number;
  76828. restitution?: number;
  76829. }): void;
  76830. protected _onXRFrame(_xrFrame: any): void;
  76831. private _detachController;
  76832. }
  76833. }
  76834. declare module "babylonjs/XR/features/index" {
  76835. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  76836. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  76837. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  76838. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  76839. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  76840. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  76841. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  76842. export * from "babylonjs/XR/features/WebXRHitTest";
  76843. }
  76844. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  76845. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76847. import { Scene } from "babylonjs/scene";
  76848. /**
  76849. * The motion controller class for all microsoft mixed reality controllers
  76850. */
  76851. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76852. protected readonly _mapping: {
  76853. defaultButton: {
  76854. valueNodeName: string;
  76855. unpressedNodeName: string;
  76856. pressedNodeName: string;
  76857. };
  76858. defaultAxis: {
  76859. valueNodeName: string;
  76860. minNodeName: string;
  76861. maxNodeName: string;
  76862. };
  76863. buttons: {
  76864. "xr-standard-trigger": {
  76865. rootNodeName: string;
  76866. componentProperty: string;
  76867. states: string[];
  76868. };
  76869. "xr-standard-squeeze": {
  76870. rootNodeName: string;
  76871. componentProperty: string;
  76872. states: string[];
  76873. };
  76874. "xr-standard-touchpad": {
  76875. rootNodeName: string;
  76876. labelAnchorNodeName: string;
  76877. touchPointNodeName: string;
  76878. };
  76879. "xr-standard-thumbstick": {
  76880. rootNodeName: string;
  76881. componentProperty: string;
  76882. states: string[];
  76883. };
  76884. };
  76885. axes: {
  76886. "xr-standard-touchpad": {
  76887. "x-axis": {
  76888. rootNodeName: string;
  76889. };
  76890. "y-axis": {
  76891. rootNodeName: string;
  76892. };
  76893. };
  76894. "xr-standard-thumbstick": {
  76895. "x-axis": {
  76896. rootNodeName: string;
  76897. };
  76898. "y-axis": {
  76899. rootNodeName: string;
  76900. };
  76901. };
  76902. };
  76903. };
  76904. /**
  76905. * The base url used to load the left and right controller models
  76906. */
  76907. static MODEL_BASE_URL: string;
  76908. /**
  76909. * The name of the left controller model file
  76910. */
  76911. static MODEL_LEFT_FILENAME: string;
  76912. /**
  76913. * The name of the right controller model file
  76914. */
  76915. static MODEL_RIGHT_FILENAME: string;
  76916. profileId: string;
  76917. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76918. protected _getFilenameAndPath(): {
  76919. filename: string;
  76920. path: string;
  76921. };
  76922. protected _getModelLoadingConstraints(): boolean;
  76923. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76924. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76925. protected _updateModel(): void;
  76926. }
  76927. }
  76928. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  76929. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76931. import { Scene } from "babylonjs/scene";
  76932. /**
  76933. * The motion controller class for oculus touch (quest, rift).
  76934. * This class supports legacy mapping as well the standard xr mapping
  76935. */
  76936. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76937. private _forceLegacyControllers;
  76938. private _modelRootNode;
  76939. /**
  76940. * The base url used to load the left and right controller models
  76941. */
  76942. static MODEL_BASE_URL: string;
  76943. /**
  76944. * The name of the left controller model file
  76945. */
  76946. static MODEL_LEFT_FILENAME: string;
  76947. /**
  76948. * The name of the right controller model file
  76949. */
  76950. static MODEL_RIGHT_FILENAME: string;
  76951. /**
  76952. * Base Url for the Quest controller model.
  76953. */
  76954. static QUEST_MODEL_BASE_URL: string;
  76955. profileId: string;
  76956. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76957. protected _getFilenameAndPath(): {
  76958. filename: string;
  76959. path: string;
  76960. };
  76961. protected _getModelLoadingConstraints(): boolean;
  76962. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76963. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76964. protected _updateModel(): void;
  76965. /**
  76966. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76967. * between the touch and touch 2.
  76968. */
  76969. private _isQuest;
  76970. }
  76971. }
  76972. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  76973. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76974. import { Scene } from "babylonjs/scene";
  76975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76976. /**
  76977. * The motion controller class for the standard HTC-Vive controllers
  76978. */
  76979. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76980. private _modelRootNode;
  76981. /**
  76982. * The base url used to load the left and right controller models
  76983. */
  76984. static MODEL_BASE_URL: string;
  76985. /**
  76986. * File name for the controller model.
  76987. */
  76988. static MODEL_FILENAME: string;
  76989. profileId: string;
  76990. /**
  76991. * Create a new Vive motion controller object
  76992. * @param scene the scene to use to create this controller
  76993. * @param gamepadObject the corresponding gamepad object
  76994. * @param handedness the handedness of the controller
  76995. */
  76996. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76997. protected _getFilenameAndPath(): {
  76998. filename: string;
  76999. path: string;
  77000. };
  77001. protected _getModelLoadingConstraints(): boolean;
  77002. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77003. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77004. protected _updateModel(): void;
  77005. }
  77006. }
  77007. declare module "babylonjs/XR/motionController/index" {
  77008. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77009. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77010. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77011. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77012. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77013. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77014. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77015. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77016. }
  77017. declare module "babylonjs/XR/index" {
  77018. export * from "babylonjs/XR/webXRCamera";
  77019. export * from "babylonjs/XR/webXREnterExitUI";
  77020. export * from "babylonjs/XR/webXRExperienceHelper";
  77021. export * from "babylonjs/XR/webXRInput";
  77022. export * from "babylonjs/XR/webXRInputSource";
  77023. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77024. export * from "babylonjs/XR/webXRTypes";
  77025. export * from "babylonjs/XR/webXRSessionManager";
  77026. export * from "babylonjs/XR/webXRDefaultExperience";
  77027. export * from "babylonjs/XR/webXRFeaturesManager";
  77028. export * from "babylonjs/XR/features/index";
  77029. export * from "babylonjs/XR/motionController/index";
  77030. }
  77031. declare module "babylonjs/index" {
  77032. export * from "babylonjs/abstractScene";
  77033. export * from "babylonjs/Actions/index";
  77034. export * from "babylonjs/Animations/index";
  77035. export * from "babylonjs/assetContainer";
  77036. export * from "babylonjs/Audio/index";
  77037. export * from "babylonjs/Behaviors/index";
  77038. export * from "babylonjs/Bones/index";
  77039. export * from "babylonjs/Cameras/index";
  77040. export * from "babylonjs/Collisions/index";
  77041. export * from "babylonjs/Culling/index";
  77042. export * from "babylonjs/Debug/index";
  77043. export * from "babylonjs/DeviceInput/index";
  77044. export * from "babylonjs/Engines/index";
  77045. export * from "babylonjs/Events/index";
  77046. export * from "babylonjs/Gamepads/index";
  77047. export * from "babylonjs/Gizmos/index";
  77048. export * from "babylonjs/Helpers/index";
  77049. export * from "babylonjs/Instrumentation/index";
  77050. export * from "babylonjs/Layers/index";
  77051. export * from "babylonjs/LensFlares/index";
  77052. export * from "babylonjs/Lights/index";
  77053. export * from "babylonjs/Loading/index";
  77054. export * from "babylonjs/Materials/index";
  77055. export * from "babylonjs/Maths/index";
  77056. export * from "babylonjs/Meshes/index";
  77057. export * from "babylonjs/Morph/index";
  77058. export * from "babylonjs/Navigation/index";
  77059. export * from "babylonjs/node";
  77060. export * from "babylonjs/Offline/index";
  77061. export * from "babylonjs/Particles/index";
  77062. export * from "babylonjs/Physics/index";
  77063. export * from "babylonjs/PostProcesses/index";
  77064. export * from "babylonjs/Probes/index";
  77065. export * from "babylonjs/Rendering/index";
  77066. export * from "babylonjs/scene";
  77067. export * from "babylonjs/sceneComponent";
  77068. export * from "babylonjs/Sprites/index";
  77069. export * from "babylonjs/States/index";
  77070. export * from "babylonjs/Misc/index";
  77071. export * from "babylonjs/XR/index";
  77072. export * from "babylonjs/types";
  77073. }
  77074. declare module "babylonjs/Animations/pathCursor" {
  77075. import { Vector3 } from "babylonjs/Maths/math.vector";
  77076. import { Path2 } from "babylonjs/Maths/math.path";
  77077. /**
  77078. * A cursor which tracks a point on a path
  77079. */
  77080. export class PathCursor {
  77081. private path;
  77082. /**
  77083. * Stores path cursor callbacks for when an onchange event is triggered
  77084. */
  77085. private _onchange;
  77086. /**
  77087. * The value of the path cursor
  77088. */
  77089. value: number;
  77090. /**
  77091. * The animation array of the path cursor
  77092. */
  77093. animations: Animation[];
  77094. /**
  77095. * Initializes the path cursor
  77096. * @param path The path to track
  77097. */
  77098. constructor(path: Path2);
  77099. /**
  77100. * Gets the cursor point on the path
  77101. * @returns A point on the path cursor at the cursor location
  77102. */
  77103. getPoint(): Vector3;
  77104. /**
  77105. * Moves the cursor ahead by the step amount
  77106. * @param step The amount to move the cursor forward
  77107. * @returns This path cursor
  77108. */
  77109. moveAhead(step?: number): PathCursor;
  77110. /**
  77111. * Moves the cursor behind by the step amount
  77112. * @param step The amount to move the cursor back
  77113. * @returns This path cursor
  77114. */
  77115. moveBack(step?: number): PathCursor;
  77116. /**
  77117. * Moves the cursor by the step amount
  77118. * If the step amount is greater than one, an exception is thrown
  77119. * @param step The amount to move the cursor
  77120. * @returns This path cursor
  77121. */
  77122. move(step: number): PathCursor;
  77123. /**
  77124. * Ensures that the value is limited between zero and one
  77125. * @returns This path cursor
  77126. */
  77127. private ensureLimits;
  77128. /**
  77129. * Runs onchange callbacks on change (used by the animation engine)
  77130. * @returns This path cursor
  77131. */
  77132. private raiseOnChange;
  77133. /**
  77134. * Executes a function on change
  77135. * @param f A path cursor onchange callback
  77136. * @returns This path cursor
  77137. */
  77138. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77139. }
  77140. }
  77141. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77142. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77143. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77144. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77145. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77146. }
  77147. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77148. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77149. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77150. }
  77151. declare module "babylonjs/Engines/Processors/index" {
  77152. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77153. export * from "babylonjs/Engines/Processors/Expressions/index";
  77154. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77155. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77156. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77157. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77158. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77159. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77160. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77161. }
  77162. declare module "babylonjs/Legacy/legacy" {
  77163. import * as Babylon from "babylonjs/index";
  77164. export * from "babylonjs/index";
  77165. }
  77166. declare module "babylonjs/Shaders/blur.fragment" {
  77167. /** @hidden */
  77168. export var blurPixelShader: {
  77169. name: string;
  77170. shader: string;
  77171. };
  77172. }
  77173. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77174. /** @hidden */
  77175. export var pointCloudVertexDeclaration: {
  77176. name: string;
  77177. shader: string;
  77178. };
  77179. }
  77180. declare module "babylonjs" {
  77181. export * from "babylonjs/Legacy/legacy";
  77182. }
  77183. declare module BABYLON {
  77184. /** Alias type for value that can be null */
  77185. export type Nullable<T> = T | null;
  77186. /**
  77187. * Alias type for number that are floats
  77188. * @ignorenaming
  77189. */
  77190. export type float = number;
  77191. /**
  77192. * Alias type for number that are doubles.
  77193. * @ignorenaming
  77194. */
  77195. export type double = number;
  77196. /**
  77197. * Alias type for number that are integer
  77198. * @ignorenaming
  77199. */
  77200. export type int = number;
  77201. /** Alias type for number array or Float32Array */
  77202. export type FloatArray = number[] | Float32Array;
  77203. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77204. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77205. /**
  77206. * Alias for types that can be used by a Buffer or VertexBuffer.
  77207. */
  77208. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77209. /**
  77210. * Alias type for primitive types
  77211. * @ignorenaming
  77212. */
  77213. type Primitive = undefined | null | boolean | string | number | Function;
  77214. /**
  77215. * Type modifier to make all the properties of an object Readonly
  77216. */
  77217. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77218. /**
  77219. * Type modifier to make all the properties of an object Readonly recursively
  77220. */
  77221. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77222. /**
  77223. * Type modifier to make object properties readonly.
  77224. */
  77225. export type DeepImmutableObject<T> = {
  77226. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77227. };
  77228. /** @hidden */
  77229. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77230. }
  77231. }
  77232. declare module BABYLON {
  77233. /**
  77234. * A class serves as a medium between the observable and its observers
  77235. */
  77236. export class EventState {
  77237. /**
  77238. * Create a new EventState
  77239. * @param mask defines the mask associated with this state
  77240. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77241. * @param target defines the original target of the state
  77242. * @param currentTarget defines the current target of the state
  77243. */
  77244. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77245. /**
  77246. * Initialize the current event state
  77247. * @param mask defines the mask associated with this state
  77248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77249. * @param target defines the original target of the state
  77250. * @param currentTarget defines the current target of the state
  77251. * @returns the current event state
  77252. */
  77253. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77254. /**
  77255. * An Observer can set this property to true to prevent subsequent observers of being notified
  77256. */
  77257. skipNextObservers: boolean;
  77258. /**
  77259. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77260. */
  77261. mask: number;
  77262. /**
  77263. * The object that originally notified the event
  77264. */
  77265. target?: any;
  77266. /**
  77267. * The current object in the bubbling phase
  77268. */
  77269. currentTarget?: any;
  77270. /**
  77271. * This will be populated with the return value of the last function that was executed.
  77272. * If it is the first function in the callback chain it will be the event data.
  77273. */
  77274. lastReturnValue?: any;
  77275. }
  77276. /**
  77277. * Represent an Observer registered to a given Observable object.
  77278. */
  77279. export class Observer<T> {
  77280. /**
  77281. * Defines the callback to call when the observer is notified
  77282. */
  77283. callback: (eventData: T, eventState: EventState) => void;
  77284. /**
  77285. * Defines the mask of the observer (used to filter notifications)
  77286. */
  77287. mask: number;
  77288. /**
  77289. * Defines the current scope used to restore the JS context
  77290. */
  77291. scope: any;
  77292. /** @hidden */
  77293. _willBeUnregistered: boolean;
  77294. /**
  77295. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77296. */
  77297. unregisterOnNextCall: boolean;
  77298. /**
  77299. * Creates a new observer
  77300. * @param callback defines the callback to call when the observer is notified
  77301. * @param mask defines the mask of the observer (used to filter notifications)
  77302. * @param scope defines the current scope used to restore the JS context
  77303. */
  77304. constructor(
  77305. /**
  77306. * Defines the callback to call when the observer is notified
  77307. */
  77308. callback: (eventData: T, eventState: EventState) => void,
  77309. /**
  77310. * Defines the mask of the observer (used to filter notifications)
  77311. */
  77312. mask: number,
  77313. /**
  77314. * Defines the current scope used to restore the JS context
  77315. */
  77316. scope?: any);
  77317. }
  77318. /**
  77319. * Represent a list of observers registered to multiple Observables object.
  77320. */
  77321. export class MultiObserver<T> {
  77322. private _observers;
  77323. private _observables;
  77324. /**
  77325. * Release associated resources
  77326. */
  77327. dispose(): void;
  77328. /**
  77329. * Raise a callback when one of the observable will notify
  77330. * @param observables defines a list of observables to watch
  77331. * @param callback defines the callback to call on notification
  77332. * @param mask defines the mask used to filter notifications
  77333. * @param scope defines the current scope used to restore the JS context
  77334. * @returns the new MultiObserver
  77335. */
  77336. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77337. }
  77338. /**
  77339. * The Observable class is a simple implementation of the Observable pattern.
  77340. *
  77341. * 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.
  77342. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77343. * 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).
  77344. * 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.
  77345. */
  77346. export class Observable<T> {
  77347. private _observers;
  77348. private _eventState;
  77349. private _onObserverAdded;
  77350. /**
  77351. * Gets the list of observers
  77352. */
  77353. get observers(): Array<Observer<T>>;
  77354. /**
  77355. * Creates a new observable
  77356. * @param onObserverAdded defines a callback to call when a new observer is added
  77357. */
  77358. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77359. /**
  77360. * Create a new Observer with the specified callback
  77361. * @param callback the callback that will be executed for that Observer
  77362. * @param mask the mask used to filter observers
  77363. * @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.
  77364. * @param scope optional scope for the callback to be called from
  77365. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77366. * @returns the new observer created for the callback
  77367. */
  77368. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77369. /**
  77370. * Create a new Observer with the specified callback and unregisters after the next notification
  77371. * @param callback the callback that will be executed for that Observer
  77372. * @returns the new observer created for the callback
  77373. */
  77374. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77375. /**
  77376. * Remove an Observer from the Observable object
  77377. * @param observer the instance of the Observer to remove
  77378. * @returns false if it doesn't belong to this Observable
  77379. */
  77380. remove(observer: Nullable<Observer<T>>): boolean;
  77381. /**
  77382. * Remove a callback from the Observable object
  77383. * @param callback the callback to remove
  77384. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77385. * @returns false if it doesn't belong to this Observable
  77386. */
  77387. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77388. private _deferUnregister;
  77389. private _remove;
  77390. /**
  77391. * Moves the observable to the top of the observer list making it get called first when notified
  77392. * @param observer the observer to move
  77393. */
  77394. makeObserverTopPriority(observer: Observer<T>): void;
  77395. /**
  77396. * Moves the observable to the bottom of the observer list making it get called last when notified
  77397. * @param observer the observer to move
  77398. */
  77399. makeObserverBottomPriority(observer: Observer<T>): void;
  77400. /**
  77401. * Notify all Observers by calling their respective callback with the given data
  77402. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77403. * @param eventData defines the data to send to all observers
  77404. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77405. * @param target defines the original target of the state
  77406. * @param currentTarget defines the current target of the state
  77407. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77408. */
  77409. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77410. /**
  77411. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77412. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77413. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77414. * and it is crucial that all callbacks will be executed.
  77415. * The order of the callbacks is kept, callbacks are not executed parallel.
  77416. *
  77417. * @param eventData The data to be sent to each callback
  77418. * @param mask is used to filter observers defaults to -1
  77419. * @param target defines the callback target (see EventState)
  77420. * @param currentTarget defines he current object in the bubbling phase
  77421. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77422. */
  77423. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77424. /**
  77425. * Notify a specific observer
  77426. * @param observer defines the observer to notify
  77427. * @param eventData defines the data to be sent to each callback
  77428. * @param mask is used to filter observers defaults to -1
  77429. */
  77430. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77431. /**
  77432. * Gets a boolean indicating if the observable has at least one observer
  77433. * @returns true is the Observable has at least one Observer registered
  77434. */
  77435. hasObservers(): boolean;
  77436. /**
  77437. * Clear the list of observers
  77438. */
  77439. clear(): void;
  77440. /**
  77441. * Clone the current observable
  77442. * @returns a new observable
  77443. */
  77444. clone(): Observable<T>;
  77445. /**
  77446. * Does this observable handles observer registered with a given mask
  77447. * @param mask defines the mask to be tested
  77448. * @return whether or not one observer registered with the given mask is handeled
  77449. **/
  77450. hasSpecificMask(mask?: number): boolean;
  77451. }
  77452. }
  77453. declare module BABYLON {
  77454. /**
  77455. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77456. * Babylon.js
  77457. */
  77458. export class DomManagement {
  77459. /**
  77460. * Checks if the window object exists
  77461. * @returns true if the window object exists
  77462. */
  77463. static IsWindowObjectExist(): boolean;
  77464. /**
  77465. * Checks if the navigator object exists
  77466. * @returns true if the navigator object exists
  77467. */
  77468. static IsNavigatorAvailable(): boolean;
  77469. /**
  77470. * Check if the document object exists
  77471. * @returns true if the document object exists
  77472. */
  77473. static IsDocumentAvailable(): boolean;
  77474. /**
  77475. * Extracts text content from a DOM element hierarchy
  77476. * @param element defines the root element
  77477. * @returns a string
  77478. */
  77479. static GetDOMTextContent(element: HTMLElement): string;
  77480. }
  77481. }
  77482. declare module BABYLON {
  77483. /**
  77484. * Logger used througouht the application to allow configuration of
  77485. * the log level required for the messages.
  77486. */
  77487. export class Logger {
  77488. /**
  77489. * No log
  77490. */
  77491. static readonly NoneLogLevel: number;
  77492. /**
  77493. * Only message logs
  77494. */
  77495. static readonly MessageLogLevel: number;
  77496. /**
  77497. * Only warning logs
  77498. */
  77499. static readonly WarningLogLevel: number;
  77500. /**
  77501. * Only error logs
  77502. */
  77503. static readonly ErrorLogLevel: number;
  77504. /**
  77505. * All logs
  77506. */
  77507. static readonly AllLogLevel: number;
  77508. private static _LogCache;
  77509. /**
  77510. * Gets a value indicating the number of loading errors
  77511. * @ignorenaming
  77512. */
  77513. static errorsCount: number;
  77514. /**
  77515. * Callback called when a new log is added
  77516. */
  77517. static OnNewCacheEntry: (entry: string) => void;
  77518. private static _AddLogEntry;
  77519. private static _FormatMessage;
  77520. private static _LogDisabled;
  77521. private static _LogEnabled;
  77522. private static _WarnDisabled;
  77523. private static _WarnEnabled;
  77524. private static _ErrorDisabled;
  77525. private static _ErrorEnabled;
  77526. /**
  77527. * Log a message to the console
  77528. */
  77529. static Log: (message: string) => void;
  77530. /**
  77531. * Write a warning message to the console
  77532. */
  77533. static Warn: (message: string) => void;
  77534. /**
  77535. * Write an error message to the console
  77536. */
  77537. static Error: (message: string) => void;
  77538. /**
  77539. * Gets current log cache (list of logs)
  77540. */
  77541. static get LogCache(): string;
  77542. /**
  77543. * Clears the log cache
  77544. */
  77545. static ClearLogCache(): void;
  77546. /**
  77547. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  77548. */
  77549. static set LogLevels(level: number);
  77550. }
  77551. }
  77552. declare module BABYLON {
  77553. /** @hidden */
  77554. export class _TypeStore {
  77555. /** @hidden */
  77556. static RegisteredTypes: {
  77557. [key: string]: Object;
  77558. };
  77559. /** @hidden */
  77560. static GetClass(fqdn: string): any;
  77561. }
  77562. }
  77563. declare module BABYLON {
  77564. /**
  77565. * Helper to manipulate strings
  77566. */
  77567. export class StringTools {
  77568. /**
  77569. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  77570. * @param str Source string
  77571. * @param suffix Suffix to search for in the source string
  77572. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77573. */
  77574. static EndsWith(str: string, suffix: string): boolean;
  77575. /**
  77576. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  77577. * @param str Source string
  77578. * @param suffix Suffix to search for in the source string
  77579. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77580. */
  77581. static StartsWith(str: string, suffix: string): boolean;
  77582. /**
  77583. * Decodes a buffer into a string
  77584. * @param buffer The buffer to decode
  77585. * @returns The decoded string
  77586. */
  77587. static Decode(buffer: Uint8Array | Uint16Array): string;
  77588. /**
  77589. * Encode a buffer to a base64 string
  77590. * @param buffer defines the buffer to encode
  77591. * @returns the encoded string
  77592. */
  77593. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  77594. /**
  77595. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  77596. * @param num the number to convert and pad
  77597. * @param length the expected length of the string
  77598. * @returns the padded string
  77599. */
  77600. static PadNumber(num: number, length: number): string;
  77601. }
  77602. }
  77603. declare module BABYLON {
  77604. /**
  77605. * Class containing a set of static utilities functions for deep copy.
  77606. */
  77607. export class DeepCopier {
  77608. /**
  77609. * Tries to copy an object by duplicating every property
  77610. * @param source defines the source object
  77611. * @param destination defines the target object
  77612. * @param doNotCopyList defines a list of properties to avoid
  77613. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  77614. */
  77615. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  77616. }
  77617. }
  77618. declare module BABYLON {
  77619. /**
  77620. * Class containing a set of static utilities functions for precision date
  77621. */
  77622. export class PrecisionDate {
  77623. /**
  77624. * Gets either window.performance.now() if supported or Date.now() else
  77625. */
  77626. static get Now(): number;
  77627. }
  77628. }
  77629. declare module BABYLON {
  77630. /** @hidden */
  77631. export class _DevTools {
  77632. static WarnImport(name: string): string;
  77633. }
  77634. }
  77635. declare module BABYLON {
  77636. /**
  77637. * Interface used to define the mechanism to get data from the network
  77638. */
  77639. export interface IWebRequest {
  77640. /**
  77641. * Returns client's response url
  77642. */
  77643. responseURL: string;
  77644. /**
  77645. * Returns client's status
  77646. */
  77647. status: number;
  77648. /**
  77649. * Returns client's status as a text
  77650. */
  77651. statusText: string;
  77652. }
  77653. }
  77654. declare module BABYLON {
  77655. /**
  77656. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  77657. */
  77658. export class WebRequest implements IWebRequest {
  77659. private _xhr;
  77660. /**
  77661. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  77662. * i.e. when loading files, where the server/service expects an Authorization header
  77663. */
  77664. static CustomRequestHeaders: {
  77665. [key: string]: string;
  77666. };
  77667. /**
  77668. * Add callback functions in this array to update all the requests before they get sent to the network
  77669. */
  77670. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  77671. private _injectCustomRequestHeaders;
  77672. /**
  77673. * Gets or sets a function to be called when loading progress changes
  77674. */
  77675. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  77676. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  77677. /**
  77678. * Returns client's state
  77679. */
  77680. get readyState(): number;
  77681. /**
  77682. * Returns client's status
  77683. */
  77684. get status(): number;
  77685. /**
  77686. * Returns client's status as a text
  77687. */
  77688. get statusText(): string;
  77689. /**
  77690. * Returns client's response
  77691. */
  77692. get response(): any;
  77693. /**
  77694. * Returns client's response url
  77695. */
  77696. get responseURL(): string;
  77697. /**
  77698. * Returns client's response as text
  77699. */
  77700. get responseText(): string;
  77701. /**
  77702. * Gets or sets the expected response type
  77703. */
  77704. get responseType(): XMLHttpRequestResponseType;
  77705. set responseType(value: XMLHttpRequestResponseType);
  77706. /** @hidden */
  77707. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  77708. /** @hidden */
  77709. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  77710. /**
  77711. * Cancels any network activity
  77712. */
  77713. abort(): void;
  77714. /**
  77715. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  77716. * @param body defines an optional request body
  77717. */
  77718. send(body?: Document | BodyInit | null): void;
  77719. /**
  77720. * Sets the request method, request URL
  77721. * @param method defines the method to use (GET, POST, etc..)
  77722. * @param url defines the url to connect with
  77723. */
  77724. open(method: string, url: string): void;
  77725. /**
  77726. * Sets the value of a request header.
  77727. * @param name The name of the header whose value is to be set
  77728. * @param value The value to set as the body of the header
  77729. */
  77730. setRequestHeader(name: string, value: string): void;
  77731. /**
  77732. * Get the string containing the text of a particular header's value.
  77733. * @param name The name of the header
  77734. * @returns The string containing the text of the given header name
  77735. */
  77736. getResponseHeader(name: string): Nullable<string>;
  77737. }
  77738. }
  77739. declare module BABYLON {
  77740. /**
  77741. * File request interface
  77742. */
  77743. export interface IFileRequest {
  77744. /**
  77745. * Raised when the request is complete (success or error).
  77746. */
  77747. onCompleteObservable: Observable<IFileRequest>;
  77748. /**
  77749. * Aborts the request for a file.
  77750. */
  77751. abort: () => void;
  77752. }
  77753. }
  77754. declare module BABYLON {
  77755. /**
  77756. * Define options used to create a render target texture
  77757. */
  77758. export class RenderTargetCreationOptions {
  77759. /**
  77760. * Specifies is mipmaps must be generated
  77761. */
  77762. generateMipMaps?: boolean;
  77763. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  77764. generateDepthBuffer?: boolean;
  77765. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  77766. generateStencilBuffer?: boolean;
  77767. /** Defines texture type (int by default) */
  77768. type?: number;
  77769. /** Defines sampling mode (trilinear by default) */
  77770. samplingMode?: number;
  77771. /** Defines format (RGBA by default) */
  77772. format?: number;
  77773. }
  77774. }
  77775. declare module BABYLON {
  77776. /** Defines the cross module used constants to avoid circular dependncies */
  77777. export class Constants {
  77778. /** Defines that alpha blending is disabled */
  77779. static readonly ALPHA_DISABLE: number;
  77780. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  77781. static readonly ALPHA_ADD: number;
  77782. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  77783. static readonly ALPHA_COMBINE: number;
  77784. /** Defines that alpha blending is DEST - SRC * DEST */
  77785. static readonly ALPHA_SUBTRACT: number;
  77786. /** Defines that alpha blending is SRC * DEST */
  77787. static readonly ALPHA_MULTIPLY: number;
  77788. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  77789. static readonly ALPHA_MAXIMIZED: number;
  77790. /** Defines that alpha blending is SRC + DEST */
  77791. static readonly ALPHA_ONEONE: number;
  77792. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  77793. static readonly ALPHA_PREMULTIPLIED: number;
  77794. /**
  77795. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  77796. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  77797. */
  77798. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  77799. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  77800. static readonly ALPHA_INTERPOLATE: number;
  77801. /**
  77802. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  77803. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  77804. */
  77805. static readonly ALPHA_SCREENMODE: number;
  77806. /**
  77807. * Defines that alpha blending is SRC + DST
  77808. * Alpha will be set to SRC ALPHA + DST ALPHA
  77809. */
  77810. static readonly ALPHA_ONEONE_ONEONE: number;
  77811. /**
  77812. * Defines that alpha blending is SRC * DST ALPHA + DST
  77813. * Alpha will be set to 0
  77814. */
  77815. static readonly ALPHA_ALPHATOCOLOR: number;
  77816. /**
  77817. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77818. */
  77819. static readonly ALPHA_REVERSEONEMINUS: number;
  77820. /**
  77821. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  77822. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  77823. */
  77824. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  77825. /**
  77826. * Defines that alpha blending is SRC + DST
  77827. * Alpha will be set to SRC ALPHA
  77828. */
  77829. static readonly ALPHA_ONEONE_ONEZERO: number;
  77830. /**
  77831. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77832. * Alpha will be set to DST ALPHA
  77833. */
  77834. static readonly ALPHA_EXCLUSION: number;
  77835. /** Defines that alpha blending equation a SUM */
  77836. static readonly ALPHA_EQUATION_ADD: number;
  77837. /** Defines that alpha blending equation a SUBSTRACTION */
  77838. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  77839. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  77840. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  77841. /** Defines that alpha blending equation a MAX operation */
  77842. static readonly ALPHA_EQUATION_MAX: number;
  77843. /** Defines that alpha blending equation a MIN operation */
  77844. static readonly ALPHA_EQUATION_MIN: number;
  77845. /**
  77846. * Defines that alpha blending equation a DARKEN operation:
  77847. * It takes the min of the src and sums the alpha channels.
  77848. */
  77849. static readonly ALPHA_EQUATION_DARKEN: number;
  77850. /** Defines that the ressource is not delayed*/
  77851. static readonly DELAYLOADSTATE_NONE: number;
  77852. /** Defines that the ressource was successfully delay loaded */
  77853. static readonly DELAYLOADSTATE_LOADED: number;
  77854. /** Defines that the ressource is currently delay loading */
  77855. static readonly DELAYLOADSTATE_LOADING: number;
  77856. /** Defines that the ressource is delayed and has not started loading */
  77857. static readonly DELAYLOADSTATE_NOTLOADED: number;
  77858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  77859. static readonly NEVER: number;
  77860. /** 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 */
  77861. static readonly ALWAYS: number;
  77862. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  77863. static readonly LESS: number;
  77864. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  77865. static readonly EQUAL: number;
  77866. /** 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 */
  77867. static readonly LEQUAL: number;
  77868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  77869. static readonly GREATER: number;
  77870. /** 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 */
  77871. static readonly GEQUAL: number;
  77872. /** 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 */
  77873. static readonly NOTEQUAL: number;
  77874. /** Passed to stencilOperation to specify that stencil value must be kept */
  77875. static readonly KEEP: number;
  77876. /** Passed to stencilOperation to specify that stencil value must be replaced */
  77877. static readonly REPLACE: number;
  77878. /** Passed to stencilOperation to specify that stencil value must be incremented */
  77879. static readonly INCR: number;
  77880. /** Passed to stencilOperation to specify that stencil value must be decremented */
  77881. static readonly DECR: number;
  77882. /** Passed to stencilOperation to specify that stencil value must be inverted */
  77883. static readonly INVERT: number;
  77884. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  77885. static readonly INCR_WRAP: number;
  77886. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  77887. static readonly DECR_WRAP: number;
  77888. /** Texture is not repeating outside of 0..1 UVs */
  77889. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  77890. /** Texture is repeating outside of 0..1 UVs */
  77891. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  77892. /** Texture is repeating and mirrored */
  77893. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  77894. /** ALPHA */
  77895. static readonly TEXTUREFORMAT_ALPHA: number;
  77896. /** LUMINANCE */
  77897. static readonly TEXTUREFORMAT_LUMINANCE: number;
  77898. /** LUMINANCE_ALPHA */
  77899. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  77900. /** RGB */
  77901. static readonly TEXTUREFORMAT_RGB: number;
  77902. /** RGBA */
  77903. static readonly TEXTUREFORMAT_RGBA: number;
  77904. /** RED */
  77905. static readonly TEXTUREFORMAT_RED: number;
  77906. /** RED (2nd reference) */
  77907. static readonly TEXTUREFORMAT_R: number;
  77908. /** RG */
  77909. static readonly TEXTUREFORMAT_RG: number;
  77910. /** RED_INTEGER */
  77911. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  77912. /** RED_INTEGER (2nd reference) */
  77913. static readonly TEXTUREFORMAT_R_INTEGER: number;
  77914. /** RG_INTEGER */
  77915. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  77916. /** RGB_INTEGER */
  77917. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  77918. /** RGBA_INTEGER */
  77919. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  77920. /** UNSIGNED_BYTE */
  77921. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  77922. /** UNSIGNED_BYTE (2nd reference) */
  77923. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  77924. /** FLOAT */
  77925. static readonly TEXTURETYPE_FLOAT: number;
  77926. /** HALF_FLOAT */
  77927. static readonly TEXTURETYPE_HALF_FLOAT: number;
  77928. /** BYTE */
  77929. static readonly TEXTURETYPE_BYTE: number;
  77930. /** SHORT */
  77931. static readonly TEXTURETYPE_SHORT: number;
  77932. /** UNSIGNED_SHORT */
  77933. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  77934. /** INT */
  77935. static readonly TEXTURETYPE_INT: number;
  77936. /** UNSIGNED_INT */
  77937. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  77938. /** UNSIGNED_SHORT_4_4_4_4 */
  77939. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  77940. /** UNSIGNED_SHORT_5_5_5_1 */
  77941. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  77942. /** UNSIGNED_SHORT_5_6_5 */
  77943. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  77944. /** UNSIGNED_INT_2_10_10_10_REV */
  77945. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  77946. /** UNSIGNED_INT_24_8 */
  77947. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  77948. /** UNSIGNED_INT_10F_11F_11F_REV */
  77949. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  77950. /** UNSIGNED_INT_5_9_9_9_REV */
  77951. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  77952. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  77953. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77954. /** nearest is mag = nearest and min = nearest and no mip */
  77955. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  77956. /** mag = nearest and min = nearest and mip = none */
  77957. static readonly TEXTURE_NEAREST_NEAREST: number;
  77958. /** Bilinear is mag = linear and min = linear and no mip */
  77959. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  77960. /** mag = linear and min = linear and mip = none */
  77961. static readonly TEXTURE_LINEAR_LINEAR: number;
  77962. /** Trilinear is mag = linear and min = linear and mip = linear */
  77963. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  77964. /** Trilinear is mag = linear and min = linear and mip = linear */
  77965. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  77966. /** mag = nearest and min = nearest and mip = nearest */
  77967. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  77968. /** mag = nearest and min = linear and mip = nearest */
  77969. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  77970. /** mag = nearest and min = linear and mip = linear */
  77971. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  77972. /** mag = nearest and min = linear and mip = none */
  77973. static readonly TEXTURE_NEAREST_LINEAR: number;
  77974. /** nearest is mag = nearest and min = nearest and mip = linear */
  77975. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  77976. /** mag = linear and min = nearest and mip = nearest */
  77977. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  77978. /** mag = linear and min = nearest and mip = linear */
  77979. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  77980. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77981. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  77982. /** mag = linear and min = nearest and mip = none */
  77983. static readonly TEXTURE_LINEAR_NEAREST: number;
  77984. /** Explicit coordinates mode */
  77985. static readonly TEXTURE_EXPLICIT_MODE: number;
  77986. /** Spherical coordinates mode */
  77987. static readonly TEXTURE_SPHERICAL_MODE: number;
  77988. /** Planar coordinates mode */
  77989. static readonly TEXTURE_PLANAR_MODE: number;
  77990. /** Cubic coordinates mode */
  77991. static readonly TEXTURE_CUBIC_MODE: number;
  77992. /** Projection coordinates mode */
  77993. static readonly TEXTURE_PROJECTION_MODE: number;
  77994. /** Skybox coordinates mode */
  77995. static readonly TEXTURE_SKYBOX_MODE: number;
  77996. /** Inverse Cubic coordinates mode */
  77997. static readonly TEXTURE_INVCUBIC_MODE: number;
  77998. /** Equirectangular coordinates mode */
  77999. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78000. /** Equirectangular Fixed coordinates mode */
  78001. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78002. /** Equirectangular Fixed Mirrored coordinates mode */
  78003. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78004. /** Offline (baking) quality for texture filtering */
  78005. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78006. /** High quality for texture filtering */
  78007. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78008. /** Medium quality for texture filtering */
  78009. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78010. /** Low quality for texture filtering */
  78011. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78012. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78013. static readonly SCALEMODE_FLOOR: number;
  78014. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78015. static readonly SCALEMODE_NEAREST: number;
  78016. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78017. static readonly SCALEMODE_CEILING: number;
  78018. /**
  78019. * The dirty texture flag value
  78020. */
  78021. static readonly MATERIAL_TextureDirtyFlag: number;
  78022. /**
  78023. * The dirty light flag value
  78024. */
  78025. static readonly MATERIAL_LightDirtyFlag: number;
  78026. /**
  78027. * The dirty fresnel flag value
  78028. */
  78029. static readonly MATERIAL_FresnelDirtyFlag: number;
  78030. /**
  78031. * The dirty attribute flag value
  78032. */
  78033. static readonly MATERIAL_AttributesDirtyFlag: number;
  78034. /**
  78035. * The dirty misc flag value
  78036. */
  78037. static readonly MATERIAL_MiscDirtyFlag: number;
  78038. /**
  78039. * The all dirty flag value
  78040. */
  78041. static readonly MATERIAL_AllDirtyFlag: number;
  78042. /**
  78043. * Returns the triangle fill mode
  78044. */
  78045. static readonly MATERIAL_TriangleFillMode: number;
  78046. /**
  78047. * Returns the wireframe mode
  78048. */
  78049. static readonly MATERIAL_WireFrameFillMode: number;
  78050. /**
  78051. * Returns the point fill mode
  78052. */
  78053. static readonly MATERIAL_PointFillMode: number;
  78054. /**
  78055. * Returns the point list draw mode
  78056. */
  78057. static readonly MATERIAL_PointListDrawMode: number;
  78058. /**
  78059. * Returns the line list draw mode
  78060. */
  78061. static readonly MATERIAL_LineListDrawMode: number;
  78062. /**
  78063. * Returns the line loop draw mode
  78064. */
  78065. static readonly MATERIAL_LineLoopDrawMode: number;
  78066. /**
  78067. * Returns the line strip draw mode
  78068. */
  78069. static readonly MATERIAL_LineStripDrawMode: number;
  78070. /**
  78071. * Returns the triangle strip draw mode
  78072. */
  78073. static readonly MATERIAL_TriangleStripDrawMode: number;
  78074. /**
  78075. * Returns the triangle fan draw mode
  78076. */
  78077. static readonly MATERIAL_TriangleFanDrawMode: number;
  78078. /**
  78079. * Stores the clock-wise side orientation
  78080. */
  78081. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78082. /**
  78083. * Stores the counter clock-wise side orientation
  78084. */
  78085. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78086. /**
  78087. * Nothing
  78088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78089. */
  78090. static readonly ACTION_NothingTrigger: number;
  78091. /**
  78092. * On pick
  78093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78094. */
  78095. static readonly ACTION_OnPickTrigger: number;
  78096. /**
  78097. * On left pick
  78098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78099. */
  78100. static readonly ACTION_OnLeftPickTrigger: number;
  78101. /**
  78102. * On right pick
  78103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78104. */
  78105. static readonly ACTION_OnRightPickTrigger: number;
  78106. /**
  78107. * On center pick
  78108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78109. */
  78110. static readonly ACTION_OnCenterPickTrigger: number;
  78111. /**
  78112. * On pick down
  78113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78114. */
  78115. static readonly ACTION_OnPickDownTrigger: number;
  78116. /**
  78117. * On double pick
  78118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78119. */
  78120. static readonly ACTION_OnDoublePickTrigger: number;
  78121. /**
  78122. * On pick up
  78123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78124. */
  78125. static readonly ACTION_OnPickUpTrigger: number;
  78126. /**
  78127. * On pick out.
  78128. * This trigger will only be raised if you also declared a OnPickDown
  78129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78130. */
  78131. static readonly ACTION_OnPickOutTrigger: number;
  78132. /**
  78133. * On long press
  78134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78135. */
  78136. static readonly ACTION_OnLongPressTrigger: number;
  78137. /**
  78138. * On pointer over
  78139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78140. */
  78141. static readonly ACTION_OnPointerOverTrigger: number;
  78142. /**
  78143. * On pointer out
  78144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78145. */
  78146. static readonly ACTION_OnPointerOutTrigger: number;
  78147. /**
  78148. * On every frame
  78149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78150. */
  78151. static readonly ACTION_OnEveryFrameTrigger: number;
  78152. /**
  78153. * On intersection enter
  78154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78155. */
  78156. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78157. /**
  78158. * On intersection exit
  78159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78160. */
  78161. static readonly ACTION_OnIntersectionExitTrigger: number;
  78162. /**
  78163. * On key down
  78164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78165. */
  78166. static readonly ACTION_OnKeyDownTrigger: number;
  78167. /**
  78168. * On key up
  78169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78170. */
  78171. static readonly ACTION_OnKeyUpTrigger: number;
  78172. /**
  78173. * Billboard mode will only apply to Y axis
  78174. */
  78175. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78176. /**
  78177. * Billboard mode will apply to all axes
  78178. */
  78179. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78180. /**
  78181. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78182. */
  78183. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78184. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78185. * Test order :
  78186. * Is the bounding sphere outside the frustum ?
  78187. * If not, are the bounding box vertices outside the frustum ?
  78188. * It not, then the cullable object is in the frustum.
  78189. */
  78190. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78191. /** Culling strategy : Bounding Sphere Only.
  78192. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78193. * It's also less accurate than the standard because some not visible objects can still be selected.
  78194. * Test : is the bounding sphere outside the frustum ?
  78195. * If not, then the cullable object is in the frustum.
  78196. */
  78197. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78198. /** Culling strategy : Optimistic Inclusion.
  78199. * This in an inclusion test first, then the standard exclusion test.
  78200. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78201. * 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.
  78202. * Anyway, it's as accurate as the standard strategy.
  78203. * Test :
  78204. * Is the cullable object bounding sphere center in the frustum ?
  78205. * If not, apply the default culling strategy.
  78206. */
  78207. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78208. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78209. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78210. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78211. * 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.
  78212. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78213. * Test :
  78214. * Is the cullable object bounding sphere center in the frustum ?
  78215. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78216. */
  78217. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78218. /**
  78219. * No logging while loading
  78220. */
  78221. static readonly SCENELOADER_NO_LOGGING: number;
  78222. /**
  78223. * Minimal logging while loading
  78224. */
  78225. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78226. /**
  78227. * Summary logging while loading
  78228. */
  78229. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78230. /**
  78231. * Detailled logging while loading
  78232. */
  78233. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78234. }
  78235. }
  78236. declare module BABYLON {
  78237. /**
  78238. * This represents the required contract to create a new type of texture loader.
  78239. */
  78240. export interface IInternalTextureLoader {
  78241. /**
  78242. * Defines wether the loader supports cascade loading the different faces.
  78243. */
  78244. supportCascades: boolean;
  78245. /**
  78246. * This returns if the loader support the current file information.
  78247. * @param extension defines the file extension of the file being loaded
  78248. * @returns true if the loader can load the specified file
  78249. */
  78250. canLoad(extension: string): boolean;
  78251. /**
  78252. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78253. * @param data contains the texture data
  78254. * @param texture defines the BabylonJS internal texture
  78255. * @param createPolynomials will be true if polynomials have been requested
  78256. * @param onLoad defines the callback to trigger once the texture is ready
  78257. * @param onError defines the callback to trigger in case of error
  78258. */
  78259. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78260. /**
  78261. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78262. * @param data contains the texture data
  78263. * @param texture defines the BabylonJS internal texture
  78264. * @param callback defines the method to call once ready to upload
  78265. */
  78266. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78267. }
  78268. }
  78269. declare module BABYLON {
  78270. /**
  78271. * Class used to store and describe the pipeline context associated with an effect
  78272. */
  78273. export interface IPipelineContext {
  78274. /**
  78275. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78276. */
  78277. isAsync: boolean;
  78278. /**
  78279. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78280. */
  78281. isReady: boolean;
  78282. /** @hidden */
  78283. _getVertexShaderCode(): string | null;
  78284. /** @hidden */
  78285. _getFragmentShaderCode(): string | null;
  78286. /** @hidden */
  78287. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78288. }
  78289. }
  78290. declare module BABYLON {
  78291. /**
  78292. * Class used to store gfx data (like WebGLBuffer)
  78293. */
  78294. export class DataBuffer {
  78295. /**
  78296. * Gets or sets the number of objects referencing this buffer
  78297. */
  78298. references: number;
  78299. /** Gets or sets the size of the underlying buffer */
  78300. capacity: number;
  78301. /**
  78302. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78303. */
  78304. is32Bits: boolean;
  78305. /**
  78306. * Gets the underlying buffer
  78307. */
  78308. get underlyingResource(): any;
  78309. }
  78310. }
  78311. declare module BABYLON {
  78312. /** @hidden */
  78313. export interface IShaderProcessor {
  78314. attributeProcessor?: (attribute: string) => string;
  78315. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78316. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78317. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78318. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78319. lineProcessor?: (line: string, isFragment: boolean) => string;
  78320. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78321. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78322. }
  78323. }
  78324. declare module BABYLON {
  78325. /** @hidden */
  78326. export interface ProcessingOptions {
  78327. defines: string[];
  78328. indexParameters: any;
  78329. isFragment: boolean;
  78330. shouldUseHighPrecisionShader: boolean;
  78331. supportsUniformBuffers: boolean;
  78332. shadersRepository: string;
  78333. includesShadersStore: {
  78334. [key: string]: string;
  78335. };
  78336. processor?: IShaderProcessor;
  78337. version: string;
  78338. platformName: string;
  78339. lookForClosingBracketForUniformBuffer?: boolean;
  78340. }
  78341. }
  78342. declare module BABYLON {
  78343. /** @hidden */
  78344. export class ShaderCodeNode {
  78345. line: string;
  78346. children: ShaderCodeNode[];
  78347. additionalDefineKey?: string;
  78348. additionalDefineValue?: string;
  78349. isValid(preprocessors: {
  78350. [key: string]: string;
  78351. }): boolean;
  78352. process(preprocessors: {
  78353. [key: string]: string;
  78354. }, options: ProcessingOptions): string;
  78355. }
  78356. }
  78357. declare module BABYLON {
  78358. /** @hidden */
  78359. export class ShaderCodeCursor {
  78360. private _lines;
  78361. lineIndex: number;
  78362. get currentLine(): string;
  78363. get canRead(): boolean;
  78364. set lines(value: string[]);
  78365. }
  78366. }
  78367. declare module BABYLON {
  78368. /** @hidden */
  78369. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78370. process(preprocessors: {
  78371. [key: string]: string;
  78372. }, options: ProcessingOptions): string;
  78373. }
  78374. }
  78375. declare module BABYLON {
  78376. /** @hidden */
  78377. export class ShaderDefineExpression {
  78378. isTrue(preprocessors: {
  78379. [key: string]: string;
  78380. }): boolean;
  78381. private static _OperatorPriority;
  78382. private static _Stack;
  78383. static postfixToInfix(postfix: string[]): string;
  78384. static infixToPostfix(infix: string): string[];
  78385. }
  78386. }
  78387. declare module BABYLON {
  78388. /** @hidden */
  78389. export class ShaderCodeTestNode extends ShaderCodeNode {
  78390. testExpression: ShaderDefineExpression;
  78391. isValid(preprocessors: {
  78392. [key: string]: string;
  78393. }): boolean;
  78394. }
  78395. }
  78396. declare module BABYLON {
  78397. /** @hidden */
  78398. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78399. define: string;
  78400. not: boolean;
  78401. constructor(define: string, not?: boolean);
  78402. isTrue(preprocessors: {
  78403. [key: string]: string;
  78404. }): boolean;
  78405. }
  78406. }
  78407. declare module BABYLON {
  78408. /** @hidden */
  78409. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78410. leftOperand: ShaderDefineExpression;
  78411. rightOperand: ShaderDefineExpression;
  78412. isTrue(preprocessors: {
  78413. [key: string]: string;
  78414. }): boolean;
  78415. }
  78416. }
  78417. declare module BABYLON {
  78418. /** @hidden */
  78419. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78420. leftOperand: ShaderDefineExpression;
  78421. rightOperand: ShaderDefineExpression;
  78422. isTrue(preprocessors: {
  78423. [key: string]: string;
  78424. }): boolean;
  78425. }
  78426. }
  78427. declare module BABYLON {
  78428. /** @hidden */
  78429. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78430. define: string;
  78431. operand: string;
  78432. testValue: string;
  78433. constructor(define: string, operand: string, testValue: string);
  78434. isTrue(preprocessors: {
  78435. [key: string]: string;
  78436. }): boolean;
  78437. }
  78438. }
  78439. declare module BABYLON {
  78440. /**
  78441. * Class used to enable access to offline support
  78442. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78443. */
  78444. export interface IOfflineProvider {
  78445. /**
  78446. * Gets a boolean indicating if scene must be saved in the database
  78447. */
  78448. enableSceneOffline: boolean;
  78449. /**
  78450. * Gets a boolean indicating if textures must be saved in the database
  78451. */
  78452. enableTexturesOffline: boolean;
  78453. /**
  78454. * Open the offline support and make it available
  78455. * @param successCallback defines the callback to call on success
  78456. * @param errorCallback defines the callback to call on error
  78457. */
  78458. open(successCallback: () => void, errorCallback: () => void): void;
  78459. /**
  78460. * Loads an image from the offline support
  78461. * @param url defines the url to load from
  78462. * @param image defines the target DOM image
  78463. */
  78464. loadImage(url: string, image: HTMLImageElement): void;
  78465. /**
  78466. * Loads a file from offline support
  78467. * @param url defines the URL to load from
  78468. * @param sceneLoaded defines a callback to call on success
  78469. * @param progressCallBack defines a callback to call when progress changed
  78470. * @param errorCallback defines a callback to call on error
  78471. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78472. */
  78473. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78474. }
  78475. }
  78476. declare module BABYLON {
  78477. /**
  78478. * Class used to help managing file picking and drag'n'drop
  78479. * File Storage
  78480. */
  78481. export class FilesInputStore {
  78482. /**
  78483. * List of files ready to be loaded
  78484. */
  78485. static FilesToLoad: {
  78486. [key: string]: File;
  78487. };
  78488. }
  78489. }
  78490. declare module BABYLON {
  78491. /**
  78492. * Class used to define a retry strategy when error happens while loading assets
  78493. */
  78494. export class RetryStrategy {
  78495. /**
  78496. * Function used to defines an exponential back off strategy
  78497. * @param maxRetries defines the maximum number of retries (3 by default)
  78498. * @param baseInterval defines the interval between retries
  78499. * @returns the strategy function to use
  78500. */
  78501. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  78502. }
  78503. }
  78504. declare module BABYLON {
  78505. /**
  78506. * @ignore
  78507. * Application error to support additional information when loading a file
  78508. */
  78509. export abstract class BaseError extends Error {
  78510. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  78511. }
  78512. }
  78513. declare module BABYLON {
  78514. /** @ignore */
  78515. export class LoadFileError extends BaseError {
  78516. request?: WebRequest;
  78517. file?: File;
  78518. /**
  78519. * Creates a new LoadFileError
  78520. * @param message defines the message of the error
  78521. * @param request defines the optional web request
  78522. * @param file defines the optional file
  78523. */
  78524. constructor(message: string, object?: WebRequest | File);
  78525. }
  78526. /** @ignore */
  78527. export class RequestFileError extends BaseError {
  78528. request: WebRequest;
  78529. /**
  78530. * Creates a new LoadFileError
  78531. * @param message defines the message of the error
  78532. * @param request defines the optional web request
  78533. */
  78534. constructor(message: string, request: WebRequest);
  78535. }
  78536. /** @ignore */
  78537. export class ReadFileError extends BaseError {
  78538. file: File;
  78539. /**
  78540. * Creates a new ReadFileError
  78541. * @param message defines the message of the error
  78542. * @param file defines the optional file
  78543. */
  78544. constructor(message: string, file: File);
  78545. }
  78546. /**
  78547. * @hidden
  78548. */
  78549. export class FileTools {
  78550. /**
  78551. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  78552. */
  78553. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  78554. /**
  78555. * Gets or sets the base URL to use to load assets
  78556. */
  78557. static BaseUrl: string;
  78558. /**
  78559. * Default behaviour for cors in the application.
  78560. * It can be a string if the expected behavior is identical in the entire app.
  78561. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  78562. */
  78563. static CorsBehavior: string | ((url: string | string[]) => string);
  78564. /**
  78565. * Gets or sets a function used to pre-process url before using them to load assets
  78566. */
  78567. static PreprocessUrl: (url: string) => string;
  78568. /**
  78569. * Removes unwanted characters from an url
  78570. * @param url defines the url to clean
  78571. * @returns the cleaned url
  78572. */
  78573. private static _CleanUrl;
  78574. /**
  78575. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  78576. * @param url define the url we are trying
  78577. * @param element define the dom element where to configure the cors policy
  78578. */
  78579. static SetCorsBehavior(url: string | string[], element: {
  78580. crossOrigin: string | null;
  78581. }): void;
  78582. /**
  78583. * Loads an image as an HTMLImageElement.
  78584. * @param input url string, ArrayBuffer, or Blob to load
  78585. * @param onLoad callback called when the image successfully loads
  78586. * @param onError callback called when the image fails to load
  78587. * @param offlineProvider offline provider for caching
  78588. * @param mimeType optional mime type
  78589. * @returns the HTMLImageElement of the loaded image
  78590. */
  78591. 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>;
  78592. /**
  78593. * Reads a file from a File object
  78594. * @param file defines the file to load
  78595. * @param onSuccess defines the callback to call when data is loaded
  78596. * @param onProgress defines the callback to call during loading process
  78597. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  78598. * @param onError defines the callback to call when an error occurs
  78599. * @returns a file request object
  78600. */
  78601. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  78602. /**
  78603. * Loads a file from a url
  78604. * @param url url to load
  78605. * @param onSuccess callback called when the file successfully loads
  78606. * @param onProgress callback called while file is loading (if the server supports this mode)
  78607. * @param offlineProvider defines the offline provider for caching
  78608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78609. * @param onError callback called when the file fails to load
  78610. * @returns a file request object
  78611. */
  78612. 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;
  78613. /**
  78614. * Loads a file
  78615. * @param url url to load
  78616. * @param onSuccess callback called when the file successfully loads
  78617. * @param onProgress callback called while file is loading (if the server supports this mode)
  78618. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78619. * @param onError callback called when the file fails to load
  78620. * @param onOpened callback called when the web request is opened
  78621. * @returns a file request object
  78622. */
  78623. 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;
  78624. /**
  78625. * Checks if the loaded document was accessed via `file:`-Protocol.
  78626. * @returns boolean
  78627. */
  78628. static IsFileURL(): boolean;
  78629. }
  78630. }
  78631. declare module BABYLON {
  78632. /** @hidden */
  78633. export class ShaderProcessor {
  78634. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  78635. private static _ProcessPrecision;
  78636. private static _ExtractOperation;
  78637. private static _BuildSubExpression;
  78638. private static _BuildExpression;
  78639. private static _MoveCursorWithinIf;
  78640. private static _MoveCursor;
  78641. private static _EvaluatePreProcessors;
  78642. private static _PreparePreProcessors;
  78643. private static _ProcessShaderConversion;
  78644. private static _ProcessIncludes;
  78645. /**
  78646. * Loads a file from a url
  78647. * @param url url to load
  78648. * @param onSuccess callback called when the file successfully loads
  78649. * @param onProgress callback called while file is loading (if the server supports this mode)
  78650. * @param offlineProvider defines the offline provider for caching
  78651. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78652. * @param onError callback called when the file fails to load
  78653. * @returns a file request object
  78654. * @hidden
  78655. */
  78656. 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;
  78657. }
  78658. }
  78659. declare module BABYLON {
  78660. /**
  78661. * @hidden
  78662. */
  78663. export interface IColor4Like {
  78664. r: float;
  78665. g: float;
  78666. b: float;
  78667. a: float;
  78668. }
  78669. /**
  78670. * @hidden
  78671. */
  78672. export interface IColor3Like {
  78673. r: float;
  78674. g: float;
  78675. b: float;
  78676. }
  78677. /**
  78678. * @hidden
  78679. */
  78680. export interface IVector4Like {
  78681. x: float;
  78682. y: float;
  78683. z: float;
  78684. w: float;
  78685. }
  78686. /**
  78687. * @hidden
  78688. */
  78689. export interface IVector3Like {
  78690. x: float;
  78691. y: float;
  78692. z: float;
  78693. }
  78694. /**
  78695. * @hidden
  78696. */
  78697. export interface IVector2Like {
  78698. x: float;
  78699. y: float;
  78700. }
  78701. /**
  78702. * @hidden
  78703. */
  78704. export interface IMatrixLike {
  78705. toArray(): DeepImmutable<Float32Array>;
  78706. updateFlag: int;
  78707. }
  78708. /**
  78709. * @hidden
  78710. */
  78711. export interface IViewportLike {
  78712. x: float;
  78713. y: float;
  78714. width: float;
  78715. height: float;
  78716. }
  78717. /**
  78718. * @hidden
  78719. */
  78720. export interface IPlaneLike {
  78721. normal: IVector3Like;
  78722. d: float;
  78723. normalize(): void;
  78724. }
  78725. }
  78726. declare module BABYLON {
  78727. /**
  78728. * Interface used to define common properties for effect fallbacks
  78729. */
  78730. export interface IEffectFallbacks {
  78731. /**
  78732. * Removes the defines that should be removed when falling back.
  78733. * @param currentDefines defines the current define statements for the shader.
  78734. * @param effect defines the current effect we try to compile
  78735. * @returns The resulting defines with defines of the current rank removed.
  78736. */
  78737. reduce(currentDefines: string, effect: Effect): string;
  78738. /**
  78739. * Removes the fallback from the bound mesh.
  78740. */
  78741. unBindMesh(): void;
  78742. /**
  78743. * Checks to see if more fallbacks are still availible.
  78744. */
  78745. hasMoreFallbacks: boolean;
  78746. }
  78747. }
  78748. declare module BABYLON {
  78749. /**
  78750. * Class used to evalaute queries containing `and` and `or` operators
  78751. */
  78752. export class AndOrNotEvaluator {
  78753. /**
  78754. * Evaluate a query
  78755. * @param query defines the query to evaluate
  78756. * @param evaluateCallback defines the callback used to filter result
  78757. * @returns true if the query matches
  78758. */
  78759. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  78760. private static _HandleParenthesisContent;
  78761. private static _SimplifyNegation;
  78762. }
  78763. }
  78764. declare module BABYLON {
  78765. /**
  78766. * Class used to store custom tags
  78767. */
  78768. export class Tags {
  78769. /**
  78770. * Adds support for tags on the given object
  78771. * @param obj defines the object to use
  78772. */
  78773. static EnableFor(obj: any): void;
  78774. /**
  78775. * Removes tags support
  78776. * @param obj defines the object to use
  78777. */
  78778. static DisableFor(obj: any): void;
  78779. /**
  78780. * Gets a boolean indicating if the given object has tags
  78781. * @param obj defines the object to use
  78782. * @returns a boolean
  78783. */
  78784. static HasTags(obj: any): boolean;
  78785. /**
  78786. * Gets the tags available on a given object
  78787. * @param obj defines the object to use
  78788. * @param asString defines if the tags must be returned as a string instead of an array of strings
  78789. * @returns the tags
  78790. */
  78791. static GetTags(obj: any, asString?: boolean): any;
  78792. /**
  78793. * Adds tags to an object
  78794. * @param obj defines the object to use
  78795. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  78796. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  78797. */
  78798. static AddTagsTo(obj: any, tagsString: string): void;
  78799. /**
  78800. * @hidden
  78801. */
  78802. static _AddTagTo(obj: any, tag: string): void;
  78803. /**
  78804. * Removes specific tags from a specific object
  78805. * @param obj defines the object to use
  78806. * @param tagsString defines the tags to remove
  78807. */
  78808. static RemoveTagsFrom(obj: any, tagsString: string): void;
  78809. /**
  78810. * @hidden
  78811. */
  78812. static _RemoveTagFrom(obj: any, tag: string): void;
  78813. /**
  78814. * Defines if tags hosted on an object match a given query
  78815. * @param obj defines the object to use
  78816. * @param tagsQuery defines the tag query
  78817. * @returns a boolean
  78818. */
  78819. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  78820. }
  78821. }
  78822. declare module BABYLON {
  78823. /**
  78824. * Scalar computation library
  78825. */
  78826. export class Scalar {
  78827. /**
  78828. * Two pi constants convenient for computation.
  78829. */
  78830. static TwoPi: number;
  78831. /**
  78832. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78833. * @param a number
  78834. * @param b number
  78835. * @param epsilon (default = 1.401298E-45)
  78836. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78837. */
  78838. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  78839. /**
  78840. * Returns a string : the upper case translation of the number i to hexadecimal.
  78841. * @param i number
  78842. * @returns the upper case translation of the number i to hexadecimal.
  78843. */
  78844. static ToHex(i: number): string;
  78845. /**
  78846. * Returns -1 if value is negative and +1 is value is positive.
  78847. * @param value the value
  78848. * @returns the value itself if it's equal to zero.
  78849. */
  78850. static Sign(value: number): number;
  78851. /**
  78852. * Returns the value itself if it's between min and max.
  78853. * Returns min if the value is lower than min.
  78854. * Returns max if the value is greater than max.
  78855. * @param value the value to clmap
  78856. * @param min the min value to clamp to (default: 0)
  78857. * @param max the max value to clamp to (default: 1)
  78858. * @returns the clamped value
  78859. */
  78860. static Clamp(value: number, min?: number, max?: number): number;
  78861. /**
  78862. * the log2 of value.
  78863. * @param value the value to compute log2 of
  78864. * @returns the log2 of value.
  78865. */
  78866. static Log2(value: number): number;
  78867. /**
  78868. * Loops the value, so that it is never larger than length and never smaller than 0.
  78869. *
  78870. * This is similar to the modulo operator but it works with floating point numbers.
  78871. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  78872. * With t = 5 and length = 2.5, the result would be 0.0.
  78873. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  78874. * @param value the value
  78875. * @param length the length
  78876. * @returns the looped value
  78877. */
  78878. static Repeat(value: number, length: number): number;
  78879. /**
  78880. * Normalize the value between 0.0 and 1.0 using min and max values
  78881. * @param value value to normalize
  78882. * @param min max to normalize between
  78883. * @param max min to normalize between
  78884. * @returns the normalized value
  78885. */
  78886. static Normalize(value: number, min: number, max: number): number;
  78887. /**
  78888. * Denormalize the value from 0.0 and 1.0 using min and max values
  78889. * @param normalized value to denormalize
  78890. * @param min max to denormalize between
  78891. * @param max min to denormalize between
  78892. * @returns the denormalized value
  78893. */
  78894. static Denormalize(normalized: number, min: number, max: number): number;
  78895. /**
  78896. * Calculates the shortest difference between two given angles given in degrees.
  78897. * @param current current angle in degrees
  78898. * @param target target angle in degrees
  78899. * @returns the delta
  78900. */
  78901. static DeltaAngle(current: number, target: number): number;
  78902. /**
  78903. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  78904. * @param tx value
  78905. * @param length length
  78906. * @returns The returned value will move back and forth between 0 and length
  78907. */
  78908. static PingPong(tx: number, length: number): number;
  78909. /**
  78910. * Interpolates between min and max with smoothing at the limits.
  78911. *
  78912. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  78913. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  78914. * @param from from
  78915. * @param to to
  78916. * @param tx value
  78917. * @returns the smooth stepped value
  78918. */
  78919. static SmoothStep(from: number, to: number, tx: number): number;
  78920. /**
  78921. * Moves a value current towards target.
  78922. *
  78923. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  78924. * Negative values of maxDelta pushes the value away from target.
  78925. * @param current current value
  78926. * @param target target value
  78927. * @param maxDelta max distance to move
  78928. * @returns resulting value
  78929. */
  78930. static MoveTowards(current: number, target: number, maxDelta: number): number;
  78931. /**
  78932. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78933. *
  78934. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  78935. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  78936. * @param current current value
  78937. * @param target target value
  78938. * @param maxDelta max distance to move
  78939. * @returns resulting angle
  78940. */
  78941. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  78942. /**
  78943. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  78944. * @param start start value
  78945. * @param end target value
  78946. * @param amount amount to lerp between
  78947. * @returns the lerped value
  78948. */
  78949. static Lerp(start: number, end: number, amount: number): number;
  78950. /**
  78951. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78952. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  78953. * @param start start value
  78954. * @param end target value
  78955. * @param amount amount to lerp between
  78956. * @returns the lerped value
  78957. */
  78958. static LerpAngle(start: number, end: number, amount: number): number;
  78959. /**
  78960. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  78961. * @param a start value
  78962. * @param b target value
  78963. * @param value value between a and b
  78964. * @returns the inverseLerp value
  78965. */
  78966. static InverseLerp(a: number, b: number, value: number): number;
  78967. /**
  78968. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  78969. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  78970. * @param value1 spline value
  78971. * @param tangent1 spline value
  78972. * @param value2 spline value
  78973. * @param tangent2 spline value
  78974. * @param amount input value
  78975. * @returns hermite result
  78976. */
  78977. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  78978. /**
  78979. * Returns a random float number between and min and max values
  78980. * @param min min value of random
  78981. * @param max max value of random
  78982. * @returns random value
  78983. */
  78984. static RandomRange(min: number, max: number): number;
  78985. /**
  78986. * This function returns percentage of a number in a given range.
  78987. *
  78988. * RangeToPercent(40,20,60) will return 0.5 (50%)
  78989. * RangeToPercent(34,0,100) will return 0.34 (34%)
  78990. * @param number to convert to percentage
  78991. * @param min min range
  78992. * @param max max range
  78993. * @returns the percentage
  78994. */
  78995. static RangeToPercent(number: number, min: number, max: number): number;
  78996. /**
  78997. * This function returns number that corresponds to the percentage in a given range.
  78998. *
  78999. * PercentToRange(0.34,0,100) will return 34.
  79000. * @param percent to convert to number
  79001. * @param min min range
  79002. * @param max max range
  79003. * @returns the number
  79004. */
  79005. static PercentToRange(percent: number, min: number, max: number): number;
  79006. /**
  79007. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79008. * @param angle The angle to normalize in radian.
  79009. * @return The converted angle.
  79010. */
  79011. static NormalizeRadians(angle: number): number;
  79012. }
  79013. }
  79014. declare module BABYLON {
  79015. /**
  79016. * Constant used to convert a value to gamma space
  79017. * @ignorenaming
  79018. */
  79019. export const ToGammaSpace: number;
  79020. /**
  79021. * Constant used to convert a value to linear space
  79022. * @ignorenaming
  79023. */
  79024. export const ToLinearSpace = 2.2;
  79025. /**
  79026. * Constant used to define the minimal number value in Babylon.js
  79027. * @ignorenaming
  79028. */
  79029. let Epsilon: number;
  79030. }
  79031. declare module BABYLON {
  79032. /**
  79033. * Class used to represent a viewport on screen
  79034. */
  79035. export class Viewport {
  79036. /** viewport left coordinate */
  79037. x: number;
  79038. /** viewport top coordinate */
  79039. y: number;
  79040. /**viewport width */
  79041. width: number;
  79042. /** viewport height */
  79043. height: number;
  79044. /**
  79045. * Creates a Viewport object located at (x, y) and sized (width, height)
  79046. * @param x defines viewport left coordinate
  79047. * @param y defines viewport top coordinate
  79048. * @param width defines the viewport width
  79049. * @param height defines the viewport height
  79050. */
  79051. constructor(
  79052. /** viewport left coordinate */
  79053. x: number,
  79054. /** viewport top coordinate */
  79055. y: number,
  79056. /**viewport width */
  79057. width: number,
  79058. /** viewport height */
  79059. height: number);
  79060. /**
  79061. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79062. * @param renderWidth defines the rendering width
  79063. * @param renderHeight defines the rendering height
  79064. * @returns a new Viewport
  79065. */
  79066. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79067. /**
  79068. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79069. * @param renderWidth defines the rendering width
  79070. * @param renderHeight defines the rendering height
  79071. * @param ref defines the target viewport
  79072. * @returns the current viewport
  79073. */
  79074. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79075. /**
  79076. * Returns a new Viewport copied from the current one
  79077. * @returns a new Viewport
  79078. */
  79079. clone(): Viewport;
  79080. }
  79081. }
  79082. declare module BABYLON {
  79083. /**
  79084. * Class containing a set of static utilities functions for arrays.
  79085. */
  79086. export class ArrayTools {
  79087. /**
  79088. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79089. * @param size the number of element to construct and put in the array
  79090. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79091. * @returns a new array filled with new objects
  79092. */
  79093. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79094. }
  79095. }
  79096. declare module BABYLON {
  79097. /**
  79098. * Represens a plane by the equation ax + by + cz + d = 0
  79099. */
  79100. export class Plane {
  79101. private static _TmpMatrix;
  79102. /**
  79103. * Normal of the plane (a,b,c)
  79104. */
  79105. normal: Vector3;
  79106. /**
  79107. * d component of the plane
  79108. */
  79109. d: number;
  79110. /**
  79111. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79112. * @param a a component of the plane
  79113. * @param b b component of the plane
  79114. * @param c c component of the plane
  79115. * @param d d component of the plane
  79116. */
  79117. constructor(a: number, b: number, c: number, d: number);
  79118. /**
  79119. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79120. */
  79121. asArray(): number[];
  79122. /**
  79123. * @returns a new plane copied from the current Plane.
  79124. */
  79125. clone(): Plane;
  79126. /**
  79127. * @returns the string "Plane".
  79128. */
  79129. getClassName(): string;
  79130. /**
  79131. * @returns the Plane hash code.
  79132. */
  79133. getHashCode(): number;
  79134. /**
  79135. * Normalize the current Plane in place.
  79136. * @returns the updated Plane.
  79137. */
  79138. normalize(): Plane;
  79139. /**
  79140. * Applies a transformation the plane and returns the result
  79141. * @param transformation the transformation matrix to be applied to the plane
  79142. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79143. */
  79144. transform(transformation: DeepImmutable<Matrix>): Plane;
  79145. /**
  79146. * Compute the dot product between the point and the plane normal
  79147. * @param point point to calculate the dot product with
  79148. * @returns the dot product (float) of the point coordinates and the plane normal.
  79149. */
  79150. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79151. /**
  79152. * Updates the current Plane from the plane defined by the three given points.
  79153. * @param point1 one of the points used to contruct the plane
  79154. * @param point2 one of the points used to contruct the plane
  79155. * @param point3 one of the points used to contruct the plane
  79156. * @returns the updated Plane.
  79157. */
  79158. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79159. /**
  79160. * Checks if the plane is facing a given direction
  79161. * @param direction the direction to check if the plane is facing
  79162. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79163. * @returns True is the vector "direction" is the same side than the plane normal.
  79164. */
  79165. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79166. /**
  79167. * Calculates the distance to a point
  79168. * @param point point to calculate distance to
  79169. * @returns the signed distance (float) from the given point to the Plane.
  79170. */
  79171. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79172. /**
  79173. * Creates a plane from an array
  79174. * @param array the array to create a plane from
  79175. * @returns a new Plane from the given array.
  79176. */
  79177. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79178. /**
  79179. * Creates a plane from three points
  79180. * @param point1 point used to create the plane
  79181. * @param point2 point used to create the plane
  79182. * @param point3 point used to create the plane
  79183. * @returns a new Plane defined by the three given points.
  79184. */
  79185. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79186. /**
  79187. * Creates a plane from an origin point and a normal
  79188. * @param origin origin of the plane to be constructed
  79189. * @param normal normal of the plane to be constructed
  79190. * @returns a new Plane the normal vector to this plane at the given origin point.
  79191. * Note : the vector "normal" is updated because normalized.
  79192. */
  79193. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79194. /**
  79195. * Calculates the distance from a plane and a point
  79196. * @param origin origin of the plane to be constructed
  79197. * @param normal normal of the plane to be constructed
  79198. * @param point point to calculate distance to
  79199. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79200. */
  79201. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79202. }
  79203. }
  79204. declare module BABYLON {
  79205. /**
  79206. * Class representing a vector containing 2 coordinates
  79207. */
  79208. export class Vector2 {
  79209. /** defines the first coordinate */
  79210. x: number;
  79211. /** defines the second coordinate */
  79212. y: number;
  79213. /**
  79214. * Creates a new Vector2 from the given x and y coordinates
  79215. * @param x defines the first coordinate
  79216. * @param y defines the second coordinate
  79217. */
  79218. constructor(
  79219. /** defines the first coordinate */
  79220. x?: number,
  79221. /** defines the second coordinate */
  79222. y?: number);
  79223. /**
  79224. * Gets a string with the Vector2 coordinates
  79225. * @returns a string with the Vector2 coordinates
  79226. */
  79227. toString(): string;
  79228. /**
  79229. * Gets class name
  79230. * @returns the string "Vector2"
  79231. */
  79232. getClassName(): string;
  79233. /**
  79234. * Gets current vector hash code
  79235. * @returns the Vector2 hash code as a number
  79236. */
  79237. getHashCode(): number;
  79238. /**
  79239. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79240. * @param array defines the source array
  79241. * @param index defines the offset in source array
  79242. * @returns the current Vector2
  79243. */
  79244. toArray(array: FloatArray, index?: number): Vector2;
  79245. /**
  79246. * Copy the current vector to an array
  79247. * @returns a new array with 2 elements: the Vector2 coordinates.
  79248. */
  79249. asArray(): number[];
  79250. /**
  79251. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79252. * @param source defines the source Vector2
  79253. * @returns the current updated Vector2
  79254. */
  79255. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79256. /**
  79257. * Sets the Vector2 coordinates with the given floats
  79258. * @param x defines the first coordinate
  79259. * @param y defines the second coordinate
  79260. * @returns the current updated Vector2
  79261. */
  79262. copyFromFloats(x: number, y: number): Vector2;
  79263. /**
  79264. * Sets the Vector2 coordinates with the given floats
  79265. * @param x defines the first coordinate
  79266. * @param y defines the second coordinate
  79267. * @returns the current updated Vector2
  79268. */
  79269. set(x: number, y: number): Vector2;
  79270. /**
  79271. * Add another vector with the current one
  79272. * @param otherVector defines the other vector
  79273. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79274. */
  79275. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79276. /**
  79277. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79278. * @param otherVector defines the other vector
  79279. * @param result defines the target vector
  79280. * @returns the unmodified current Vector2
  79281. */
  79282. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79283. /**
  79284. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79285. * @param otherVector defines the other vector
  79286. * @returns the current updated Vector2
  79287. */
  79288. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79289. /**
  79290. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79291. * @param otherVector defines the other vector
  79292. * @returns a new Vector2
  79293. */
  79294. addVector3(otherVector: Vector3): Vector2;
  79295. /**
  79296. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79297. * @param otherVector defines the other vector
  79298. * @returns a new Vector2
  79299. */
  79300. subtract(otherVector: Vector2): Vector2;
  79301. /**
  79302. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79303. * @param otherVector defines the other vector
  79304. * @param result defines the target vector
  79305. * @returns the unmodified current Vector2
  79306. */
  79307. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79308. /**
  79309. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79310. * @param otherVector defines the other vector
  79311. * @returns the current updated Vector2
  79312. */
  79313. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79314. /**
  79315. * Multiplies in place the current Vector2 coordinates by the given ones
  79316. * @param otherVector defines the other vector
  79317. * @returns the current updated Vector2
  79318. */
  79319. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79320. /**
  79321. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79322. * @param otherVector defines the other vector
  79323. * @returns a new Vector2
  79324. */
  79325. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79326. /**
  79327. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79328. * @param otherVector defines the other vector
  79329. * @param result defines the target vector
  79330. * @returns the unmodified current Vector2
  79331. */
  79332. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79333. /**
  79334. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79335. * @param x defines the first coordinate
  79336. * @param y defines the second coordinate
  79337. * @returns a new Vector2
  79338. */
  79339. multiplyByFloats(x: number, y: number): Vector2;
  79340. /**
  79341. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79342. * @param otherVector defines the other vector
  79343. * @returns a new Vector2
  79344. */
  79345. divide(otherVector: Vector2): Vector2;
  79346. /**
  79347. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79348. * @param otherVector defines the other vector
  79349. * @param result defines the target vector
  79350. * @returns the unmodified current Vector2
  79351. */
  79352. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79353. /**
  79354. * Divides the current Vector2 coordinates by the given ones
  79355. * @param otherVector defines the other vector
  79356. * @returns the current updated Vector2
  79357. */
  79358. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79359. /**
  79360. * Gets a new Vector2 with current Vector2 negated coordinates
  79361. * @returns a new Vector2
  79362. */
  79363. negate(): Vector2;
  79364. /**
  79365. * Negate this vector in place
  79366. * @returns this
  79367. */
  79368. negateInPlace(): Vector2;
  79369. /**
  79370. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79371. * @param result defines the Vector3 object where to store the result
  79372. * @returns the current Vector2
  79373. */
  79374. negateToRef(result: Vector2): Vector2;
  79375. /**
  79376. * Multiply the Vector2 coordinates by scale
  79377. * @param scale defines the scaling factor
  79378. * @returns the current updated Vector2
  79379. */
  79380. scaleInPlace(scale: number): Vector2;
  79381. /**
  79382. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79383. * @param scale defines the scaling factor
  79384. * @returns a new Vector2
  79385. */
  79386. scale(scale: number): Vector2;
  79387. /**
  79388. * Scale the current Vector2 values by a factor to a given Vector2
  79389. * @param scale defines the scale factor
  79390. * @param result defines the Vector2 object where to store the result
  79391. * @returns the unmodified current Vector2
  79392. */
  79393. scaleToRef(scale: number, result: Vector2): Vector2;
  79394. /**
  79395. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79396. * @param scale defines the scale factor
  79397. * @param result defines the Vector2 object where to store the result
  79398. * @returns the unmodified current Vector2
  79399. */
  79400. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79401. /**
  79402. * Gets a boolean if two vectors are equals
  79403. * @param otherVector defines the other vector
  79404. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79405. */
  79406. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79407. /**
  79408. * Gets a boolean if two vectors are equals (using an epsilon value)
  79409. * @param otherVector defines the other vector
  79410. * @param epsilon defines the minimal distance to consider equality
  79411. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79412. */
  79413. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79414. /**
  79415. * Gets a new Vector2 from current Vector2 floored values
  79416. * @returns a new Vector2
  79417. */
  79418. floor(): Vector2;
  79419. /**
  79420. * Gets a new Vector2 from current Vector2 floored values
  79421. * @returns a new Vector2
  79422. */
  79423. fract(): Vector2;
  79424. /**
  79425. * Gets the length of the vector
  79426. * @returns the vector length (float)
  79427. */
  79428. length(): number;
  79429. /**
  79430. * Gets the vector squared length
  79431. * @returns the vector squared length (float)
  79432. */
  79433. lengthSquared(): number;
  79434. /**
  79435. * Normalize the vector
  79436. * @returns the current updated Vector2
  79437. */
  79438. normalize(): Vector2;
  79439. /**
  79440. * Gets a new Vector2 copied from the Vector2
  79441. * @returns a new Vector2
  79442. */
  79443. clone(): Vector2;
  79444. /**
  79445. * Gets a new Vector2(0, 0)
  79446. * @returns a new Vector2
  79447. */
  79448. static Zero(): Vector2;
  79449. /**
  79450. * Gets a new Vector2(1, 1)
  79451. * @returns a new Vector2
  79452. */
  79453. static One(): Vector2;
  79454. /**
  79455. * Gets a new Vector2 set from the given index element of the given array
  79456. * @param array defines the data source
  79457. * @param offset defines the offset in the data source
  79458. * @returns a new Vector2
  79459. */
  79460. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79461. /**
  79462. * Sets "result" from the given index element of the given array
  79463. * @param array defines the data source
  79464. * @param offset defines the offset in the data source
  79465. * @param result defines the target vector
  79466. */
  79467. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79468. /**
  79469. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79470. * @param value1 defines 1st point of control
  79471. * @param value2 defines 2nd point of control
  79472. * @param value3 defines 3rd point of control
  79473. * @param value4 defines 4th point of control
  79474. * @param amount defines the interpolation factor
  79475. * @returns a new Vector2
  79476. */
  79477. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  79478. /**
  79479. * 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".
  79480. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  79481. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  79482. * @param value defines the value to clamp
  79483. * @param min defines the lower limit
  79484. * @param max defines the upper limit
  79485. * @returns a new Vector2
  79486. */
  79487. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  79488. /**
  79489. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  79490. * @param value1 defines the 1st control point
  79491. * @param tangent1 defines the outgoing tangent
  79492. * @param value2 defines the 2nd control point
  79493. * @param tangent2 defines the incoming tangent
  79494. * @param amount defines the interpolation factor
  79495. * @returns a new Vector2
  79496. */
  79497. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  79498. /**
  79499. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  79500. * @param start defines the start vector
  79501. * @param end defines the end vector
  79502. * @param amount defines the interpolation factor
  79503. * @returns a new Vector2
  79504. */
  79505. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  79506. /**
  79507. * Gets the dot product of the vector "left" and the vector "right"
  79508. * @param left defines first vector
  79509. * @param right defines second vector
  79510. * @returns the dot product (float)
  79511. */
  79512. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  79513. /**
  79514. * Returns a new Vector2 equal to the normalized given vector
  79515. * @param vector defines the vector to normalize
  79516. * @returns a new Vector2
  79517. */
  79518. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  79519. /**
  79520. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  79521. * @param left defines 1st vector
  79522. * @param right defines 2nd vector
  79523. * @returns a new Vector2
  79524. */
  79525. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79526. /**
  79527. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  79528. * @param left defines 1st vector
  79529. * @param right defines 2nd vector
  79530. * @returns a new Vector2
  79531. */
  79532. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79533. /**
  79534. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  79535. * @param vector defines the vector to transform
  79536. * @param transformation defines the matrix to apply
  79537. * @returns a new Vector2
  79538. */
  79539. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  79540. /**
  79541. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  79542. * @param vector defines the vector to transform
  79543. * @param transformation defines the matrix to apply
  79544. * @param result defines the target vector
  79545. */
  79546. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  79547. /**
  79548. * Determines if a given vector is included in a triangle
  79549. * @param p defines the vector to test
  79550. * @param p0 defines 1st triangle point
  79551. * @param p1 defines 2nd triangle point
  79552. * @param p2 defines 3rd triangle point
  79553. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  79554. */
  79555. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  79556. /**
  79557. * Gets the distance between the vectors "value1" and "value2"
  79558. * @param value1 defines first vector
  79559. * @param value2 defines second vector
  79560. * @returns the distance between vectors
  79561. */
  79562. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79563. /**
  79564. * Returns the squared distance between the vectors "value1" and "value2"
  79565. * @param value1 defines first vector
  79566. * @param value2 defines second vector
  79567. * @returns the squared distance between vectors
  79568. */
  79569. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79570. /**
  79571. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  79572. * @param value1 defines first vector
  79573. * @param value2 defines second vector
  79574. * @returns a new Vector2
  79575. */
  79576. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  79577. /**
  79578. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  79579. * @param p defines the middle point
  79580. * @param segA defines one point of the segment
  79581. * @param segB defines the other point of the segment
  79582. * @returns the shortest distance
  79583. */
  79584. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  79585. }
  79586. /**
  79587. * Class used to store (x,y,z) vector representation
  79588. * A Vector3 is the main object used in 3D geometry
  79589. * It can represent etiher the coordinates of a point the space, either a direction
  79590. * Reminder: js uses a left handed forward facing system
  79591. */
  79592. export class Vector3 {
  79593. /**
  79594. * Defines the first coordinates (on X axis)
  79595. */
  79596. x: number;
  79597. /**
  79598. * Defines the second coordinates (on Y axis)
  79599. */
  79600. y: number;
  79601. /**
  79602. * Defines the third coordinates (on Z axis)
  79603. */
  79604. z: number;
  79605. private static _UpReadOnly;
  79606. private static _ZeroReadOnly;
  79607. /**
  79608. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  79609. * @param x defines the first coordinates (on X axis)
  79610. * @param y defines the second coordinates (on Y axis)
  79611. * @param z defines the third coordinates (on Z axis)
  79612. */
  79613. constructor(
  79614. /**
  79615. * Defines the first coordinates (on X axis)
  79616. */
  79617. x?: number,
  79618. /**
  79619. * Defines the second coordinates (on Y axis)
  79620. */
  79621. y?: number,
  79622. /**
  79623. * Defines the third coordinates (on Z axis)
  79624. */
  79625. z?: number);
  79626. /**
  79627. * Creates a string representation of the Vector3
  79628. * @returns a string with the Vector3 coordinates.
  79629. */
  79630. toString(): string;
  79631. /**
  79632. * Gets the class name
  79633. * @returns the string "Vector3"
  79634. */
  79635. getClassName(): string;
  79636. /**
  79637. * Creates the Vector3 hash code
  79638. * @returns a number which tends to be unique between Vector3 instances
  79639. */
  79640. getHashCode(): number;
  79641. /**
  79642. * Creates an array containing three elements : the coordinates of the Vector3
  79643. * @returns a new array of numbers
  79644. */
  79645. asArray(): number[];
  79646. /**
  79647. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  79648. * @param array defines the destination array
  79649. * @param index defines the offset in the destination array
  79650. * @returns the current Vector3
  79651. */
  79652. toArray(array: FloatArray, index?: number): Vector3;
  79653. /**
  79654. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  79655. * @returns a new Quaternion object, computed from the Vector3 coordinates
  79656. */
  79657. toQuaternion(): Quaternion;
  79658. /**
  79659. * Adds the given vector to the current Vector3
  79660. * @param otherVector defines the second operand
  79661. * @returns the current updated Vector3
  79662. */
  79663. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79664. /**
  79665. * Adds the given coordinates to the current Vector3
  79666. * @param x defines the x coordinate of the operand
  79667. * @param y defines the y coordinate of the operand
  79668. * @param z defines the z coordinate of the operand
  79669. * @returns the current updated Vector3
  79670. */
  79671. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79672. /**
  79673. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  79674. * @param otherVector defines the second operand
  79675. * @returns the resulting Vector3
  79676. */
  79677. add(otherVector: DeepImmutable<Vector3>): Vector3;
  79678. /**
  79679. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  79680. * @param otherVector defines the second operand
  79681. * @param result defines the Vector3 object where to store the result
  79682. * @returns the current Vector3
  79683. */
  79684. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79685. /**
  79686. * Subtract the given vector from the current Vector3
  79687. * @param otherVector defines the second operand
  79688. * @returns the current updated Vector3
  79689. */
  79690. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79691. /**
  79692. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  79693. * @param otherVector defines the second operand
  79694. * @returns the resulting Vector3
  79695. */
  79696. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  79697. /**
  79698. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  79699. * @param otherVector defines the second operand
  79700. * @param result defines the Vector3 object where to store the result
  79701. * @returns the current Vector3
  79702. */
  79703. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79704. /**
  79705. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  79706. * @param x defines the x coordinate of the operand
  79707. * @param y defines the y coordinate of the operand
  79708. * @param z defines the z coordinate of the operand
  79709. * @returns the resulting Vector3
  79710. */
  79711. subtractFromFloats(x: number, y: number, z: number): Vector3;
  79712. /**
  79713. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  79714. * @param x defines the x coordinate of the operand
  79715. * @param y defines the y coordinate of the operand
  79716. * @param z defines the z coordinate of the operand
  79717. * @param result defines the Vector3 object where to store the result
  79718. * @returns the current Vector3
  79719. */
  79720. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  79721. /**
  79722. * Gets a new Vector3 set with the current Vector3 negated coordinates
  79723. * @returns a new Vector3
  79724. */
  79725. negate(): Vector3;
  79726. /**
  79727. * Negate this vector in place
  79728. * @returns this
  79729. */
  79730. negateInPlace(): Vector3;
  79731. /**
  79732. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  79733. * @param result defines the Vector3 object where to store the result
  79734. * @returns the current Vector3
  79735. */
  79736. negateToRef(result: Vector3): Vector3;
  79737. /**
  79738. * Multiplies the Vector3 coordinates by the float "scale"
  79739. * @param scale defines the multiplier factor
  79740. * @returns the current updated Vector3
  79741. */
  79742. scaleInPlace(scale: number): Vector3;
  79743. /**
  79744. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  79745. * @param scale defines the multiplier factor
  79746. * @returns a new Vector3
  79747. */
  79748. scale(scale: number): Vector3;
  79749. /**
  79750. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  79751. * @param scale defines the multiplier factor
  79752. * @param result defines the Vector3 object where to store the result
  79753. * @returns the current Vector3
  79754. */
  79755. scaleToRef(scale: number, result: Vector3): Vector3;
  79756. /**
  79757. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  79758. * @param scale defines the scale factor
  79759. * @param result defines the Vector3 object where to store the result
  79760. * @returns the unmodified current Vector3
  79761. */
  79762. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  79763. /**
  79764. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79765. * @param origin defines the origin of the projection ray
  79766. * @param plane defines the plane to project to
  79767. * @returns the projected vector3
  79768. */
  79769. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  79770. /**
  79771. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79772. * @param origin defines the origin of the projection ray
  79773. * @param plane defines the plane to project to
  79774. * @param result defines the Vector3 where to store the result
  79775. */
  79776. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  79777. /**
  79778. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  79779. * @param otherVector defines the second operand
  79780. * @returns true if both vectors are equals
  79781. */
  79782. equals(otherVector: DeepImmutable<Vector3>): boolean;
  79783. /**
  79784. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  79785. * @param otherVector defines the second operand
  79786. * @param epsilon defines the minimal distance to define values as equals
  79787. * @returns true if both vectors are distant less than epsilon
  79788. */
  79789. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  79790. /**
  79791. * Returns true if the current Vector3 coordinates equals the given floats
  79792. * @param x defines the x coordinate of the operand
  79793. * @param y defines the y coordinate of the operand
  79794. * @param z defines the z coordinate of the operand
  79795. * @returns true if both vectors are equals
  79796. */
  79797. equalsToFloats(x: number, y: number, z: number): boolean;
  79798. /**
  79799. * Multiplies the current Vector3 coordinates by the given ones
  79800. * @param otherVector defines the second operand
  79801. * @returns the current updated Vector3
  79802. */
  79803. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79804. /**
  79805. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  79806. * @param otherVector defines the second operand
  79807. * @returns the new Vector3
  79808. */
  79809. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  79810. /**
  79811. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  79812. * @param otherVector defines the second operand
  79813. * @param result defines the Vector3 object where to store the result
  79814. * @returns the current Vector3
  79815. */
  79816. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79817. /**
  79818. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  79819. * @param x defines the x coordinate of the operand
  79820. * @param y defines the y coordinate of the operand
  79821. * @param z defines the z coordinate of the operand
  79822. * @returns the new Vector3
  79823. */
  79824. multiplyByFloats(x: number, y: number, z: number): Vector3;
  79825. /**
  79826. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  79827. * @param otherVector defines the second operand
  79828. * @returns the new Vector3
  79829. */
  79830. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  79831. /**
  79832. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  79833. * @param otherVector defines the second operand
  79834. * @param result defines the Vector3 object where to store the result
  79835. * @returns the current Vector3
  79836. */
  79837. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79838. /**
  79839. * Divides the current Vector3 coordinates by the given ones.
  79840. * @param otherVector defines the second operand
  79841. * @returns the current updated Vector3
  79842. */
  79843. divideInPlace(otherVector: Vector3): Vector3;
  79844. /**
  79845. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  79846. * @param other defines the second operand
  79847. * @returns the current updated Vector3
  79848. */
  79849. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79850. /**
  79851. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  79852. * @param other defines the second operand
  79853. * @returns the current updated Vector3
  79854. */
  79855. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79856. /**
  79857. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  79858. * @param x defines the x coordinate of the operand
  79859. * @param y defines the y coordinate of the operand
  79860. * @param z defines the z coordinate of the operand
  79861. * @returns the current updated Vector3
  79862. */
  79863. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79864. /**
  79865. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  79866. * @param x defines the x coordinate of the operand
  79867. * @param y defines the y coordinate of the operand
  79868. * @param z defines the z coordinate of the operand
  79869. * @returns the current updated Vector3
  79870. */
  79871. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79872. /**
  79873. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  79874. * Check if is non uniform within a certain amount of decimal places to account for this
  79875. * @param epsilon the amount the values can differ
  79876. * @returns if the the vector is non uniform to a certain number of decimal places
  79877. */
  79878. isNonUniformWithinEpsilon(epsilon: number): boolean;
  79879. /**
  79880. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  79881. */
  79882. get isNonUniform(): boolean;
  79883. /**
  79884. * Gets a new Vector3 from current Vector3 floored values
  79885. * @returns a new Vector3
  79886. */
  79887. floor(): Vector3;
  79888. /**
  79889. * Gets a new Vector3 from current Vector3 floored values
  79890. * @returns a new Vector3
  79891. */
  79892. fract(): Vector3;
  79893. /**
  79894. * Gets the length of the Vector3
  79895. * @returns the length of the Vector3
  79896. */
  79897. length(): number;
  79898. /**
  79899. * Gets the squared length of the Vector3
  79900. * @returns squared length of the Vector3
  79901. */
  79902. lengthSquared(): number;
  79903. /**
  79904. * Normalize the current Vector3.
  79905. * Please note that this is an in place operation.
  79906. * @returns the current updated Vector3
  79907. */
  79908. normalize(): Vector3;
  79909. /**
  79910. * Reorders the x y z properties of the vector in place
  79911. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  79912. * @returns the current updated vector
  79913. */
  79914. reorderInPlace(order: string): this;
  79915. /**
  79916. * Rotates the vector around 0,0,0 by a quaternion
  79917. * @param quaternion the rotation quaternion
  79918. * @param result vector to store the result
  79919. * @returns the resulting vector
  79920. */
  79921. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  79922. /**
  79923. * Rotates a vector around a given point
  79924. * @param quaternion the rotation quaternion
  79925. * @param point the point to rotate around
  79926. * @param result vector to store the result
  79927. * @returns the resulting vector
  79928. */
  79929. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  79930. /**
  79931. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  79932. * The cross product is then orthogonal to both current and "other"
  79933. * @param other defines the right operand
  79934. * @returns the cross product
  79935. */
  79936. cross(other: Vector3): Vector3;
  79937. /**
  79938. * Normalize the current Vector3 with the given input length.
  79939. * Please note that this is an in place operation.
  79940. * @param len the length of the vector
  79941. * @returns the current updated Vector3
  79942. */
  79943. normalizeFromLength(len: number): Vector3;
  79944. /**
  79945. * Normalize the current Vector3 to a new vector
  79946. * @returns the new Vector3
  79947. */
  79948. normalizeToNew(): Vector3;
  79949. /**
  79950. * Normalize the current Vector3 to the reference
  79951. * @param reference define the Vector3 to update
  79952. * @returns the updated Vector3
  79953. */
  79954. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  79955. /**
  79956. * Creates a new Vector3 copied from the current Vector3
  79957. * @returns the new Vector3
  79958. */
  79959. clone(): Vector3;
  79960. /**
  79961. * Copies the given vector coordinates to the current Vector3 ones
  79962. * @param source defines the source Vector3
  79963. * @returns the current updated Vector3
  79964. */
  79965. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  79966. /**
  79967. * Copies the given floats to the current Vector3 coordinates
  79968. * @param x defines the x coordinate of the operand
  79969. * @param y defines the y coordinate of the operand
  79970. * @param z defines the z coordinate of the operand
  79971. * @returns the current updated Vector3
  79972. */
  79973. copyFromFloats(x: number, y: number, z: number): Vector3;
  79974. /**
  79975. * Copies the given floats to the current Vector3 coordinates
  79976. * @param x defines the x coordinate of the operand
  79977. * @param y defines the y coordinate of the operand
  79978. * @param z defines the z coordinate of the operand
  79979. * @returns the current updated Vector3
  79980. */
  79981. set(x: number, y: number, z: number): Vector3;
  79982. /**
  79983. * Copies the given float to the current Vector3 coordinates
  79984. * @param v defines the x, y and z coordinates of the operand
  79985. * @returns the current updated Vector3
  79986. */
  79987. setAll(v: number): Vector3;
  79988. /**
  79989. * Get the clip factor between two vectors
  79990. * @param vector0 defines the first operand
  79991. * @param vector1 defines the second operand
  79992. * @param axis defines the axis to use
  79993. * @param size defines the size along the axis
  79994. * @returns the clip factor
  79995. */
  79996. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  79997. /**
  79998. * Get angle between two vectors
  79999. * @param vector0 angle between vector0 and vector1
  80000. * @param vector1 angle between vector0 and vector1
  80001. * @param normal direction of the normal
  80002. * @return the angle between vector0 and vector1
  80003. */
  80004. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80005. /**
  80006. * Returns a new Vector3 set from the index "offset" of the given array
  80007. * @param array defines the source array
  80008. * @param offset defines the offset in the source array
  80009. * @returns the new Vector3
  80010. */
  80011. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80012. /**
  80013. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80014. * @param array defines the source array
  80015. * @param offset defines the offset in the source array
  80016. * @returns the new Vector3
  80017. * @deprecated Please use FromArray instead.
  80018. */
  80019. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80020. /**
  80021. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80022. * @param array defines the source array
  80023. * @param offset defines the offset in the source array
  80024. * @param result defines the Vector3 where to store the result
  80025. */
  80026. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80027. /**
  80028. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80029. * @param array defines the source array
  80030. * @param offset defines the offset in the source array
  80031. * @param result defines the Vector3 where to store the result
  80032. * @deprecated Please use FromArrayToRef instead.
  80033. */
  80034. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80035. /**
  80036. * Sets the given vector "result" with the given floats.
  80037. * @param x defines the x coordinate of the source
  80038. * @param y defines the y coordinate of the source
  80039. * @param z defines the z coordinate of the source
  80040. * @param result defines the Vector3 where to store the result
  80041. */
  80042. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80043. /**
  80044. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80045. * @returns a new empty Vector3
  80046. */
  80047. static Zero(): Vector3;
  80048. /**
  80049. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80050. * @returns a new unit Vector3
  80051. */
  80052. static One(): Vector3;
  80053. /**
  80054. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80055. * @returns a new up Vector3
  80056. */
  80057. static Up(): Vector3;
  80058. /**
  80059. * Gets a up Vector3 that must not be updated
  80060. */
  80061. static get UpReadOnly(): DeepImmutable<Vector3>;
  80062. /**
  80063. * Gets a zero Vector3 that must not be updated
  80064. */
  80065. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80066. /**
  80067. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80068. * @returns a new down Vector3
  80069. */
  80070. static Down(): Vector3;
  80071. /**
  80072. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80073. * @param rightHandedSystem is the scene right-handed (negative z)
  80074. * @returns a new forward Vector3
  80075. */
  80076. static Forward(rightHandedSystem?: boolean): Vector3;
  80077. /**
  80078. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80079. * @param rightHandedSystem is the scene right-handed (negative-z)
  80080. * @returns a new forward Vector3
  80081. */
  80082. static Backward(rightHandedSystem?: boolean): Vector3;
  80083. /**
  80084. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80085. * @returns a new right Vector3
  80086. */
  80087. static Right(): Vector3;
  80088. /**
  80089. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80090. * @returns a new left Vector3
  80091. */
  80092. static Left(): Vector3;
  80093. /**
  80094. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80095. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80096. * @param vector defines the Vector3 to transform
  80097. * @param transformation defines the transformation matrix
  80098. * @returns the transformed Vector3
  80099. */
  80100. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80101. /**
  80102. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80103. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80104. * @param vector defines the Vector3 to transform
  80105. * @param transformation defines the transformation matrix
  80106. * @param result defines the Vector3 where to store the result
  80107. */
  80108. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80109. /**
  80110. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80111. * This method computes tranformed coordinates only, not transformed direction vectors
  80112. * @param x define the x coordinate of the source vector
  80113. * @param y define the y coordinate of the source vector
  80114. * @param z define the z coordinate of the source vector
  80115. * @param transformation defines the transformation matrix
  80116. * @param result defines the Vector3 where to store the result
  80117. */
  80118. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80119. /**
  80120. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80121. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80122. * @param vector defines the Vector3 to transform
  80123. * @param transformation defines the transformation matrix
  80124. * @returns the new Vector3
  80125. */
  80126. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80127. /**
  80128. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80129. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80130. * @param vector defines the Vector3 to transform
  80131. * @param transformation defines the transformation matrix
  80132. * @param result defines the Vector3 where to store the result
  80133. */
  80134. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80135. /**
  80136. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80137. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80138. * @param x define the x coordinate of the source vector
  80139. * @param y define the y coordinate of the source vector
  80140. * @param z define the z coordinate of the source vector
  80141. * @param transformation defines the transformation matrix
  80142. * @param result defines the Vector3 where to store the result
  80143. */
  80144. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80145. /**
  80146. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80147. * @param value1 defines the first control point
  80148. * @param value2 defines the second control point
  80149. * @param value3 defines the third control point
  80150. * @param value4 defines the fourth control point
  80151. * @param amount defines the amount on the spline to use
  80152. * @returns the new Vector3
  80153. */
  80154. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80155. /**
  80156. * 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"
  80157. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80158. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80159. * @param value defines the current value
  80160. * @param min defines the lower range value
  80161. * @param max defines the upper range value
  80162. * @returns the new Vector3
  80163. */
  80164. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80165. /**
  80166. * 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"
  80167. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80168. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80169. * @param value defines the current value
  80170. * @param min defines the lower range value
  80171. * @param max defines the upper range value
  80172. * @param result defines the Vector3 where to store the result
  80173. */
  80174. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80175. /**
  80176. * Checks if a given vector is inside a specific range
  80177. * @param v defines the vector to test
  80178. * @param min defines the minimum range
  80179. * @param max defines the maximum range
  80180. */
  80181. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80182. /**
  80183. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80184. * @param value1 defines the first control point
  80185. * @param tangent1 defines the first tangent vector
  80186. * @param value2 defines the second control point
  80187. * @param tangent2 defines the second tangent vector
  80188. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80189. * @returns the new Vector3
  80190. */
  80191. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80192. /**
  80193. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80194. * @param start defines the start value
  80195. * @param end defines the end value
  80196. * @param amount max defines amount between both (between 0 and 1)
  80197. * @returns the new Vector3
  80198. */
  80199. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80200. /**
  80201. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80202. * @param start defines the start value
  80203. * @param end defines the end value
  80204. * @param amount max defines amount between both (between 0 and 1)
  80205. * @param result defines the Vector3 where to store the result
  80206. */
  80207. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80208. /**
  80209. * Returns the dot product (float) between the vectors "left" and "right"
  80210. * @param left defines the left operand
  80211. * @param right defines the right operand
  80212. * @returns the dot product
  80213. */
  80214. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80215. /**
  80216. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80217. * The cross product is then orthogonal to both "left" and "right"
  80218. * @param left defines the left operand
  80219. * @param right defines the right operand
  80220. * @returns the cross product
  80221. */
  80222. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80223. /**
  80224. * Sets the given vector "result" with the cross product of "left" and "right"
  80225. * The cross product is then orthogonal to both "left" and "right"
  80226. * @param left defines the left operand
  80227. * @param right defines the right operand
  80228. * @param result defines the Vector3 where to store the result
  80229. */
  80230. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80231. /**
  80232. * Returns a new Vector3 as the normalization of the given vector
  80233. * @param vector defines the Vector3 to normalize
  80234. * @returns the new Vector3
  80235. */
  80236. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80237. /**
  80238. * Sets the given vector "result" with the normalization of the given first vector
  80239. * @param vector defines the Vector3 to normalize
  80240. * @param result defines the Vector3 where to store the result
  80241. */
  80242. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80243. /**
  80244. * Project a Vector3 onto screen space
  80245. * @param vector defines the Vector3 to project
  80246. * @param world defines the world matrix to use
  80247. * @param transform defines the transform (view x projection) matrix to use
  80248. * @param viewport defines the screen viewport to use
  80249. * @returns the new Vector3
  80250. */
  80251. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80252. /** @hidden */
  80253. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80254. /**
  80255. * Unproject from screen space to object space
  80256. * @param source defines the screen space Vector3 to use
  80257. * @param viewportWidth defines the current width of the viewport
  80258. * @param viewportHeight defines the current height of the viewport
  80259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80260. * @param transform defines the transform (view x projection) matrix to use
  80261. * @returns the new Vector3
  80262. */
  80263. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80264. /**
  80265. * Unproject from screen space to object space
  80266. * @param source defines the screen space Vector3 to use
  80267. * @param viewportWidth defines the current width of the viewport
  80268. * @param viewportHeight defines the current height of the viewport
  80269. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80270. * @param view defines the view matrix to use
  80271. * @param projection defines the projection matrix to use
  80272. * @returns the new Vector3
  80273. */
  80274. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80275. /**
  80276. * Unproject from screen space to object space
  80277. * @param source defines the screen space Vector3 to use
  80278. * @param viewportWidth defines the current width of the viewport
  80279. * @param viewportHeight defines the current height of the viewport
  80280. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80281. * @param view defines the view matrix to use
  80282. * @param projection defines the projection matrix to use
  80283. * @param result defines the Vector3 where to store the result
  80284. */
  80285. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80286. /**
  80287. * Unproject from screen space to object space
  80288. * @param sourceX defines the screen space x coordinate to use
  80289. * @param sourceY defines the screen space y coordinate to use
  80290. * @param sourceZ defines the screen space z coordinate to use
  80291. * @param viewportWidth defines the current width of the viewport
  80292. * @param viewportHeight defines the current height of the viewport
  80293. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80294. * @param view defines the view matrix to use
  80295. * @param projection defines the projection matrix to use
  80296. * @param result defines the Vector3 where to store the result
  80297. */
  80298. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80299. /**
  80300. * Gets the minimal coordinate values between two Vector3
  80301. * @param left defines the first operand
  80302. * @param right defines the second operand
  80303. * @returns the new Vector3
  80304. */
  80305. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80306. /**
  80307. * Gets the maximal coordinate values between two Vector3
  80308. * @param left defines the first operand
  80309. * @param right defines the second operand
  80310. * @returns the new Vector3
  80311. */
  80312. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80313. /**
  80314. * Returns the distance between the vectors "value1" and "value2"
  80315. * @param value1 defines the first operand
  80316. * @param value2 defines the second operand
  80317. * @returns the distance
  80318. */
  80319. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80320. /**
  80321. * Returns the squared distance between the vectors "value1" and "value2"
  80322. * @param value1 defines the first operand
  80323. * @param value2 defines the second operand
  80324. * @returns the squared distance
  80325. */
  80326. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80327. /**
  80328. * Returns a new Vector3 located at the center between "value1" and "value2"
  80329. * @param value1 defines the first operand
  80330. * @param value2 defines the second operand
  80331. * @returns the new Vector3
  80332. */
  80333. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80334. /**
  80335. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80336. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80337. * to something in order to rotate it from its local system to the given target system
  80338. * Note: axis1, axis2 and axis3 are normalized during this operation
  80339. * @param axis1 defines the first axis
  80340. * @param axis2 defines the second axis
  80341. * @param axis3 defines the third axis
  80342. * @returns a new Vector3
  80343. */
  80344. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80345. /**
  80346. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80347. * @param axis1 defines the first axis
  80348. * @param axis2 defines the second axis
  80349. * @param axis3 defines the third axis
  80350. * @param ref defines the Vector3 where to store the result
  80351. */
  80352. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80353. }
  80354. /**
  80355. * Vector4 class created for EulerAngle class conversion to Quaternion
  80356. */
  80357. export class Vector4 {
  80358. /** x value of the vector */
  80359. x: number;
  80360. /** y value of the vector */
  80361. y: number;
  80362. /** z value of the vector */
  80363. z: number;
  80364. /** w value of the vector */
  80365. w: number;
  80366. /**
  80367. * Creates a Vector4 object from the given floats.
  80368. * @param x x value of the vector
  80369. * @param y y value of the vector
  80370. * @param z z value of the vector
  80371. * @param w w value of the vector
  80372. */
  80373. constructor(
  80374. /** x value of the vector */
  80375. x: number,
  80376. /** y value of the vector */
  80377. y: number,
  80378. /** z value of the vector */
  80379. z: number,
  80380. /** w value of the vector */
  80381. w: number);
  80382. /**
  80383. * Returns the string with the Vector4 coordinates.
  80384. * @returns a string containing all the vector values
  80385. */
  80386. toString(): string;
  80387. /**
  80388. * Returns the string "Vector4".
  80389. * @returns "Vector4"
  80390. */
  80391. getClassName(): string;
  80392. /**
  80393. * Returns the Vector4 hash code.
  80394. * @returns a unique hash code
  80395. */
  80396. getHashCode(): number;
  80397. /**
  80398. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80399. * @returns the resulting array
  80400. */
  80401. asArray(): number[];
  80402. /**
  80403. * Populates the given array from the given index with the Vector4 coordinates.
  80404. * @param array array to populate
  80405. * @param index index of the array to start at (default: 0)
  80406. * @returns the Vector4.
  80407. */
  80408. toArray(array: FloatArray, index?: number): Vector4;
  80409. /**
  80410. * Adds the given vector to the current Vector4.
  80411. * @param otherVector the vector to add
  80412. * @returns the updated Vector4.
  80413. */
  80414. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80415. /**
  80416. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80417. * @param otherVector the vector to add
  80418. * @returns the resulting vector
  80419. */
  80420. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80421. /**
  80422. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80423. * @param otherVector the vector to add
  80424. * @param result the vector to store the result
  80425. * @returns the current Vector4.
  80426. */
  80427. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80428. /**
  80429. * Subtract in place the given vector from the current Vector4.
  80430. * @param otherVector the vector to subtract
  80431. * @returns the updated Vector4.
  80432. */
  80433. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80434. /**
  80435. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80436. * @param otherVector the vector to add
  80437. * @returns the new vector with the result
  80438. */
  80439. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80440. /**
  80441. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80442. * @param otherVector the vector to subtract
  80443. * @param result the vector to store the result
  80444. * @returns the current Vector4.
  80445. */
  80446. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80447. /**
  80448. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80449. */
  80450. /**
  80451. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80452. * @param x value to subtract
  80453. * @param y value to subtract
  80454. * @param z value to subtract
  80455. * @param w value to subtract
  80456. * @returns new vector containing the result
  80457. */
  80458. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80459. /**
  80460. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80461. * @param x value to subtract
  80462. * @param y value to subtract
  80463. * @param z value to subtract
  80464. * @param w value to subtract
  80465. * @param result the vector to store the result in
  80466. * @returns the current Vector4.
  80467. */
  80468. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80469. /**
  80470. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80471. * @returns a new vector with the negated values
  80472. */
  80473. negate(): Vector4;
  80474. /**
  80475. * Negate this vector in place
  80476. * @returns this
  80477. */
  80478. negateInPlace(): Vector4;
  80479. /**
  80480. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80481. * @param result defines the Vector3 object where to store the result
  80482. * @returns the current Vector4
  80483. */
  80484. negateToRef(result: Vector4): Vector4;
  80485. /**
  80486. * Multiplies the current Vector4 coordinates by scale (float).
  80487. * @param scale the number to scale with
  80488. * @returns the updated Vector4.
  80489. */
  80490. scaleInPlace(scale: number): Vector4;
  80491. /**
  80492. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  80493. * @param scale the number to scale with
  80494. * @returns a new vector with the result
  80495. */
  80496. scale(scale: number): Vector4;
  80497. /**
  80498. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  80499. * @param scale the number to scale with
  80500. * @param result a vector to store the result in
  80501. * @returns the current Vector4.
  80502. */
  80503. scaleToRef(scale: number, result: Vector4): Vector4;
  80504. /**
  80505. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  80506. * @param scale defines the scale factor
  80507. * @param result defines the Vector4 object where to store the result
  80508. * @returns the unmodified current Vector4
  80509. */
  80510. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  80511. /**
  80512. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  80513. * @param otherVector the vector to compare against
  80514. * @returns true if they are equal
  80515. */
  80516. equals(otherVector: DeepImmutable<Vector4>): boolean;
  80517. /**
  80518. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  80519. * @param otherVector vector to compare against
  80520. * @param epsilon (Default: very small number)
  80521. * @returns true if they are equal
  80522. */
  80523. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  80524. /**
  80525. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  80526. * @param x x value to compare against
  80527. * @param y y value to compare against
  80528. * @param z z value to compare against
  80529. * @param w w value to compare against
  80530. * @returns true if equal
  80531. */
  80532. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  80533. /**
  80534. * Multiplies in place the current Vector4 by the given one.
  80535. * @param otherVector vector to multiple with
  80536. * @returns the updated Vector4.
  80537. */
  80538. multiplyInPlace(otherVector: Vector4): Vector4;
  80539. /**
  80540. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  80541. * @param otherVector vector to multiple with
  80542. * @returns resulting new vector
  80543. */
  80544. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  80545. /**
  80546. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  80547. * @param otherVector vector to multiple with
  80548. * @param result vector to store the result
  80549. * @returns the current Vector4.
  80550. */
  80551. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80552. /**
  80553. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  80554. * @param x x value multiply with
  80555. * @param y y value multiply with
  80556. * @param z z value multiply with
  80557. * @param w w value multiply with
  80558. * @returns resulting new vector
  80559. */
  80560. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  80561. /**
  80562. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  80563. * @param otherVector vector to devide with
  80564. * @returns resulting new vector
  80565. */
  80566. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  80567. /**
  80568. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  80569. * @param otherVector vector to devide with
  80570. * @param result vector to store the result
  80571. * @returns the current Vector4.
  80572. */
  80573. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80574. /**
  80575. * Divides the current Vector3 coordinates by the given ones.
  80576. * @param otherVector vector to devide with
  80577. * @returns the updated Vector3.
  80578. */
  80579. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80580. /**
  80581. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  80582. * @param other defines the second operand
  80583. * @returns the current updated Vector4
  80584. */
  80585. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80586. /**
  80587. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  80588. * @param other defines the second operand
  80589. * @returns the current updated Vector4
  80590. */
  80591. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80592. /**
  80593. * Gets a new Vector4 from current Vector4 floored values
  80594. * @returns a new Vector4
  80595. */
  80596. floor(): Vector4;
  80597. /**
  80598. * Gets a new Vector4 from current Vector3 floored values
  80599. * @returns a new Vector4
  80600. */
  80601. fract(): Vector4;
  80602. /**
  80603. * Returns the Vector4 length (float).
  80604. * @returns the length
  80605. */
  80606. length(): number;
  80607. /**
  80608. * Returns the Vector4 squared length (float).
  80609. * @returns the length squared
  80610. */
  80611. lengthSquared(): number;
  80612. /**
  80613. * Normalizes in place the Vector4.
  80614. * @returns the updated Vector4.
  80615. */
  80616. normalize(): Vector4;
  80617. /**
  80618. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  80619. * @returns this converted to a new vector3
  80620. */
  80621. toVector3(): Vector3;
  80622. /**
  80623. * Returns a new Vector4 copied from the current one.
  80624. * @returns the new cloned vector
  80625. */
  80626. clone(): Vector4;
  80627. /**
  80628. * Updates the current Vector4 with the given one coordinates.
  80629. * @param source the source vector to copy from
  80630. * @returns the updated Vector4.
  80631. */
  80632. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  80633. /**
  80634. * Updates the current Vector4 coordinates with the given floats.
  80635. * @param x float to copy from
  80636. * @param y float to copy from
  80637. * @param z float to copy from
  80638. * @param w float to copy from
  80639. * @returns the updated Vector4.
  80640. */
  80641. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80642. /**
  80643. * Updates the current Vector4 coordinates with the given floats.
  80644. * @param x float to set from
  80645. * @param y float to set from
  80646. * @param z float to set from
  80647. * @param w float to set from
  80648. * @returns the updated Vector4.
  80649. */
  80650. set(x: number, y: number, z: number, w: number): Vector4;
  80651. /**
  80652. * Copies the given float to the current Vector3 coordinates
  80653. * @param v defines the x, y, z and w coordinates of the operand
  80654. * @returns the current updated Vector3
  80655. */
  80656. setAll(v: number): Vector4;
  80657. /**
  80658. * Returns a new Vector4 set from the starting index of the given array.
  80659. * @param array the array to pull values from
  80660. * @param offset the offset into the array to start at
  80661. * @returns the new vector
  80662. */
  80663. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  80664. /**
  80665. * Updates the given vector "result" from the starting index of the given array.
  80666. * @param array the array to pull values from
  80667. * @param offset the offset into the array to start at
  80668. * @param result the vector to store the result in
  80669. */
  80670. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  80671. /**
  80672. * Updates the given vector "result" from the starting index of the given Float32Array.
  80673. * @param array the array to pull values from
  80674. * @param offset the offset into the array to start at
  80675. * @param result the vector to store the result in
  80676. */
  80677. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  80678. /**
  80679. * Updates the given vector "result" coordinates from the given floats.
  80680. * @param x float to set from
  80681. * @param y float to set from
  80682. * @param z float to set from
  80683. * @param w float to set from
  80684. * @param result the vector to the floats in
  80685. */
  80686. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  80687. /**
  80688. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  80689. * @returns the new vector
  80690. */
  80691. static Zero(): Vector4;
  80692. /**
  80693. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  80694. * @returns the new vector
  80695. */
  80696. static One(): Vector4;
  80697. /**
  80698. * Returns a new normalized Vector4 from the given one.
  80699. * @param vector the vector to normalize
  80700. * @returns the vector
  80701. */
  80702. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  80703. /**
  80704. * Updates the given vector "result" from the normalization of the given one.
  80705. * @param vector the vector to normalize
  80706. * @param result the vector to store the result in
  80707. */
  80708. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  80709. /**
  80710. * Returns a vector with the minimum values from the left and right vectors
  80711. * @param left left vector to minimize
  80712. * @param right right vector to minimize
  80713. * @returns a new vector with the minimum of the left and right vector values
  80714. */
  80715. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80716. /**
  80717. * Returns a vector with the maximum values from the left and right vectors
  80718. * @param left left vector to maximize
  80719. * @param right right vector to maximize
  80720. * @returns a new vector with the maximum of the left and right vector values
  80721. */
  80722. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80723. /**
  80724. * Returns the distance (float) between the vectors "value1" and "value2".
  80725. * @param value1 value to calulate the distance between
  80726. * @param value2 value to calulate the distance between
  80727. * @return the distance between the two vectors
  80728. */
  80729. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80730. /**
  80731. * Returns the squared distance (float) between the vectors "value1" and "value2".
  80732. * @param value1 value to calulate the distance between
  80733. * @param value2 value to calulate the distance between
  80734. * @return the distance between the two vectors squared
  80735. */
  80736. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80737. /**
  80738. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  80739. * @param value1 value to calulate the center between
  80740. * @param value2 value to calulate the center between
  80741. * @return the center between the two vectors
  80742. */
  80743. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  80744. /**
  80745. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  80746. * This methods computes transformed normalized direction vectors only.
  80747. * @param vector the vector to transform
  80748. * @param transformation the transformation matrix to apply
  80749. * @returns the new vector
  80750. */
  80751. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  80752. /**
  80753. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  80754. * This methods computes transformed normalized direction vectors only.
  80755. * @param vector the vector to transform
  80756. * @param transformation the transformation matrix to apply
  80757. * @param result the vector to store the result in
  80758. */
  80759. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80760. /**
  80761. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  80762. * This methods computes transformed normalized direction vectors only.
  80763. * @param x value to transform
  80764. * @param y value to transform
  80765. * @param z value to transform
  80766. * @param w value to transform
  80767. * @param transformation the transformation matrix to apply
  80768. * @param result the vector to store the results in
  80769. */
  80770. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80771. /**
  80772. * Creates a new Vector4 from a Vector3
  80773. * @param source defines the source data
  80774. * @param w defines the 4th component (default is 0)
  80775. * @returns a new Vector4
  80776. */
  80777. static FromVector3(source: Vector3, w?: number): Vector4;
  80778. }
  80779. /**
  80780. * Class used to store quaternion data
  80781. * @see https://en.wikipedia.org/wiki/Quaternion
  80782. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  80783. */
  80784. export class Quaternion {
  80785. /** defines the first component (0 by default) */
  80786. x: number;
  80787. /** defines the second component (0 by default) */
  80788. y: number;
  80789. /** defines the third component (0 by default) */
  80790. z: number;
  80791. /** defines the fourth component (1.0 by default) */
  80792. w: number;
  80793. /**
  80794. * Creates a new Quaternion from the given floats
  80795. * @param x defines the first component (0 by default)
  80796. * @param y defines the second component (0 by default)
  80797. * @param z defines the third component (0 by default)
  80798. * @param w defines the fourth component (1.0 by default)
  80799. */
  80800. constructor(
  80801. /** defines the first component (0 by default) */
  80802. x?: number,
  80803. /** defines the second component (0 by default) */
  80804. y?: number,
  80805. /** defines the third component (0 by default) */
  80806. z?: number,
  80807. /** defines the fourth component (1.0 by default) */
  80808. w?: number);
  80809. /**
  80810. * Gets a string representation for the current quaternion
  80811. * @returns a string with the Quaternion coordinates
  80812. */
  80813. toString(): string;
  80814. /**
  80815. * Gets the class name of the quaternion
  80816. * @returns the string "Quaternion"
  80817. */
  80818. getClassName(): string;
  80819. /**
  80820. * Gets a hash code for this quaternion
  80821. * @returns the quaternion hash code
  80822. */
  80823. getHashCode(): number;
  80824. /**
  80825. * Copy the quaternion to an array
  80826. * @returns a new array populated with 4 elements from the quaternion coordinates
  80827. */
  80828. asArray(): number[];
  80829. /**
  80830. * Check if two quaternions are equals
  80831. * @param otherQuaternion defines the second operand
  80832. * @return true if the current quaternion and the given one coordinates are strictly equals
  80833. */
  80834. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  80835. /**
  80836. * Gets a boolean if two quaternions are equals (using an epsilon value)
  80837. * @param otherQuaternion defines the other quaternion
  80838. * @param epsilon defines the minimal distance to consider equality
  80839. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  80840. */
  80841. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  80842. /**
  80843. * Clone the current quaternion
  80844. * @returns a new quaternion copied from the current one
  80845. */
  80846. clone(): Quaternion;
  80847. /**
  80848. * Copy a quaternion to the current one
  80849. * @param other defines the other quaternion
  80850. * @returns the updated current quaternion
  80851. */
  80852. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  80853. /**
  80854. * Updates the current quaternion with the given float coordinates
  80855. * @param x defines the x coordinate
  80856. * @param y defines the y coordinate
  80857. * @param z defines the z coordinate
  80858. * @param w defines the w coordinate
  80859. * @returns the updated current quaternion
  80860. */
  80861. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  80862. /**
  80863. * Updates the current quaternion from the given float coordinates
  80864. * @param x defines the x coordinate
  80865. * @param y defines the y coordinate
  80866. * @param z defines the z coordinate
  80867. * @param w defines the w coordinate
  80868. * @returns the updated current quaternion
  80869. */
  80870. set(x: number, y: number, z: number, w: number): Quaternion;
  80871. /**
  80872. * Adds two quaternions
  80873. * @param other defines the second operand
  80874. * @returns a new quaternion as the addition result of the given one and the current quaternion
  80875. */
  80876. add(other: DeepImmutable<Quaternion>): Quaternion;
  80877. /**
  80878. * Add a quaternion to the current one
  80879. * @param other defines the quaternion to add
  80880. * @returns the current quaternion
  80881. */
  80882. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  80883. /**
  80884. * Subtract two quaternions
  80885. * @param other defines the second operand
  80886. * @returns a new quaternion as the subtraction result of the given one from the current one
  80887. */
  80888. subtract(other: Quaternion): Quaternion;
  80889. /**
  80890. * Multiplies the current quaternion by a scale factor
  80891. * @param value defines the scale factor
  80892. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  80893. */
  80894. scale(value: number): Quaternion;
  80895. /**
  80896. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  80897. * @param scale defines the scale factor
  80898. * @param result defines the Quaternion object where to store the result
  80899. * @returns the unmodified current quaternion
  80900. */
  80901. scaleToRef(scale: number, result: Quaternion): Quaternion;
  80902. /**
  80903. * Multiplies in place the current quaternion by a scale factor
  80904. * @param value defines the scale factor
  80905. * @returns the current modified quaternion
  80906. */
  80907. scaleInPlace(value: number): Quaternion;
  80908. /**
  80909. * Scale the current quaternion values by a factor and add the result to a given quaternion
  80910. * @param scale defines the scale factor
  80911. * @param result defines the Quaternion object where to store the result
  80912. * @returns the unmodified current quaternion
  80913. */
  80914. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  80915. /**
  80916. * Multiplies two quaternions
  80917. * @param q1 defines the second operand
  80918. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  80919. */
  80920. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  80921. /**
  80922. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  80923. * @param q1 defines the second operand
  80924. * @param result defines the target quaternion
  80925. * @returns the current quaternion
  80926. */
  80927. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  80928. /**
  80929. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  80930. * @param q1 defines the second operand
  80931. * @returns the currentupdated quaternion
  80932. */
  80933. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  80934. /**
  80935. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  80936. * @param ref defines the target quaternion
  80937. * @returns the current quaternion
  80938. */
  80939. conjugateToRef(ref: Quaternion): Quaternion;
  80940. /**
  80941. * Conjugates in place (1-q) the current quaternion
  80942. * @returns the current updated quaternion
  80943. */
  80944. conjugateInPlace(): Quaternion;
  80945. /**
  80946. * Conjugates in place (1-q) the current quaternion
  80947. * @returns a new quaternion
  80948. */
  80949. conjugate(): Quaternion;
  80950. /**
  80951. * Gets length of current quaternion
  80952. * @returns the quaternion length (float)
  80953. */
  80954. length(): number;
  80955. /**
  80956. * Normalize in place the current quaternion
  80957. * @returns the current updated quaternion
  80958. */
  80959. normalize(): Quaternion;
  80960. /**
  80961. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  80962. * @param order is a reserved parameter and is ignore for now
  80963. * @returns a new Vector3 containing the Euler angles
  80964. */
  80965. toEulerAngles(order?: string): Vector3;
  80966. /**
  80967. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  80968. * @param result defines the vector which will be filled with the Euler angles
  80969. * @param order is a reserved parameter and is ignore for now
  80970. * @returns the current unchanged quaternion
  80971. */
  80972. toEulerAnglesToRef(result: Vector3): Quaternion;
  80973. /**
  80974. * Updates the given rotation matrix with the current quaternion values
  80975. * @param result defines the target matrix
  80976. * @returns the current unchanged quaternion
  80977. */
  80978. toRotationMatrix(result: Matrix): Quaternion;
  80979. /**
  80980. * Updates the current quaternion from the given rotation matrix values
  80981. * @param matrix defines the source matrix
  80982. * @returns the current updated quaternion
  80983. */
  80984. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80985. /**
  80986. * Creates a new quaternion from a rotation matrix
  80987. * @param matrix defines the source matrix
  80988. * @returns a new quaternion created from the given rotation matrix values
  80989. */
  80990. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80991. /**
  80992. * Updates the given quaternion with the given rotation matrix values
  80993. * @param matrix defines the source matrix
  80994. * @param result defines the target quaternion
  80995. */
  80996. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  80997. /**
  80998. * Returns the dot product (float) between the quaternions "left" and "right"
  80999. * @param left defines the left operand
  81000. * @param right defines the right operand
  81001. * @returns the dot product
  81002. */
  81003. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81004. /**
  81005. * Checks if the two quaternions are close to each other
  81006. * @param quat0 defines the first quaternion to check
  81007. * @param quat1 defines the second quaternion to check
  81008. * @returns true if the two quaternions are close to each other
  81009. */
  81010. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81011. /**
  81012. * Creates an empty quaternion
  81013. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81014. */
  81015. static Zero(): Quaternion;
  81016. /**
  81017. * Inverse a given quaternion
  81018. * @param q defines the source quaternion
  81019. * @returns a new quaternion as the inverted current quaternion
  81020. */
  81021. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81022. /**
  81023. * Inverse a given quaternion
  81024. * @param q defines the source quaternion
  81025. * @param result the quaternion the result will be stored in
  81026. * @returns the result quaternion
  81027. */
  81028. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81029. /**
  81030. * Creates an identity quaternion
  81031. * @returns the identity quaternion
  81032. */
  81033. static Identity(): Quaternion;
  81034. /**
  81035. * Gets a boolean indicating if the given quaternion is identity
  81036. * @param quaternion defines the quaternion to check
  81037. * @returns true if the quaternion is identity
  81038. */
  81039. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81040. /**
  81041. * Creates a quaternion from a rotation around an axis
  81042. * @param axis defines the axis to use
  81043. * @param angle defines the angle to use
  81044. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81045. */
  81046. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81047. /**
  81048. * Creates a rotation around an axis and stores it into the given quaternion
  81049. * @param axis defines the axis to use
  81050. * @param angle defines the angle to use
  81051. * @param result defines the target quaternion
  81052. * @returns the target quaternion
  81053. */
  81054. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81055. /**
  81056. * Creates a new quaternion from data stored into an array
  81057. * @param array defines the data source
  81058. * @param offset defines the offset in the source array where the data starts
  81059. * @returns a new quaternion
  81060. */
  81061. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81062. /**
  81063. * Updates the given quaternion "result" from the starting index of the given array.
  81064. * @param array the array to pull values from
  81065. * @param offset the offset into the array to start at
  81066. * @param result the quaternion to store the result in
  81067. */
  81068. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81069. /**
  81070. * Create a quaternion from Euler rotation angles
  81071. * @param x Pitch
  81072. * @param y Yaw
  81073. * @param z Roll
  81074. * @returns the new Quaternion
  81075. */
  81076. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81077. /**
  81078. * Updates a quaternion from Euler rotation angles
  81079. * @param x Pitch
  81080. * @param y Yaw
  81081. * @param z Roll
  81082. * @param result the quaternion to store the result
  81083. * @returns the updated quaternion
  81084. */
  81085. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81086. /**
  81087. * Create a quaternion from Euler rotation vector
  81088. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81089. * @returns the new Quaternion
  81090. */
  81091. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81092. /**
  81093. * Updates a quaternion from Euler rotation vector
  81094. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81095. * @param result the quaternion to store the result
  81096. * @returns the updated quaternion
  81097. */
  81098. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81099. /**
  81100. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81101. * @param yaw defines the rotation around Y axis
  81102. * @param pitch defines the rotation around X axis
  81103. * @param roll defines the rotation around Z axis
  81104. * @returns the new quaternion
  81105. */
  81106. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81107. /**
  81108. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81109. * @param yaw defines the rotation around Y axis
  81110. * @param pitch defines the rotation around X axis
  81111. * @param roll defines the rotation around Z axis
  81112. * @param result defines the target quaternion
  81113. */
  81114. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81115. /**
  81116. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81117. * @param alpha defines the rotation around first axis
  81118. * @param beta defines the rotation around second axis
  81119. * @param gamma defines the rotation around third axis
  81120. * @returns the new quaternion
  81121. */
  81122. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81123. /**
  81124. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81125. * @param alpha defines the rotation around first axis
  81126. * @param beta defines the rotation around second axis
  81127. * @param gamma defines the rotation around third axis
  81128. * @param result defines the target quaternion
  81129. */
  81130. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81131. /**
  81132. * 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)
  81133. * @param axis1 defines the first axis
  81134. * @param axis2 defines the second axis
  81135. * @param axis3 defines the third axis
  81136. * @returns the new quaternion
  81137. */
  81138. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81139. /**
  81140. * 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
  81141. * @param axis1 defines the first axis
  81142. * @param axis2 defines the second axis
  81143. * @param axis3 defines the third axis
  81144. * @param ref defines the target quaternion
  81145. */
  81146. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81147. /**
  81148. * Interpolates between two quaternions
  81149. * @param left defines first quaternion
  81150. * @param right defines second quaternion
  81151. * @param amount defines the gradient to use
  81152. * @returns the new interpolated quaternion
  81153. */
  81154. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81155. /**
  81156. * Interpolates between two quaternions and stores it into a target quaternion
  81157. * @param left defines first quaternion
  81158. * @param right defines second quaternion
  81159. * @param amount defines the gradient to use
  81160. * @param result defines the target quaternion
  81161. */
  81162. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81163. /**
  81164. * Interpolate between two quaternions using Hermite interpolation
  81165. * @param value1 defines first quaternion
  81166. * @param tangent1 defines the incoming tangent
  81167. * @param value2 defines second quaternion
  81168. * @param tangent2 defines the outgoing tangent
  81169. * @param amount defines the target quaternion
  81170. * @returns the new interpolated quaternion
  81171. */
  81172. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81173. }
  81174. /**
  81175. * Class used to store matrix data (4x4)
  81176. */
  81177. export class Matrix {
  81178. private static _updateFlagSeed;
  81179. private static _identityReadOnly;
  81180. private _isIdentity;
  81181. private _isIdentityDirty;
  81182. private _isIdentity3x2;
  81183. private _isIdentity3x2Dirty;
  81184. /**
  81185. * Gets the update flag of the matrix which is an unique number for the matrix.
  81186. * It will be incremented every time the matrix data change.
  81187. * You can use it to speed the comparison between two versions of the same matrix.
  81188. */
  81189. updateFlag: number;
  81190. private readonly _m;
  81191. /**
  81192. * Gets the internal data of the matrix
  81193. */
  81194. get m(): DeepImmutable<Float32Array>;
  81195. /** @hidden */
  81196. _markAsUpdated(): void;
  81197. /** @hidden */
  81198. private _updateIdentityStatus;
  81199. /**
  81200. * Creates an empty matrix (filled with zeros)
  81201. */
  81202. constructor();
  81203. /**
  81204. * Check if the current matrix is identity
  81205. * @returns true is the matrix is the identity matrix
  81206. */
  81207. isIdentity(): boolean;
  81208. /**
  81209. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81210. * @returns true is the matrix is the identity matrix
  81211. */
  81212. isIdentityAs3x2(): boolean;
  81213. /**
  81214. * Gets the determinant of the matrix
  81215. * @returns the matrix determinant
  81216. */
  81217. determinant(): number;
  81218. /**
  81219. * Returns the matrix as a Float32Array
  81220. * @returns the matrix underlying array
  81221. */
  81222. toArray(): DeepImmutable<Float32Array>;
  81223. /**
  81224. * Returns the matrix as a Float32Array
  81225. * @returns the matrix underlying array.
  81226. */
  81227. asArray(): DeepImmutable<Float32Array>;
  81228. /**
  81229. * Inverts the current matrix in place
  81230. * @returns the current inverted matrix
  81231. */
  81232. invert(): Matrix;
  81233. /**
  81234. * Sets all the matrix elements to zero
  81235. * @returns the current matrix
  81236. */
  81237. reset(): Matrix;
  81238. /**
  81239. * Adds the current matrix with a second one
  81240. * @param other defines the matrix to add
  81241. * @returns a new matrix as the addition of the current matrix and the given one
  81242. */
  81243. add(other: DeepImmutable<Matrix>): Matrix;
  81244. /**
  81245. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81246. * @param other defines the matrix to add
  81247. * @param result defines the target matrix
  81248. * @returns the current matrix
  81249. */
  81250. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81251. /**
  81252. * Adds in place the given matrix to the current matrix
  81253. * @param other defines the second operand
  81254. * @returns the current updated matrix
  81255. */
  81256. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81257. /**
  81258. * Sets the given matrix to the current inverted Matrix
  81259. * @param other defines the target matrix
  81260. * @returns the unmodified current matrix
  81261. */
  81262. invertToRef(other: Matrix): Matrix;
  81263. /**
  81264. * add a value at the specified position in the current Matrix
  81265. * @param index the index of the value within the matrix. between 0 and 15.
  81266. * @param value the value to be added
  81267. * @returns the current updated matrix
  81268. */
  81269. addAtIndex(index: number, value: number): Matrix;
  81270. /**
  81271. * mutiply the specified position in the current Matrix by a value
  81272. * @param index the index of the value within the matrix. between 0 and 15.
  81273. * @param value the value to be added
  81274. * @returns the current updated matrix
  81275. */
  81276. multiplyAtIndex(index: number, value: number): Matrix;
  81277. /**
  81278. * Inserts the translation vector (using 3 floats) in the current matrix
  81279. * @param x defines the 1st component of the translation
  81280. * @param y defines the 2nd component of the translation
  81281. * @param z defines the 3rd component of the translation
  81282. * @returns the current updated matrix
  81283. */
  81284. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81285. /**
  81286. * Adds the translation vector (using 3 floats) in the current matrix
  81287. * @param x defines the 1st component of the translation
  81288. * @param y defines the 2nd component of the translation
  81289. * @param z defines the 3rd component of the translation
  81290. * @returns the current updated matrix
  81291. */
  81292. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81293. /**
  81294. * Inserts the translation vector in the current matrix
  81295. * @param vector3 defines the translation to insert
  81296. * @returns the current updated matrix
  81297. */
  81298. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81299. /**
  81300. * Gets the translation value of the current matrix
  81301. * @returns a new Vector3 as the extracted translation from the matrix
  81302. */
  81303. getTranslation(): Vector3;
  81304. /**
  81305. * Fill a Vector3 with the extracted translation from the matrix
  81306. * @param result defines the Vector3 where to store the translation
  81307. * @returns the current matrix
  81308. */
  81309. getTranslationToRef(result: Vector3): Matrix;
  81310. /**
  81311. * Remove rotation and scaling part from the matrix
  81312. * @returns the updated matrix
  81313. */
  81314. removeRotationAndScaling(): Matrix;
  81315. /**
  81316. * Multiply two matrices
  81317. * @param other defines the second operand
  81318. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81319. */
  81320. multiply(other: DeepImmutable<Matrix>): Matrix;
  81321. /**
  81322. * Copy the current matrix from the given one
  81323. * @param other defines the source matrix
  81324. * @returns the current updated matrix
  81325. */
  81326. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81327. /**
  81328. * Populates the given array from the starting index with the current matrix values
  81329. * @param array defines the target array
  81330. * @param offset defines the offset in the target array where to start storing values
  81331. * @returns the current matrix
  81332. */
  81333. copyToArray(array: Float32Array, offset?: number): Matrix;
  81334. /**
  81335. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81336. * @param other defines the second operand
  81337. * @param result defines the matrix where to store the multiplication
  81338. * @returns the current matrix
  81339. */
  81340. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81341. /**
  81342. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81343. * @param other defines the second operand
  81344. * @param result defines the array where to store the multiplication
  81345. * @param offset defines the offset in the target array where to start storing values
  81346. * @returns the current matrix
  81347. */
  81348. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81349. /**
  81350. * Check equality between this matrix and a second one
  81351. * @param value defines the second matrix to compare
  81352. * @returns true is the current matrix and the given one values are strictly equal
  81353. */
  81354. equals(value: DeepImmutable<Matrix>): boolean;
  81355. /**
  81356. * Clone the current matrix
  81357. * @returns a new matrix from the current matrix
  81358. */
  81359. clone(): Matrix;
  81360. /**
  81361. * Returns the name of the current matrix class
  81362. * @returns the string "Matrix"
  81363. */
  81364. getClassName(): string;
  81365. /**
  81366. * Gets the hash code of the current matrix
  81367. * @returns the hash code
  81368. */
  81369. getHashCode(): number;
  81370. /**
  81371. * Decomposes the current Matrix into a translation, rotation and scaling components
  81372. * @param scale defines the scale vector3 given as a reference to update
  81373. * @param rotation defines the rotation quaternion given as a reference to update
  81374. * @param translation defines the translation vector3 given as a reference to update
  81375. * @returns true if operation was successful
  81376. */
  81377. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81378. /**
  81379. * Gets specific row of the matrix
  81380. * @param index defines the number of the row to get
  81381. * @returns the index-th row of the current matrix as a new Vector4
  81382. */
  81383. getRow(index: number): Nullable<Vector4>;
  81384. /**
  81385. * Sets the index-th row of the current matrix to the vector4 values
  81386. * @param index defines the number of the row to set
  81387. * @param row defines the target vector4
  81388. * @returns the updated current matrix
  81389. */
  81390. setRow(index: number, row: Vector4): Matrix;
  81391. /**
  81392. * Compute the transpose of the matrix
  81393. * @returns the new transposed matrix
  81394. */
  81395. transpose(): Matrix;
  81396. /**
  81397. * Compute the transpose of the matrix and store it in a given matrix
  81398. * @param result defines the target matrix
  81399. * @returns the current matrix
  81400. */
  81401. transposeToRef(result: Matrix): Matrix;
  81402. /**
  81403. * Sets the index-th row of the current matrix with the given 4 x float values
  81404. * @param index defines the row index
  81405. * @param x defines the x component to set
  81406. * @param y defines the y component to set
  81407. * @param z defines the z component to set
  81408. * @param w defines the w component to set
  81409. * @returns the updated current matrix
  81410. */
  81411. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81412. /**
  81413. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81414. * @param scale defines the scale factor
  81415. * @returns a new matrix
  81416. */
  81417. scale(scale: number): Matrix;
  81418. /**
  81419. * Scale the current matrix values by a factor to a given result matrix
  81420. * @param scale defines the scale factor
  81421. * @param result defines the matrix to store the result
  81422. * @returns the current matrix
  81423. */
  81424. scaleToRef(scale: number, result: Matrix): Matrix;
  81425. /**
  81426. * Scale the current matrix values by a factor and add the result to a given matrix
  81427. * @param scale defines the scale factor
  81428. * @param result defines the Matrix to store the result
  81429. * @returns the current matrix
  81430. */
  81431. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81432. /**
  81433. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81434. * @param ref matrix to store the result
  81435. */
  81436. toNormalMatrix(ref: Matrix): void;
  81437. /**
  81438. * Gets only rotation part of the current matrix
  81439. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81440. */
  81441. getRotationMatrix(): Matrix;
  81442. /**
  81443. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81444. * @param result defines the target matrix to store data to
  81445. * @returns the current matrix
  81446. */
  81447. getRotationMatrixToRef(result: Matrix): Matrix;
  81448. /**
  81449. * Toggles model matrix from being right handed to left handed in place and vice versa
  81450. */
  81451. toggleModelMatrixHandInPlace(): void;
  81452. /**
  81453. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81454. */
  81455. toggleProjectionMatrixHandInPlace(): void;
  81456. /**
  81457. * Creates a matrix from an array
  81458. * @param array defines the source array
  81459. * @param offset defines an offset in the source array
  81460. * @returns a new Matrix set from the starting index of the given array
  81461. */
  81462. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81463. /**
  81464. * Copy the content of an array into a given matrix
  81465. * @param array defines the source array
  81466. * @param offset defines an offset in the source array
  81467. * @param result defines the target matrix
  81468. */
  81469. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81470. /**
  81471. * Stores an array into a matrix after having multiplied each component by a given factor
  81472. * @param array defines the source array
  81473. * @param offset defines the offset in the source array
  81474. * @param scale defines the scaling factor
  81475. * @param result defines the target matrix
  81476. */
  81477. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  81478. /**
  81479. * Gets an identity matrix that must not be updated
  81480. */
  81481. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  81482. /**
  81483. * Stores a list of values (16) inside a given matrix
  81484. * @param initialM11 defines 1st value of 1st row
  81485. * @param initialM12 defines 2nd value of 1st row
  81486. * @param initialM13 defines 3rd value of 1st row
  81487. * @param initialM14 defines 4th value of 1st row
  81488. * @param initialM21 defines 1st value of 2nd row
  81489. * @param initialM22 defines 2nd value of 2nd row
  81490. * @param initialM23 defines 3rd value of 2nd row
  81491. * @param initialM24 defines 4th value of 2nd row
  81492. * @param initialM31 defines 1st value of 3rd row
  81493. * @param initialM32 defines 2nd value of 3rd row
  81494. * @param initialM33 defines 3rd value of 3rd row
  81495. * @param initialM34 defines 4th value of 3rd row
  81496. * @param initialM41 defines 1st value of 4th row
  81497. * @param initialM42 defines 2nd value of 4th row
  81498. * @param initialM43 defines 3rd value of 4th row
  81499. * @param initialM44 defines 4th value of 4th row
  81500. * @param result defines the target matrix
  81501. */
  81502. 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;
  81503. /**
  81504. * Creates new matrix from a list of values (16)
  81505. * @param initialM11 defines 1st value of 1st row
  81506. * @param initialM12 defines 2nd value of 1st row
  81507. * @param initialM13 defines 3rd value of 1st row
  81508. * @param initialM14 defines 4th value of 1st row
  81509. * @param initialM21 defines 1st value of 2nd row
  81510. * @param initialM22 defines 2nd value of 2nd row
  81511. * @param initialM23 defines 3rd value of 2nd row
  81512. * @param initialM24 defines 4th value of 2nd row
  81513. * @param initialM31 defines 1st value of 3rd row
  81514. * @param initialM32 defines 2nd value of 3rd row
  81515. * @param initialM33 defines 3rd value of 3rd row
  81516. * @param initialM34 defines 4th value of 3rd row
  81517. * @param initialM41 defines 1st value of 4th row
  81518. * @param initialM42 defines 2nd value of 4th row
  81519. * @param initialM43 defines 3rd value of 4th row
  81520. * @param initialM44 defines 4th value of 4th row
  81521. * @returns the new matrix
  81522. */
  81523. 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;
  81524. /**
  81525. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81526. * @param scale defines the scale vector3
  81527. * @param rotation defines the rotation quaternion
  81528. * @param translation defines the translation vector3
  81529. * @returns a new matrix
  81530. */
  81531. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  81532. /**
  81533. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81534. * @param scale defines the scale vector3
  81535. * @param rotation defines the rotation quaternion
  81536. * @param translation defines the translation vector3
  81537. * @param result defines the target matrix
  81538. */
  81539. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  81540. /**
  81541. * Creates a new identity matrix
  81542. * @returns a new identity matrix
  81543. */
  81544. static Identity(): Matrix;
  81545. /**
  81546. * Creates a new identity matrix and stores the result in a given matrix
  81547. * @param result defines the target matrix
  81548. */
  81549. static IdentityToRef(result: Matrix): void;
  81550. /**
  81551. * Creates a new zero matrix
  81552. * @returns a new zero matrix
  81553. */
  81554. static Zero(): Matrix;
  81555. /**
  81556. * Creates a new rotation matrix for "angle" radians around the X axis
  81557. * @param angle defines the angle (in radians) to use
  81558. * @return the new matrix
  81559. */
  81560. static RotationX(angle: number): Matrix;
  81561. /**
  81562. * Creates a new matrix as the invert of a given matrix
  81563. * @param source defines the source matrix
  81564. * @returns the new matrix
  81565. */
  81566. static Invert(source: DeepImmutable<Matrix>): Matrix;
  81567. /**
  81568. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  81569. * @param angle defines the angle (in radians) to use
  81570. * @param result defines the target matrix
  81571. */
  81572. static RotationXToRef(angle: number, result: Matrix): void;
  81573. /**
  81574. * Creates a new rotation matrix for "angle" radians around the Y axis
  81575. * @param angle defines the angle (in radians) to use
  81576. * @return the new matrix
  81577. */
  81578. static RotationY(angle: number): Matrix;
  81579. /**
  81580. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  81581. * @param angle defines the angle (in radians) to use
  81582. * @param result defines the target matrix
  81583. */
  81584. static RotationYToRef(angle: number, result: Matrix): void;
  81585. /**
  81586. * Creates a new rotation matrix for "angle" radians around the Z axis
  81587. * @param angle defines the angle (in radians) to use
  81588. * @return the new matrix
  81589. */
  81590. static RotationZ(angle: number): Matrix;
  81591. /**
  81592. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  81593. * @param angle defines the angle (in radians) to use
  81594. * @param result defines the target matrix
  81595. */
  81596. static RotationZToRef(angle: number, result: Matrix): void;
  81597. /**
  81598. * Creates a new rotation matrix for "angle" radians around the given axis
  81599. * @param axis defines the axis to use
  81600. * @param angle defines the angle (in radians) to use
  81601. * @return the new matrix
  81602. */
  81603. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  81604. /**
  81605. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  81606. * @param axis defines the axis to use
  81607. * @param angle defines the angle (in radians) to use
  81608. * @param result defines the target matrix
  81609. */
  81610. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  81611. /**
  81612. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  81613. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  81614. * @param from defines the vector to align
  81615. * @param to defines the vector to align to
  81616. * @param result defines the target matrix
  81617. */
  81618. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  81619. /**
  81620. * Creates a rotation matrix
  81621. * @param yaw defines the yaw angle in radians (Y axis)
  81622. * @param pitch defines the pitch angle in radians (X axis)
  81623. * @param roll defines the roll angle in radians (X axis)
  81624. * @returns the new rotation matrix
  81625. */
  81626. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  81627. /**
  81628. * Creates a rotation matrix and stores it in a given matrix
  81629. * @param yaw defines the yaw angle in radians (Y axis)
  81630. * @param pitch defines the pitch angle in radians (X axis)
  81631. * @param roll defines the roll angle in radians (X axis)
  81632. * @param result defines the target matrix
  81633. */
  81634. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  81635. /**
  81636. * Creates a scaling matrix
  81637. * @param x defines the scale factor on X axis
  81638. * @param y defines the scale factor on Y axis
  81639. * @param z defines the scale factor on Z axis
  81640. * @returns the new matrix
  81641. */
  81642. static Scaling(x: number, y: number, z: number): Matrix;
  81643. /**
  81644. * Creates a scaling matrix and stores it in a given matrix
  81645. * @param x defines the scale factor on X axis
  81646. * @param y defines the scale factor on Y axis
  81647. * @param z defines the scale factor on Z axis
  81648. * @param result defines the target matrix
  81649. */
  81650. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  81651. /**
  81652. * Creates a translation matrix
  81653. * @param x defines the translation on X axis
  81654. * @param y defines the translation on Y axis
  81655. * @param z defines the translationon Z axis
  81656. * @returns the new matrix
  81657. */
  81658. static Translation(x: number, y: number, z: number): Matrix;
  81659. /**
  81660. * Creates a translation matrix and stores it in a given matrix
  81661. * @param x defines the translation on X axis
  81662. * @param y defines the translation on Y axis
  81663. * @param z defines the translationon Z axis
  81664. * @param result defines the target matrix
  81665. */
  81666. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  81667. /**
  81668. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81669. * @param startValue defines the start value
  81670. * @param endValue defines the end value
  81671. * @param gradient defines the gradient factor
  81672. * @returns the new matrix
  81673. */
  81674. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81675. /**
  81676. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81677. * @param startValue defines the start value
  81678. * @param endValue defines the end value
  81679. * @param gradient defines the gradient factor
  81680. * @param result defines the Matrix object where to store data
  81681. */
  81682. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81683. /**
  81684. * Builds a new matrix whose values are computed by:
  81685. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81686. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81687. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81688. * @param startValue defines the first matrix
  81689. * @param endValue defines the second matrix
  81690. * @param gradient defines the gradient between the two matrices
  81691. * @returns the new matrix
  81692. */
  81693. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81694. /**
  81695. * Update a matrix to values which are computed by:
  81696. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81697. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81698. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81699. * @param startValue defines the first matrix
  81700. * @param endValue defines the second matrix
  81701. * @param gradient defines the gradient between the two matrices
  81702. * @param result defines the target matrix
  81703. */
  81704. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81705. /**
  81706. * 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"
  81707. * This function works in left handed mode
  81708. * @param eye defines the final position of the entity
  81709. * @param target defines where the entity should look at
  81710. * @param up defines the up vector for the entity
  81711. * @returns the new matrix
  81712. */
  81713. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81714. /**
  81715. * 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".
  81716. * This function works in left handed mode
  81717. * @param eye defines the final position of the entity
  81718. * @param target defines where the entity should look at
  81719. * @param up defines the up vector for the entity
  81720. * @param result defines the target matrix
  81721. */
  81722. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81723. /**
  81724. * 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"
  81725. * This function works in right handed mode
  81726. * @param eye defines the final position of the entity
  81727. * @param target defines where the entity should look at
  81728. * @param up defines the up vector for the entity
  81729. * @returns the new matrix
  81730. */
  81731. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81732. /**
  81733. * 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".
  81734. * This function works in right handed mode
  81735. * @param eye defines the final position of the entity
  81736. * @param target defines where the entity should look at
  81737. * @param up defines the up vector for the entity
  81738. * @param result defines the target matrix
  81739. */
  81740. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81741. /**
  81742. * Create a left-handed orthographic projection matrix
  81743. * @param width defines the viewport width
  81744. * @param height defines the viewport height
  81745. * @param znear defines the near clip plane
  81746. * @param zfar defines the far clip plane
  81747. * @returns a new matrix as a left-handed orthographic projection matrix
  81748. */
  81749. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81750. /**
  81751. * Store a left-handed orthographic projection to a given matrix
  81752. * @param width defines the viewport width
  81753. * @param height defines the viewport height
  81754. * @param znear defines the near clip plane
  81755. * @param zfar defines the far clip plane
  81756. * @param result defines the target matrix
  81757. */
  81758. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  81759. /**
  81760. * Create a left-handed orthographic projection matrix
  81761. * @param left defines the viewport left coordinate
  81762. * @param right defines the viewport right coordinate
  81763. * @param bottom defines the viewport bottom coordinate
  81764. * @param top defines the viewport top coordinate
  81765. * @param znear defines the near clip plane
  81766. * @param zfar defines the far clip plane
  81767. * @returns a new matrix as a left-handed orthographic projection matrix
  81768. */
  81769. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81770. /**
  81771. * Stores a left-handed orthographic projection into a given matrix
  81772. * @param left defines the viewport left coordinate
  81773. * @param right defines the viewport right coordinate
  81774. * @param bottom defines the viewport bottom coordinate
  81775. * @param top defines the viewport top coordinate
  81776. * @param znear defines the near clip plane
  81777. * @param zfar defines the far clip plane
  81778. * @param result defines the target matrix
  81779. */
  81780. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81781. /**
  81782. * Creates a right-handed orthographic projection matrix
  81783. * @param left defines the viewport left coordinate
  81784. * @param right defines the viewport right coordinate
  81785. * @param bottom defines the viewport bottom coordinate
  81786. * @param top defines the viewport top coordinate
  81787. * @param znear defines the near clip plane
  81788. * @param zfar defines the far clip plane
  81789. * @returns a new matrix as a right-handed orthographic projection matrix
  81790. */
  81791. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81792. /**
  81793. * Stores a right-handed orthographic projection into a given matrix
  81794. * @param left defines the viewport left coordinate
  81795. * @param right defines the viewport right coordinate
  81796. * @param bottom defines the viewport bottom coordinate
  81797. * @param top defines the viewport top coordinate
  81798. * @param znear defines the near clip plane
  81799. * @param zfar defines the far clip plane
  81800. * @param result defines the target matrix
  81801. */
  81802. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81803. /**
  81804. * Creates a left-handed perspective projection matrix
  81805. * @param width defines the viewport width
  81806. * @param height defines the viewport height
  81807. * @param znear defines the near clip plane
  81808. * @param zfar defines the far clip plane
  81809. * @returns a new matrix as a left-handed perspective projection matrix
  81810. */
  81811. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81812. /**
  81813. * Creates a left-handed perspective projection matrix
  81814. * @param fov defines the horizontal field of view
  81815. * @param aspect defines the aspect ratio
  81816. * @param znear defines the near clip plane
  81817. * @param zfar defines the far clip plane
  81818. * @returns a new matrix as a left-handed perspective projection matrix
  81819. */
  81820. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81821. /**
  81822. * Stores a left-handed perspective projection into a given matrix
  81823. * @param fov defines the horizontal field of view
  81824. * @param aspect defines the aspect ratio
  81825. * @param znear defines the near clip plane
  81826. * @param zfar defines the far clip plane
  81827. * @param result defines the target matrix
  81828. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81829. */
  81830. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81831. /**
  81832. * Stores a left-handed perspective projection into a given matrix with depth reversed
  81833. * @param fov defines the horizontal field of view
  81834. * @param aspect defines the aspect ratio
  81835. * @param znear defines the near clip plane
  81836. * @param zfar not used as infinity is used as far clip
  81837. * @param result defines the target matrix
  81838. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81839. */
  81840. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81841. /**
  81842. * Creates a right-handed perspective projection matrix
  81843. * @param fov defines the horizontal field of view
  81844. * @param aspect defines the aspect ratio
  81845. * @param znear defines the near clip plane
  81846. * @param zfar defines the far clip plane
  81847. * @returns a new matrix as a right-handed perspective projection matrix
  81848. */
  81849. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81850. /**
  81851. * Stores a right-handed perspective projection into a given matrix
  81852. * @param fov defines the horizontal field of view
  81853. * @param aspect defines the aspect ratio
  81854. * @param znear defines the near clip plane
  81855. * @param zfar defines the far clip plane
  81856. * @param result defines the target matrix
  81857. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81858. */
  81859. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81860. /**
  81861. * Stores a right-handed perspective projection into a given matrix
  81862. * @param fov defines the horizontal field of view
  81863. * @param aspect defines the aspect ratio
  81864. * @param znear defines the near clip plane
  81865. * @param zfar not used as infinity is used as far clip
  81866. * @param result defines the target matrix
  81867. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81868. */
  81869. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81870. /**
  81871. * Stores a perspective projection for WebVR info a given matrix
  81872. * @param fov defines the field of view
  81873. * @param znear defines the near clip plane
  81874. * @param zfar defines the far clip plane
  81875. * @param result defines the target matrix
  81876. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  81877. */
  81878. static PerspectiveFovWebVRToRef(fov: {
  81879. upDegrees: number;
  81880. downDegrees: number;
  81881. leftDegrees: number;
  81882. rightDegrees: number;
  81883. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  81884. /**
  81885. * Computes a complete transformation matrix
  81886. * @param viewport defines the viewport to use
  81887. * @param world defines the world matrix
  81888. * @param view defines the view matrix
  81889. * @param projection defines the projection matrix
  81890. * @param zmin defines the near clip plane
  81891. * @param zmax defines the far clip plane
  81892. * @returns the transformation matrix
  81893. */
  81894. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  81895. /**
  81896. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  81897. * @param matrix defines the matrix to use
  81898. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  81899. */
  81900. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  81901. /**
  81902. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  81903. * @param matrix defines the matrix to use
  81904. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  81905. */
  81906. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  81907. /**
  81908. * Compute the transpose of a given matrix
  81909. * @param matrix defines the matrix to transpose
  81910. * @returns the new matrix
  81911. */
  81912. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  81913. /**
  81914. * Compute the transpose of a matrix and store it in a target matrix
  81915. * @param matrix defines the matrix to transpose
  81916. * @param result defines the target matrix
  81917. */
  81918. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  81919. /**
  81920. * Computes a reflection matrix from a plane
  81921. * @param plane defines the reflection plane
  81922. * @returns a new matrix
  81923. */
  81924. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  81925. /**
  81926. * Computes a reflection matrix from a plane
  81927. * @param plane defines the reflection plane
  81928. * @param result defines the target matrix
  81929. */
  81930. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  81931. /**
  81932. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  81933. * @param xaxis defines the value of the 1st axis
  81934. * @param yaxis defines the value of the 2nd axis
  81935. * @param zaxis defines the value of the 3rd axis
  81936. * @param result defines the target matrix
  81937. */
  81938. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  81939. /**
  81940. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  81941. * @param quat defines the quaternion to use
  81942. * @param result defines the target matrix
  81943. */
  81944. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  81945. }
  81946. /**
  81947. * @hidden
  81948. */
  81949. export class TmpVectors {
  81950. static Vector2: Vector2[];
  81951. static Vector3: Vector3[];
  81952. static Vector4: Vector4[];
  81953. static Quaternion: Quaternion[];
  81954. static Matrix: Matrix[];
  81955. }
  81956. }
  81957. declare module BABYLON {
  81958. /**
  81959. * Defines potential orientation for back face culling
  81960. */
  81961. export enum Orientation {
  81962. /**
  81963. * Clockwise
  81964. */
  81965. CW = 0,
  81966. /** Counter clockwise */
  81967. CCW = 1
  81968. }
  81969. /** Class used to represent a Bezier curve */
  81970. export class BezierCurve {
  81971. /**
  81972. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  81973. * @param t defines the time
  81974. * @param x1 defines the left coordinate on X axis
  81975. * @param y1 defines the left coordinate on Y axis
  81976. * @param x2 defines the right coordinate on X axis
  81977. * @param y2 defines the right coordinate on Y axis
  81978. * @returns the interpolated value
  81979. */
  81980. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  81981. }
  81982. /**
  81983. * Defines angle representation
  81984. */
  81985. export class Angle {
  81986. private _radians;
  81987. /**
  81988. * Creates an Angle object of "radians" radians (float).
  81989. * @param radians the angle in radians
  81990. */
  81991. constructor(radians: number);
  81992. /**
  81993. * Get value in degrees
  81994. * @returns the Angle value in degrees (float)
  81995. */
  81996. degrees(): number;
  81997. /**
  81998. * Get value in radians
  81999. * @returns the Angle value in radians (float)
  82000. */
  82001. radians(): number;
  82002. /**
  82003. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82004. * @param a defines first vector
  82005. * @param b defines second vector
  82006. * @returns a new Angle
  82007. */
  82008. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82009. /**
  82010. * Gets a new Angle object from the given float in radians
  82011. * @param radians defines the angle value in radians
  82012. * @returns a new Angle
  82013. */
  82014. static FromRadians(radians: number): Angle;
  82015. /**
  82016. * Gets a new Angle object from the given float in degrees
  82017. * @param degrees defines the angle value in degrees
  82018. * @returns a new Angle
  82019. */
  82020. static FromDegrees(degrees: number): Angle;
  82021. }
  82022. /**
  82023. * This represents an arc in a 2d space.
  82024. */
  82025. export class Arc2 {
  82026. /** Defines the start point of the arc */
  82027. startPoint: Vector2;
  82028. /** Defines the mid point of the arc */
  82029. midPoint: Vector2;
  82030. /** Defines the end point of the arc */
  82031. endPoint: Vector2;
  82032. /**
  82033. * Defines the center point of the arc.
  82034. */
  82035. centerPoint: Vector2;
  82036. /**
  82037. * Defines the radius of the arc.
  82038. */
  82039. radius: number;
  82040. /**
  82041. * Defines the angle of the arc (from mid point to end point).
  82042. */
  82043. angle: Angle;
  82044. /**
  82045. * Defines the start angle of the arc (from start point to middle point).
  82046. */
  82047. startAngle: Angle;
  82048. /**
  82049. * Defines the orientation of the arc (clock wise/counter clock wise).
  82050. */
  82051. orientation: Orientation;
  82052. /**
  82053. * Creates an Arc object from the three given points : start, middle and end.
  82054. * @param startPoint Defines the start point of the arc
  82055. * @param midPoint Defines the midlle point of the arc
  82056. * @param endPoint Defines the end point of the arc
  82057. */
  82058. constructor(
  82059. /** Defines the start point of the arc */
  82060. startPoint: Vector2,
  82061. /** Defines the mid point of the arc */
  82062. midPoint: Vector2,
  82063. /** Defines the end point of the arc */
  82064. endPoint: Vector2);
  82065. }
  82066. /**
  82067. * Represents a 2D path made up of multiple 2D points
  82068. */
  82069. export class Path2 {
  82070. private _points;
  82071. private _length;
  82072. /**
  82073. * If the path start and end point are the same
  82074. */
  82075. closed: boolean;
  82076. /**
  82077. * Creates a Path2 object from the starting 2D coordinates x and y.
  82078. * @param x the starting points x value
  82079. * @param y the starting points y value
  82080. */
  82081. constructor(x: number, y: number);
  82082. /**
  82083. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82084. * @param x the added points x value
  82085. * @param y the added points y value
  82086. * @returns the updated Path2.
  82087. */
  82088. addLineTo(x: number, y: number): Path2;
  82089. /**
  82090. * 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.
  82091. * @param midX middle point x value
  82092. * @param midY middle point y value
  82093. * @param endX end point x value
  82094. * @param endY end point y value
  82095. * @param numberOfSegments (default: 36)
  82096. * @returns the updated Path2.
  82097. */
  82098. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82099. /**
  82100. * Closes the Path2.
  82101. * @returns the Path2.
  82102. */
  82103. close(): Path2;
  82104. /**
  82105. * Gets the sum of the distance between each sequential point in the path
  82106. * @returns the Path2 total length (float).
  82107. */
  82108. length(): number;
  82109. /**
  82110. * Gets the points which construct the path
  82111. * @returns the Path2 internal array of points.
  82112. */
  82113. getPoints(): Vector2[];
  82114. /**
  82115. * Retreives the point at the distance aways from the starting point
  82116. * @param normalizedLengthPosition the length along the path to retreive the point from
  82117. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82118. */
  82119. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82120. /**
  82121. * Creates a new path starting from an x and y position
  82122. * @param x starting x value
  82123. * @param y starting y value
  82124. * @returns a new Path2 starting at the coordinates (x, y).
  82125. */
  82126. static StartingAt(x: number, y: number): Path2;
  82127. }
  82128. /**
  82129. * Represents a 3D path made up of multiple 3D points
  82130. */
  82131. export class Path3D {
  82132. /**
  82133. * an array of Vector3, the curve axis of the Path3D
  82134. */
  82135. path: Vector3[];
  82136. private _curve;
  82137. private _distances;
  82138. private _tangents;
  82139. private _normals;
  82140. private _binormals;
  82141. private _raw;
  82142. private _alignTangentsWithPath;
  82143. private readonly _pointAtData;
  82144. /**
  82145. * new Path3D(path, normal, raw)
  82146. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82147. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82148. * @param path an array of Vector3, the curve axis of the Path3D
  82149. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82150. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82151. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82152. */
  82153. constructor(
  82154. /**
  82155. * an array of Vector3, the curve axis of the Path3D
  82156. */
  82157. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82158. /**
  82159. * Returns the Path3D array of successive Vector3 designing its curve.
  82160. * @returns the Path3D array of successive Vector3 designing its curve.
  82161. */
  82162. getCurve(): Vector3[];
  82163. /**
  82164. * Returns the Path3D array of successive Vector3 designing its curve.
  82165. * @returns the Path3D array of successive Vector3 designing its curve.
  82166. */
  82167. getPoints(): Vector3[];
  82168. /**
  82169. * @returns the computed length (float) of the path.
  82170. */
  82171. length(): number;
  82172. /**
  82173. * Returns an array populated with tangent vectors on each Path3D curve point.
  82174. * @returns an array populated with tangent vectors on each Path3D curve point.
  82175. */
  82176. getTangents(): Vector3[];
  82177. /**
  82178. * Returns an array populated with normal vectors on each Path3D curve point.
  82179. * @returns an array populated with normal vectors on each Path3D curve point.
  82180. */
  82181. getNormals(): Vector3[];
  82182. /**
  82183. * Returns an array populated with binormal vectors on each Path3D curve point.
  82184. * @returns an array populated with binormal vectors on each Path3D curve point.
  82185. */
  82186. getBinormals(): Vector3[];
  82187. /**
  82188. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82189. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82190. */
  82191. getDistances(): number[];
  82192. /**
  82193. * Returns an interpolated point along this path
  82194. * @param position the position of the point along this path, from 0.0 to 1.0
  82195. * @returns a new Vector3 as the point
  82196. */
  82197. getPointAt(position: number): Vector3;
  82198. /**
  82199. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82200. * @param position the position of the point along this path, from 0.0 to 1.0
  82201. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82202. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82203. */
  82204. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82205. /**
  82206. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82207. * @param position the position of the point along this path, from 0.0 to 1.0
  82208. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82209. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82210. */
  82211. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82212. /**
  82213. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82214. * @param position the position of the point along this path, from 0.0 to 1.0
  82215. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82216. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82217. */
  82218. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82219. /**
  82220. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82221. * @param position the position of the point along this path, from 0.0 to 1.0
  82222. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82223. */
  82224. getDistanceAt(position: number): number;
  82225. /**
  82226. * Returns the array index of the previous point of an interpolated point along this path
  82227. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82228. * @returns the array index
  82229. */
  82230. getPreviousPointIndexAt(position: number): number;
  82231. /**
  82232. * 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)
  82233. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82234. * @returns the sub position
  82235. */
  82236. getSubPositionAt(position: number): number;
  82237. /**
  82238. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82239. * @param target the vector of which to get the closest position to
  82240. * @returns the position of the closest virtual point on this path to the target vector
  82241. */
  82242. getClosestPositionTo(target: Vector3): number;
  82243. /**
  82244. * Returns a sub path (slice) of this path
  82245. * @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
  82246. * @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
  82247. * @returns a sub path (slice) of this path
  82248. */
  82249. slice(start?: number, end?: number): Path3D;
  82250. /**
  82251. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82252. * @param path path which all values are copied into the curves points
  82253. * @param firstNormal which should be projected onto the curve
  82254. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82255. * @returns the same object updated.
  82256. */
  82257. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82258. private _compute;
  82259. private _getFirstNonNullVector;
  82260. private _getLastNonNullVector;
  82261. private _normalVector;
  82262. /**
  82263. * Updates the point at data for an interpolated point along this curve
  82264. * @param position the position of the point along this curve, from 0.0 to 1.0
  82265. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82266. * @returns the (updated) point at data
  82267. */
  82268. private _updatePointAtData;
  82269. /**
  82270. * Updates the point at data from the specified parameters
  82271. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82272. * @param point the interpolated point
  82273. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82274. */
  82275. private _setPointAtData;
  82276. /**
  82277. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82278. */
  82279. private _updateInterpolationMatrix;
  82280. }
  82281. /**
  82282. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82283. * A Curve3 is designed from a series of successive Vector3.
  82284. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82285. */
  82286. export class Curve3 {
  82287. private _points;
  82288. private _length;
  82289. /**
  82290. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82291. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82292. * @param v1 (Vector3) the control point
  82293. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82294. * @param nbPoints (integer) the wanted number of points in the curve
  82295. * @returns the created Curve3
  82296. */
  82297. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82298. /**
  82299. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82300. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82301. * @param v1 (Vector3) the first control point
  82302. * @param v2 (Vector3) the second control point
  82303. * @param v3 (Vector3) the end point of the Cubic Bezier
  82304. * @param nbPoints (integer) the wanted number of points in the curve
  82305. * @returns the created Curve3
  82306. */
  82307. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82308. /**
  82309. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82310. * @param p1 (Vector3) the origin point of the Hermite Spline
  82311. * @param t1 (Vector3) the tangent vector at the origin point
  82312. * @param p2 (Vector3) the end point of the Hermite Spline
  82313. * @param t2 (Vector3) the tangent vector at the end point
  82314. * @param nbPoints (integer) the wanted number of points in the curve
  82315. * @returns the created Curve3
  82316. */
  82317. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82318. /**
  82319. * Returns a Curve3 object along a CatmullRom Spline curve :
  82320. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82321. * @param nbPoints (integer) the wanted number of points between each curve control points
  82322. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82323. * @returns the created Curve3
  82324. */
  82325. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82326. /**
  82327. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82328. * A Curve3 is designed from a series of successive Vector3.
  82329. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82330. * @param points points which make up the curve
  82331. */
  82332. constructor(points: Vector3[]);
  82333. /**
  82334. * @returns the Curve3 stored array of successive Vector3
  82335. */
  82336. getPoints(): Vector3[];
  82337. /**
  82338. * @returns the computed length (float) of the curve.
  82339. */
  82340. length(): number;
  82341. /**
  82342. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82343. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82344. * curveA and curveB keep unchanged.
  82345. * @param curve the curve to continue from this curve
  82346. * @returns the newly constructed curve
  82347. */
  82348. continue(curve: DeepImmutable<Curve3>): Curve3;
  82349. private _computeLength;
  82350. }
  82351. }
  82352. declare module BABYLON {
  82353. /**
  82354. * This represents the main contract an easing function should follow.
  82355. * Easing functions are used throughout the animation system.
  82356. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82357. */
  82358. export interface IEasingFunction {
  82359. /**
  82360. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82361. * of the easing function.
  82362. * The link below provides some of the most common examples of easing functions.
  82363. * @see https://easings.net/
  82364. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82365. * @returns the corresponding value on the curve defined by the easing function
  82366. */
  82367. ease(gradient: number): number;
  82368. }
  82369. /**
  82370. * Base class used for every default easing function.
  82371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82372. */
  82373. export class EasingFunction implements IEasingFunction {
  82374. /**
  82375. * Interpolation follows the mathematical formula associated with the easing function.
  82376. */
  82377. static readonly EASINGMODE_EASEIN: number;
  82378. /**
  82379. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82380. */
  82381. static readonly EASINGMODE_EASEOUT: number;
  82382. /**
  82383. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82384. */
  82385. static readonly EASINGMODE_EASEINOUT: number;
  82386. private _easingMode;
  82387. /**
  82388. * Sets the easing mode of the current function.
  82389. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82390. */
  82391. setEasingMode(easingMode: number): void;
  82392. /**
  82393. * Gets the current easing mode.
  82394. * @returns the easing mode
  82395. */
  82396. getEasingMode(): number;
  82397. /**
  82398. * @hidden
  82399. */
  82400. easeInCore(gradient: number): number;
  82401. /**
  82402. * Given an input gradient between 0 and 1, this returns the corresponding value
  82403. * of the easing function.
  82404. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82405. * @returns the corresponding value on the curve defined by the easing function
  82406. */
  82407. ease(gradient: number): number;
  82408. }
  82409. /**
  82410. * Easing function with a circle shape (see link below).
  82411. * @see https://easings.net/#easeInCirc
  82412. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82413. */
  82414. export class CircleEase extends EasingFunction implements IEasingFunction {
  82415. /** @hidden */
  82416. easeInCore(gradient: number): number;
  82417. }
  82418. /**
  82419. * Easing function with a ease back shape (see link below).
  82420. * @see https://easings.net/#easeInBack
  82421. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82422. */
  82423. export class BackEase extends EasingFunction implements IEasingFunction {
  82424. /** Defines the amplitude of the function */
  82425. amplitude: number;
  82426. /**
  82427. * Instantiates a back ease easing
  82428. * @see https://easings.net/#easeInBack
  82429. * @param amplitude Defines the amplitude of the function
  82430. */
  82431. constructor(
  82432. /** Defines the amplitude of the function */
  82433. amplitude?: number);
  82434. /** @hidden */
  82435. easeInCore(gradient: number): number;
  82436. }
  82437. /**
  82438. * Easing function with a bouncing shape (see link below).
  82439. * @see https://easings.net/#easeInBounce
  82440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82441. */
  82442. export class BounceEase extends EasingFunction implements IEasingFunction {
  82443. /** Defines the number of bounces */
  82444. bounces: number;
  82445. /** Defines the amplitude of the bounce */
  82446. bounciness: number;
  82447. /**
  82448. * Instantiates a bounce easing
  82449. * @see https://easings.net/#easeInBounce
  82450. * @param bounces Defines the number of bounces
  82451. * @param bounciness Defines the amplitude of the bounce
  82452. */
  82453. constructor(
  82454. /** Defines the number of bounces */
  82455. bounces?: number,
  82456. /** Defines the amplitude of the bounce */
  82457. bounciness?: number);
  82458. /** @hidden */
  82459. easeInCore(gradient: number): number;
  82460. }
  82461. /**
  82462. * Easing function with a power of 3 shape (see link below).
  82463. * @see https://easings.net/#easeInCubic
  82464. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82465. */
  82466. export class CubicEase extends EasingFunction implements IEasingFunction {
  82467. /** @hidden */
  82468. easeInCore(gradient: number): number;
  82469. }
  82470. /**
  82471. * Easing function with an elastic shape (see link below).
  82472. * @see https://easings.net/#easeInElastic
  82473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82474. */
  82475. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82476. /** Defines the number of oscillations*/
  82477. oscillations: number;
  82478. /** Defines the amplitude of the oscillations*/
  82479. springiness: number;
  82480. /**
  82481. * Instantiates an elastic easing function
  82482. * @see https://easings.net/#easeInElastic
  82483. * @param oscillations Defines the number of oscillations
  82484. * @param springiness Defines the amplitude of the oscillations
  82485. */
  82486. constructor(
  82487. /** Defines the number of oscillations*/
  82488. oscillations?: number,
  82489. /** Defines the amplitude of the oscillations*/
  82490. springiness?: number);
  82491. /** @hidden */
  82492. easeInCore(gradient: number): number;
  82493. }
  82494. /**
  82495. * Easing function with an exponential shape (see link below).
  82496. * @see https://easings.net/#easeInExpo
  82497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82498. */
  82499. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  82500. /** Defines the exponent of the function */
  82501. exponent: number;
  82502. /**
  82503. * Instantiates an exponential easing function
  82504. * @see https://easings.net/#easeInExpo
  82505. * @param exponent Defines the exponent of the function
  82506. */
  82507. constructor(
  82508. /** Defines the exponent of the function */
  82509. exponent?: number);
  82510. /** @hidden */
  82511. easeInCore(gradient: number): number;
  82512. }
  82513. /**
  82514. * Easing function with a power shape (see link below).
  82515. * @see https://easings.net/#easeInQuad
  82516. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82517. */
  82518. export class PowerEase extends EasingFunction implements IEasingFunction {
  82519. /** Defines the power of the function */
  82520. power: number;
  82521. /**
  82522. * Instantiates an power base easing function
  82523. * @see https://easings.net/#easeInQuad
  82524. * @param power Defines the power of the function
  82525. */
  82526. constructor(
  82527. /** Defines the power of the function */
  82528. power?: number);
  82529. /** @hidden */
  82530. easeInCore(gradient: number): number;
  82531. }
  82532. /**
  82533. * Easing function with a power of 2 shape (see link below).
  82534. * @see https://easings.net/#easeInQuad
  82535. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82536. */
  82537. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  82538. /** @hidden */
  82539. easeInCore(gradient: number): number;
  82540. }
  82541. /**
  82542. * Easing function with a power of 4 shape (see link below).
  82543. * @see https://easings.net/#easeInQuart
  82544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82545. */
  82546. export class QuarticEase extends EasingFunction implements IEasingFunction {
  82547. /** @hidden */
  82548. easeInCore(gradient: number): number;
  82549. }
  82550. /**
  82551. * Easing function with a power of 5 shape (see link below).
  82552. * @see https://easings.net/#easeInQuint
  82553. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82554. */
  82555. export class QuinticEase extends EasingFunction implements IEasingFunction {
  82556. /** @hidden */
  82557. easeInCore(gradient: number): number;
  82558. }
  82559. /**
  82560. * Easing function with a sin shape (see link below).
  82561. * @see https://easings.net/#easeInSine
  82562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82563. */
  82564. export class SineEase extends EasingFunction implements IEasingFunction {
  82565. /** @hidden */
  82566. easeInCore(gradient: number): number;
  82567. }
  82568. /**
  82569. * Easing function with a bezier shape (see link below).
  82570. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82572. */
  82573. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  82574. /** Defines the x component of the start tangent in the bezier curve */
  82575. x1: number;
  82576. /** Defines the y component of the start tangent in the bezier curve */
  82577. y1: number;
  82578. /** Defines the x component of the end tangent in the bezier curve */
  82579. x2: number;
  82580. /** Defines the y component of the end tangent in the bezier curve */
  82581. y2: number;
  82582. /**
  82583. * Instantiates a bezier function
  82584. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82585. * @param x1 Defines the x component of the start tangent in the bezier curve
  82586. * @param y1 Defines the y component of the start tangent in the bezier curve
  82587. * @param x2 Defines the x component of the end tangent in the bezier curve
  82588. * @param y2 Defines the y component of the end tangent in the bezier curve
  82589. */
  82590. constructor(
  82591. /** Defines the x component of the start tangent in the bezier curve */
  82592. x1?: number,
  82593. /** Defines the y component of the start tangent in the bezier curve */
  82594. y1?: number,
  82595. /** Defines the x component of the end tangent in the bezier curve */
  82596. x2?: number,
  82597. /** Defines the y component of the end tangent in the bezier curve */
  82598. y2?: number);
  82599. /** @hidden */
  82600. easeInCore(gradient: number): number;
  82601. }
  82602. }
  82603. declare module BABYLON {
  82604. /**
  82605. * Class used to hold a RBG color
  82606. */
  82607. export class Color3 {
  82608. /**
  82609. * Defines the red component (between 0 and 1, default is 0)
  82610. */
  82611. r: number;
  82612. /**
  82613. * Defines the green component (between 0 and 1, default is 0)
  82614. */
  82615. g: number;
  82616. /**
  82617. * Defines the blue component (between 0 and 1, default is 0)
  82618. */
  82619. b: number;
  82620. /**
  82621. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  82622. * @param r defines the red component (between 0 and 1, default is 0)
  82623. * @param g defines the green component (between 0 and 1, default is 0)
  82624. * @param b defines the blue component (between 0 and 1, default is 0)
  82625. */
  82626. constructor(
  82627. /**
  82628. * Defines the red component (between 0 and 1, default is 0)
  82629. */
  82630. r?: number,
  82631. /**
  82632. * Defines the green component (between 0 and 1, default is 0)
  82633. */
  82634. g?: number,
  82635. /**
  82636. * Defines the blue component (between 0 and 1, default is 0)
  82637. */
  82638. b?: number);
  82639. /**
  82640. * Creates a string with the Color3 current values
  82641. * @returns the string representation of the Color3 object
  82642. */
  82643. toString(): string;
  82644. /**
  82645. * Returns the string "Color3"
  82646. * @returns "Color3"
  82647. */
  82648. getClassName(): string;
  82649. /**
  82650. * Compute the Color3 hash code
  82651. * @returns an unique number that can be used to hash Color3 objects
  82652. */
  82653. getHashCode(): number;
  82654. /**
  82655. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  82656. * @param array defines the array where to store the r,g,b components
  82657. * @param index defines an optional index in the target array to define where to start storing values
  82658. * @returns the current Color3 object
  82659. */
  82660. toArray(array: FloatArray, index?: number): Color3;
  82661. /**
  82662. * Returns a new Color4 object from the current Color3 and the given alpha
  82663. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  82664. * @returns a new Color4 object
  82665. */
  82666. toColor4(alpha?: number): Color4;
  82667. /**
  82668. * Returns a new array populated with 3 numeric elements : red, green and blue values
  82669. * @returns the new array
  82670. */
  82671. asArray(): number[];
  82672. /**
  82673. * Returns the luminance value
  82674. * @returns a float value
  82675. */
  82676. toLuminance(): number;
  82677. /**
  82678. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  82679. * @param otherColor defines the second operand
  82680. * @returns the new Color3 object
  82681. */
  82682. multiply(otherColor: DeepImmutable<Color3>): Color3;
  82683. /**
  82684. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  82685. * @param otherColor defines the second operand
  82686. * @param result defines the Color3 object where to store the result
  82687. * @returns the current Color3
  82688. */
  82689. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82690. /**
  82691. * Determines equality between Color3 objects
  82692. * @param otherColor defines the second operand
  82693. * @returns true if the rgb values are equal to the given ones
  82694. */
  82695. equals(otherColor: DeepImmutable<Color3>): boolean;
  82696. /**
  82697. * Determines equality between the current Color3 object and a set of r,b,g values
  82698. * @param r defines the red component to check
  82699. * @param g defines the green component to check
  82700. * @param b defines the blue component to check
  82701. * @returns true if the rgb values are equal to the given ones
  82702. */
  82703. equalsFloats(r: number, g: number, b: number): boolean;
  82704. /**
  82705. * Multiplies in place each rgb value by scale
  82706. * @param scale defines the scaling factor
  82707. * @returns the updated Color3
  82708. */
  82709. scale(scale: number): Color3;
  82710. /**
  82711. * Multiplies the rgb values by scale and stores the result into "result"
  82712. * @param scale defines the scaling factor
  82713. * @param result defines the Color3 object where to store the result
  82714. * @returns the unmodified current Color3
  82715. */
  82716. scaleToRef(scale: number, result: Color3): Color3;
  82717. /**
  82718. * Scale the current Color3 values by a factor and add the result to a given Color3
  82719. * @param scale defines the scale factor
  82720. * @param result defines color to store the result into
  82721. * @returns the unmodified current Color3
  82722. */
  82723. scaleAndAddToRef(scale: number, result: Color3): Color3;
  82724. /**
  82725. * Clamps the rgb values by the min and max values and stores the result into "result"
  82726. * @param min defines minimum clamping value (default is 0)
  82727. * @param max defines maximum clamping value (default is 1)
  82728. * @param result defines color to store the result into
  82729. * @returns the original Color3
  82730. */
  82731. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  82732. /**
  82733. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  82734. * @param otherColor defines the second operand
  82735. * @returns the new Color3
  82736. */
  82737. add(otherColor: DeepImmutable<Color3>): Color3;
  82738. /**
  82739. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  82740. * @param otherColor defines the second operand
  82741. * @param result defines Color3 object to store the result into
  82742. * @returns the unmodified current Color3
  82743. */
  82744. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82745. /**
  82746. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  82747. * @param otherColor defines the second operand
  82748. * @returns the new Color3
  82749. */
  82750. subtract(otherColor: DeepImmutable<Color3>): Color3;
  82751. /**
  82752. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  82753. * @param otherColor defines the second operand
  82754. * @param result defines Color3 object to store the result into
  82755. * @returns the unmodified current Color3
  82756. */
  82757. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82758. /**
  82759. * Copy the current object
  82760. * @returns a new Color3 copied the current one
  82761. */
  82762. clone(): Color3;
  82763. /**
  82764. * Copies the rgb values from the source in the current Color3
  82765. * @param source defines the source Color3 object
  82766. * @returns the updated Color3 object
  82767. */
  82768. copyFrom(source: DeepImmutable<Color3>): Color3;
  82769. /**
  82770. * Updates the Color3 rgb values from the given floats
  82771. * @param r defines the red component to read from
  82772. * @param g defines the green component to read from
  82773. * @param b defines the blue component to read from
  82774. * @returns the current Color3 object
  82775. */
  82776. copyFromFloats(r: number, g: number, b: number): Color3;
  82777. /**
  82778. * Updates the Color3 rgb values from the given floats
  82779. * @param r defines the red component to read from
  82780. * @param g defines the green component to read from
  82781. * @param b defines the blue component to read from
  82782. * @returns the current Color3 object
  82783. */
  82784. set(r: number, g: number, b: number): Color3;
  82785. /**
  82786. * Compute the Color3 hexadecimal code as a string
  82787. * @returns a string containing the hexadecimal representation of the Color3 object
  82788. */
  82789. toHexString(): string;
  82790. /**
  82791. * Computes a new Color3 converted from the current one to linear space
  82792. * @returns a new Color3 object
  82793. */
  82794. toLinearSpace(): Color3;
  82795. /**
  82796. * Converts current color in rgb space to HSV values
  82797. * @returns a new color3 representing the HSV values
  82798. */
  82799. toHSV(): Color3;
  82800. /**
  82801. * Converts current color in rgb space to HSV values
  82802. * @param result defines the Color3 where to store the HSV values
  82803. */
  82804. toHSVToRef(result: Color3): void;
  82805. /**
  82806. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  82807. * @param convertedColor defines the Color3 object where to store the linear space version
  82808. * @returns the unmodified Color3
  82809. */
  82810. toLinearSpaceToRef(convertedColor: Color3): Color3;
  82811. /**
  82812. * Computes a new Color3 converted from the current one to gamma space
  82813. * @returns a new Color3 object
  82814. */
  82815. toGammaSpace(): Color3;
  82816. /**
  82817. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  82818. * @param convertedColor defines the Color3 object where to store the gamma space version
  82819. * @returns the unmodified Color3
  82820. */
  82821. toGammaSpaceToRef(convertedColor: Color3): Color3;
  82822. private static _BlackReadOnly;
  82823. /**
  82824. * Convert Hue, saturation and value to a Color3 (RGB)
  82825. * @param hue defines the hue
  82826. * @param saturation defines the saturation
  82827. * @param value defines the value
  82828. * @param result defines the Color3 where to store the RGB values
  82829. */
  82830. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  82831. /**
  82832. * Creates a new Color3 from the string containing valid hexadecimal values
  82833. * @param hex defines a string containing valid hexadecimal values
  82834. * @returns a new Color3 object
  82835. */
  82836. static FromHexString(hex: string): Color3;
  82837. /**
  82838. * Creates a new Color3 from the starting index of the given array
  82839. * @param array defines the source array
  82840. * @param offset defines an offset in the source array
  82841. * @returns a new Color3 object
  82842. */
  82843. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  82844. /**
  82845. * Creates a new Color3 from integer values (< 256)
  82846. * @param r defines the red component to read from (value between 0 and 255)
  82847. * @param g defines the green component to read from (value between 0 and 255)
  82848. * @param b defines the blue component to read from (value between 0 and 255)
  82849. * @returns a new Color3 object
  82850. */
  82851. static FromInts(r: number, g: number, b: number): Color3;
  82852. /**
  82853. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82854. * @param start defines the start Color3 value
  82855. * @param end defines the end Color3 value
  82856. * @param amount defines the gradient value between start and end
  82857. * @returns a new Color3 object
  82858. */
  82859. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  82860. /**
  82861. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82862. * @param left defines the start value
  82863. * @param right defines the end value
  82864. * @param amount defines the gradient factor
  82865. * @param result defines the Color3 object where to store the result
  82866. */
  82867. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  82868. /**
  82869. * Returns a Color3 value containing a red color
  82870. * @returns a new Color3 object
  82871. */
  82872. static Red(): Color3;
  82873. /**
  82874. * Returns a Color3 value containing a green color
  82875. * @returns a new Color3 object
  82876. */
  82877. static Green(): Color3;
  82878. /**
  82879. * Returns a Color3 value containing a blue color
  82880. * @returns a new Color3 object
  82881. */
  82882. static Blue(): Color3;
  82883. /**
  82884. * Returns a Color3 value containing a black color
  82885. * @returns a new Color3 object
  82886. */
  82887. static Black(): Color3;
  82888. /**
  82889. * Gets a Color3 value containing a black color that must not be updated
  82890. */
  82891. static get BlackReadOnly(): DeepImmutable<Color3>;
  82892. /**
  82893. * Returns a Color3 value containing a white color
  82894. * @returns a new Color3 object
  82895. */
  82896. static White(): Color3;
  82897. /**
  82898. * Returns a Color3 value containing a purple color
  82899. * @returns a new Color3 object
  82900. */
  82901. static Purple(): Color3;
  82902. /**
  82903. * Returns a Color3 value containing a magenta color
  82904. * @returns a new Color3 object
  82905. */
  82906. static Magenta(): Color3;
  82907. /**
  82908. * Returns a Color3 value containing a yellow color
  82909. * @returns a new Color3 object
  82910. */
  82911. static Yellow(): Color3;
  82912. /**
  82913. * Returns a Color3 value containing a gray color
  82914. * @returns a new Color3 object
  82915. */
  82916. static Gray(): Color3;
  82917. /**
  82918. * Returns a Color3 value containing a teal color
  82919. * @returns a new Color3 object
  82920. */
  82921. static Teal(): Color3;
  82922. /**
  82923. * Returns a Color3 value containing a random color
  82924. * @returns a new Color3 object
  82925. */
  82926. static Random(): Color3;
  82927. }
  82928. /**
  82929. * Class used to hold a RBGA color
  82930. */
  82931. export class Color4 {
  82932. /**
  82933. * Defines the red component (between 0 and 1, default is 0)
  82934. */
  82935. r: number;
  82936. /**
  82937. * Defines the green component (between 0 and 1, default is 0)
  82938. */
  82939. g: number;
  82940. /**
  82941. * Defines the blue component (between 0 and 1, default is 0)
  82942. */
  82943. b: number;
  82944. /**
  82945. * Defines the alpha component (between 0 and 1, default is 1)
  82946. */
  82947. a: number;
  82948. /**
  82949. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  82950. * @param r defines the red component (between 0 and 1, default is 0)
  82951. * @param g defines the green component (between 0 and 1, default is 0)
  82952. * @param b defines the blue component (between 0 and 1, default is 0)
  82953. * @param a defines the alpha component (between 0 and 1, default is 1)
  82954. */
  82955. constructor(
  82956. /**
  82957. * Defines the red component (between 0 and 1, default is 0)
  82958. */
  82959. r?: number,
  82960. /**
  82961. * Defines the green component (between 0 and 1, default is 0)
  82962. */
  82963. g?: number,
  82964. /**
  82965. * Defines the blue component (between 0 and 1, default is 0)
  82966. */
  82967. b?: number,
  82968. /**
  82969. * Defines the alpha component (between 0 and 1, default is 1)
  82970. */
  82971. a?: number);
  82972. /**
  82973. * Adds in place the given Color4 values to the current Color4 object
  82974. * @param right defines the second operand
  82975. * @returns the current updated Color4 object
  82976. */
  82977. addInPlace(right: DeepImmutable<Color4>): Color4;
  82978. /**
  82979. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  82980. * @returns the new array
  82981. */
  82982. asArray(): number[];
  82983. /**
  82984. * Stores from the starting index in the given array the Color4 successive values
  82985. * @param array defines the array where to store the r,g,b components
  82986. * @param index defines an optional index in the target array to define where to start storing values
  82987. * @returns the current Color4 object
  82988. */
  82989. toArray(array: number[], index?: number): Color4;
  82990. /**
  82991. * Determines equality between Color4 objects
  82992. * @param otherColor defines the second operand
  82993. * @returns true if the rgba values are equal to the given ones
  82994. */
  82995. equals(otherColor: DeepImmutable<Color4>): boolean;
  82996. /**
  82997. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  82998. * @param right defines the second operand
  82999. * @returns a new Color4 object
  83000. */
  83001. add(right: DeepImmutable<Color4>): Color4;
  83002. /**
  83003. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83004. * @param right defines the second operand
  83005. * @returns a new Color4 object
  83006. */
  83007. subtract(right: DeepImmutable<Color4>): Color4;
  83008. /**
  83009. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83010. * @param right defines the second operand
  83011. * @param result defines the Color4 object where to store the result
  83012. * @returns the current Color4 object
  83013. */
  83014. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83015. /**
  83016. * Creates a new Color4 with the current Color4 values multiplied by scale
  83017. * @param scale defines the scaling factor to apply
  83018. * @returns a new Color4 object
  83019. */
  83020. scale(scale: number): Color4;
  83021. /**
  83022. * Multiplies the current Color4 values by scale and stores the result in "result"
  83023. * @param scale defines the scaling factor to apply
  83024. * @param result defines the Color4 object where to store the result
  83025. * @returns the current unmodified Color4
  83026. */
  83027. scaleToRef(scale: number, result: Color4): Color4;
  83028. /**
  83029. * Scale the current Color4 values by a factor and add the result to a given Color4
  83030. * @param scale defines the scale factor
  83031. * @param result defines the Color4 object where to store the result
  83032. * @returns the unmodified current Color4
  83033. */
  83034. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83035. /**
  83036. * Clamps the rgb values by the min and max values and stores the result into "result"
  83037. * @param min defines minimum clamping value (default is 0)
  83038. * @param max defines maximum clamping value (default is 1)
  83039. * @param result defines color to store the result into.
  83040. * @returns the cuurent Color4
  83041. */
  83042. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83043. /**
  83044. * Multipy an Color4 value by another and return a new Color4 object
  83045. * @param color defines the Color4 value to multiply by
  83046. * @returns a new Color4 object
  83047. */
  83048. multiply(color: Color4): Color4;
  83049. /**
  83050. * Multipy a Color4 value by another and push the result in a reference value
  83051. * @param color defines the Color4 value to multiply by
  83052. * @param result defines the Color4 to fill the result in
  83053. * @returns the result Color4
  83054. */
  83055. multiplyToRef(color: Color4, result: Color4): Color4;
  83056. /**
  83057. * Creates a string with the Color4 current values
  83058. * @returns the string representation of the Color4 object
  83059. */
  83060. toString(): string;
  83061. /**
  83062. * Returns the string "Color4"
  83063. * @returns "Color4"
  83064. */
  83065. getClassName(): string;
  83066. /**
  83067. * Compute the Color4 hash code
  83068. * @returns an unique number that can be used to hash Color4 objects
  83069. */
  83070. getHashCode(): number;
  83071. /**
  83072. * Creates a new Color4 copied from the current one
  83073. * @returns a new Color4 object
  83074. */
  83075. clone(): Color4;
  83076. /**
  83077. * Copies the given Color4 values into the current one
  83078. * @param source defines the source Color4 object
  83079. * @returns the current updated Color4 object
  83080. */
  83081. copyFrom(source: Color4): Color4;
  83082. /**
  83083. * Copies the given float values into the current one
  83084. * @param r defines the red component to read from
  83085. * @param g defines the green component to read from
  83086. * @param b defines the blue component to read from
  83087. * @param a defines the alpha component to read from
  83088. * @returns the current updated Color4 object
  83089. */
  83090. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83091. /**
  83092. * Copies the given float values into the current one
  83093. * @param r defines the red component to read from
  83094. * @param g defines the green component to read from
  83095. * @param b defines the blue component to read from
  83096. * @param a defines the alpha component to read from
  83097. * @returns the current updated Color4 object
  83098. */
  83099. set(r: number, g: number, b: number, a: number): Color4;
  83100. /**
  83101. * Compute the Color4 hexadecimal code as a string
  83102. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83103. * @returns a string containing the hexadecimal representation of the Color4 object
  83104. */
  83105. toHexString(returnAsColor3?: boolean): string;
  83106. /**
  83107. * Computes a new Color4 converted from the current one to linear space
  83108. * @returns a new Color4 object
  83109. */
  83110. toLinearSpace(): Color4;
  83111. /**
  83112. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83113. * @param convertedColor defines the Color4 object where to store the linear space version
  83114. * @returns the unmodified Color4
  83115. */
  83116. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83117. /**
  83118. * Computes a new Color4 converted from the current one to gamma space
  83119. * @returns a new Color4 object
  83120. */
  83121. toGammaSpace(): Color4;
  83122. /**
  83123. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83124. * @param convertedColor defines the Color4 object where to store the gamma space version
  83125. * @returns the unmodified Color4
  83126. */
  83127. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83128. /**
  83129. * Creates a new Color4 from the string containing valid hexadecimal values
  83130. * @param hex defines a string containing valid hexadecimal values
  83131. * @returns a new Color4 object
  83132. */
  83133. static FromHexString(hex: string): Color4;
  83134. /**
  83135. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83136. * @param left defines the start value
  83137. * @param right defines the end value
  83138. * @param amount defines the gradient factor
  83139. * @returns a new Color4 object
  83140. */
  83141. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83142. /**
  83143. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83144. * @param left defines the start value
  83145. * @param right defines the end value
  83146. * @param amount defines the gradient factor
  83147. * @param result defines the Color4 object where to store data
  83148. */
  83149. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83150. /**
  83151. * Creates a new Color4 from a Color3 and an alpha value
  83152. * @param color3 defines the source Color3 to read from
  83153. * @param alpha defines the alpha component (1.0 by default)
  83154. * @returns a new Color4 object
  83155. */
  83156. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83157. /**
  83158. * Creates a new Color4 from the starting index element of the given array
  83159. * @param array defines the source array to read from
  83160. * @param offset defines the offset in the source array
  83161. * @returns a new Color4 object
  83162. */
  83163. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83164. /**
  83165. * Creates a new Color3 from integer values (< 256)
  83166. * @param r defines the red component to read from (value between 0 and 255)
  83167. * @param g defines the green component to read from (value between 0 and 255)
  83168. * @param b defines the blue component to read from (value between 0 and 255)
  83169. * @param a defines the alpha component to read from (value between 0 and 255)
  83170. * @returns a new Color3 object
  83171. */
  83172. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83173. /**
  83174. * Check the content of a given array and convert it to an array containing RGBA data
  83175. * If the original array was already containing count * 4 values then it is returned directly
  83176. * @param colors defines the array to check
  83177. * @param count defines the number of RGBA data to expect
  83178. * @returns an array containing count * 4 values (RGBA)
  83179. */
  83180. static CheckColors4(colors: number[], count: number): number[];
  83181. }
  83182. /**
  83183. * @hidden
  83184. */
  83185. export class TmpColors {
  83186. static Color3: Color3[];
  83187. static Color4: Color4[];
  83188. }
  83189. }
  83190. declare module BABYLON {
  83191. /**
  83192. * Defines an interface which represents an animation key frame
  83193. */
  83194. export interface IAnimationKey {
  83195. /**
  83196. * Frame of the key frame
  83197. */
  83198. frame: number;
  83199. /**
  83200. * Value at the specifies key frame
  83201. */
  83202. value: any;
  83203. /**
  83204. * The input tangent for the cubic hermite spline
  83205. */
  83206. inTangent?: any;
  83207. /**
  83208. * The output tangent for the cubic hermite spline
  83209. */
  83210. outTangent?: any;
  83211. /**
  83212. * The animation interpolation type
  83213. */
  83214. interpolation?: AnimationKeyInterpolation;
  83215. }
  83216. /**
  83217. * Enum for the animation key frame interpolation type
  83218. */
  83219. export enum AnimationKeyInterpolation {
  83220. /**
  83221. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83222. */
  83223. STEP = 1
  83224. }
  83225. }
  83226. declare module BABYLON {
  83227. /**
  83228. * Represents the range of an animation
  83229. */
  83230. export class AnimationRange {
  83231. /**The name of the animation range**/
  83232. name: string;
  83233. /**The starting frame of the animation */
  83234. from: number;
  83235. /**The ending frame of the animation*/
  83236. to: number;
  83237. /**
  83238. * Initializes the range of an animation
  83239. * @param name The name of the animation range
  83240. * @param from The starting frame of the animation
  83241. * @param to The ending frame of the animation
  83242. */
  83243. constructor(
  83244. /**The name of the animation range**/
  83245. name: string,
  83246. /**The starting frame of the animation */
  83247. from: number,
  83248. /**The ending frame of the animation*/
  83249. to: number);
  83250. /**
  83251. * Makes a copy of the animation range
  83252. * @returns A copy of the animation range
  83253. */
  83254. clone(): AnimationRange;
  83255. }
  83256. }
  83257. declare module BABYLON {
  83258. /**
  83259. * Composed of a frame, and an action function
  83260. */
  83261. export class AnimationEvent {
  83262. /** The frame for which the event is triggered **/
  83263. frame: number;
  83264. /** The event to perform when triggered **/
  83265. action: (currentFrame: number) => void;
  83266. /** Specifies if the event should be triggered only once**/
  83267. onlyOnce?: boolean | undefined;
  83268. /**
  83269. * Specifies if the animation event is done
  83270. */
  83271. isDone: boolean;
  83272. /**
  83273. * Initializes the animation event
  83274. * @param frame The frame for which the event is triggered
  83275. * @param action The event to perform when triggered
  83276. * @param onlyOnce Specifies if the event should be triggered only once
  83277. */
  83278. constructor(
  83279. /** The frame for which the event is triggered **/
  83280. frame: number,
  83281. /** The event to perform when triggered **/
  83282. action: (currentFrame: number) => void,
  83283. /** Specifies if the event should be triggered only once**/
  83284. onlyOnce?: boolean | undefined);
  83285. /** @hidden */
  83286. _clone(): AnimationEvent;
  83287. }
  83288. }
  83289. declare module BABYLON {
  83290. /**
  83291. * Interface used to define a behavior
  83292. */
  83293. export interface Behavior<T> {
  83294. /** gets or sets behavior's name */
  83295. name: string;
  83296. /**
  83297. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83298. */
  83299. init(): void;
  83300. /**
  83301. * Called when the behavior is attached to a target
  83302. * @param target defines the target where the behavior is attached to
  83303. */
  83304. attach(target: T): void;
  83305. /**
  83306. * Called when the behavior is detached from its target
  83307. */
  83308. detach(): void;
  83309. }
  83310. /**
  83311. * Interface implemented by classes supporting behaviors
  83312. */
  83313. export interface IBehaviorAware<T> {
  83314. /**
  83315. * Attach a behavior
  83316. * @param behavior defines the behavior to attach
  83317. * @returns the current host
  83318. */
  83319. addBehavior(behavior: Behavior<T>): T;
  83320. /**
  83321. * Remove a behavior from the current object
  83322. * @param behavior defines the behavior to detach
  83323. * @returns the current host
  83324. */
  83325. removeBehavior(behavior: Behavior<T>): T;
  83326. /**
  83327. * Gets a behavior using its name to search
  83328. * @param name defines the name to search
  83329. * @returns the behavior or null if not found
  83330. */
  83331. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83332. }
  83333. }
  83334. declare module BABYLON {
  83335. /**
  83336. * Defines an array and its length.
  83337. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83338. */
  83339. export interface ISmartArrayLike<T> {
  83340. /**
  83341. * The data of the array.
  83342. */
  83343. data: Array<T>;
  83344. /**
  83345. * The active length of the array.
  83346. */
  83347. length: number;
  83348. }
  83349. /**
  83350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83351. */
  83352. export class SmartArray<T> implements ISmartArrayLike<T> {
  83353. /**
  83354. * The full set of data from the array.
  83355. */
  83356. data: Array<T>;
  83357. /**
  83358. * The active length of the array.
  83359. */
  83360. length: number;
  83361. protected _id: number;
  83362. /**
  83363. * Instantiates a Smart Array.
  83364. * @param capacity defines the default capacity of the array.
  83365. */
  83366. constructor(capacity: number);
  83367. /**
  83368. * Pushes a value at the end of the active data.
  83369. * @param value defines the object to push in the array.
  83370. */
  83371. push(value: T): void;
  83372. /**
  83373. * Iterates over the active data and apply the lambda to them.
  83374. * @param func defines the action to apply on each value.
  83375. */
  83376. forEach(func: (content: T) => void): void;
  83377. /**
  83378. * Sorts the full sets of data.
  83379. * @param compareFn defines the comparison function to apply.
  83380. */
  83381. sort(compareFn: (a: T, b: T) => number): void;
  83382. /**
  83383. * Resets the active data to an empty array.
  83384. */
  83385. reset(): void;
  83386. /**
  83387. * Releases all the data from the array as well as the array.
  83388. */
  83389. dispose(): void;
  83390. /**
  83391. * Concats the active data with a given array.
  83392. * @param array defines the data to concatenate with.
  83393. */
  83394. concat(array: any): void;
  83395. /**
  83396. * Returns the position of a value in the active data.
  83397. * @param value defines the value to find the index for
  83398. * @returns the index if found in the active data otherwise -1
  83399. */
  83400. indexOf(value: T): number;
  83401. /**
  83402. * Returns whether an element is part of the active data.
  83403. * @param value defines the value to look for
  83404. * @returns true if found in the active data otherwise false
  83405. */
  83406. contains(value: T): boolean;
  83407. private static _GlobalId;
  83408. }
  83409. /**
  83410. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83411. * The data in this array can only be present once
  83412. */
  83413. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83414. private _duplicateId;
  83415. /**
  83416. * Pushes a value at the end of the active data.
  83417. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83418. * @param value defines the object to push in the array.
  83419. */
  83420. push(value: T): void;
  83421. /**
  83422. * Pushes a value at the end of the active data.
  83423. * If the data is already present, it won t be added again
  83424. * @param value defines the object to push in the array.
  83425. * @returns true if added false if it was already present
  83426. */
  83427. pushNoDuplicate(value: T): boolean;
  83428. /**
  83429. * Resets the active data to an empty array.
  83430. */
  83431. reset(): void;
  83432. /**
  83433. * Concats the active data with a given array.
  83434. * This ensures no dupplicate will be present in the result.
  83435. * @param array defines the data to concatenate with.
  83436. */
  83437. concatWithNoDuplicate(array: any): void;
  83438. }
  83439. }
  83440. declare module BABYLON {
  83441. /**
  83442. * @ignore
  83443. * This is a list of all the different input types that are available in the application.
  83444. * Fo instance: ArcRotateCameraGamepadInput...
  83445. */
  83446. export var CameraInputTypes: {};
  83447. /**
  83448. * This is the contract to implement in order to create a new input class.
  83449. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83450. */
  83451. export interface ICameraInput<TCamera extends Camera> {
  83452. /**
  83453. * Defines the camera the input is attached to.
  83454. */
  83455. camera: Nullable<TCamera>;
  83456. /**
  83457. * Gets the class name of the current intput.
  83458. * @returns the class name
  83459. */
  83460. getClassName(): string;
  83461. /**
  83462. * Get the friendly name associated with the input class.
  83463. * @returns the input friendly name
  83464. */
  83465. getSimpleName(): string;
  83466. /**
  83467. * Attach the input controls to a specific dom element to get the input from.
  83468. * @param element Defines the element the controls should be listened from
  83469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83470. */
  83471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83472. /**
  83473. * Detach the current controls from the specified dom element.
  83474. * @param element Defines the element to stop listening the inputs from
  83475. */
  83476. detachControl(element: Nullable<HTMLElement>): void;
  83477. /**
  83478. * Update the current camera state depending on the inputs that have been used this frame.
  83479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83480. */
  83481. checkInputs?: () => void;
  83482. }
  83483. /**
  83484. * Represents a map of input types to input instance or input index to input instance.
  83485. */
  83486. export interface CameraInputsMap<TCamera extends Camera> {
  83487. /**
  83488. * Accessor to the input by input type.
  83489. */
  83490. [name: string]: ICameraInput<TCamera>;
  83491. /**
  83492. * Accessor to the input by input index.
  83493. */
  83494. [idx: number]: ICameraInput<TCamera>;
  83495. }
  83496. /**
  83497. * This represents the input manager used within a camera.
  83498. * It helps dealing with all the different kind of input attached to a camera.
  83499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83500. */
  83501. export class CameraInputsManager<TCamera extends Camera> {
  83502. /**
  83503. * Defines the list of inputs attahed to the camera.
  83504. */
  83505. attached: CameraInputsMap<TCamera>;
  83506. /**
  83507. * Defines the dom element the camera is collecting inputs from.
  83508. * This is null if the controls have not been attached.
  83509. */
  83510. attachedElement: Nullable<HTMLElement>;
  83511. /**
  83512. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83513. */
  83514. noPreventDefault: boolean;
  83515. /**
  83516. * Defined the camera the input manager belongs to.
  83517. */
  83518. camera: TCamera;
  83519. /**
  83520. * Update the current camera state depending on the inputs that have been used this frame.
  83521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83522. */
  83523. checkInputs: () => void;
  83524. /**
  83525. * Instantiate a new Camera Input Manager.
  83526. * @param camera Defines the camera the input manager blongs to
  83527. */
  83528. constructor(camera: TCamera);
  83529. /**
  83530. * Add an input method to a camera
  83531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83532. * @param input camera input method
  83533. */
  83534. add(input: ICameraInput<TCamera>): void;
  83535. /**
  83536. * Remove a specific input method from a camera
  83537. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  83538. * @param inputToRemove camera input method
  83539. */
  83540. remove(inputToRemove: ICameraInput<TCamera>): void;
  83541. /**
  83542. * Remove a specific input type from a camera
  83543. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  83544. * @param inputType the type of the input to remove
  83545. */
  83546. removeByType(inputType: string): void;
  83547. private _addCheckInputs;
  83548. /**
  83549. * Attach the input controls to the currently attached dom element to listen the events from.
  83550. * @param input Defines the input to attach
  83551. */
  83552. attachInput(input: ICameraInput<TCamera>): void;
  83553. /**
  83554. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  83555. * @param element Defines the dom element to collect the events from
  83556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83557. */
  83558. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  83559. /**
  83560. * Detach the current manager inputs controls from a specific dom element.
  83561. * @param element Defines the dom element to collect the events from
  83562. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  83563. */
  83564. detachElement(element: HTMLElement, disconnect?: boolean): void;
  83565. /**
  83566. * Rebuild the dynamic inputCheck function from the current list of
  83567. * defined inputs in the manager.
  83568. */
  83569. rebuildInputCheck(): void;
  83570. /**
  83571. * Remove all attached input methods from a camera
  83572. */
  83573. clear(): void;
  83574. /**
  83575. * Serialize the current input manager attached to a camera.
  83576. * This ensures than once parsed,
  83577. * the input associated to the camera will be identical to the current ones
  83578. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  83579. */
  83580. serialize(serializedCamera: any): void;
  83581. /**
  83582. * Parses an input manager serialized JSON to restore the previous list of inputs
  83583. * and states associated to a camera.
  83584. * @param parsedCamera Defines the JSON to parse
  83585. */
  83586. parse(parsedCamera: any): void;
  83587. }
  83588. }
  83589. declare module BABYLON {
  83590. /**
  83591. * Class used to store data that will be store in GPU memory
  83592. */
  83593. export class Buffer {
  83594. private _engine;
  83595. private _buffer;
  83596. /** @hidden */
  83597. _data: Nullable<DataArray>;
  83598. private _updatable;
  83599. private _instanced;
  83600. private _divisor;
  83601. /**
  83602. * Gets the byte stride.
  83603. */
  83604. readonly byteStride: number;
  83605. /**
  83606. * Constructor
  83607. * @param engine the engine
  83608. * @param data the data to use for this buffer
  83609. * @param updatable whether the data is updatable
  83610. * @param stride the stride (optional)
  83611. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83612. * @param instanced whether the buffer is instanced (optional)
  83613. * @param useBytes set to true if the stride in in bytes (optional)
  83614. * @param divisor sets an optional divisor for instances (1 by default)
  83615. */
  83616. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  83617. /**
  83618. * Create a new VertexBuffer based on the current buffer
  83619. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83620. * @param offset defines offset in the buffer (0 by default)
  83621. * @param size defines the size in floats of attributes (position is 3 for instance)
  83622. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83623. * @param instanced defines if the vertex buffer contains indexed data
  83624. * @param useBytes defines if the offset and stride are in bytes *
  83625. * @param divisor sets an optional divisor for instances (1 by default)
  83626. * @returns the new vertex buffer
  83627. */
  83628. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  83629. /**
  83630. * Gets a boolean indicating if the Buffer is updatable?
  83631. * @returns true if the buffer is updatable
  83632. */
  83633. isUpdatable(): boolean;
  83634. /**
  83635. * Gets current buffer's data
  83636. * @returns a DataArray or null
  83637. */
  83638. getData(): Nullable<DataArray>;
  83639. /**
  83640. * Gets underlying native buffer
  83641. * @returns underlying native buffer
  83642. */
  83643. getBuffer(): Nullable<DataBuffer>;
  83644. /**
  83645. * Gets the stride in float32 units (i.e. byte stride / 4).
  83646. * May not be an integer if the byte stride is not divisible by 4.
  83647. * @returns the stride in float32 units
  83648. * @deprecated Please use byteStride instead.
  83649. */
  83650. getStrideSize(): number;
  83651. /**
  83652. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83653. * @param data defines the data to store
  83654. */
  83655. create(data?: Nullable<DataArray>): void;
  83656. /** @hidden */
  83657. _rebuild(): void;
  83658. /**
  83659. * Update current buffer data
  83660. * @param data defines the data to store
  83661. */
  83662. update(data: DataArray): void;
  83663. /**
  83664. * Updates the data directly.
  83665. * @param data the new data
  83666. * @param offset the new offset
  83667. * @param vertexCount the vertex count (optional)
  83668. * @param useBytes set to true if the offset is in bytes
  83669. */
  83670. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  83671. /**
  83672. * Release all resources
  83673. */
  83674. dispose(): void;
  83675. }
  83676. /**
  83677. * Specialized buffer used to store vertex data
  83678. */
  83679. export class VertexBuffer {
  83680. /** @hidden */
  83681. _buffer: Buffer;
  83682. private _kind;
  83683. private _size;
  83684. private _ownsBuffer;
  83685. private _instanced;
  83686. private _instanceDivisor;
  83687. /**
  83688. * The byte type.
  83689. */
  83690. static readonly BYTE: number;
  83691. /**
  83692. * The unsigned byte type.
  83693. */
  83694. static readonly UNSIGNED_BYTE: number;
  83695. /**
  83696. * The short type.
  83697. */
  83698. static readonly SHORT: number;
  83699. /**
  83700. * The unsigned short type.
  83701. */
  83702. static readonly UNSIGNED_SHORT: number;
  83703. /**
  83704. * The integer type.
  83705. */
  83706. static readonly INT: number;
  83707. /**
  83708. * The unsigned integer type.
  83709. */
  83710. static readonly UNSIGNED_INT: number;
  83711. /**
  83712. * The float type.
  83713. */
  83714. static readonly FLOAT: number;
  83715. /**
  83716. * Gets or sets the instance divisor when in instanced mode
  83717. */
  83718. get instanceDivisor(): number;
  83719. set instanceDivisor(value: number);
  83720. /**
  83721. * Gets the byte stride.
  83722. */
  83723. readonly byteStride: number;
  83724. /**
  83725. * Gets the byte offset.
  83726. */
  83727. readonly byteOffset: number;
  83728. /**
  83729. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  83730. */
  83731. readonly normalized: boolean;
  83732. /**
  83733. * Gets the data type of each component in the array.
  83734. */
  83735. readonly type: number;
  83736. /**
  83737. * Constructor
  83738. * @param engine the engine
  83739. * @param data the data to use for this vertex buffer
  83740. * @param kind the vertex buffer kind
  83741. * @param updatable whether the data is updatable
  83742. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83743. * @param stride the stride (optional)
  83744. * @param instanced whether the buffer is instanced (optional)
  83745. * @param offset the offset of the data (optional)
  83746. * @param size the number of components (optional)
  83747. * @param type the type of the component (optional)
  83748. * @param normalized whether the data contains normalized data (optional)
  83749. * @param useBytes set to true if stride and offset are in bytes (optional)
  83750. * @param divisor defines the instance divisor to use (1 by default)
  83751. */
  83752. 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);
  83753. /** @hidden */
  83754. _rebuild(): void;
  83755. /**
  83756. * Returns the kind of the VertexBuffer (string)
  83757. * @returns a string
  83758. */
  83759. getKind(): string;
  83760. /**
  83761. * Gets a boolean indicating if the VertexBuffer is updatable?
  83762. * @returns true if the buffer is updatable
  83763. */
  83764. isUpdatable(): boolean;
  83765. /**
  83766. * Gets current buffer's data
  83767. * @returns a DataArray or null
  83768. */
  83769. getData(): Nullable<DataArray>;
  83770. /**
  83771. * Gets underlying native buffer
  83772. * @returns underlying native buffer
  83773. */
  83774. getBuffer(): Nullable<DataBuffer>;
  83775. /**
  83776. * Gets the stride in float32 units (i.e. byte stride / 4).
  83777. * May not be an integer if the byte stride is not divisible by 4.
  83778. * @returns the stride in float32 units
  83779. * @deprecated Please use byteStride instead.
  83780. */
  83781. getStrideSize(): number;
  83782. /**
  83783. * Returns the offset as a multiple of the type byte length.
  83784. * @returns the offset in bytes
  83785. * @deprecated Please use byteOffset instead.
  83786. */
  83787. getOffset(): number;
  83788. /**
  83789. * Returns the number of components per vertex attribute (integer)
  83790. * @returns the size in float
  83791. */
  83792. getSize(): number;
  83793. /**
  83794. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83795. * @returns true if this buffer is instanced
  83796. */
  83797. getIsInstanced(): boolean;
  83798. /**
  83799. * Returns the instancing divisor, zero for non-instanced (integer).
  83800. * @returns a number
  83801. */
  83802. getInstanceDivisor(): number;
  83803. /**
  83804. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83805. * @param data defines the data to store
  83806. */
  83807. create(data?: DataArray): void;
  83808. /**
  83809. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83810. * This function will create a new buffer if the current one is not updatable
  83811. * @param data defines the data to store
  83812. */
  83813. update(data: DataArray): void;
  83814. /**
  83815. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83816. * Returns the directly updated WebGLBuffer.
  83817. * @param data the new data
  83818. * @param offset the new offset
  83819. * @param useBytes set to true if the offset is in bytes
  83820. */
  83821. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  83822. /**
  83823. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83824. */
  83825. dispose(): void;
  83826. /**
  83827. * Enumerates each value of this vertex buffer as numbers.
  83828. * @param count the number of values to enumerate
  83829. * @param callback the callback function called for each value
  83830. */
  83831. forEach(count: number, callback: (value: number, index: number) => void): void;
  83832. /**
  83833. * Positions
  83834. */
  83835. static readonly PositionKind: string;
  83836. /**
  83837. * Normals
  83838. */
  83839. static readonly NormalKind: string;
  83840. /**
  83841. * Tangents
  83842. */
  83843. static readonly TangentKind: string;
  83844. /**
  83845. * Texture coordinates
  83846. */
  83847. static readonly UVKind: string;
  83848. /**
  83849. * Texture coordinates 2
  83850. */
  83851. static readonly UV2Kind: string;
  83852. /**
  83853. * Texture coordinates 3
  83854. */
  83855. static readonly UV3Kind: string;
  83856. /**
  83857. * Texture coordinates 4
  83858. */
  83859. static readonly UV4Kind: string;
  83860. /**
  83861. * Texture coordinates 5
  83862. */
  83863. static readonly UV5Kind: string;
  83864. /**
  83865. * Texture coordinates 6
  83866. */
  83867. static readonly UV6Kind: string;
  83868. /**
  83869. * Colors
  83870. */
  83871. static readonly ColorKind: string;
  83872. /**
  83873. * Matrix indices (for bones)
  83874. */
  83875. static readonly MatricesIndicesKind: string;
  83876. /**
  83877. * Matrix weights (for bones)
  83878. */
  83879. static readonly MatricesWeightsKind: string;
  83880. /**
  83881. * Additional matrix indices (for bones)
  83882. */
  83883. static readonly MatricesIndicesExtraKind: string;
  83884. /**
  83885. * Additional matrix weights (for bones)
  83886. */
  83887. static readonly MatricesWeightsExtraKind: string;
  83888. /**
  83889. * Deduces the stride given a kind.
  83890. * @param kind The kind string to deduce
  83891. * @returns The deduced stride
  83892. */
  83893. static DeduceStride(kind: string): number;
  83894. /**
  83895. * Gets the byte length of the given type.
  83896. * @param type the type
  83897. * @returns the number of bytes
  83898. */
  83899. static GetTypeByteLength(type: number): number;
  83900. /**
  83901. * Enumerates each value of the given parameters as numbers.
  83902. * @param data the data to enumerate
  83903. * @param byteOffset the byte offset of the data
  83904. * @param byteStride the byte stride of the data
  83905. * @param componentCount the number of components per element
  83906. * @param componentType the type of the component
  83907. * @param count the number of values to enumerate
  83908. * @param normalized whether the data is normalized
  83909. * @param callback the callback function called for each value
  83910. */
  83911. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  83912. private static _GetFloatValue;
  83913. }
  83914. }
  83915. declare module BABYLON {
  83916. /**
  83917. * @hidden
  83918. */
  83919. export class IntersectionInfo {
  83920. bu: Nullable<number>;
  83921. bv: Nullable<number>;
  83922. distance: number;
  83923. faceId: number;
  83924. subMeshId: number;
  83925. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  83926. }
  83927. }
  83928. declare module BABYLON {
  83929. /**
  83930. * Class used to store bounding sphere information
  83931. */
  83932. export class BoundingSphere {
  83933. /**
  83934. * Gets the center of the bounding sphere in local space
  83935. */
  83936. readonly center: Vector3;
  83937. /**
  83938. * Radius of the bounding sphere in local space
  83939. */
  83940. radius: number;
  83941. /**
  83942. * Gets the center of the bounding sphere in world space
  83943. */
  83944. readonly centerWorld: Vector3;
  83945. /**
  83946. * Radius of the bounding sphere in world space
  83947. */
  83948. radiusWorld: number;
  83949. /**
  83950. * Gets the minimum vector in local space
  83951. */
  83952. readonly minimum: Vector3;
  83953. /**
  83954. * Gets the maximum vector in local space
  83955. */
  83956. readonly maximum: Vector3;
  83957. private _worldMatrix;
  83958. private static readonly TmpVector3;
  83959. /**
  83960. * Creates a new bounding sphere
  83961. * @param min defines the minimum vector (in local space)
  83962. * @param max defines the maximum vector (in local space)
  83963. * @param worldMatrix defines the new world matrix
  83964. */
  83965. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83966. /**
  83967. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  83968. * @param min defines the new minimum vector (in local space)
  83969. * @param max defines the new maximum vector (in local space)
  83970. * @param worldMatrix defines the new world matrix
  83971. */
  83972. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83973. /**
  83974. * Scale the current bounding sphere by applying a scale factor
  83975. * @param factor defines the scale factor to apply
  83976. * @returns the current bounding box
  83977. */
  83978. scale(factor: number): BoundingSphere;
  83979. /**
  83980. * Gets the world matrix of the bounding box
  83981. * @returns a matrix
  83982. */
  83983. getWorldMatrix(): DeepImmutable<Matrix>;
  83984. /** @hidden */
  83985. _update(worldMatrix: DeepImmutable<Matrix>): void;
  83986. /**
  83987. * Tests if the bounding sphere is intersecting the frustum planes
  83988. * @param frustumPlanes defines the frustum planes to test
  83989. * @returns true if there is an intersection
  83990. */
  83991. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83992. /**
  83993. * Tests if the bounding sphere center is in between the frustum planes.
  83994. * Used for optimistic fast inclusion.
  83995. * @param frustumPlanes defines the frustum planes to test
  83996. * @returns true if the sphere center is in between the frustum planes
  83997. */
  83998. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83999. /**
  84000. * Tests if a point is inside the bounding sphere
  84001. * @param point defines the point to test
  84002. * @returns true if the point is inside the bounding sphere
  84003. */
  84004. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84005. /**
  84006. * Checks if two sphere intersct
  84007. * @param sphere0 sphere 0
  84008. * @param sphere1 sphere 1
  84009. * @returns true if the speres intersect
  84010. */
  84011. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84012. }
  84013. }
  84014. declare module BABYLON {
  84015. /**
  84016. * Class used to store bounding box information
  84017. */
  84018. export class BoundingBox implements ICullable {
  84019. /**
  84020. * Gets the 8 vectors representing the bounding box in local space
  84021. */
  84022. readonly vectors: Vector3[];
  84023. /**
  84024. * Gets the center of the bounding box in local space
  84025. */
  84026. readonly center: Vector3;
  84027. /**
  84028. * Gets the center of the bounding box in world space
  84029. */
  84030. readonly centerWorld: Vector3;
  84031. /**
  84032. * Gets the extend size in local space
  84033. */
  84034. readonly extendSize: Vector3;
  84035. /**
  84036. * Gets the extend size in world space
  84037. */
  84038. readonly extendSizeWorld: Vector3;
  84039. /**
  84040. * Gets the OBB (object bounding box) directions
  84041. */
  84042. readonly directions: Vector3[];
  84043. /**
  84044. * Gets the 8 vectors representing the bounding box in world space
  84045. */
  84046. readonly vectorsWorld: Vector3[];
  84047. /**
  84048. * Gets the minimum vector in world space
  84049. */
  84050. readonly minimumWorld: Vector3;
  84051. /**
  84052. * Gets the maximum vector in world space
  84053. */
  84054. readonly maximumWorld: Vector3;
  84055. /**
  84056. * Gets the minimum vector in local space
  84057. */
  84058. readonly minimum: Vector3;
  84059. /**
  84060. * Gets the maximum vector in local space
  84061. */
  84062. readonly maximum: Vector3;
  84063. private _worldMatrix;
  84064. private static readonly TmpVector3;
  84065. /**
  84066. * @hidden
  84067. */
  84068. _tag: number;
  84069. /**
  84070. * Creates a new bounding box
  84071. * @param min defines the minimum vector (in local space)
  84072. * @param max defines the maximum vector (in local space)
  84073. * @param worldMatrix defines the new world matrix
  84074. */
  84075. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84076. /**
  84077. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84078. * @param min defines the new minimum vector (in local space)
  84079. * @param max defines the new maximum vector (in local space)
  84080. * @param worldMatrix defines the new world matrix
  84081. */
  84082. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84083. /**
  84084. * Scale the current bounding box by applying a scale factor
  84085. * @param factor defines the scale factor to apply
  84086. * @returns the current bounding box
  84087. */
  84088. scale(factor: number): BoundingBox;
  84089. /**
  84090. * Gets the world matrix of the bounding box
  84091. * @returns a matrix
  84092. */
  84093. getWorldMatrix(): DeepImmutable<Matrix>;
  84094. /** @hidden */
  84095. _update(world: DeepImmutable<Matrix>): void;
  84096. /**
  84097. * Tests if the bounding box is intersecting the frustum planes
  84098. * @param frustumPlanes defines the frustum planes to test
  84099. * @returns true if there is an intersection
  84100. */
  84101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84102. /**
  84103. * Tests if the bounding box is entirely inside the frustum planes
  84104. * @param frustumPlanes defines the frustum planes to test
  84105. * @returns true if there is an inclusion
  84106. */
  84107. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84108. /**
  84109. * Tests if a point is inside the bounding box
  84110. * @param point defines the point to test
  84111. * @returns true if the point is inside the bounding box
  84112. */
  84113. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84114. /**
  84115. * Tests if the bounding box intersects with a bounding sphere
  84116. * @param sphere defines the sphere to test
  84117. * @returns true if there is an intersection
  84118. */
  84119. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84120. /**
  84121. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84122. * @param min defines the min vector to use
  84123. * @param max defines the max vector to use
  84124. * @returns true if there is an intersection
  84125. */
  84126. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84127. /**
  84128. * Tests if two bounding boxes are intersections
  84129. * @param box0 defines the first box to test
  84130. * @param box1 defines the second box to test
  84131. * @returns true if there is an intersection
  84132. */
  84133. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84134. /**
  84135. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84136. * @param minPoint defines the minimum vector of the bounding box
  84137. * @param maxPoint defines the maximum vector of the bounding box
  84138. * @param sphereCenter defines the sphere center
  84139. * @param sphereRadius defines the sphere radius
  84140. * @returns true if there is an intersection
  84141. */
  84142. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84143. /**
  84144. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84145. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84146. * @param frustumPlanes defines the frustum planes to test
  84147. * @return true if there is an inclusion
  84148. */
  84149. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84150. /**
  84151. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84152. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84153. * @param frustumPlanes defines the frustum planes to test
  84154. * @return true if there is an intersection
  84155. */
  84156. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84157. }
  84158. }
  84159. declare module BABYLON {
  84160. /** @hidden */
  84161. export class Collider {
  84162. /** Define if a collision was found */
  84163. collisionFound: boolean;
  84164. /**
  84165. * Define last intersection point in local space
  84166. */
  84167. intersectionPoint: Vector3;
  84168. /**
  84169. * Define last collided mesh
  84170. */
  84171. collidedMesh: Nullable<AbstractMesh>;
  84172. private _collisionPoint;
  84173. private _planeIntersectionPoint;
  84174. private _tempVector;
  84175. private _tempVector2;
  84176. private _tempVector3;
  84177. private _tempVector4;
  84178. private _edge;
  84179. private _baseToVertex;
  84180. private _destinationPoint;
  84181. private _slidePlaneNormal;
  84182. private _displacementVector;
  84183. /** @hidden */
  84184. _radius: Vector3;
  84185. /** @hidden */
  84186. _retry: number;
  84187. private _velocity;
  84188. private _basePoint;
  84189. private _epsilon;
  84190. /** @hidden */
  84191. _velocityWorldLength: number;
  84192. /** @hidden */
  84193. _basePointWorld: Vector3;
  84194. private _velocityWorld;
  84195. private _normalizedVelocity;
  84196. /** @hidden */
  84197. _initialVelocity: Vector3;
  84198. /** @hidden */
  84199. _initialPosition: Vector3;
  84200. private _nearestDistance;
  84201. private _collisionMask;
  84202. get collisionMask(): number;
  84203. set collisionMask(mask: number);
  84204. /**
  84205. * Gets the plane normal used to compute the sliding response (in local space)
  84206. */
  84207. get slidePlaneNormal(): Vector3;
  84208. /** @hidden */
  84209. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84210. /** @hidden */
  84211. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84212. /** @hidden */
  84213. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84214. /** @hidden */
  84215. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84216. /** @hidden */
  84217. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84218. /** @hidden */
  84219. _getResponse(pos: Vector3, vel: Vector3): void;
  84220. }
  84221. }
  84222. declare module BABYLON {
  84223. /**
  84224. * Interface for cullable objects
  84225. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84226. */
  84227. export interface ICullable {
  84228. /**
  84229. * Checks if the object or part of the object is in the frustum
  84230. * @param frustumPlanes Camera near/planes
  84231. * @returns true if the object is in frustum otherwise false
  84232. */
  84233. isInFrustum(frustumPlanes: Plane[]): boolean;
  84234. /**
  84235. * Checks if a cullable object (mesh...) is in the camera frustum
  84236. * Unlike isInFrustum this cheks the full bounding box
  84237. * @param frustumPlanes Camera near/planes
  84238. * @returns true if the object is in frustum otherwise false
  84239. */
  84240. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84241. }
  84242. /**
  84243. * Info for a bounding data of a mesh
  84244. */
  84245. export class BoundingInfo implements ICullable {
  84246. /**
  84247. * Bounding box for the mesh
  84248. */
  84249. readonly boundingBox: BoundingBox;
  84250. /**
  84251. * Bounding sphere for the mesh
  84252. */
  84253. readonly boundingSphere: BoundingSphere;
  84254. private _isLocked;
  84255. private static readonly TmpVector3;
  84256. /**
  84257. * Constructs bounding info
  84258. * @param minimum min vector of the bounding box/sphere
  84259. * @param maximum max vector of the bounding box/sphere
  84260. * @param worldMatrix defines the new world matrix
  84261. */
  84262. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84263. /**
  84264. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84265. * @param min defines the new minimum vector (in local space)
  84266. * @param max defines the new maximum vector (in local space)
  84267. * @param worldMatrix defines the new world matrix
  84268. */
  84269. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84270. /**
  84271. * min vector of the bounding box/sphere
  84272. */
  84273. get minimum(): Vector3;
  84274. /**
  84275. * max vector of the bounding box/sphere
  84276. */
  84277. get maximum(): Vector3;
  84278. /**
  84279. * If the info is locked and won't be updated to avoid perf overhead
  84280. */
  84281. get isLocked(): boolean;
  84282. set isLocked(value: boolean);
  84283. /**
  84284. * Updates the bounding sphere and box
  84285. * @param world world matrix to be used to update
  84286. */
  84287. update(world: DeepImmutable<Matrix>): void;
  84288. /**
  84289. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84290. * @param center New center of the bounding info
  84291. * @param extend New extend of the bounding info
  84292. * @returns the current bounding info
  84293. */
  84294. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84295. /**
  84296. * Scale the current bounding info by applying a scale factor
  84297. * @param factor defines the scale factor to apply
  84298. * @returns the current bounding info
  84299. */
  84300. scale(factor: number): BoundingInfo;
  84301. /**
  84302. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84303. * @param frustumPlanes defines the frustum to test
  84304. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84305. * @returns true if the bounding info is in the frustum planes
  84306. */
  84307. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84308. /**
  84309. * Gets the world distance between the min and max points of the bounding box
  84310. */
  84311. get diagonalLength(): number;
  84312. /**
  84313. * Checks if a cullable object (mesh...) is in the camera frustum
  84314. * Unlike isInFrustum this cheks the full bounding box
  84315. * @param frustumPlanes Camera near/planes
  84316. * @returns true if the object is in frustum otherwise false
  84317. */
  84318. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84319. /** @hidden */
  84320. _checkCollision(collider: Collider): boolean;
  84321. /**
  84322. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84323. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84324. * @param point the point to check intersection with
  84325. * @returns if the point intersects
  84326. */
  84327. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84328. /**
  84329. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84330. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84331. * @param boundingInfo the bounding info to check intersection with
  84332. * @param precise if the intersection should be done using OBB
  84333. * @returns if the bounding info intersects
  84334. */
  84335. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /**
  84340. * Extracts minimum and maximum values from a list of indexed positions
  84341. * @param positions defines the positions to use
  84342. * @param indices defines the indices to the positions
  84343. * @param indexStart defines the start index
  84344. * @param indexCount defines the end index
  84345. * @param bias defines bias value to add to the result
  84346. * @return minimum and maximum values
  84347. */
  84348. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84349. minimum: Vector3;
  84350. maximum: Vector3;
  84351. };
  84352. /**
  84353. * Extracts minimum and maximum values from a list of positions
  84354. * @param positions defines the positions to use
  84355. * @param start defines the start index in the positions array
  84356. * @param count defines the number of positions to handle
  84357. * @param bias defines bias value to add to the result
  84358. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84359. * @return minimum and maximum values
  84360. */
  84361. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84362. minimum: Vector3;
  84363. maximum: Vector3;
  84364. };
  84365. }
  84366. declare module BABYLON {
  84367. /** @hidden */
  84368. export class WebGLDataBuffer extends DataBuffer {
  84369. private _buffer;
  84370. constructor(resource: WebGLBuffer);
  84371. get underlyingResource(): any;
  84372. }
  84373. }
  84374. declare module BABYLON {
  84375. /** @hidden */
  84376. export class WebGLPipelineContext implements IPipelineContext {
  84377. engine: ThinEngine;
  84378. program: Nullable<WebGLProgram>;
  84379. context?: WebGLRenderingContext;
  84380. vertexShader?: WebGLShader;
  84381. fragmentShader?: WebGLShader;
  84382. isParallelCompiled: boolean;
  84383. onCompiled?: () => void;
  84384. transformFeedback?: WebGLTransformFeedback | null;
  84385. vertexCompilationError: Nullable<string>;
  84386. fragmentCompilationError: Nullable<string>;
  84387. programLinkError: Nullable<string>;
  84388. programValidationError: Nullable<string>;
  84389. get isAsync(): boolean;
  84390. get isReady(): boolean;
  84391. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84392. _getVertexShaderCode(): string | null;
  84393. _getFragmentShaderCode(): string | null;
  84394. }
  84395. }
  84396. declare module BABYLON {
  84397. interface ThinEngine {
  84398. /**
  84399. * Create an uniform buffer
  84400. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84401. * @param elements defines the content of the uniform buffer
  84402. * @returns the webGL uniform buffer
  84403. */
  84404. createUniformBuffer(elements: FloatArray): DataBuffer;
  84405. /**
  84406. * Create a dynamic uniform buffer
  84407. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84408. * @param elements defines the content of the uniform buffer
  84409. * @returns the webGL uniform buffer
  84410. */
  84411. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84412. /**
  84413. * Update an existing uniform buffer
  84414. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84415. * @param uniformBuffer defines the target uniform buffer
  84416. * @param elements defines the content to update
  84417. * @param offset defines the offset in the uniform buffer where update should start
  84418. * @param count defines the size of the data to update
  84419. */
  84420. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84421. /**
  84422. * Bind an uniform buffer to the current webGL context
  84423. * @param buffer defines the buffer to bind
  84424. */
  84425. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84426. /**
  84427. * Bind a buffer to the current webGL context at a given location
  84428. * @param buffer defines the buffer to bind
  84429. * @param location defines the index where to bind the buffer
  84430. */
  84431. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84432. /**
  84433. * Bind a specific block at a given index in a specific shader program
  84434. * @param pipelineContext defines the pipeline context to use
  84435. * @param blockName defines the block name
  84436. * @param index defines the index where to bind the block
  84437. */
  84438. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84439. }
  84440. }
  84441. declare module BABYLON {
  84442. /**
  84443. * Uniform buffer objects.
  84444. *
  84445. * Handles blocks of uniform on the GPU.
  84446. *
  84447. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84448. *
  84449. * For more information, please refer to :
  84450. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84451. */
  84452. export class UniformBuffer {
  84453. private _engine;
  84454. private _buffer;
  84455. private _data;
  84456. private _bufferData;
  84457. private _dynamic?;
  84458. private _uniformLocations;
  84459. private _uniformSizes;
  84460. private _uniformLocationPointer;
  84461. private _needSync;
  84462. private _noUBO;
  84463. private _currentEffect;
  84464. /** @hidden */
  84465. _alreadyBound: boolean;
  84466. private static _MAX_UNIFORM_SIZE;
  84467. private static _tempBuffer;
  84468. /**
  84469. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84470. * This is dynamic to allow compat with webgl 1 and 2.
  84471. * You will need to pass the name of the uniform as well as the value.
  84472. */
  84473. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84474. /**
  84475. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84476. * This is dynamic to allow compat with webgl 1 and 2.
  84477. * You will need to pass the name of the uniform as well as the value.
  84478. */
  84479. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84480. /**
  84481. * Lambda to Update a single float in a uniform buffer.
  84482. * This is dynamic to allow compat with webgl 1 and 2.
  84483. * You will need to pass the name of the uniform as well as the value.
  84484. */
  84485. updateFloat: (name: string, x: number) => void;
  84486. /**
  84487. * Lambda to Update a vec2 of float in a uniform buffer.
  84488. * This is dynamic to allow compat with webgl 1 and 2.
  84489. * You will need to pass the name of the uniform as well as the value.
  84490. */
  84491. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84492. /**
  84493. * Lambda to Update a vec3 of float in a uniform buffer.
  84494. * This is dynamic to allow compat with webgl 1 and 2.
  84495. * You will need to pass the name of the uniform as well as the value.
  84496. */
  84497. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84498. /**
  84499. * Lambda to Update a vec4 of float in a uniform buffer.
  84500. * This is dynamic to allow compat with webgl 1 and 2.
  84501. * You will need to pass the name of the uniform as well as the value.
  84502. */
  84503. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84504. /**
  84505. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84506. * This is dynamic to allow compat with webgl 1 and 2.
  84507. * You will need to pass the name of the uniform as well as the value.
  84508. */
  84509. updateMatrix: (name: string, mat: Matrix) => void;
  84510. /**
  84511. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84512. * This is dynamic to allow compat with webgl 1 and 2.
  84513. * You will need to pass the name of the uniform as well as the value.
  84514. */
  84515. updateVector3: (name: string, vector: Vector3) => void;
  84516. /**
  84517. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84518. * This is dynamic to allow compat with webgl 1 and 2.
  84519. * You will need to pass the name of the uniform as well as the value.
  84520. */
  84521. updateVector4: (name: string, vector: Vector4) => void;
  84522. /**
  84523. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84524. * This is dynamic to allow compat with webgl 1 and 2.
  84525. * You will need to pass the name of the uniform as well as the value.
  84526. */
  84527. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84528. /**
  84529. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84530. * This is dynamic to allow compat with webgl 1 and 2.
  84531. * You will need to pass the name of the uniform as well as the value.
  84532. */
  84533. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84534. /**
  84535. * Instantiates a new Uniform buffer objects.
  84536. *
  84537. * Handles blocks of uniform on the GPU.
  84538. *
  84539. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84540. *
  84541. * For more information, please refer to :
  84542. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84543. * @param engine Define the engine the buffer is associated with
  84544. * @param data Define the data contained in the buffer
  84545. * @param dynamic Define if the buffer is updatable
  84546. */
  84547. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84548. /**
  84549. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84550. * or just falling back on setUniformXXX calls.
  84551. */
  84552. get useUbo(): boolean;
  84553. /**
  84554. * Indicates if the WebGL underlying uniform buffer is in sync
  84555. * with the javascript cache data.
  84556. */
  84557. get isSync(): boolean;
  84558. /**
  84559. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84560. * Also, a dynamic UniformBuffer will disable cache verification and always
  84561. * update the underlying WebGL uniform buffer to the GPU.
  84562. * @returns if Dynamic, otherwise false
  84563. */
  84564. isDynamic(): boolean;
  84565. /**
  84566. * The data cache on JS side.
  84567. * @returns the underlying data as a float array
  84568. */
  84569. getData(): Float32Array;
  84570. /**
  84571. * The underlying WebGL Uniform buffer.
  84572. * @returns the webgl buffer
  84573. */
  84574. getBuffer(): Nullable<DataBuffer>;
  84575. /**
  84576. * std140 layout specifies how to align data within an UBO structure.
  84577. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84578. * for specs.
  84579. */
  84580. private _fillAlignment;
  84581. /**
  84582. * Adds an uniform in the buffer.
  84583. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84584. * for the layout to be correct !
  84585. * @param name Name of the uniform, as used in the uniform block in the shader.
  84586. * @param size Data size, or data directly.
  84587. */
  84588. addUniform(name: string, size: number | number[]): void;
  84589. /**
  84590. * Adds a Matrix 4x4 to the uniform buffer.
  84591. * @param name Name of the uniform, as used in the uniform block in the shader.
  84592. * @param mat A 4x4 matrix.
  84593. */
  84594. addMatrix(name: string, mat: Matrix): void;
  84595. /**
  84596. * Adds a vec2 to the uniform buffer.
  84597. * @param name Name of the uniform, as used in the uniform block in the shader.
  84598. * @param x Define the x component value of the vec2
  84599. * @param y Define the y component value of the vec2
  84600. */
  84601. addFloat2(name: string, x: number, y: number): void;
  84602. /**
  84603. * Adds a vec3 to the uniform buffer.
  84604. * @param name Name of the uniform, as used in the uniform block in the shader.
  84605. * @param x Define the x component value of the vec3
  84606. * @param y Define the y component value of the vec3
  84607. * @param z Define the z component value of the vec3
  84608. */
  84609. addFloat3(name: string, x: number, y: number, z: number): void;
  84610. /**
  84611. * Adds a vec3 to the uniform buffer.
  84612. * @param name Name of the uniform, as used in the uniform block in the shader.
  84613. * @param color Define the vec3 from a Color
  84614. */
  84615. addColor3(name: string, color: Color3): void;
  84616. /**
  84617. * Adds a vec4 to the uniform buffer.
  84618. * @param name Name of the uniform, as used in the uniform block in the shader.
  84619. * @param color Define the rgb components from a Color
  84620. * @param alpha Define the a component of the vec4
  84621. */
  84622. addColor4(name: string, color: Color3, alpha: number): void;
  84623. /**
  84624. * Adds a vec3 to the uniform buffer.
  84625. * @param name Name of the uniform, as used in the uniform block in the shader.
  84626. * @param vector Define the vec3 components from a Vector
  84627. */
  84628. addVector3(name: string, vector: Vector3): void;
  84629. /**
  84630. * Adds a Matrix 3x3 to the uniform buffer.
  84631. * @param name Name of the uniform, as used in the uniform block in the shader.
  84632. */
  84633. addMatrix3x3(name: string): void;
  84634. /**
  84635. * Adds a Matrix 2x2 to the uniform buffer.
  84636. * @param name Name of the uniform, as used in the uniform block in the shader.
  84637. */
  84638. addMatrix2x2(name: string): void;
  84639. /**
  84640. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84641. */
  84642. create(): void;
  84643. /** @hidden */
  84644. _rebuild(): void;
  84645. /**
  84646. * Updates the WebGL Uniform Buffer on the GPU.
  84647. * If the `dynamic` flag is set to true, no cache comparison is done.
  84648. * Otherwise, the buffer will be updated only if the cache differs.
  84649. */
  84650. update(): void;
  84651. /**
  84652. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84653. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84654. * @param data Define the flattened data
  84655. * @param size Define the size of the data.
  84656. */
  84657. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84658. private _valueCache;
  84659. private _cacheMatrix;
  84660. private _updateMatrix3x3ForUniform;
  84661. private _updateMatrix3x3ForEffect;
  84662. private _updateMatrix2x2ForEffect;
  84663. private _updateMatrix2x2ForUniform;
  84664. private _updateFloatForEffect;
  84665. private _updateFloatForUniform;
  84666. private _updateFloat2ForEffect;
  84667. private _updateFloat2ForUniform;
  84668. private _updateFloat3ForEffect;
  84669. private _updateFloat3ForUniform;
  84670. private _updateFloat4ForEffect;
  84671. private _updateFloat4ForUniform;
  84672. private _updateMatrixForEffect;
  84673. private _updateMatrixForUniform;
  84674. private _updateVector3ForEffect;
  84675. private _updateVector3ForUniform;
  84676. private _updateVector4ForEffect;
  84677. private _updateVector4ForUniform;
  84678. private _updateColor3ForEffect;
  84679. private _updateColor3ForUniform;
  84680. private _updateColor4ForEffect;
  84681. private _updateColor4ForUniform;
  84682. /**
  84683. * Sets a sampler uniform on the effect.
  84684. * @param name Define the name of the sampler.
  84685. * @param texture Define the texture to set in the sampler
  84686. */
  84687. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84688. /**
  84689. * Directly updates the value of the uniform in the cache AND on the GPU.
  84690. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84691. * @param data Define the flattened data
  84692. */
  84693. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84694. /**
  84695. * Binds this uniform buffer to an effect.
  84696. * @param effect Define the effect to bind the buffer to
  84697. * @param name Name of the uniform block in the shader.
  84698. */
  84699. bindToEffect(effect: Effect, name: string): void;
  84700. /**
  84701. * Disposes the uniform buffer.
  84702. */
  84703. dispose(): void;
  84704. }
  84705. }
  84706. declare module BABYLON {
  84707. /**
  84708. * Enum that determines the text-wrapping mode to use.
  84709. */
  84710. export enum InspectableType {
  84711. /**
  84712. * Checkbox for booleans
  84713. */
  84714. Checkbox = 0,
  84715. /**
  84716. * Sliders for numbers
  84717. */
  84718. Slider = 1,
  84719. /**
  84720. * Vector3
  84721. */
  84722. Vector3 = 2,
  84723. /**
  84724. * Quaternions
  84725. */
  84726. Quaternion = 3,
  84727. /**
  84728. * Color3
  84729. */
  84730. Color3 = 4,
  84731. /**
  84732. * String
  84733. */
  84734. String = 5
  84735. }
  84736. /**
  84737. * Interface used to define custom inspectable properties.
  84738. * This interface is used by the inspector to display custom property grids
  84739. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84740. */
  84741. export interface IInspectable {
  84742. /**
  84743. * Gets the label to display
  84744. */
  84745. label: string;
  84746. /**
  84747. * Gets the name of the property to edit
  84748. */
  84749. propertyName: string;
  84750. /**
  84751. * Gets the type of the editor to use
  84752. */
  84753. type: InspectableType;
  84754. /**
  84755. * Gets the minimum value of the property when using in "slider" mode
  84756. */
  84757. min?: number;
  84758. /**
  84759. * Gets the maximum value of the property when using in "slider" mode
  84760. */
  84761. max?: number;
  84762. /**
  84763. * Gets the setp to use when using in "slider" mode
  84764. */
  84765. step?: number;
  84766. }
  84767. }
  84768. declare module BABYLON {
  84769. /**
  84770. * Class used to provide helper for timing
  84771. */
  84772. export class TimingTools {
  84773. /**
  84774. * Polyfill for setImmediate
  84775. * @param action defines the action to execute after the current execution block
  84776. */
  84777. static SetImmediate(action: () => void): void;
  84778. }
  84779. }
  84780. declare module BABYLON {
  84781. /**
  84782. * Class used to enable instatition of objects by class name
  84783. */
  84784. export class InstantiationTools {
  84785. /**
  84786. * Use this object to register external classes like custom textures or material
  84787. * to allow the laoders to instantiate them
  84788. */
  84789. static RegisteredExternalClasses: {
  84790. [key: string]: Object;
  84791. };
  84792. /**
  84793. * Tries to instantiate a new object from a given class name
  84794. * @param className defines the class name to instantiate
  84795. * @returns the new object or null if the system was not able to do the instantiation
  84796. */
  84797. static Instantiate(className: string): any;
  84798. }
  84799. }
  84800. declare module BABYLON {
  84801. /**
  84802. * Define options used to create a depth texture
  84803. */
  84804. export class DepthTextureCreationOptions {
  84805. /** Specifies whether or not a stencil should be allocated in the texture */
  84806. generateStencil?: boolean;
  84807. /** Specifies whether or not bilinear filtering is enable on the texture */
  84808. bilinearFiltering?: boolean;
  84809. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84810. comparisonFunction?: number;
  84811. /** Specifies if the created texture is a cube texture */
  84812. isCube?: boolean;
  84813. }
  84814. }
  84815. declare module BABYLON {
  84816. interface ThinEngine {
  84817. /**
  84818. * Creates a depth stencil cube texture.
  84819. * This is only available in WebGL 2.
  84820. * @param size The size of face edge in the cube texture.
  84821. * @param options The options defining the cube texture.
  84822. * @returns The cube texture
  84823. */
  84824. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  84825. /**
  84826. * Creates a cube texture
  84827. * @param rootUrl defines the url where the files to load is located
  84828. * @param scene defines the current scene
  84829. * @param files defines the list of files to load (1 per face)
  84830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84831. * @param onLoad defines an optional callback raised when the texture is loaded
  84832. * @param onError defines an optional callback raised if there is an issue to load the texture
  84833. * @param format defines the format of the data
  84834. * @param forcedExtension defines the extension to use to pick the right loader
  84835. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84838. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84839. * @returns the cube texture as an InternalTexture
  84840. */
  84841. 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;
  84842. /**
  84843. * Creates a cube texture
  84844. * @param rootUrl defines the url where the files to load is located
  84845. * @param scene defines the current scene
  84846. * @param files defines the list of files to load (1 per face)
  84847. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84848. * @param onLoad defines an optional callback raised when the texture is loaded
  84849. * @param onError defines an optional callback raised if there is an issue to load the texture
  84850. * @param format defines the format of the data
  84851. * @param forcedExtension defines the extension to use to pick the right loader
  84852. * @returns the cube texture as an InternalTexture
  84853. */
  84854. 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;
  84855. /**
  84856. * Creates a cube texture
  84857. * @param rootUrl defines the url where the files to load is located
  84858. * @param scene defines the current scene
  84859. * @param files defines the list of files to load (1 per face)
  84860. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84861. * @param onLoad defines an optional callback raised when the texture is loaded
  84862. * @param onError defines an optional callback raised if there is an issue to load the texture
  84863. * @param format defines the format of the data
  84864. * @param forcedExtension defines the extension to use to pick the right loader
  84865. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84866. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84867. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84868. * @returns the cube texture as an InternalTexture
  84869. */
  84870. 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;
  84871. /** @hidden */
  84872. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  84873. /** @hidden */
  84874. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  84875. /** @hidden */
  84876. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84877. /** @hidden */
  84878. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84879. /**
  84880. * @hidden
  84881. */
  84882. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84883. }
  84884. }
  84885. declare module BABYLON {
  84886. /**
  84887. * Class for creating a cube texture
  84888. */
  84889. export class CubeTexture extends BaseTexture {
  84890. private _delayedOnLoad;
  84891. /**
  84892. * Observable triggered once the texture has been loaded.
  84893. */
  84894. onLoadObservable: Observable<CubeTexture>;
  84895. /**
  84896. * The url of the texture
  84897. */
  84898. url: string;
  84899. /**
  84900. * Gets or sets the center of the bounding box associated with the cube texture.
  84901. * It must define where the camera used to render the texture was set
  84902. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84903. */
  84904. boundingBoxPosition: Vector3;
  84905. private _boundingBoxSize;
  84906. /**
  84907. * Gets or sets the size of the bounding box associated with the cube texture
  84908. * When defined, the cubemap will switch to local mode
  84909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84910. * @example https://www.babylonjs-playground.com/#RNASML
  84911. */
  84912. set boundingBoxSize(value: Vector3);
  84913. /**
  84914. * Returns the bounding box size
  84915. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84916. */
  84917. get boundingBoxSize(): Vector3;
  84918. protected _rotationY: number;
  84919. /**
  84920. * Sets texture matrix rotation angle around Y axis in radians.
  84921. */
  84922. set rotationY(value: number);
  84923. /**
  84924. * Gets texture matrix rotation angle around Y axis radians.
  84925. */
  84926. get rotationY(): number;
  84927. /**
  84928. * Are mip maps generated for this texture or not.
  84929. */
  84930. get noMipmap(): boolean;
  84931. private _noMipmap;
  84932. private _files;
  84933. protected _forcedExtension: Nullable<string>;
  84934. private _extensions;
  84935. private _textureMatrix;
  84936. private _format;
  84937. private _createPolynomials;
  84938. /**
  84939. * Creates a cube texture from an array of image urls
  84940. * @param files defines an array of image urls
  84941. * @param scene defines the hosting scene
  84942. * @param noMipmap specifies if mip maps are not used
  84943. * @returns a cube texture
  84944. */
  84945. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  84946. /**
  84947. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  84948. * @param url defines the url of the prefiltered texture
  84949. * @param scene defines the scene the texture is attached to
  84950. * @param forcedExtension defines the extension of the file if different from the url
  84951. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84952. * @return the prefiltered texture
  84953. */
  84954. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  84955. /**
  84956. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  84957. * as prefiltered data.
  84958. * @param rootUrl defines the url of the texture or the root name of the six images
  84959. * @param null defines the scene or engine the texture is attached to
  84960. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  84961. * @param noMipmap defines if mipmaps should be created or not
  84962. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  84963. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  84964. * @param onError defines a callback triggered in case of error during load
  84965. * @param format defines the internal format to use for the texture once loaded
  84966. * @param prefiltered defines whether or not the texture is created from prefiltered data
  84967. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  84968. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84969. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84970. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84971. * @return the cube texture
  84972. */
  84973. 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);
  84974. /**
  84975. * Get the current class name of the texture useful for serialization or dynamic coding.
  84976. * @returns "CubeTexture"
  84977. */
  84978. getClassName(): string;
  84979. /**
  84980. * Update the url (and optional buffer) of this texture if url was null during construction.
  84981. * @param url the url of the texture
  84982. * @param forcedExtension defines the extension to use
  84983. * @param onLoad callback called when the texture is loaded (defaults to null)
  84984. * @param prefiltered Defines whether the updated texture is prefiltered or not
  84985. */
  84986. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  84987. /**
  84988. * Delays loading of the cube texture
  84989. * @param forcedExtension defines the extension to use
  84990. */
  84991. delayLoad(forcedExtension?: string): void;
  84992. /**
  84993. * Returns the reflection texture matrix
  84994. * @returns the reflection texture matrix
  84995. */
  84996. getReflectionTextureMatrix(): Matrix;
  84997. /**
  84998. * Sets the reflection texture matrix
  84999. * @param value Reflection texture matrix
  85000. */
  85001. setReflectionTextureMatrix(value: Matrix): void;
  85002. /**
  85003. * Parses text to create a cube texture
  85004. * @param parsedTexture define the serialized text to read from
  85005. * @param scene defines the hosting scene
  85006. * @param rootUrl defines the root url of the cube texture
  85007. * @returns a cube texture
  85008. */
  85009. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85010. /**
  85011. * Makes a clone, or deep copy, of the cube texture
  85012. * @returns a new cube texture
  85013. */
  85014. clone(): CubeTexture;
  85015. }
  85016. }
  85017. declare module BABYLON {
  85018. /**
  85019. * Manages the defines for the Material
  85020. */
  85021. export class MaterialDefines {
  85022. /** @hidden */
  85023. protected _keys: string[];
  85024. private _isDirty;
  85025. /** @hidden */
  85026. _renderId: number;
  85027. /** @hidden */
  85028. _areLightsDirty: boolean;
  85029. /** @hidden */
  85030. _areLightsDisposed: boolean;
  85031. /** @hidden */
  85032. _areAttributesDirty: boolean;
  85033. /** @hidden */
  85034. _areTexturesDirty: boolean;
  85035. /** @hidden */
  85036. _areFresnelDirty: boolean;
  85037. /** @hidden */
  85038. _areMiscDirty: boolean;
  85039. /** @hidden */
  85040. _areImageProcessingDirty: boolean;
  85041. /** @hidden */
  85042. _normals: boolean;
  85043. /** @hidden */
  85044. _uvs: boolean;
  85045. /** @hidden */
  85046. _needNormals: boolean;
  85047. /** @hidden */
  85048. _needUVs: boolean;
  85049. [id: string]: any;
  85050. /**
  85051. * Specifies if the material needs to be re-calculated
  85052. */
  85053. get isDirty(): boolean;
  85054. /**
  85055. * Marks the material to indicate that it has been re-calculated
  85056. */
  85057. markAsProcessed(): void;
  85058. /**
  85059. * Marks the material to indicate that it needs to be re-calculated
  85060. */
  85061. markAsUnprocessed(): void;
  85062. /**
  85063. * Marks the material to indicate all of its defines need to be re-calculated
  85064. */
  85065. markAllAsDirty(): void;
  85066. /**
  85067. * Marks the material to indicate that image processing needs to be re-calculated
  85068. */
  85069. markAsImageProcessingDirty(): void;
  85070. /**
  85071. * Marks the material to indicate the lights need to be re-calculated
  85072. * @param disposed Defines whether the light is dirty due to dispose or not
  85073. */
  85074. markAsLightDirty(disposed?: boolean): void;
  85075. /**
  85076. * Marks the attribute state as changed
  85077. */
  85078. markAsAttributesDirty(): void;
  85079. /**
  85080. * Marks the texture state as changed
  85081. */
  85082. markAsTexturesDirty(): void;
  85083. /**
  85084. * Marks the fresnel state as changed
  85085. */
  85086. markAsFresnelDirty(): void;
  85087. /**
  85088. * Marks the misc state as changed
  85089. */
  85090. markAsMiscDirty(): void;
  85091. /**
  85092. * Rebuilds the material defines
  85093. */
  85094. rebuild(): void;
  85095. /**
  85096. * Specifies if two material defines are equal
  85097. * @param other - A material define instance to compare to
  85098. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85099. */
  85100. isEqual(other: MaterialDefines): boolean;
  85101. /**
  85102. * Clones this instance's defines to another instance
  85103. * @param other - material defines to clone values to
  85104. */
  85105. cloneTo(other: MaterialDefines): void;
  85106. /**
  85107. * Resets the material define values
  85108. */
  85109. reset(): void;
  85110. /**
  85111. * Converts the material define values to a string
  85112. * @returns - String of material define information
  85113. */
  85114. toString(): string;
  85115. }
  85116. }
  85117. declare module BABYLON {
  85118. /**
  85119. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85120. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85121. * 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;
  85122. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85123. */
  85124. export class ColorCurves {
  85125. private _dirty;
  85126. private _tempColor;
  85127. private _globalCurve;
  85128. private _highlightsCurve;
  85129. private _midtonesCurve;
  85130. private _shadowsCurve;
  85131. private _positiveCurve;
  85132. private _negativeCurve;
  85133. private _globalHue;
  85134. private _globalDensity;
  85135. private _globalSaturation;
  85136. private _globalExposure;
  85137. /**
  85138. * Gets the global Hue value.
  85139. * 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).
  85140. */
  85141. get globalHue(): number;
  85142. /**
  85143. * Sets the global Hue value.
  85144. * 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).
  85145. */
  85146. set globalHue(value: number);
  85147. /**
  85148. * Gets the global Density value.
  85149. * 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.
  85150. * Values less than zero provide a filter of opposite hue.
  85151. */
  85152. get globalDensity(): number;
  85153. /**
  85154. * Sets the global Density value.
  85155. * 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.
  85156. * Values less than zero provide a filter of opposite hue.
  85157. */
  85158. set globalDensity(value: number);
  85159. /**
  85160. * Gets the global Saturation value.
  85161. * 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.
  85162. */
  85163. get globalSaturation(): number;
  85164. /**
  85165. * Sets the global Saturation value.
  85166. * 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.
  85167. */
  85168. set globalSaturation(value: number);
  85169. /**
  85170. * Gets the global Exposure value.
  85171. * 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.
  85172. */
  85173. get globalExposure(): number;
  85174. /**
  85175. * Sets the global Exposure value.
  85176. * 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.
  85177. */
  85178. set globalExposure(value: number);
  85179. private _highlightsHue;
  85180. private _highlightsDensity;
  85181. private _highlightsSaturation;
  85182. private _highlightsExposure;
  85183. /**
  85184. * Gets the highlights Hue value.
  85185. * 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).
  85186. */
  85187. get highlightsHue(): number;
  85188. /**
  85189. * Sets the highlights Hue value.
  85190. * 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).
  85191. */
  85192. set highlightsHue(value: number);
  85193. /**
  85194. * Gets the highlights Density value.
  85195. * 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.
  85196. * Values less than zero provide a filter of opposite hue.
  85197. */
  85198. get highlightsDensity(): number;
  85199. /**
  85200. * Sets the highlights Density value.
  85201. * 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.
  85202. * Values less than zero provide a filter of opposite hue.
  85203. */
  85204. set highlightsDensity(value: number);
  85205. /**
  85206. * Gets the highlights Saturation value.
  85207. * 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.
  85208. */
  85209. get highlightsSaturation(): number;
  85210. /**
  85211. * Sets the highlights Saturation value.
  85212. * 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.
  85213. */
  85214. set highlightsSaturation(value: number);
  85215. /**
  85216. * Gets the highlights Exposure value.
  85217. * 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.
  85218. */
  85219. get highlightsExposure(): number;
  85220. /**
  85221. * Sets the highlights Exposure value.
  85222. * 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.
  85223. */
  85224. set highlightsExposure(value: number);
  85225. private _midtonesHue;
  85226. private _midtonesDensity;
  85227. private _midtonesSaturation;
  85228. private _midtonesExposure;
  85229. /**
  85230. * Gets the midtones Hue value.
  85231. * 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).
  85232. */
  85233. get midtonesHue(): number;
  85234. /**
  85235. * Sets the midtones Hue value.
  85236. * 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).
  85237. */
  85238. set midtonesHue(value: number);
  85239. /**
  85240. * Gets the midtones Density value.
  85241. * 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.
  85242. * Values less than zero provide a filter of opposite hue.
  85243. */
  85244. get midtonesDensity(): number;
  85245. /**
  85246. * Sets the midtones Density value.
  85247. * 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.
  85248. * Values less than zero provide a filter of opposite hue.
  85249. */
  85250. set midtonesDensity(value: number);
  85251. /**
  85252. * Gets the midtones Saturation value.
  85253. * 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.
  85254. */
  85255. get midtonesSaturation(): number;
  85256. /**
  85257. * Sets the midtones Saturation value.
  85258. * 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.
  85259. */
  85260. set midtonesSaturation(value: number);
  85261. /**
  85262. * Gets the midtones Exposure value.
  85263. * 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.
  85264. */
  85265. get midtonesExposure(): number;
  85266. /**
  85267. * Sets the midtones Exposure value.
  85268. * 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.
  85269. */
  85270. set midtonesExposure(value: number);
  85271. private _shadowsHue;
  85272. private _shadowsDensity;
  85273. private _shadowsSaturation;
  85274. private _shadowsExposure;
  85275. /**
  85276. * Gets the shadows Hue value.
  85277. * 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).
  85278. */
  85279. get shadowsHue(): number;
  85280. /**
  85281. * Sets the shadows Hue value.
  85282. * 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).
  85283. */
  85284. set shadowsHue(value: number);
  85285. /**
  85286. * Gets the shadows Density value.
  85287. * 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.
  85288. * Values less than zero provide a filter of opposite hue.
  85289. */
  85290. get shadowsDensity(): number;
  85291. /**
  85292. * Sets the shadows Density value.
  85293. * 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.
  85294. * Values less than zero provide a filter of opposite hue.
  85295. */
  85296. set shadowsDensity(value: number);
  85297. /**
  85298. * Gets the shadows Saturation value.
  85299. * 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.
  85300. */
  85301. get shadowsSaturation(): number;
  85302. /**
  85303. * Sets the shadows Saturation value.
  85304. * 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.
  85305. */
  85306. set shadowsSaturation(value: number);
  85307. /**
  85308. * Gets the shadows Exposure value.
  85309. * 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.
  85310. */
  85311. get shadowsExposure(): number;
  85312. /**
  85313. * Sets the shadows Exposure value.
  85314. * 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.
  85315. */
  85316. set shadowsExposure(value: number);
  85317. /**
  85318. * Returns the class name
  85319. * @returns The class name
  85320. */
  85321. getClassName(): string;
  85322. /**
  85323. * Binds the color curves to the shader.
  85324. * @param colorCurves The color curve to bind
  85325. * @param effect The effect to bind to
  85326. * @param positiveUniform The positive uniform shader parameter
  85327. * @param neutralUniform The neutral uniform shader parameter
  85328. * @param negativeUniform The negative uniform shader parameter
  85329. */
  85330. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85331. /**
  85332. * Prepare the list of uniforms associated with the ColorCurves effects.
  85333. * @param uniformsList The list of uniforms used in the effect
  85334. */
  85335. static PrepareUniforms(uniformsList: string[]): void;
  85336. /**
  85337. * Returns color grading data based on a hue, density, saturation and exposure value.
  85338. * @param filterHue The hue of the color filter.
  85339. * @param filterDensity The density of the color filter.
  85340. * @param saturation The saturation.
  85341. * @param exposure The exposure.
  85342. * @param result The result data container.
  85343. */
  85344. private getColorGradingDataToRef;
  85345. /**
  85346. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85347. * @param value The input slider value in range [-100,100].
  85348. * @returns Adjusted value.
  85349. */
  85350. private static applyColorGradingSliderNonlinear;
  85351. /**
  85352. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85353. * @param hue The hue (H) input.
  85354. * @param saturation The saturation (S) input.
  85355. * @param brightness The brightness (B) input.
  85356. * @result An RGBA color represented as Vector4.
  85357. */
  85358. private static fromHSBToRef;
  85359. /**
  85360. * Returns a value clamped between min and max
  85361. * @param value The value to clamp
  85362. * @param min The minimum of value
  85363. * @param max The maximum of value
  85364. * @returns The clamped value.
  85365. */
  85366. private static clamp;
  85367. /**
  85368. * Clones the current color curve instance.
  85369. * @return The cloned curves
  85370. */
  85371. clone(): ColorCurves;
  85372. /**
  85373. * Serializes the current color curve instance to a json representation.
  85374. * @return a JSON representation
  85375. */
  85376. serialize(): any;
  85377. /**
  85378. * Parses the color curve from a json representation.
  85379. * @param source the JSON source to parse
  85380. * @return The parsed curves
  85381. */
  85382. static Parse(source: any): ColorCurves;
  85383. }
  85384. }
  85385. declare module BABYLON {
  85386. /**
  85387. * Interface to follow in your material defines to integrate easily the
  85388. * Image proccessing functions.
  85389. * @hidden
  85390. */
  85391. export interface IImageProcessingConfigurationDefines {
  85392. IMAGEPROCESSING: boolean;
  85393. VIGNETTE: boolean;
  85394. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85395. VIGNETTEBLENDMODEOPAQUE: boolean;
  85396. TONEMAPPING: boolean;
  85397. TONEMAPPING_ACES: boolean;
  85398. CONTRAST: boolean;
  85399. EXPOSURE: boolean;
  85400. COLORCURVES: boolean;
  85401. COLORGRADING: boolean;
  85402. COLORGRADING3D: boolean;
  85403. SAMPLER3DGREENDEPTH: boolean;
  85404. SAMPLER3DBGRMAP: boolean;
  85405. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85406. }
  85407. /**
  85408. * @hidden
  85409. */
  85410. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85411. IMAGEPROCESSING: boolean;
  85412. VIGNETTE: boolean;
  85413. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85414. VIGNETTEBLENDMODEOPAQUE: boolean;
  85415. TONEMAPPING: boolean;
  85416. TONEMAPPING_ACES: boolean;
  85417. CONTRAST: boolean;
  85418. COLORCURVES: boolean;
  85419. COLORGRADING: boolean;
  85420. COLORGRADING3D: boolean;
  85421. SAMPLER3DGREENDEPTH: boolean;
  85422. SAMPLER3DBGRMAP: boolean;
  85423. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85424. EXPOSURE: boolean;
  85425. constructor();
  85426. }
  85427. /**
  85428. * This groups together the common properties used for image processing either in direct forward pass
  85429. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85430. * or not.
  85431. */
  85432. export class ImageProcessingConfiguration {
  85433. /**
  85434. * Default tone mapping applied in BabylonJS.
  85435. */
  85436. static readonly TONEMAPPING_STANDARD: number;
  85437. /**
  85438. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85439. * to other engines rendering to increase portability.
  85440. */
  85441. static readonly TONEMAPPING_ACES: number;
  85442. /**
  85443. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85444. */
  85445. colorCurves: Nullable<ColorCurves>;
  85446. private _colorCurvesEnabled;
  85447. /**
  85448. * Gets wether the color curves effect is enabled.
  85449. */
  85450. get colorCurvesEnabled(): boolean;
  85451. /**
  85452. * Sets wether the color curves effect is enabled.
  85453. */
  85454. set colorCurvesEnabled(value: boolean);
  85455. private _colorGradingTexture;
  85456. /**
  85457. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85458. */
  85459. get colorGradingTexture(): Nullable<BaseTexture>;
  85460. /**
  85461. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85462. */
  85463. set colorGradingTexture(value: Nullable<BaseTexture>);
  85464. private _colorGradingEnabled;
  85465. /**
  85466. * Gets wether the color grading effect is enabled.
  85467. */
  85468. get colorGradingEnabled(): boolean;
  85469. /**
  85470. * Sets wether the color grading effect is enabled.
  85471. */
  85472. set colorGradingEnabled(value: boolean);
  85473. private _colorGradingWithGreenDepth;
  85474. /**
  85475. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85476. */
  85477. get colorGradingWithGreenDepth(): boolean;
  85478. /**
  85479. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85480. */
  85481. set colorGradingWithGreenDepth(value: boolean);
  85482. private _colorGradingBGR;
  85483. /**
  85484. * Gets wether the color grading texture contains BGR values.
  85485. */
  85486. get colorGradingBGR(): boolean;
  85487. /**
  85488. * Sets wether the color grading texture contains BGR values.
  85489. */
  85490. set colorGradingBGR(value: boolean);
  85491. /** @hidden */
  85492. _exposure: number;
  85493. /**
  85494. * Gets the Exposure used in the effect.
  85495. */
  85496. get exposure(): number;
  85497. /**
  85498. * Sets the Exposure used in the effect.
  85499. */
  85500. set exposure(value: number);
  85501. private _toneMappingEnabled;
  85502. /**
  85503. * Gets wether the tone mapping effect is enabled.
  85504. */
  85505. get toneMappingEnabled(): boolean;
  85506. /**
  85507. * Sets wether the tone mapping effect is enabled.
  85508. */
  85509. set toneMappingEnabled(value: boolean);
  85510. private _toneMappingType;
  85511. /**
  85512. * Gets the type of tone mapping effect.
  85513. */
  85514. get toneMappingType(): number;
  85515. /**
  85516. * Sets the type of tone mapping effect used in BabylonJS.
  85517. */
  85518. set toneMappingType(value: number);
  85519. protected _contrast: number;
  85520. /**
  85521. * Gets the contrast used in the effect.
  85522. */
  85523. get contrast(): number;
  85524. /**
  85525. * Sets the contrast used in the effect.
  85526. */
  85527. set contrast(value: number);
  85528. /**
  85529. * Vignette stretch size.
  85530. */
  85531. vignetteStretch: number;
  85532. /**
  85533. * Vignette centre X Offset.
  85534. */
  85535. vignetteCentreX: number;
  85536. /**
  85537. * Vignette centre Y Offset.
  85538. */
  85539. vignetteCentreY: number;
  85540. /**
  85541. * Vignette weight or intensity of the vignette effect.
  85542. */
  85543. vignetteWeight: number;
  85544. /**
  85545. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85546. * if vignetteEnabled is set to true.
  85547. */
  85548. vignetteColor: Color4;
  85549. /**
  85550. * Camera field of view used by the Vignette effect.
  85551. */
  85552. vignetteCameraFov: number;
  85553. private _vignetteBlendMode;
  85554. /**
  85555. * Gets the vignette blend mode allowing different kind of effect.
  85556. */
  85557. get vignetteBlendMode(): number;
  85558. /**
  85559. * Sets the vignette blend mode allowing different kind of effect.
  85560. */
  85561. set vignetteBlendMode(value: number);
  85562. private _vignetteEnabled;
  85563. /**
  85564. * Gets wether the vignette effect is enabled.
  85565. */
  85566. get vignetteEnabled(): boolean;
  85567. /**
  85568. * Sets wether the vignette effect is enabled.
  85569. */
  85570. set vignetteEnabled(value: boolean);
  85571. private _applyByPostProcess;
  85572. /**
  85573. * Gets wether the image processing is applied through a post process or not.
  85574. */
  85575. get applyByPostProcess(): boolean;
  85576. /**
  85577. * Sets wether the image processing is applied through a post process or not.
  85578. */
  85579. set applyByPostProcess(value: boolean);
  85580. private _isEnabled;
  85581. /**
  85582. * Gets wether the image processing is enabled or not.
  85583. */
  85584. get isEnabled(): boolean;
  85585. /**
  85586. * Sets wether the image processing is enabled or not.
  85587. */
  85588. set isEnabled(value: boolean);
  85589. /**
  85590. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85591. */
  85592. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85593. /**
  85594. * Method called each time the image processing information changes requires to recompile the effect.
  85595. */
  85596. protected _updateParameters(): void;
  85597. /**
  85598. * Gets the current class name.
  85599. * @return "ImageProcessingConfiguration"
  85600. */
  85601. getClassName(): string;
  85602. /**
  85603. * Prepare the list of uniforms associated with the Image Processing effects.
  85604. * @param uniforms The list of uniforms used in the effect
  85605. * @param defines the list of defines currently in use
  85606. */
  85607. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85608. /**
  85609. * Prepare the list of samplers associated with the Image Processing effects.
  85610. * @param samplersList The list of uniforms used in the effect
  85611. * @param defines the list of defines currently in use
  85612. */
  85613. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85614. /**
  85615. * Prepare the list of defines associated to the shader.
  85616. * @param defines the list of defines to complete
  85617. * @param forPostProcess Define if we are currently in post process mode or not
  85618. */
  85619. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85620. /**
  85621. * Returns true if all the image processing information are ready.
  85622. * @returns True if ready, otherwise, false
  85623. */
  85624. isReady(): boolean;
  85625. /**
  85626. * Binds the image processing to the shader.
  85627. * @param effect The effect to bind to
  85628. * @param overrideAspectRatio Override the aspect ratio of the effect
  85629. */
  85630. bind(effect: Effect, overrideAspectRatio?: number): void;
  85631. /**
  85632. * Clones the current image processing instance.
  85633. * @return The cloned image processing
  85634. */
  85635. clone(): ImageProcessingConfiguration;
  85636. /**
  85637. * Serializes the current image processing instance to a json representation.
  85638. * @return a JSON representation
  85639. */
  85640. serialize(): any;
  85641. /**
  85642. * Parses the image processing from a json representation.
  85643. * @param source the JSON source to parse
  85644. * @return The parsed image processing
  85645. */
  85646. static Parse(source: any): ImageProcessingConfiguration;
  85647. private static _VIGNETTEMODE_MULTIPLY;
  85648. private static _VIGNETTEMODE_OPAQUE;
  85649. /**
  85650. * Used to apply the vignette as a mix with the pixel color.
  85651. */
  85652. static get VIGNETTEMODE_MULTIPLY(): number;
  85653. /**
  85654. * Used to apply the vignette as a replacement of the pixel color.
  85655. */
  85656. static get VIGNETTEMODE_OPAQUE(): number;
  85657. }
  85658. }
  85659. declare module BABYLON {
  85660. /** @hidden */
  85661. export var postprocessVertexShader: {
  85662. name: string;
  85663. shader: string;
  85664. };
  85665. }
  85666. declare module BABYLON {
  85667. interface ThinEngine {
  85668. /**
  85669. * Creates a new render target texture
  85670. * @param size defines the size of the texture
  85671. * @param options defines the options used to create the texture
  85672. * @returns a new render target texture stored in an InternalTexture
  85673. */
  85674. createRenderTargetTexture(size: number | {
  85675. width: number;
  85676. height: number;
  85677. layers?: number;
  85678. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85679. /**
  85680. * Creates a depth stencil texture.
  85681. * This is only available in WebGL 2 or with the depth texture extension available.
  85682. * @param size The size of face edge in the texture.
  85683. * @param options The options defining the texture.
  85684. * @returns The texture
  85685. */
  85686. createDepthStencilTexture(size: number | {
  85687. width: number;
  85688. height: number;
  85689. layers?: number;
  85690. }, options: DepthTextureCreationOptions): InternalTexture;
  85691. /** @hidden */
  85692. _createDepthStencilTexture(size: number | {
  85693. width: number;
  85694. height: number;
  85695. layers?: number;
  85696. }, options: DepthTextureCreationOptions): InternalTexture;
  85697. }
  85698. }
  85699. declare module BABYLON {
  85700. /**
  85701. * Defines the kind of connection point for node based material
  85702. */
  85703. export enum NodeMaterialBlockConnectionPointTypes {
  85704. /** Float */
  85705. Float = 1,
  85706. /** Int */
  85707. Int = 2,
  85708. /** Vector2 */
  85709. Vector2 = 4,
  85710. /** Vector3 */
  85711. Vector3 = 8,
  85712. /** Vector4 */
  85713. Vector4 = 16,
  85714. /** Color3 */
  85715. Color3 = 32,
  85716. /** Color4 */
  85717. Color4 = 64,
  85718. /** Matrix */
  85719. Matrix = 128,
  85720. /** Custom object */
  85721. Object = 256,
  85722. /** Detect type based on connection */
  85723. AutoDetect = 1024,
  85724. /** Output type that will be defined by input type */
  85725. BasedOnInput = 2048
  85726. }
  85727. }
  85728. declare module BABYLON {
  85729. /**
  85730. * Enum used to define the target of a block
  85731. */
  85732. export enum NodeMaterialBlockTargets {
  85733. /** Vertex shader */
  85734. Vertex = 1,
  85735. /** Fragment shader */
  85736. Fragment = 2,
  85737. /** Neutral */
  85738. Neutral = 4,
  85739. /** Vertex and Fragment */
  85740. VertexAndFragment = 3
  85741. }
  85742. }
  85743. declare module BABYLON {
  85744. /**
  85745. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  85746. */
  85747. export enum NodeMaterialBlockConnectionPointMode {
  85748. /** Value is an uniform */
  85749. Uniform = 0,
  85750. /** Value is a mesh attribute */
  85751. Attribute = 1,
  85752. /** Value is a varying between vertex and fragment shaders */
  85753. Varying = 2,
  85754. /** Mode is undefined */
  85755. Undefined = 3
  85756. }
  85757. }
  85758. declare module BABYLON {
  85759. /**
  85760. * Enum used to define system values e.g. values automatically provided by the system
  85761. */
  85762. export enum NodeMaterialSystemValues {
  85763. /** World */
  85764. World = 1,
  85765. /** View */
  85766. View = 2,
  85767. /** Projection */
  85768. Projection = 3,
  85769. /** ViewProjection */
  85770. ViewProjection = 4,
  85771. /** WorldView */
  85772. WorldView = 5,
  85773. /** WorldViewProjection */
  85774. WorldViewProjection = 6,
  85775. /** CameraPosition */
  85776. CameraPosition = 7,
  85777. /** Fog Color */
  85778. FogColor = 8,
  85779. /** Delta time */
  85780. DeltaTime = 9
  85781. }
  85782. }
  85783. declare module BABYLON {
  85784. /** Defines supported spaces */
  85785. export enum Space {
  85786. /** Local (object) space */
  85787. LOCAL = 0,
  85788. /** World space */
  85789. WORLD = 1,
  85790. /** Bone space */
  85791. BONE = 2
  85792. }
  85793. /** Defines the 3 main axes */
  85794. export class Axis {
  85795. /** X axis */
  85796. static X: Vector3;
  85797. /** Y axis */
  85798. static Y: Vector3;
  85799. /** Z axis */
  85800. static Z: Vector3;
  85801. }
  85802. }
  85803. declare module BABYLON {
  85804. /**
  85805. * Represents a camera frustum
  85806. */
  85807. export class Frustum {
  85808. /**
  85809. * Gets the planes representing the frustum
  85810. * @param transform matrix to be applied to the returned planes
  85811. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85812. */
  85813. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85814. /**
  85815. * Gets the near frustum plane transformed by the transform matrix
  85816. * @param transform transformation matrix to be applied to the resulting frustum plane
  85817. * @param frustumPlane the resuling frustum plane
  85818. */
  85819. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85820. /**
  85821. * Gets the far frustum plane transformed by the transform matrix
  85822. * @param transform transformation matrix to be applied to the resulting frustum plane
  85823. * @param frustumPlane the resuling frustum plane
  85824. */
  85825. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85826. /**
  85827. * Gets the left frustum plane transformed by the transform matrix
  85828. * @param transform transformation matrix to be applied to the resulting frustum plane
  85829. * @param frustumPlane the resuling frustum plane
  85830. */
  85831. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85832. /**
  85833. * Gets the right frustum plane transformed by the transform matrix
  85834. * @param transform transformation matrix to be applied to the resulting frustum plane
  85835. * @param frustumPlane the resuling frustum plane
  85836. */
  85837. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85838. /**
  85839. * Gets the top frustum plane transformed by the transform matrix
  85840. * @param transform transformation matrix to be applied to the resulting frustum plane
  85841. * @param frustumPlane the resuling frustum plane
  85842. */
  85843. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85844. /**
  85845. * Gets the bottom frustum plane transformed by the transform matrix
  85846. * @param transform transformation matrix to be applied to the resulting frustum plane
  85847. * @param frustumPlane the resuling frustum plane
  85848. */
  85849. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85850. /**
  85851. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85852. * @param transform transformation matrix to be applied to the resulting frustum planes
  85853. * @param frustumPlanes the resuling frustum planes
  85854. */
  85855. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85856. }
  85857. }
  85858. declare module BABYLON {
  85859. /**
  85860. * Interface for the size containing width and height
  85861. */
  85862. export interface ISize {
  85863. /**
  85864. * Width
  85865. */
  85866. width: number;
  85867. /**
  85868. * Heighht
  85869. */
  85870. height: number;
  85871. }
  85872. /**
  85873. * Size containing widht and height
  85874. */
  85875. export class Size implements ISize {
  85876. /**
  85877. * Width
  85878. */
  85879. width: number;
  85880. /**
  85881. * Height
  85882. */
  85883. height: number;
  85884. /**
  85885. * Creates a Size object from the given width and height (floats).
  85886. * @param width width of the new size
  85887. * @param height height of the new size
  85888. */
  85889. constructor(width: number, height: number);
  85890. /**
  85891. * Returns a string with the Size width and height
  85892. * @returns a string with the Size width and height
  85893. */
  85894. toString(): string;
  85895. /**
  85896. * "Size"
  85897. * @returns the string "Size"
  85898. */
  85899. getClassName(): string;
  85900. /**
  85901. * Returns the Size hash code.
  85902. * @returns a hash code for a unique width and height
  85903. */
  85904. getHashCode(): number;
  85905. /**
  85906. * Updates the current size from the given one.
  85907. * @param src the given size
  85908. */
  85909. copyFrom(src: Size): void;
  85910. /**
  85911. * Updates in place the current Size from the given floats.
  85912. * @param width width of the new size
  85913. * @param height height of the new size
  85914. * @returns the updated Size.
  85915. */
  85916. copyFromFloats(width: number, height: number): Size;
  85917. /**
  85918. * Updates in place the current Size from the given floats.
  85919. * @param width width to set
  85920. * @param height height to set
  85921. * @returns the updated Size.
  85922. */
  85923. set(width: number, height: number): Size;
  85924. /**
  85925. * Multiplies the width and height by numbers
  85926. * @param w factor to multiple the width by
  85927. * @param h factor to multiple the height by
  85928. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85929. */
  85930. multiplyByFloats(w: number, h: number): Size;
  85931. /**
  85932. * Clones the size
  85933. * @returns a new Size copied from the given one.
  85934. */
  85935. clone(): Size;
  85936. /**
  85937. * True if the current Size and the given one width and height are strictly equal.
  85938. * @param other the other size to compare against
  85939. * @returns True if the current Size and the given one width and height are strictly equal.
  85940. */
  85941. equals(other: Size): boolean;
  85942. /**
  85943. * The surface of the Size : width * height (float).
  85944. */
  85945. get surface(): number;
  85946. /**
  85947. * Create a new size of zero
  85948. * @returns a new Size set to (0.0, 0.0)
  85949. */
  85950. static Zero(): Size;
  85951. /**
  85952. * Sums the width and height of two sizes
  85953. * @param otherSize size to add to this size
  85954. * @returns a new Size set as the addition result of the current Size and the given one.
  85955. */
  85956. add(otherSize: Size): Size;
  85957. /**
  85958. * Subtracts the width and height of two
  85959. * @param otherSize size to subtract to this size
  85960. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85961. */
  85962. subtract(otherSize: Size): Size;
  85963. /**
  85964. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85965. * @param start starting size to lerp between
  85966. * @param end end size to lerp between
  85967. * @param amount amount to lerp between the start and end values
  85968. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85969. */
  85970. static Lerp(start: Size, end: Size, amount: number): Size;
  85971. }
  85972. }
  85973. declare module BABYLON {
  85974. /**
  85975. * Contains position and normal vectors for a vertex
  85976. */
  85977. export class PositionNormalVertex {
  85978. /** the position of the vertex (defaut: 0,0,0) */
  85979. position: Vector3;
  85980. /** the normal of the vertex (defaut: 0,1,0) */
  85981. normal: Vector3;
  85982. /**
  85983. * Creates a PositionNormalVertex
  85984. * @param position the position of the vertex (defaut: 0,0,0)
  85985. * @param normal the normal of the vertex (defaut: 0,1,0)
  85986. */
  85987. constructor(
  85988. /** the position of the vertex (defaut: 0,0,0) */
  85989. position?: Vector3,
  85990. /** the normal of the vertex (defaut: 0,1,0) */
  85991. normal?: Vector3);
  85992. /**
  85993. * Clones the PositionNormalVertex
  85994. * @returns the cloned PositionNormalVertex
  85995. */
  85996. clone(): PositionNormalVertex;
  85997. }
  85998. /**
  85999. * Contains position, normal and uv vectors for a vertex
  86000. */
  86001. export class PositionNormalTextureVertex {
  86002. /** the position of the vertex (defaut: 0,0,0) */
  86003. position: Vector3;
  86004. /** the normal of the vertex (defaut: 0,1,0) */
  86005. normal: Vector3;
  86006. /** the uv of the vertex (default: 0,0) */
  86007. uv: Vector2;
  86008. /**
  86009. * Creates a PositionNormalTextureVertex
  86010. * @param position the position of the vertex (defaut: 0,0,0)
  86011. * @param normal the normal of the vertex (defaut: 0,1,0)
  86012. * @param uv the uv of the vertex (default: 0,0)
  86013. */
  86014. constructor(
  86015. /** the position of the vertex (defaut: 0,0,0) */
  86016. position?: Vector3,
  86017. /** the normal of the vertex (defaut: 0,1,0) */
  86018. normal?: Vector3,
  86019. /** the uv of the vertex (default: 0,0) */
  86020. uv?: Vector2);
  86021. /**
  86022. * Clones the PositionNormalTextureVertex
  86023. * @returns the cloned PositionNormalTextureVertex
  86024. */
  86025. clone(): PositionNormalTextureVertex;
  86026. }
  86027. }
  86028. declare module BABYLON {
  86029. /**
  86030. * Enum defining the type of animations supported by InputBlock
  86031. */
  86032. export enum AnimatedInputBlockTypes {
  86033. /** No animation */
  86034. None = 0,
  86035. /** Time based animation. Will only work for floats */
  86036. Time = 1
  86037. }
  86038. }
  86039. declare module BABYLON {
  86040. /**
  86041. * Interface describing all the common properties and methods a shadow light needs to implement.
  86042. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86043. * as well as binding the different shadow properties to the effects.
  86044. */
  86045. export interface IShadowLight extends Light {
  86046. /**
  86047. * The light id in the scene (used in scene.findLighById for instance)
  86048. */
  86049. id: string;
  86050. /**
  86051. * The position the shdow will be casted from.
  86052. */
  86053. position: Vector3;
  86054. /**
  86055. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86056. */
  86057. direction: Vector3;
  86058. /**
  86059. * The transformed position. Position of the light in world space taking parenting in account.
  86060. */
  86061. transformedPosition: Vector3;
  86062. /**
  86063. * The transformed direction. Direction of the light in world space taking parenting in account.
  86064. */
  86065. transformedDirection: Vector3;
  86066. /**
  86067. * The friendly name of the light in the scene.
  86068. */
  86069. name: string;
  86070. /**
  86071. * Defines the shadow projection clipping minimum z value.
  86072. */
  86073. shadowMinZ: number;
  86074. /**
  86075. * Defines the shadow projection clipping maximum z value.
  86076. */
  86077. shadowMaxZ: number;
  86078. /**
  86079. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86080. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86081. */
  86082. computeTransformedInformation(): boolean;
  86083. /**
  86084. * Gets the scene the light belongs to.
  86085. * @returns The scene
  86086. */
  86087. getScene(): Scene;
  86088. /**
  86089. * Callback defining a custom Projection Matrix Builder.
  86090. * This can be used to override the default projection matrix computation.
  86091. */
  86092. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86093. /**
  86094. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86095. * @param matrix The materix to updated with the projection information
  86096. * @param viewMatrix The transform matrix of the light
  86097. * @param renderList The list of mesh to render in the map
  86098. * @returns The current light
  86099. */
  86100. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86101. /**
  86102. * Gets the current depth scale used in ESM.
  86103. * @returns The scale
  86104. */
  86105. getDepthScale(): number;
  86106. /**
  86107. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86108. * @returns true if a cube texture needs to be use
  86109. */
  86110. needCube(): boolean;
  86111. /**
  86112. * Detects if the projection matrix requires to be recomputed this frame.
  86113. * @returns true if it requires to be recomputed otherwise, false.
  86114. */
  86115. needProjectionMatrixCompute(): boolean;
  86116. /**
  86117. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86118. */
  86119. forceProjectionMatrixCompute(): void;
  86120. /**
  86121. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86122. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86123. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86124. */
  86125. getShadowDirection(faceIndex?: number): Vector3;
  86126. /**
  86127. * Gets the minZ used for shadow according to both the scene and the light.
  86128. * @param activeCamera The camera we are returning the min for
  86129. * @returns the depth min z
  86130. */
  86131. getDepthMinZ(activeCamera: Camera): number;
  86132. /**
  86133. * Gets the maxZ used for shadow according to both the scene and the light.
  86134. * @param activeCamera The camera we are returning the max for
  86135. * @returns the depth max z
  86136. */
  86137. getDepthMaxZ(activeCamera: Camera): number;
  86138. }
  86139. /**
  86140. * Base implementation IShadowLight
  86141. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86142. */
  86143. export abstract class ShadowLight extends Light implements IShadowLight {
  86144. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86145. protected _position: Vector3;
  86146. protected _setPosition(value: Vector3): void;
  86147. /**
  86148. * Sets the position the shadow will be casted from. Also use as the light position for both
  86149. * point and spot lights.
  86150. */
  86151. get position(): Vector3;
  86152. /**
  86153. * Sets the position the shadow will be casted from. Also use as the light position for both
  86154. * point and spot lights.
  86155. */
  86156. set position(value: Vector3);
  86157. protected _direction: Vector3;
  86158. protected _setDirection(value: Vector3): void;
  86159. /**
  86160. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86161. * Also use as the light direction on spot and directional lights.
  86162. */
  86163. get direction(): Vector3;
  86164. /**
  86165. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86166. * Also use as the light direction on spot and directional lights.
  86167. */
  86168. set direction(value: Vector3);
  86169. protected _shadowMinZ: number;
  86170. /**
  86171. * Gets the shadow projection clipping minimum z value.
  86172. */
  86173. get shadowMinZ(): number;
  86174. /**
  86175. * Sets the shadow projection clipping minimum z value.
  86176. */
  86177. set shadowMinZ(value: number);
  86178. protected _shadowMaxZ: number;
  86179. /**
  86180. * Sets the shadow projection clipping maximum z value.
  86181. */
  86182. get shadowMaxZ(): number;
  86183. /**
  86184. * Gets the shadow projection clipping maximum z value.
  86185. */
  86186. set shadowMaxZ(value: number);
  86187. /**
  86188. * Callback defining a custom Projection Matrix Builder.
  86189. * This can be used to override the default projection matrix computation.
  86190. */
  86191. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86192. /**
  86193. * The transformed position. Position of the light in world space taking parenting in account.
  86194. */
  86195. transformedPosition: Vector3;
  86196. /**
  86197. * The transformed direction. Direction of the light in world space taking parenting in account.
  86198. */
  86199. transformedDirection: Vector3;
  86200. private _needProjectionMatrixCompute;
  86201. /**
  86202. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86203. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86204. */
  86205. computeTransformedInformation(): boolean;
  86206. /**
  86207. * Return the depth scale used for the shadow map.
  86208. * @returns the depth scale.
  86209. */
  86210. getDepthScale(): number;
  86211. /**
  86212. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86213. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86214. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86215. */
  86216. getShadowDirection(faceIndex?: number): Vector3;
  86217. /**
  86218. * Returns the ShadowLight absolute position in the World.
  86219. * @returns the position vector in world space
  86220. */
  86221. getAbsolutePosition(): Vector3;
  86222. /**
  86223. * Sets the ShadowLight direction toward the passed target.
  86224. * @param target The point to target in local space
  86225. * @returns the updated ShadowLight direction
  86226. */
  86227. setDirectionToTarget(target: Vector3): Vector3;
  86228. /**
  86229. * Returns the light rotation in euler definition.
  86230. * @returns the x y z rotation in local space.
  86231. */
  86232. getRotation(): Vector3;
  86233. /**
  86234. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86235. * @returns true if a cube texture needs to be use
  86236. */
  86237. needCube(): boolean;
  86238. /**
  86239. * Detects if the projection matrix requires to be recomputed this frame.
  86240. * @returns true if it requires to be recomputed otherwise, false.
  86241. */
  86242. needProjectionMatrixCompute(): boolean;
  86243. /**
  86244. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86245. */
  86246. forceProjectionMatrixCompute(): void;
  86247. /** @hidden */
  86248. _initCache(): void;
  86249. /** @hidden */
  86250. _isSynchronized(): boolean;
  86251. /**
  86252. * Computes the world matrix of the node
  86253. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86254. * @returns the world matrix
  86255. */
  86256. computeWorldMatrix(force?: boolean): Matrix;
  86257. /**
  86258. * Gets the minZ used for shadow according to both the scene and the light.
  86259. * @param activeCamera The camera we are returning the min for
  86260. * @returns the depth min z
  86261. */
  86262. getDepthMinZ(activeCamera: Camera): number;
  86263. /**
  86264. * Gets the maxZ used for shadow according to both the scene and the light.
  86265. * @param activeCamera The camera we are returning the max for
  86266. * @returns the depth max z
  86267. */
  86268. getDepthMaxZ(activeCamera: Camera): number;
  86269. /**
  86270. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86271. * @param matrix The materix to updated with the projection information
  86272. * @param viewMatrix The transform matrix of the light
  86273. * @param renderList The list of mesh to render in the map
  86274. * @returns The current light
  86275. */
  86276. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86277. }
  86278. }
  86279. declare module BABYLON {
  86280. /** @hidden */
  86281. export var packingFunctions: {
  86282. name: string;
  86283. shader: string;
  86284. };
  86285. }
  86286. declare module BABYLON {
  86287. /** @hidden */
  86288. export var bayerDitherFunctions: {
  86289. name: string;
  86290. shader: string;
  86291. };
  86292. }
  86293. declare module BABYLON {
  86294. /** @hidden */
  86295. export var shadowMapFragmentDeclaration: {
  86296. name: string;
  86297. shader: string;
  86298. };
  86299. }
  86300. declare module BABYLON {
  86301. /** @hidden */
  86302. export var clipPlaneFragmentDeclaration: {
  86303. name: string;
  86304. shader: string;
  86305. };
  86306. }
  86307. declare module BABYLON {
  86308. /** @hidden */
  86309. export var clipPlaneFragment: {
  86310. name: string;
  86311. shader: string;
  86312. };
  86313. }
  86314. declare module BABYLON {
  86315. /** @hidden */
  86316. export var shadowMapFragment: {
  86317. name: string;
  86318. shader: string;
  86319. };
  86320. }
  86321. declare module BABYLON {
  86322. /** @hidden */
  86323. export var shadowMapPixelShader: {
  86324. name: string;
  86325. shader: string;
  86326. };
  86327. }
  86328. declare module BABYLON {
  86329. /** @hidden */
  86330. export var bonesDeclaration: {
  86331. name: string;
  86332. shader: string;
  86333. };
  86334. }
  86335. declare module BABYLON {
  86336. /** @hidden */
  86337. export var morphTargetsVertexGlobalDeclaration: {
  86338. name: string;
  86339. shader: string;
  86340. };
  86341. }
  86342. declare module BABYLON {
  86343. /** @hidden */
  86344. export var morphTargetsVertexDeclaration: {
  86345. name: string;
  86346. shader: string;
  86347. };
  86348. }
  86349. declare module BABYLON {
  86350. /** @hidden */
  86351. export var instancesDeclaration: {
  86352. name: string;
  86353. shader: string;
  86354. };
  86355. }
  86356. declare module BABYLON {
  86357. /** @hidden */
  86358. export var helperFunctions: {
  86359. name: string;
  86360. shader: string;
  86361. };
  86362. }
  86363. declare module BABYLON {
  86364. /** @hidden */
  86365. export var shadowMapVertexDeclaration: {
  86366. name: string;
  86367. shader: string;
  86368. };
  86369. }
  86370. declare module BABYLON {
  86371. /** @hidden */
  86372. export var clipPlaneVertexDeclaration: {
  86373. name: string;
  86374. shader: string;
  86375. };
  86376. }
  86377. declare module BABYLON {
  86378. /** @hidden */
  86379. export var morphTargetsVertex: {
  86380. name: string;
  86381. shader: string;
  86382. };
  86383. }
  86384. declare module BABYLON {
  86385. /** @hidden */
  86386. export var instancesVertex: {
  86387. name: string;
  86388. shader: string;
  86389. };
  86390. }
  86391. declare module BABYLON {
  86392. /** @hidden */
  86393. export var bonesVertex: {
  86394. name: string;
  86395. shader: string;
  86396. };
  86397. }
  86398. declare module BABYLON {
  86399. /** @hidden */
  86400. export var shadowMapVertexNormalBias: {
  86401. name: string;
  86402. shader: string;
  86403. };
  86404. }
  86405. declare module BABYLON {
  86406. /** @hidden */
  86407. export var shadowMapVertexMetric: {
  86408. name: string;
  86409. shader: string;
  86410. };
  86411. }
  86412. declare module BABYLON {
  86413. /** @hidden */
  86414. export var clipPlaneVertex: {
  86415. name: string;
  86416. shader: string;
  86417. };
  86418. }
  86419. declare module BABYLON {
  86420. /** @hidden */
  86421. export var shadowMapVertexShader: {
  86422. name: string;
  86423. shader: string;
  86424. };
  86425. }
  86426. declare module BABYLON {
  86427. /** @hidden */
  86428. export var depthBoxBlurPixelShader: {
  86429. name: string;
  86430. shader: string;
  86431. };
  86432. }
  86433. declare module BABYLON {
  86434. /** @hidden */
  86435. export var shadowMapFragmentSoftTransparentShadow: {
  86436. name: string;
  86437. shader: string;
  86438. };
  86439. }
  86440. declare module BABYLON {
  86441. /**
  86442. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86443. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86444. */
  86445. export class EffectFallbacks implements IEffectFallbacks {
  86446. private _defines;
  86447. private _currentRank;
  86448. private _maxRank;
  86449. private _mesh;
  86450. /**
  86451. * Removes the fallback from the bound mesh.
  86452. */
  86453. unBindMesh(): void;
  86454. /**
  86455. * Adds a fallback on the specified property.
  86456. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86457. * @param define The name of the define in the shader
  86458. */
  86459. addFallback(rank: number, define: string): void;
  86460. /**
  86461. * Sets the mesh to use CPU skinning when needing to fallback.
  86462. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86463. * @param mesh The mesh to use the fallbacks.
  86464. */
  86465. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86466. /**
  86467. * Checks to see if more fallbacks are still availible.
  86468. */
  86469. get hasMoreFallbacks(): boolean;
  86470. /**
  86471. * Removes the defines that should be removed when falling back.
  86472. * @param currentDefines defines the current define statements for the shader.
  86473. * @param effect defines the current effect we try to compile
  86474. * @returns The resulting defines with defines of the current rank removed.
  86475. */
  86476. reduce(currentDefines: string, effect: Effect): string;
  86477. }
  86478. }
  86479. declare module BABYLON {
  86480. /**
  86481. * Interface used to define Action
  86482. */
  86483. export interface IAction {
  86484. /**
  86485. * Trigger for the action
  86486. */
  86487. trigger: number;
  86488. /** Options of the trigger */
  86489. triggerOptions: any;
  86490. /**
  86491. * Gets the trigger parameters
  86492. * @returns the trigger parameters
  86493. */
  86494. getTriggerParameter(): any;
  86495. /**
  86496. * Internal only - executes current action event
  86497. * @hidden
  86498. */
  86499. _executeCurrent(evt?: ActionEvent): void;
  86500. /**
  86501. * Serialize placeholder for child classes
  86502. * @param parent of child
  86503. * @returns the serialized object
  86504. */
  86505. serialize(parent: any): any;
  86506. /**
  86507. * Internal only
  86508. * @hidden
  86509. */
  86510. _prepare(): void;
  86511. /**
  86512. * Internal only - manager for action
  86513. * @hidden
  86514. */
  86515. _actionManager: AbstractActionManager;
  86516. /**
  86517. * Adds action to chain of actions, may be a DoNothingAction
  86518. * @param action defines the next action to execute
  86519. * @returns The action passed in
  86520. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86521. */
  86522. then(action: IAction): IAction;
  86523. }
  86524. /**
  86525. * The action to be carried out following a trigger
  86526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  86527. */
  86528. export class Action implements IAction {
  86529. /** the trigger, with or without parameters, for the action */
  86530. triggerOptions: any;
  86531. /**
  86532. * Trigger for the action
  86533. */
  86534. trigger: number;
  86535. /**
  86536. * Internal only - manager for action
  86537. * @hidden
  86538. */
  86539. _actionManager: ActionManager;
  86540. private _nextActiveAction;
  86541. private _child;
  86542. private _condition?;
  86543. private _triggerParameter;
  86544. /**
  86545. * An event triggered prior to action being executed.
  86546. */
  86547. onBeforeExecuteObservable: Observable<Action>;
  86548. /**
  86549. * Creates a new Action
  86550. * @param triggerOptions the trigger, with or without parameters, for the action
  86551. * @param condition an optional determinant of action
  86552. */
  86553. constructor(
  86554. /** the trigger, with or without parameters, for the action */
  86555. triggerOptions: any, condition?: Condition);
  86556. /**
  86557. * Internal only
  86558. * @hidden
  86559. */
  86560. _prepare(): void;
  86561. /**
  86562. * Gets the trigger parameters
  86563. * @returns the trigger parameters
  86564. */
  86565. getTriggerParameter(): any;
  86566. /**
  86567. * Internal only - executes current action event
  86568. * @hidden
  86569. */
  86570. _executeCurrent(evt?: ActionEvent): void;
  86571. /**
  86572. * Execute placeholder for child classes
  86573. * @param evt optional action event
  86574. */
  86575. execute(evt?: ActionEvent): void;
  86576. /**
  86577. * Skips to next active action
  86578. */
  86579. skipToNextActiveAction(): void;
  86580. /**
  86581. * Adds action to chain of actions, may be a DoNothingAction
  86582. * @param action defines the next action to execute
  86583. * @returns The action passed in
  86584. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86585. */
  86586. then(action: Action): Action;
  86587. /**
  86588. * Internal only
  86589. * @hidden
  86590. */
  86591. _getProperty(propertyPath: string): string;
  86592. /**
  86593. * Internal only
  86594. * @hidden
  86595. */
  86596. _getEffectiveTarget(target: any, propertyPath: string): any;
  86597. /**
  86598. * Serialize placeholder for child classes
  86599. * @param parent of child
  86600. * @returns the serialized object
  86601. */
  86602. serialize(parent: any): any;
  86603. /**
  86604. * Internal only called by serialize
  86605. * @hidden
  86606. */
  86607. protected _serialize(serializedAction: any, parent?: any): any;
  86608. /**
  86609. * Internal only
  86610. * @hidden
  86611. */
  86612. static _SerializeValueAsString: (value: any) => string;
  86613. /**
  86614. * Internal only
  86615. * @hidden
  86616. */
  86617. static _GetTargetProperty: (target: Node | Scene) => {
  86618. name: string;
  86619. targetType: string;
  86620. value: string;
  86621. };
  86622. }
  86623. }
  86624. declare module BABYLON {
  86625. /**
  86626. * A Condition applied to an Action
  86627. */
  86628. export class Condition {
  86629. /**
  86630. * Internal only - manager for action
  86631. * @hidden
  86632. */
  86633. _actionManager: ActionManager;
  86634. /**
  86635. * Internal only
  86636. * @hidden
  86637. */
  86638. _evaluationId: number;
  86639. /**
  86640. * Internal only
  86641. * @hidden
  86642. */
  86643. _currentResult: boolean;
  86644. /**
  86645. * Creates a new Condition
  86646. * @param actionManager the manager of the action the condition is applied to
  86647. */
  86648. constructor(actionManager: ActionManager);
  86649. /**
  86650. * Check if the current condition is valid
  86651. * @returns a boolean
  86652. */
  86653. isValid(): boolean;
  86654. /**
  86655. * Internal only
  86656. * @hidden
  86657. */
  86658. _getProperty(propertyPath: string): string;
  86659. /**
  86660. * Internal only
  86661. * @hidden
  86662. */
  86663. _getEffectiveTarget(target: any, propertyPath: string): any;
  86664. /**
  86665. * Serialize placeholder for child classes
  86666. * @returns the serialized object
  86667. */
  86668. serialize(): any;
  86669. /**
  86670. * Internal only
  86671. * @hidden
  86672. */
  86673. protected _serialize(serializedCondition: any): any;
  86674. }
  86675. /**
  86676. * Defines specific conditional operators as extensions of Condition
  86677. */
  86678. export class ValueCondition extends Condition {
  86679. /** path to specify the property of the target the conditional operator uses */
  86680. propertyPath: string;
  86681. /** the value compared by the conditional operator against the current value of the property */
  86682. value: any;
  86683. /** the conditional operator, default ValueCondition.IsEqual */
  86684. operator: number;
  86685. /**
  86686. * Internal only
  86687. * @hidden
  86688. */
  86689. private static _IsEqual;
  86690. /**
  86691. * Internal only
  86692. * @hidden
  86693. */
  86694. private static _IsDifferent;
  86695. /**
  86696. * Internal only
  86697. * @hidden
  86698. */
  86699. private static _IsGreater;
  86700. /**
  86701. * Internal only
  86702. * @hidden
  86703. */
  86704. private static _IsLesser;
  86705. /**
  86706. * returns the number for IsEqual
  86707. */
  86708. static get IsEqual(): number;
  86709. /**
  86710. * Returns the number for IsDifferent
  86711. */
  86712. static get IsDifferent(): number;
  86713. /**
  86714. * Returns the number for IsGreater
  86715. */
  86716. static get IsGreater(): number;
  86717. /**
  86718. * Returns the number for IsLesser
  86719. */
  86720. static get IsLesser(): number;
  86721. /**
  86722. * Internal only The action manager for the condition
  86723. * @hidden
  86724. */
  86725. _actionManager: ActionManager;
  86726. /**
  86727. * Internal only
  86728. * @hidden
  86729. */
  86730. private _target;
  86731. /**
  86732. * Internal only
  86733. * @hidden
  86734. */
  86735. private _effectiveTarget;
  86736. /**
  86737. * Internal only
  86738. * @hidden
  86739. */
  86740. private _property;
  86741. /**
  86742. * Creates a new ValueCondition
  86743. * @param actionManager manager for the action the condition applies to
  86744. * @param target for the action
  86745. * @param propertyPath path to specify the property of the target the conditional operator uses
  86746. * @param value the value compared by the conditional operator against the current value of the property
  86747. * @param operator the conditional operator, default ValueCondition.IsEqual
  86748. */
  86749. constructor(actionManager: ActionManager, target: any,
  86750. /** path to specify the property of the target the conditional operator uses */
  86751. propertyPath: string,
  86752. /** the value compared by the conditional operator against the current value of the property */
  86753. value: any,
  86754. /** the conditional operator, default ValueCondition.IsEqual */
  86755. operator?: number);
  86756. /**
  86757. * Compares the given value with the property value for the specified conditional operator
  86758. * @returns the result of the comparison
  86759. */
  86760. isValid(): boolean;
  86761. /**
  86762. * Serialize the ValueCondition into a JSON compatible object
  86763. * @returns serialization object
  86764. */
  86765. serialize(): any;
  86766. /**
  86767. * Gets the name of the conditional operator for the ValueCondition
  86768. * @param operator the conditional operator
  86769. * @returns the name
  86770. */
  86771. static GetOperatorName(operator: number): string;
  86772. }
  86773. /**
  86774. * Defines a predicate condition as an extension of Condition
  86775. */
  86776. export class PredicateCondition extends Condition {
  86777. /** defines the predicate function used to validate the condition */
  86778. predicate: () => boolean;
  86779. /**
  86780. * Internal only - manager for action
  86781. * @hidden
  86782. */
  86783. _actionManager: ActionManager;
  86784. /**
  86785. * Creates a new PredicateCondition
  86786. * @param actionManager manager for the action the condition applies to
  86787. * @param predicate defines the predicate function used to validate the condition
  86788. */
  86789. constructor(actionManager: ActionManager,
  86790. /** defines the predicate function used to validate the condition */
  86791. predicate: () => boolean);
  86792. /**
  86793. * @returns the validity of the predicate condition
  86794. */
  86795. isValid(): boolean;
  86796. }
  86797. /**
  86798. * Defines a state condition as an extension of Condition
  86799. */
  86800. export class StateCondition extends Condition {
  86801. /** Value to compare with target state */
  86802. value: string;
  86803. /**
  86804. * Internal only - manager for action
  86805. * @hidden
  86806. */
  86807. _actionManager: ActionManager;
  86808. /**
  86809. * Internal only
  86810. * @hidden
  86811. */
  86812. private _target;
  86813. /**
  86814. * Creates a new StateCondition
  86815. * @param actionManager manager for the action the condition applies to
  86816. * @param target of the condition
  86817. * @param value to compare with target state
  86818. */
  86819. constructor(actionManager: ActionManager, target: any,
  86820. /** Value to compare with target state */
  86821. value: string);
  86822. /**
  86823. * Gets a boolean indicating if the current condition is met
  86824. * @returns the validity of the state
  86825. */
  86826. isValid(): boolean;
  86827. /**
  86828. * Serialize the StateCondition into a JSON compatible object
  86829. * @returns serialization object
  86830. */
  86831. serialize(): any;
  86832. }
  86833. }
  86834. declare module BABYLON {
  86835. /**
  86836. * This defines an action responsible to toggle a boolean once triggered.
  86837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86838. */
  86839. export class SwitchBooleanAction extends Action {
  86840. /**
  86841. * The path to the boolean property in the target object
  86842. */
  86843. propertyPath: string;
  86844. private _target;
  86845. private _effectiveTarget;
  86846. private _property;
  86847. /**
  86848. * Instantiate the action
  86849. * @param triggerOptions defines the trigger options
  86850. * @param target defines the object containing the boolean
  86851. * @param propertyPath defines the path to the boolean property in the target object
  86852. * @param condition defines the trigger related conditions
  86853. */
  86854. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  86855. /** @hidden */
  86856. _prepare(): void;
  86857. /**
  86858. * Execute the action toggle the boolean value.
  86859. */
  86860. execute(): void;
  86861. /**
  86862. * Serializes the actions and its related information.
  86863. * @param parent defines the object to serialize in
  86864. * @returns the serialized object
  86865. */
  86866. serialize(parent: any): any;
  86867. }
  86868. /**
  86869. * This defines an action responsible to set a the state field of the target
  86870. * to a desired value once triggered.
  86871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86872. */
  86873. export class SetStateAction extends Action {
  86874. /**
  86875. * The value to store in the state field.
  86876. */
  86877. value: string;
  86878. private _target;
  86879. /**
  86880. * Instantiate the action
  86881. * @param triggerOptions defines the trigger options
  86882. * @param target defines the object containing the state property
  86883. * @param value defines the value to store in the state field
  86884. * @param condition defines the trigger related conditions
  86885. */
  86886. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  86887. /**
  86888. * Execute the action and store the value on the target state property.
  86889. */
  86890. execute(): void;
  86891. /**
  86892. * Serializes the actions and its related information.
  86893. * @param parent defines the object to serialize in
  86894. * @returns the serialized object
  86895. */
  86896. serialize(parent: any): any;
  86897. }
  86898. /**
  86899. * This defines an action responsible to set a property of the target
  86900. * to a desired value once triggered.
  86901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86902. */
  86903. export class SetValueAction extends Action {
  86904. /**
  86905. * The path of the property to set in the target.
  86906. */
  86907. propertyPath: string;
  86908. /**
  86909. * The value to set in the property
  86910. */
  86911. value: any;
  86912. private _target;
  86913. private _effectiveTarget;
  86914. private _property;
  86915. /**
  86916. * Instantiate the action
  86917. * @param triggerOptions defines the trigger options
  86918. * @param target defines the object containing the property
  86919. * @param propertyPath defines the path of the property to set in the target
  86920. * @param value defines the value to set in the property
  86921. * @param condition defines the trigger related conditions
  86922. */
  86923. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86924. /** @hidden */
  86925. _prepare(): void;
  86926. /**
  86927. * Execute the action and set the targetted property to the desired value.
  86928. */
  86929. execute(): void;
  86930. /**
  86931. * Serializes the actions and its related information.
  86932. * @param parent defines the object to serialize in
  86933. * @returns the serialized object
  86934. */
  86935. serialize(parent: any): any;
  86936. }
  86937. /**
  86938. * This defines an action responsible to increment the target value
  86939. * to a desired value once triggered.
  86940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86941. */
  86942. export class IncrementValueAction extends Action {
  86943. /**
  86944. * The path of the property to increment in the target.
  86945. */
  86946. propertyPath: string;
  86947. /**
  86948. * The value we should increment the property by.
  86949. */
  86950. value: any;
  86951. private _target;
  86952. private _effectiveTarget;
  86953. private _property;
  86954. /**
  86955. * Instantiate the action
  86956. * @param triggerOptions defines the trigger options
  86957. * @param target defines the object containing the property
  86958. * @param propertyPath defines the path of the property to increment in the target
  86959. * @param value defines the value value we should increment the property by
  86960. * @param condition defines the trigger related conditions
  86961. */
  86962. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86963. /** @hidden */
  86964. _prepare(): void;
  86965. /**
  86966. * Execute the action and increment the target of the value amount.
  86967. */
  86968. execute(): void;
  86969. /**
  86970. * Serializes the actions and its related information.
  86971. * @param parent defines the object to serialize in
  86972. * @returns the serialized object
  86973. */
  86974. serialize(parent: any): any;
  86975. }
  86976. /**
  86977. * This defines an action responsible to start an animation once triggered.
  86978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86979. */
  86980. export class PlayAnimationAction extends Action {
  86981. /**
  86982. * Where the animation should start (animation frame)
  86983. */
  86984. from: number;
  86985. /**
  86986. * Where the animation should stop (animation frame)
  86987. */
  86988. to: number;
  86989. /**
  86990. * Define if the animation should loop or stop after the first play.
  86991. */
  86992. loop?: boolean;
  86993. private _target;
  86994. /**
  86995. * Instantiate the action
  86996. * @param triggerOptions defines the trigger options
  86997. * @param target defines the target animation or animation name
  86998. * @param from defines from where the animation should start (animation frame)
  86999. * @param end defines where the animation should stop (animation frame)
  87000. * @param loop defines if the animation should loop or stop after the first play
  87001. * @param condition defines the trigger related conditions
  87002. */
  87003. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87004. /** @hidden */
  87005. _prepare(): void;
  87006. /**
  87007. * Execute the action and play the animation.
  87008. */
  87009. execute(): void;
  87010. /**
  87011. * Serializes the actions and its related information.
  87012. * @param parent defines the object to serialize in
  87013. * @returns the serialized object
  87014. */
  87015. serialize(parent: any): any;
  87016. }
  87017. /**
  87018. * This defines an action responsible to stop an animation once triggered.
  87019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87020. */
  87021. export class StopAnimationAction extends Action {
  87022. private _target;
  87023. /**
  87024. * Instantiate the action
  87025. * @param triggerOptions defines the trigger options
  87026. * @param target defines the target animation or animation name
  87027. * @param condition defines the trigger related conditions
  87028. */
  87029. constructor(triggerOptions: any, target: any, condition?: Condition);
  87030. /** @hidden */
  87031. _prepare(): void;
  87032. /**
  87033. * Execute the action and stop the animation.
  87034. */
  87035. execute(): void;
  87036. /**
  87037. * Serializes the actions and its related information.
  87038. * @param parent defines the object to serialize in
  87039. * @returns the serialized object
  87040. */
  87041. serialize(parent: any): any;
  87042. }
  87043. /**
  87044. * This defines an action responsible that does nothing once triggered.
  87045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87046. */
  87047. export class DoNothingAction extends Action {
  87048. /**
  87049. * Instantiate the action
  87050. * @param triggerOptions defines the trigger options
  87051. * @param condition defines the trigger related conditions
  87052. */
  87053. constructor(triggerOptions?: any, condition?: Condition);
  87054. /**
  87055. * Execute the action and do nothing.
  87056. */
  87057. execute(): void;
  87058. /**
  87059. * Serializes the actions and its related information.
  87060. * @param parent defines the object to serialize in
  87061. * @returns the serialized object
  87062. */
  87063. serialize(parent: any): any;
  87064. }
  87065. /**
  87066. * This defines an action responsible to trigger several actions once triggered.
  87067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87068. */
  87069. export class CombineAction extends Action {
  87070. /**
  87071. * The list of aggregated animations to run.
  87072. */
  87073. children: Action[];
  87074. /**
  87075. * Instantiate the action
  87076. * @param triggerOptions defines the trigger options
  87077. * @param children defines the list of aggregated animations to run
  87078. * @param condition defines the trigger related conditions
  87079. */
  87080. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87081. /** @hidden */
  87082. _prepare(): void;
  87083. /**
  87084. * Execute the action and executes all the aggregated actions.
  87085. */
  87086. execute(evt: ActionEvent): void;
  87087. /**
  87088. * Serializes the actions and its related information.
  87089. * @param parent defines the object to serialize in
  87090. * @returns the serialized object
  87091. */
  87092. serialize(parent: any): any;
  87093. }
  87094. /**
  87095. * This defines an action responsible to run code (external event) once triggered.
  87096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87097. */
  87098. export class ExecuteCodeAction extends Action {
  87099. /**
  87100. * The callback function to run.
  87101. */
  87102. func: (evt: ActionEvent) => void;
  87103. /**
  87104. * Instantiate the action
  87105. * @param triggerOptions defines the trigger options
  87106. * @param func defines the callback function to run
  87107. * @param condition defines the trigger related conditions
  87108. */
  87109. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87110. /**
  87111. * Execute the action and run the attached code.
  87112. */
  87113. execute(evt: ActionEvent): void;
  87114. }
  87115. /**
  87116. * This defines an action responsible to set the parent property of the target once triggered.
  87117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87118. */
  87119. export class SetParentAction extends Action {
  87120. private _parent;
  87121. private _target;
  87122. /**
  87123. * Instantiate the action
  87124. * @param triggerOptions defines the trigger options
  87125. * @param target defines the target containing the parent property
  87126. * @param parent defines from where the animation should start (animation frame)
  87127. * @param condition defines the trigger related conditions
  87128. */
  87129. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87130. /** @hidden */
  87131. _prepare(): void;
  87132. /**
  87133. * Execute the action and set the parent property.
  87134. */
  87135. execute(): void;
  87136. /**
  87137. * Serializes the actions and its related information.
  87138. * @param parent defines the object to serialize in
  87139. * @returns the serialized object
  87140. */
  87141. serialize(parent: any): any;
  87142. }
  87143. }
  87144. declare module BABYLON {
  87145. /**
  87146. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87147. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87149. */
  87150. export class ActionManager extends AbstractActionManager {
  87151. /**
  87152. * Nothing
  87153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87154. */
  87155. static readonly NothingTrigger: number;
  87156. /**
  87157. * On pick
  87158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87159. */
  87160. static readonly OnPickTrigger: number;
  87161. /**
  87162. * On left pick
  87163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87164. */
  87165. static readonly OnLeftPickTrigger: number;
  87166. /**
  87167. * On right pick
  87168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87169. */
  87170. static readonly OnRightPickTrigger: number;
  87171. /**
  87172. * On center pick
  87173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87174. */
  87175. static readonly OnCenterPickTrigger: number;
  87176. /**
  87177. * On pick down
  87178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87179. */
  87180. static readonly OnPickDownTrigger: number;
  87181. /**
  87182. * On double pick
  87183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87184. */
  87185. static readonly OnDoublePickTrigger: number;
  87186. /**
  87187. * On pick up
  87188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87189. */
  87190. static readonly OnPickUpTrigger: number;
  87191. /**
  87192. * On pick out.
  87193. * This trigger will only be raised if you also declared a OnPickDown
  87194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87195. */
  87196. static readonly OnPickOutTrigger: number;
  87197. /**
  87198. * On long press
  87199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87200. */
  87201. static readonly OnLongPressTrigger: number;
  87202. /**
  87203. * On pointer over
  87204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87205. */
  87206. static readonly OnPointerOverTrigger: number;
  87207. /**
  87208. * On pointer out
  87209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87210. */
  87211. static readonly OnPointerOutTrigger: number;
  87212. /**
  87213. * On every frame
  87214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87215. */
  87216. static readonly OnEveryFrameTrigger: number;
  87217. /**
  87218. * On intersection enter
  87219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87220. */
  87221. static readonly OnIntersectionEnterTrigger: number;
  87222. /**
  87223. * On intersection exit
  87224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87225. */
  87226. static readonly OnIntersectionExitTrigger: number;
  87227. /**
  87228. * On key down
  87229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87230. */
  87231. static readonly OnKeyDownTrigger: number;
  87232. /**
  87233. * On key up
  87234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87235. */
  87236. static readonly OnKeyUpTrigger: number;
  87237. private _scene;
  87238. /**
  87239. * Creates a new action manager
  87240. * @param scene defines the hosting scene
  87241. */
  87242. constructor(scene: Scene);
  87243. /**
  87244. * Releases all associated resources
  87245. */
  87246. dispose(): void;
  87247. /**
  87248. * Gets hosting scene
  87249. * @returns the hosting scene
  87250. */
  87251. getScene(): Scene;
  87252. /**
  87253. * Does this action manager handles actions of any of the given triggers
  87254. * @param triggers defines the triggers to be tested
  87255. * @return a boolean indicating whether one (or more) of the triggers is handled
  87256. */
  87257. hasSpecificTriggers(triggers: number[]): boolean;
  87258. /**
  87259. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87260. * speed.
  87261. * @param triggerA defines the trigger to be tested
  87262. * @param triggerB defines the trigger to be tested
  87263. * @return a boolean indicating whether one (or more) of the triggers is handled
  87264. */
  87265. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87266. /**
  87267. * Does this action manager handles actions of a given trigger
  87268. * @param trigger defines the trigger to be tested
  87269. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87270. * @return whether the trigger is handled
  87271. */
  87272. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87273. /**
  87274. * Does this action manager has pointer triggers
  87275. */
  87276. get hasPointerTriggers(): boolean;
  87277. /**
  87278. * Does this action manager has pick triggers
  87279. */
  87280. get hasPickTriggers(): boolean;
  87281. /**
  87282. * Registers an action to this action manager
  87283. * @param action defines the action to be registered
  87284. * @return the action amended (prepared) after registration
  87285. */
  87286. registerAction(action: IAction): Nullable<IAction>;
  87287. /**
  87288. * Unregisters an action to this action manager
  87289. * @param action defines the action to be unregistered
  87290. * @return a boolean indicating whether the action has been unregistered
  87291. */
  87292. unregisterAction(action: IAction): Boolean;
  87293. /**
  87294. * Process a specific trigger
  87295. * @param trigger defines the trigger to process
  87296. * @param evt defines the event details to be processed
  87297. */
  87298. processTrigger(trigger: number, evt?: IActionEvent): void;
  87299. /** @hidden */
  87300. _getEffectiveTarget(target: any, propertyPath: string): any;
  87301. /** @hidden */
  87302. _getProperty(propertyPath: string): string;
  87303. /**
  87304. * Serialize this manager to a JSON object
  87305. * @param name defines the property name to store this manager
  87306. * @returns a JSON representation of this manager
  87307. */
  87308. serialize(name: string): any;
  87309. /**
  87310. * Creates a new ActionManager from a JSON data
  87311. * @param parsedActions defines the JSON data to read from
  87312. * @param object defines the hosting mesh
  87313. * @param scene defines the hosting scene
  87314. */
  87315. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87316. /**
  87317. * Get a trigger name by index
  87318. * @param trigger defines the trigger index
  87319. * @returns a trigger name
  87320. */
  87321. static GetTriggerName(trigger: number): string;
  87322. }
  87323. }
  87324. declare module BABYLON {
  87325. /**
  87326. * Class used to represent a sprite
  87327. * @see http://doc.babylonjs.com/babylon101/sprites
  87328. */
  87329. export class Sprite implements IAnimatable {
  87330. /** defines the name */
  87331. name: string;
  87332. /** Gets or sets the current world position */
  87333. position: Vector3;
  87334. /** Gets or sets the main color */
  87335. color: Color4;
  87336. /** Gets or sets the width */
  87337. width: number;
  87338. /** Gets or sets the height */
  87339. height: number;
  87340. /** Gets or sets rotation angle */
  87341. angle: number;
  87342. /** Gets or sets the cell index in the sprite sheet */
  87343. cellIndex: number;
  87344. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87345. cellRef: string;
  87346. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87347. invertU: boolean;
  87348. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87349. invertV: boolean;
  87350. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87351. disposeWhenFinishedAnimating: boolean;
  87352. /** Gets the list of attached animations */
  87353. animations: Nullable<Array<Animation>>;
  87354. /** Gets or sets a boolean indicating if the sprite can be picked */
  87355. isPickable: boolean;
  87356. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87357. useAlphaForPicking: boolean;
  87358. /** @hidden */
  87359. _xOffset: number;
  87360. /** @hidden */
  87361. _yOffset: number;
  87362. /** @hidden */
  87363. _xSize: number;
  87364. /** @hidden */
  87365. _ySize: number;
  87366. /**
  87367. * Gets or sets the associated action manager
  87368. */
  87369. actionManager: Nullable<ActionManager>;
  87370. /**
  87371. * An event triggered when the control has been disposed
  87372. */
  87373. onDisposeObservable: Observable<Sprite>;
  87374. private _animationStarted;
  87375. private _loopAnimation;
  87376. private _fromIndex;
  87377. private _toIndex;
  87378. private _delay;
  87379. private _direction;
  87380. private _manager;
  87381. private _time;
  87382. private _onAnimationEnd;
  87383. /**
  87384. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87385. */
  87386. isVisible: boolean;
  87387. /**
  87388. * Gets or sets the sprite size
  87389. */
  87390. get size(): number;
  87391. set size(value: number);
  87392. /**
  87393. * Returns a boolean indicating if the animation is started
  87394. */
  87395. get animationStarted(): boolean;
  87396. /**
  87397. * Gets or sets the unique id of the sprite
  87398. */
  87399. uniqueId: number;
  87400. /**
  87401. * Gets the manager of this sprite
  87402. */
  87403. get manager(): ISpriteManager;
  87404. /**
  87405. * Creates a new Sprite
  87406. * @param name defines the name
  87407. * @param manager defines the manager
  87408. */
  87409. constructor(
  87410. /** defines the name */
  87411. name: string, manager: ISpriteManager);
  87412. /**
  87413. * Returns the string "Sprite"
  87414. * @returns "Sprite"
  87415. */
  87416. getClassName(): string;
  87417. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87418. get fromIndex(): number;
  87419. set fromIndex(value: number);
  87420. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87421. get toIndex(): number;
  87422. set toIndex(value: number);
  87423. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87424. get loopAnimation(): boolean;
  87425. set loopAnimation(value: boolean);
  87426. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87427. get delay(): number;
  87428. set delay(value: number);
  87429. /**
  87430. * Starts an animation
  87431. * @param from defines the initial key
  87432. * @param to defines the end key
  87433. * @param loop defines if the animation must loop
  87434. * @param delay defines the start delay (in ms)
  87435. * @param onAnimationEnd defines a callback to call when animation ends
  87436. */
  87437. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87438. /** Stops current animation (if any) */
  87439. stopAnimation(): void;
  87440. /** @hidden */
  87441. _animate(deltaTime: number): void;
  87442. /** Release associated resources */
  87443. dispose(): void;
  87444. /**
  87445. * Serializes the sprite to a JSON object
  87446. * @returns the JSON object
  87447. */
  87448. serialize(): any;
  87449. /**
  87450. * Parses a JSON object to create a new sprite
  87451. * @param parsedSprite The JSON object to parse
  87452. * @param manager defines the hosting manager
  87453. * @returns the new sprite
  87454. */
  87455. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87456. }
  87457. }
  87458. declare module BABYLON {
  87459. /**
  87460. * Information about the result of picking within a scene
  87461. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87462. */
  87463. export class PickingInfo {
  87464. /** @hidden */
  87465. _pickingUnavailable: boolean;
  87466. /**
  87467. * If the pick collided with an object
  87468. */
  87469. hit: boolean;
  87470. /**
  87471. * Distance away where the pick collided
  87472. */
  87473. distance: number;
  87474. /**
  87475. * The location of pick collision
  87476. */
  87477. pickedPoint: Nullable<Vector3>;
  87478. /**
  87479. * The mesh corresponding the the pick collision
  87480. */
  87481. pickedMesh: Nullable<AbstractMesh>;
  87482. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  87483. bu: number;
  87484. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  87485. bv: number;
  87486. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87487. faceId: number;
  87488. /** Id of the the submesh that was picked */
  87489. subMeshId: number;
  87490. /** If a sprite was picked, this will be the sprite the pick collided with */
  87491. pickedSprite: Nullable<Sprite>;
  87492. /**
  87493. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  87494. */
  87495. originMesh: Nullable<AbstractMesh>;
  87496. /**
  87497. * The ray that was used to perform the picking.
  87498. */
  87499. ray: Nullable<Ray>;
  87500. /**
  87501. * Gets the normal correspodning to the face the pick collided with
  87502. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  87503. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  87504. * @returns The normal correspodning to the face the pick collided with
  87505. */
  87506. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  87507. /**
  87508. * Gets the texture coordinates of where the pick occured
  87509. * @returns the vector containing the coordnates of the texture
  87510. */
  87511. getTextureCoordinates(): Nullable<Vector2>;
  87512. }
  87513. }
  87514. declare module BABYLON {
  87515. /**
  87516. * Class representing a ray with position and direction
  87517. */
  87518. export class Ray {
  87519. /** origin point */
  87520. origin: Vector3;
  87521. /** direction */
  87522. direction: Vector3;
  87523. /** length of the ray */
  87524. length: number;
  87525. private static readonly TmpVector3;
  87526. private _tmpRay;
  87527. /**
  87528. * Creates a new ray
  87529. * @param origin origin point
  87530. * @param direction direction
  87531. * @param length length of the ray
  87532. */
  87533. constructor(
  87534. /** origin point */
  87535. origin: Vector3,
  87536. /** direction */
  87537. direction: Vector3,
  87538. /** length of the ray */
  87539. length?: number);
  87540. /**
  87541. * Checks if the ray intersects a box
  87542. * This does not account for the ray lenght by design to improve perfs.
  87543. * @param minimum bound of the box
  87544. * @param maximum bound of the box
  87545. * @param intersectionTreshold extra extend to be added to the box in all direction
  87546. * @returns if the box was hit
  87547. */
  87548. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  87549. /**
  87550. * Checks if the ray intersects a box
  87551. * This does not account for the ray lenght by design to improve perfs.
  87552. * @param box the bounding box to check
  87553. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  87554. * @returns if the box was hit
  87555. */
  87556. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  87557. /**
  87558. * If the ray hits a sphere
  87559. * @param sphere the bounding sphere to check
  87560. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  87561. * @returns true if it hits the sphere
  87562. */
  87563. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  87564. /**
  87565. * If the ray hits a triange
  87566. * @param vertex0 triangle vertex
  87567. * @param vertex1 triangle vertex
  87568. * @param vertex2 triangle vertex
  87569. * @returns intersection information if hit
  87570. */
  87571. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  87572. /**
  87573. * Checks if ray intersects a plane
  87574. * @param plane the plane to check
  87575. * @returns the distance away it was hit
  87576. */
  87577. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  87578. /**
  87579. * Calculate the intercept of a ray on a given axis
  87580. * @param axis to check 'x' | 'y' | 'z'
  87581. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  87582. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  87583. */
  87584. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  87585. /**
  87586. * Checks if ray intersects a mesh
  87587. * @param mesh the mesh to check
  87588. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87589. * @returns picking info of the intersecton
  87590. */
  87591. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  87592. /**
  87593. * Checks if ray intersects a mesh
  87594. * @param meshes the meshes to check
  87595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87596. * @param results array to store result in
  87597. * @returns Array of picking infos
  87598. */
  87599. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  87600. private _comparePickingInfo;
  87601. private static smallnum;
  87602. private static rayl;
  87603. /**
  87604. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  87605. * @param sega the first point of the segment to test the intersection against
  87606. * @param segb the second point of the segment to test the intersection against
  87607. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  87608. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  87609. */
  87610. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  87611. /**
  87612. * Update the ray from viewport position
  87613. * @param x position
  87614. * @param y y position
  87615. * @param viewportWidth viewport width
  87616. * @param viewportHeight viewport height
  87617. * @param world world matrix
  87618. * @param view view matrix
  87619. * @param projection projection matrix
  87620. * @returns this ray updated
  87621. */
  87622. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87623. /**
  87624. * Creates a ray with origin and direction of 0,0,0
  87625. * @returns the new ray
  87626. */
  87627. static Zero(): Ray;
  87628. /**
  87629. * Creates a new ray from screen space and viewport
  87630. * @param x position
  87631. * @param y y position
  87632. * @param viewportWidth viewport width
  87633. * @param viewportHeight viewport height
  87634. * @param world world matrix
  87635. * @param view view matrix
  87636. * @param projection projection matrix
  87637. * @returns new ray
  87638. */
  87639. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87640. /**
  87641. * 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
  87642. * transformed to the given world matrix.
  87643. * @param origin The origin point
  87644. * @param end The end point
  87645. * @param world a matrix to transform the ray to. Default is the identity matrix.
  87646. * @returns the new ray
  87647. */
  87648. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  87649. /**
  87650. * Transforms a ray by a matrix
  87651. * @param ray ray to transform
  87652. * @param matrix matrix to apply
  87653. * @returns the resulting new ray
  87654. */
  87655. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  87656. /**
  87657. * Transforms a ray by a matrix
  87658. * @param ray ray to transform
  87659. * @param matrix matrix to apply
  87660. * @param result ray to store result in
  87661. */
  87662. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  87663. /**
  87664. * Unproject a ray from screen space to object space
  87665. * @param sourceX defines the screen space x coordinate to use
  87666. * @param sourceY defines the screen space y coordinate to use
  87667. * @param viewportWidth defines the current width of the viewport
  87668. * @param viewportHeight defines the current height of the viewport
  87669. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  87670. * @param view defines the view matrix to use
  87671. * @param projection defines the projection matrix to use
  87672. */
  87673. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  87674. }
  87675. /**
  87676. * Type used to define predicate used to select faces when a mesh intersection is detected
  87677. */
  87678. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  87679. interface Scene {
  87680. /** @hidden */
  87681. _tempPickingRay: Nullable<Ray>;
  87682. /** @hidden */
  87683. _cachedRayForTransform: Ray;
  87684. /** @hidden */
  87685. _pickWithRayInverseMatrix: Matrix;
  87686. /** @hidden */
  87687. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  87688. /** @hidden */
  87689. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /**
  87694. * Groups all the scene component constants in one place to ease maintenance.
  87695. * @hidden
  87696. */
  87697. export class SceneComponentConstants {
  87698. static readonly NAME_EFFECTLAYER: string;
  87699. static readonly NAME_LAYER: string;
  87700. static readonly NAME_LENSFLARESYSTEM: string;
  87701. static readonly NAME_BOUNDINGBOXRENDERER: string;
  87702. static readonly NAME_PARTICLESYSTEM: string;
  87703. static readonly NAME_GAMEPAD: string;
  87704. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  87705. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  87706. static readonly NAME_DEPTHRENDERER: string;
  87707. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  87708. static readonly NAME_SPRITE: string;
  87709. static readonly NAME_OUTLINERENDERER: string;
  87710. static readonly NAME_PROCEDURALTEXTURE: string;
  87711. static readonly NAME_SHADOWGENERATOR: string;
  87712. static readonly NAME_OCTREE: string;
  87713. static readonly NAME_PHYSICSENGINE: string;
  87714. static readonly NAME_AUDIO: string;
  87715. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  87716. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87717. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  87718. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87719. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  87720. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  87721. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  87722. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  87723. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  87724. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  87725. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  87726. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  87727. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  87728. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  87729. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  87730. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  87731. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  87732. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  87733. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  87734. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  87735. static readonly STEP_AFTERRENDER_AUDIO: number;
  87736. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  87737. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  87738. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  87739. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  87740. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  87741. static readonly STEP_POINTERMOVE_SPRITE: number;
  87742. static readonly STEP_POINTERDOWN_SPRITE: number;
  87743. static readonly STEP_POINTERUP_SPRITE: number;
  87744. }
  87745. /**
  87746. * This represents a scene component.
  87747. *
  87748. * This is used to decouple the dependency the scene is having on the different workloads like
  87749. * layers, post processes...
  87750. */
  87751. export interface ISceneComponent {
  87752. /**
  87753. * The name of the component. Each component must have a unique name.
  87754. */
  87755. name: string;
  87756. /**
  87757. * The scene the component belongs to.
  87758. */
  87759. scene: Scene;
  87760. /**
  87761. * Register the component to one instance of a scene.
  87762. */
  87763. register(): void;
  87764. /**
  87765. * Rebuilds the elements related to this component in case of
  87766. * context lost for instance.
  87767. */
  87768. rebuild(): void;
  87769. /**
  87770. * Disposes the component and the associated ressources.
  87771. */
  87772. dispose(): void;
  87773. }
  87774. /**
  87775. * This represents a SERIALIZABLE scene component.
  87776. *
  87777. * This extends Scene Component to add Serialization methods on top.
  87778. */
  87779. export interface ISceneSerializableComponent extends ISceneComponent {
  87780. /**
  87781. * Adds all the elements from the container to the scene
  87782. * @param container the container holding the elements
  87783. */
  87784. addFromContainer(container: AbstractScene): void;
  87785. /**
  87786. * Removes all the elements in the container from the scene
  87787. * @param container contains the elements to remove
  87788. * @param dispose if the removed element should be disposed (default: false)
  87789. */
  87790. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  87791. /**
  87792. * Serializes the component data to the specified json object
  87793. * @param serializationObject The object to serialize to
  87794. */
  87795. serialize(serializationObject: any): void;
  87796. }
  87797. /**
  87798. * Strong typing of a Mesh related stage step action
  87799. */
  87800. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  87801. /**
  87802. * Strong typing of a Evaluate Sub Mesh related stage step action
  87803. */
  87804. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  87805. /**
  87806. * Strong typing of a Active Mesh related stage step action
  87807. */
  87808. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  87809. /**
  87810. * Strong typing of a Camera related stage step action
  87811. */
  87812. export type CameraStageAction = (camera: Camera) => void;
  87813. /**
  87814. * Strong typing of a Camera Frame buffer related stage step action
  87815. */
  87816. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  87817. /**
  87818. * Strong typing of a Render Target related stage step action
  87819. */
  87820. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  87821. /**
  87822. * Strong typing of a RenderingGroup related stage step action
  87823. */
  87824. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  87825. /**
  87826. * Strong typing of a Mesh Render related stage step action
  87827. */
  87828. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  87829. /**
  87830. * Strong typing of a simple stage step action
  87831. */
  87832. export type SimpleStageAction = () => void;
  87833. /**
  87834. * Strong typing of a render target action.
  87835. */
  87836. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  87837. /**
  87838. * Strong typing of a pointer move action.
  87839. */
  87840. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  87841. /**
  87842. * Strong typing of a pointer up/down action.
  87843. */
  87844. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  87845. /**
  87846. * Representation of a stage in the scene (Basically a list of ordered steps)
  87847. * @hidden
  87848. */
  87849. export class Stage<T extends Function> extends Array<{
  87850. index: number;
  87851. component: ISceneComponent;
  87852. action: T;
  87853. }> {
  87854. /**
  87855. * Hide ctor from the rest of the world.
  87856. * @param items The items to add.
  87857. */
  87858. private constructor();
  87859. /**
  87860. * Creates a new Stage.
  87861. * @returns A new instance of a Stage
  87862. */
  87863. static Create<T extends Function>(): Stage<T>;
  87864. /**
  87865. * Registers a step in an ordered way in the targeted stage.
  87866. * @param index Defines the position to register the step in
  87867. * @param component Defines the component attached to the step
  87868. * @param action Defines the action to launch during the step
  87869. */
  87870. registerStep(index: number, component: ISceneComponent, action: T): void;
  87871. /**
  87872. * Clears all the steps from the stage.
  87873. */
  87874. clear(): void;
  87875. }
  87876. }
  87877. declare module BABYLON {
  87878. interface Scene {
  87879. /** @hidden */
  87880. _pointerOverSprite: Nullable<Sprite>;
  87881. /** @hidden */
  87882. _pickedDownSprite: Nullable<Sprite>;
  87883. /** @hidden */
  87884. _tempSpritePickingRay: Nullable<Ray>;
  87885. /**
  87886. * All of the sprite managers added to this scene
  87887. * @see http://doc.babylonjs.com/babylon101/sprites
  87888. */
  87889. spriteManagers: Array<ISpriteManager>;
  87890. /**
  87891. * An event triggered when sprites rendering is about to start
  87892. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87893. */
  87894. onBeforeSpritesRenderingObservable: Observable<Scene>;
  87895. /**
  87896. * An event triggered when sprites rendering is done
  87897. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87898. */
  87899. onAfterSpritesRenderingObservable: Observable<Scene>;
  87900. /** @hidden */
  87901. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87902. /** Launch a ray to try to pick a sprite in the scene
  87903. * @param x position on screen
  87904. * @param y position on screen
  87905. * @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
  87906. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87907. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87908. * @returns a PickingInfo
  87909. */
  87910. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87911. /** Use the given ray to pick a sprite in the scene
  87912. * @param ray The ray (in world space) to use to pick meshes
  87913. * @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
  87914. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87915. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87916. * @returns a PickingInfo
  87917. */
  87918. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87919. /** @hidden */
  87920. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87921. /** Launch a ray to try to pick sprites in the scene
  87922. * @param x position on screen
  87923. * @param y position on screen
  87924. * @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
  87925. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87926. * @returns a PickingInfo array
  87927. */
  87928. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87929. /** Use the given ray to pick sprites in the scene
  87930. * @param ray The ray (in world space) to use to pick meshes
  87931. * @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
  87932. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87933. * @returns a PickingInfo array
  87934. */
  87935. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87936. /**
  87937. * Force the sprite under the pointer
  87938. * @param sprite defines the sprite to use
  87939. */
  87940. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  87941. /**
  87942. * Gets the sprite under the pointer
  87943. * @returns a Sprite or null if no sprite is under the pointer
  87944. */
  87945. getPointerOverSprite(): Nullable<Sprite>;
  87946. }
  87947. /**
  87948. * Defines the sprite scene component responsible to manage sprites
  87949. * in a given scene.
  87950. */
  87951. export class SpriteSceneComponent implements ISceneComponent {
  87952. /**
  87953. * The component name helpfull to identify the component in the list of scene components.
  87954. */
  87955. readonly name: string;
  87956. /**
  87957. * The scene the component belongs to.
  87958. */
  87959. scene: Scene;
  87960. /** @hidden */
  87961. private _spritePredicate;
  87962. /**
  87963. * Creates a new instance of the component for the given scene
  87964. * @param scene Defines the scene to register the component in
  87965. */
  87966. constructor(scene: Scene);
  87967. /**
  87968. * Registers the component in a given scene
  87969. */
  87970. register(): void;
  87971. /**
  87972. * Rebuilds the elements related to this component in case of
  87973. * context lost for instance.
  87974. */
  87975. rebuild(): void;
  87976. /**
  87977. * Disposes the component and the associated ressources.
  87978. */
  87979. dispose(): void;
  87980. private _pickSpriteButKeepRay;
  87981. private _pointerMove;
  87982. private _pointerDown;
  87983. private _pointerUp;
  87984. }
  87985. }
  87986. declare module BABYLON {
  87987. /** @hidden */
  87988. export var fogFragmentDeclaration: {
  87989. name: string;
  87990. shader: string;
  87991. };
  87992. }
  87993. declare module BABYLON {
  87994. /** @hidden */
  87995. export var fogFragment: {
  87996. name: string;
  87997. shader: string;
  87998. };
  87999. }
  88000. declare module BABYLON {
  88001. /** @hidden */
  88002. export var spritesPixelShader: {
  88003. name: string;
  88004. shader: string;
  88005. };
  88006. }
  88007. declare module BABYLON {
  88008. /** @hidden */
  88009. export var fogVertexDeclaration: {
  88010. name: string;
  88011. shader: string;
  88012. };
  88013. }
  88014. declare module BABYLON {
  88015. /** @hidden */
  88016. export var spritesVertexShader: {
  88017. name: string;
  88018. shader: string;
  88019. };
  88020. }
  88021. declare module BABYLON {
  88022. /**
  88023. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88024. */
  88025. export interface ISpriteManager extends IDisposable {
  88026. /**
  88027. * Gets manager's name
  88028. */
  88029. name: string;
  88030. /**
  88031. * Restricts the camera to viewing objects with the same layerMask.
  88032. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88033. */
  88034. layerMask: number;
  88035. /**
  88036. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88037. */
  88038. isPickable: boolean;
  88039. /**
  88040. * Gets the hosting scene
  88041. */
  88042. scene: Scene;
  88043. /**
  88044. * Specifies the rendering group id for this mesh (0 by default)
  88045. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88046. */
  88047. renderingGroupId: number;
  88048. /**
  88049. * Defines the list of sprites managed by the manager.
  88050. */
  88051. sprites: Array<Sprite>;
  88052. /**
  88053. * Gets or sets the spritesheet texture
  88054. */
  88055. texture: Texture;
  88056. /** Defines the default width of a cell in the spritesheet */
  88057. cellWidth: number;
  88058. /** Defines the default height of a cell in the spritesheet */
  88059. cellHeight: number;
  88060. /**
  88061. * Tests the intersection of a sprite with a specific ray.
  88062. * @param ray The ray we are sending to test the collision
  88063. * @param camera The camera space we are sending rays in
  88064. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88065. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88066. * @returns picking info or null.
  88067. */
  88068. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88069. /**
  88070. * Intersects the sprites with a ray
  88071. * @param ray defines the ray to intersect with
  88072. * @param camera defines the current active camera
  88073. * @param predicate defines a predicate used to select candidate sprites
  88074. * @returns null if no hit or a PickingInfo array
  88075. */
  88076. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88077. /**
  88078. * Renders the list of sprites on screen.
  88079. */
  88080. render(): void;
  88081. }
  88082. /**
  88083. * Class used to manage multiple sprites on the same spritesheet
  88084. * @see http://doc.babylonjs.com/babylon101/sprites
  88085. */
  88086. export class SpriteManager implements ISpriteManager {
  88087. /** defines the manager's name */
  88088. name: string;
  88089. /** Define the Url to load snippets */
  88090. static SnippetUrl: string;
  88091. /** Snippet ID if the manager was created from the snippet server */
  88092. snippetId: string;
  88093. /** Gets the list of sprites */
  88094. sprites: Sprite[];
  88095. /** Gets or sets the rendering group id (0 by default) */
  88096. renderingGroupId: number;
  88097. /** Gets or sets camera layer mask */
  88098. layerMask: number;
  88099. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88100. fogEnabled: boolean;
  88101. /** Gets or sets a boolean indicating if the sprites are pickable */
  88102. isPickable: boolean;
  88103. /** Defines the default width of a cell in the spritesheet */
  88104. cellWidth: number;
  88105. /** Defines the default height of a cell in the spritesheet */
  88106. cellHeight: number;
  88107. /** Associative array from JSON sprite data file */
  88108. private _cellData;
  88109. /** Array of sprite names from JSON sprite data file */
  88110. private _spriteMap;
  88111. /** True when packed cell data from JSON file is ready*/
  88112. private _packedAndReady;
  88113. private _textureContent;
  88114. /**
  88115. * An event triggered when the manager is disposed.
  88116. */
  88117. onDisposeObservable: Observable<SpriteManager>;
  88118. private _onDisposeObserver;
  88119. /**
  88120. * Callback called when the manager is disposed
  88121. */
  88122. set onDispose(callback: () => void);
  88123. private _capacity;
  88124. private _fromPacked;
  88125. private _spriteTexture;
  88126. private _epsilon;
  88127. private _scene;
  88128. private _vertexData;
  88129. private _buffer;
  88130. private _vertexBuffers;
  88131. private _indexBuffer;
  88132. private _effectBase;
  88133. private _effectFog;
  88134. /**
  88135. * Gets or sets the unique id of the sprite
  88136. */
  88137. uniqueId: number;
  88138. /**
  88139. * Gets the array of sprites
  88140. */
  88141. get children(): Sprite[];
  88142. /**
  88143. * Gets the hosting scene
  88144. */
  88145. get scene(): Scene;
  88146. /**
  88147. * Gets the capacity of the manager
  88148. */
  88149. get capacity(): number;
  88150. /**
  88151. * Gets or sets the spritesheet texture
  88152. */
  88153. get texture(): Texture;
  88154. set texture(value: Texture);
  88155. private _blendMode;
  88156. /**
  88157. * Blend mode use to render the particle, it can be any of
  88158. * the static Constants.ALPHA_x properties provided in this class.
  88159. * Default value is Constants.ALPHA_COMBINE
  88160. */
  88161. get blendMode(): number;
  88162. set blendMode(blendMode: number);
  88163. /** Disables writing to the depth buffer when rendering the sprites.
  88164. * It can be handy to disable depth writing when using textures without alpha channel
  88165. * and setting some specific blend modes.
  88166. */
  88167. disableDepthWrite: boolean;
  88168. /**
  88169. * Creates a new sprite manager
  88170. * @param name defines the manager's name
  88171. * @param imgUrl defines the sprite sheet url
  88172. * @param capacity defines the maximum allowed number of sprites
  88173. * @param cellSize defines the size of a sprite cell
  88174. * @param scene defines the hosting scene
  88175. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88176. * @param samplingMode defines the smapling mode to use with spritesheet
  88177. * @param fromPacked set to false; do not alter
  88178. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88179. */
  88180. constructor(
  88181. /** defines the manager's name */
  88182. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88183. /**
  88184. * Returns the string "SpriteManager"
  88185. * @returns "SpriteManager"
  88186. */
  88187. getClassName(): string;
  88188. private _makePacked;
  88189. private _appendSpriteVertex;
  88190. private _checkTextureAlpha;
  88191. /**
  88192. * Intersects the sprites with a ray
  88193. * @param ray defines the ray to intersect with
  88194. * @param camera defines the current active camera
  88195. * @param predicate defines a predicate used to select candidate sprites
  88196. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88197. * @returns null if no hit or a PickingInfo
  88198. */
  88199. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88200. /**
  88201. * Intersects the sprites with a ray
  88202. * @param ray defines the ray to intersect with
  88203. * @param camera defines the current active camera
  88204. * @param predicate defines a predicate used to select candidate sprites
  88205. * @returns null if no hit or a PickingInfo array
  88206. */
  88207. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88208. /**
  88209. * Render all child sprites
  88210. */
  88211. render(): void;
  88212. /**
  88213. * Release associated resources
  88214. */
  88215. dispose(): void;
  88216. /**
  88217. * Serializes the sprite manager to a JSON object
  88218. * @param serializeTexture defines if the texture must be serialized as well
  88219. * @returns the JSON object
  88220. */
  88221. serialize(serializeTexture?: boolean): any;
  88222. /**
  88223. * Parses a JSON object to create a new sprite manager.
  88224. * @param parsedManager The JSON object to parse
  88225. * @param scene The scene to create the sprite managerin
  88226. * @param rootUrl The root url to use to load external dependencies like texture
  88227. * @returns the new sprite manager
  88228. */
  88229. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88230. /**
  88231. * Creates a sprite manager from a snippet saved in a remote file
  88232. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88233. * @param url defines the url to load from
  88234. * @param scene defines the hosting scene
  88235. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88236. * @returns a promise that will resolve to the new sprite manager
  88237. */
  88238. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88239. /**
  88240. * Creates a sprite manager from a snippet saved by the sprite editor
  88241. * @param snippetId defines the snippet to load
  88242. * @param scene defines the hosting scene
  88243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88244. * @returns a promise that will resolve to the new sprite manager
  88245. */
  88246. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88247. }
  88248. }
  88249. declare module BABYLON {
  88250. /** Interface used by value gradients (color, factor, ...) */
  88251. export interface IValueGradient {
  88252. /**
  88253. * Gets or sets the gradient value (between 0 and 1)
  88254. */
  88255. gradient: number;
  88256. }
  88257. /** Class used to store color4 gradient */
  88258. export class ColorGradient implements IValueGradient {
  88259. /**
  88260. * Gets or sets the gradient value (between 0 and 1)
  88261. */
  88262. gradient: number;
  88263. /**
  88264. * Gets or sets first associated color
  88265. */
  88266. color1: Color4;
  88267. /**
  88268. * Gets or sets second associated color
  88269. */
  88270. color2?: Color4 | undefined;
  88271. /**
  88272. * Creates a new color4 gradient
  88273. * @param gradient gets or sets the gradient value (between 0 and 1)
  88274. * @param color1 gets or sets first associated color
  88275. * @param color2 gets or sets first second color
  88276. */
  88277. constructor(
  88278. /**
  88279. * Gets or sets the gradient value (between 0 and 1)
  88280. */
  88281. gradient: number,
  88282. /**
  88283. * Gets or sets first associated color
  88284. */
  88285. color1: Color4,
  88286. /**
  88287. * Gets or sets second associated color
  88288. */
  88289. color2?: Color4 | undefined);
  88290. /**
  88291. * Will get a color picked randomly between color1 and color2.
  88292. * If color2 is undefined then color1 will be used
  88293. * @param result defines the target Color4 to store the result in
  88294. */
  88295. getColorToRef(result: Color4): void;
  88296. }
  88297. /** Class used to store color 3 gradient */
  88298. export class Color3Gradient implements IValueGradient {
  88299. /**
  88300. * Gets or sets the gradient value (between 0 and 1)
  88301. */
  88302. gradient: number;
  88303. /**
  88304. * Gets or sets the associated color
  88305. */
  88306. color: Color3;
  88307. /**
  88308. * Creates a new color3 gradient
  88309. * @param gradient gets or sets the gradient value (between 0 and 1)
  88310. * @param color gets or sets associated color
  88311. */
  88312. constructor(
  88313. /**
  88314. * Gets or sets the gradient value (between 0 and 1)
  88315. */
  88316. gradient: number,
  88317. /**
  88318. * Gets or sets the associated color
  88319. */
  88320. color: Color3);
  88321. }
  88322. /** Class used to store factor gradient */
  88323. export class FactorGradient implements IValueGradient {
  88324. /**
  88325. * Gets or sets the gradient value (between 0 and 1)
  88326. */
  88327. gradient: number;
  88328. /**
  88329. * Gets or sets first associated factor
  88330. */
  88331. factor1: number;
  88332. /**
  88333. * Gets or sets second associated factor
  88334. */
  88335. factor2?: number | undefined;
  88336. /**
  88337. * Creates a new factor gradient
  88338. * @param gradient gets or sets the gradient value (between 0 and 1)
  88339. * @param factor1 gets or sets first associated factor
  88340. * @param factor2 gets or sets second associated factor
  88341. */
  88342. constructor(
  88343. /**
  88344. * Gets or sets the gradient value (between 0 and 1)
  88345. */
  88346. gradient: number,
  88347. /**
  88348. * Gets or sets first associated factor
  88349. */
  88350. factor1: number,
  88351. /**
  88352. * Gets or sets second associated factor
  88353. */
  88354. factor2?: number | undefined);
  88355. /**
  88356. * Will get a number picked randomly between factor1 and factor2.
  88357. * If factor2 is undefined then factor1 will be used
  88358. * @returns the picked number
  88359. */
  88360. getFactor(): number;
  88361. }
  88362. /**
  88363. * Helper used to simplify some generic gradient tasks
  88364. */
  88365. export class GradientHelper {
  88366. /**
  88367. * Gets the current gradient from an array of IValueGradient
  88368. * @param ratio defines the current ratio to get
  88369. * @param gradients defines the array of IValueGradient
  88370. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88371. */
  88372. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88373. }
  88374. }
  88375. declare module BABYLON {
  88376. interface ThinEngine {
  88377. /**
  88378. * Creates a dynamic texture
  88379. * @param width defines the width of the texture
  88380. * @param height defines the height of the texture
  88381. * @param generateMipMaps defines if the engine should generate the mip levels
  88382. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88383. * @returns the dynamic texture inside an InternalTexture
  88384. */
  88385. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88386. /**
  88387. * Update the content of a dynamic texture
  88388. * @param texture defines the texture to update
  88389. * @param canvas defines the canvas containing the source
  88390. * @param invertY defines if data must be stored with Y axis inverted
  88391. * @param premulAlpha defines if alpha is stored as premultiplied
  88392. * @param format defines the format of the data
  88393. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88394. */
  88395. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88396. }
  88397. }
  88398. declare module BABYLON {
  88399. /**
  88400. * Helper class used to generate a canvas to manipulate images
  88401. */
  88402. export class CanvasGenerator {
  88403. /**
  88404. * Create a new canvas (or offscreen canvas depending on the context)
  88405. * @param width defines the expected width
  88406. * @param height defines the expected height
  88407. * @return a new canvas or offscreen canvas
  88408. */
  88409. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88410. }
  88411. }
  88412. declare module BABYLON {
  88413. /**
  88414. * A class extending Texture allowing drawing on a texture
  88415. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88416. */
  88417. export class DynamicTexture extends Texture {
  88418. private _generateMipMaps;
  88419. private _canvas;
  88420. private _context;
  88421. /**
  88422. * Creates a DynamicTexture
  88423. * @param name defines the name of the texture
  88424. * @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
  88425. * @param scene defines the scene where you want the texture
  88426. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88427. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88428. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88429. */
  88430. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88431. /**
  88432. * Get the current class name of the texture useful for serialization or dynamic coding.
  88433. * @returns "DynamicTexture"
  88434. */
  88435. getClassName(): string;
  88436. /**
  88437. * Gets the current state of canRescale
  88438. */
  88439. get canRescale(): boolean;
  88440. private _recreate;
  88441. /**
  88442. * Scales the texture
  88443. * @param ratio the scale factor to apply to both width and height
  88444. */
  88445. scale(ratio: number): void;
  88446. /**
  88447. * Resizes the texture
  88448. * @param width the new width
  88449. * @param height the new height
  88450. */
  88451. scaleTo(width: number, height: number): void;
  88452. /**
  88453. * Gets the context of the canvas used by the texture
  88454. * @returns the canvas context of the dynamic texture
  88455. */
  88456. getContext(): CanvasRenderingContext2D;
  88457. /**
  88458. * Clears the texture
  88459. */
  88460. clear(): void;
  88461. /**
  88462. * Updates the texture
  88463. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88464. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88465. */
  88466. update(invertY?: boolean, premulAlpha?: boolean): void;
  88467. /**
  88468. * Draws text onto the texture
  88469. * @param text defines the text to be drawn
  88470. * @param x defines the placement of the text from the left
  88471. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88472. * @param font defines the font to be used with font-style, font-size, font-name
  88473. * @param color defines the color used for the text
  88474. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88475. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88476. * @param update defines whether texture is immediately update (default is true)
  88477. */
  88478. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  88479. /**
  88480. * Clones the texture
  88481. * @returns the clone of the texture.
  88482. */
  88483. clone(): DynamicTexture;
  88484. /**
  88485. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88486. * @returns a serialized dynamic texture object
  88487. */
  88488. serialize(): any;
  88489. /** @hidden */
  88490. _rebuild(): void;
  88491. }
  88492. }
  88493. declare module BABYLON {
  88494. interface ThinEngine {
  88495. /**
  88496. * Creates a raw texture
  88497. * @param data defines the data to store in the texture
  88498. * @param width defines the width of the texture
  88499. * @param height defines the height of the texture
  88500. * @param format defines the format of the data
  88501. * @param generateMipMaps defines if the engine should generate the mip levels
  88502. * @param invertY defines if data must be stored with Y axis inverted
  88503. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88504. * @param compression defines the compression used (null by default)
  88505. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88506. * @returns the raw texture inside an InternalTexture
  88507. */
  88508. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88509. /**
  88510. * Update a raw texture
  88511. * @param texture defines the texture to update
  88512. * @param data defines the data to store in the texture
  88513. * @param format defines the format of the data
  88514. * @param invertY defines if data must be stored with Y axis inverted
  88515. */
  88516. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88517. /**
  88518. * Update a raw texture
  88519. * @param texture defines the texture to update
  88520. * @param data defines the data to store in the texture
  88521. * @param format defines the format of the data
  88522. * @param invertY defines if data must be stored with Y axis inverted
  88523. * @param compression defines the compression used (null by default)
  88524. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88525. */
  88526. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88527. /**
  88528. * Creates a new raw cube texture
  88529. * @param data defines the array of data to use to create each face
  88530. * @param size defines the size of the textures
  88531. * @param format defines the format of the data
  88532. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88533. * @param generateMipMaps defines if the engine should generate the mip levels
  88534. * @param invertY defines if data must be stored with Y axis inverted
  88535. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88536. * @param compression defines the compression used (null by default)
  88537. * @returns the cube texture as an InternalTexture
  88538. */
  88539. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88540. /**
  88541. * Update a raw cube texture
  88542. * @param texture defines the texture to udpdate
  88543. * @param data defines the data to store
  88544. * @param format defines the data format
  88545. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88546. * @param invertY defines if data must be stored with Y axis inverted
  88547. */
  88548. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88549. /**
  88550. * Update a raw cube texture
  88551. * @param texture defines the texture to udpdate
  88552. * @param data defines the data to store
  88553. * @param format defines the data format
  88554. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88555. * @param invertY defines if data must be stored with Y axis inverted
  88556. * @param compression defines the compression used (null by default)
  88557. */
  88558. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88559. /**
  88560. * Update a raw cube texture
  88561. * @param texture defines the texture to udpdate
  88562. * @param data defines the data to store
  88563. * @param format defines the data format
  88564. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88565. * @param invertY defines if data must be stored with Y axis inverted
  88566. * @param compression defines the compression used (null by default)
  88567. * @param level defines which level of the texture to update
  88568. */
  88569. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88570. /**
  88571. * Creates a new raw cube texture from a specified url
  88572. * @param url defines the url where the data is located
  88573. * @param scene defines the current scene
  88574. * @param size defines the size of the textures
  88575. * @param format defines the format of the data
  88576. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88577. * @param noMipmap defines if the engine should avoid generating the mip levels
  88578. * @param callback defines a callback used to extract texture data from loaded data
  88579. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88580. * @param onLoad defines a callback called when texture is loaded
  88581. * @param onError defines a callback called if there is an error
  88582. * @returns the cube texture as an InternalTexture
  88583. */
  88584. 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;
  88585. /**
  88586. * Creates a new raw cube texture from a specified url
  88587. * @param url defines the url where the data is located
  88588. * @param scene defines the current scene
  88589. * @param size defines the size of the textures
  88590. * @param format defines the format of the data
  88591. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88592. * @param noMipmap defines if the engine should avoid generating the mip levels
  88593. * @param callback defines a callback used to extract texture data from loaded data
  88594. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88595. * @param onLoad defines a callback called when texture is loaded
  88596. * @param onError defines a callback called if there is an error
  88597. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88598. * @param invertY defines if data must be stored with Y axis inverted
  88599. * @returns the cube texture as an InternalTexture
  88600. */
  88601. 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;
  88602. /**
  88603. * Creates a new raw 3D texture
  88604. * @param data defines the data used to create the texture
  88605. * @param width defines the width of the texture
  88606. * @param height defines the height of the texture
  88607. * @param depth defines the depth of the texture
  88608. * @param format defines the format of the texture
  88609. * @param generateMipMaps defines if the engine must generate mip levels
  88610. * @param invertY defines if data must be stored with Y axis inverted
  88611. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88612. * @param compression defines the compressed used (can be null)
  88613. * @param textureType defines the compressed used (can be null)
  88614. * @returns a new raw 3D texture (stored in an InternalTexture)
  88615. */
  88616. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88617. /**
  88618. * Update a raw 3D texture
  88619. * @param texture defines the texture to update
  88620. * @param data defines the data to store
  88621. * @param format defines the data format
  88622. * @param invertY defines if data must be stored with Y axis inverted
  88623. */
  88624. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88625. /**
  88626. * Update a raw 3D texture
  88627. * @param texture defines the texture to update
  88628. * @param data defines the data to store
  88629. * @param format defines the data format
  88630. * @param invertY defines if data must be stored with Y axis inverted
  88631. * @param compression defines the used compression (can be null)
  88632. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88633. */
  88634. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88635. /**
  88636. * Creates a new raw 2D array texture
  88637. * @param data defines the data used to create the texture
  88638. * @param width defines the width of the texture
  88639. * @param height defines the height of the texture
  88640. * @param depth defines the number of layers of the texture
  88641. * @param format defines the format of the texture
  88642. * @param generateMipMaps defines if the engine must generate mip levels
  88643. * @param invertY defines if data must be stored with Y axis inverted
  88644. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88645. * @param compression defines the compressed used (can be null)
  88646. * @param textureType defines the compressed used (can be null)
  88647. * @returns a new raw 2D array texture (stored in an InternalTexture)
  88648. */
  88649. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88650. /**
  88651. * Update a raw 2D array texture
  88652. * @param texture defines the texture to update
  88653. * @param data defines the data to store
  88654. * @param format defines the data format
  88655. * @param invertY defines if data must be stored with Y axis inverted
  88656. */
  88657. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88658. /**
  88659. * Update a raw 2D array texture
  88660. * @param texture defines the texture to update
  88661. * @param data defines the data to store
  88662. * @param format defines the data format
  88663. * @param invertY defines if data must be stored with Y axis inverted
  88664. * @param compression defines the used compression (can be null)
  88665. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88666. */
  88667. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88668. }
  88669. }
  88670. declare module BABYLON {
  88671. /**
  88672. * Raw texture can help creating a texture directly from an array of data.
  88673. * This can be super useful if you either get the data from an uncompressed source or
  88674. * if you wish to create your texture pixel by pixel.
  88675. */
  88676. export class RawTexture extends Texture {
  88677. /**
  88678. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88679. */
  88680. format: number;
  88681. /**
  88682. * Instantiates a new RawTexture.
  88683. * Raw texture can help creating a texture directly from an array of data.
  88684. * This can be super useful if you either get the data from an uncompressed source or
  88685. * if you wish to create your texture pixel by pixel.
  88686. * @param data define the array of data to use to create the texture
  88687. * @param width define the width of the texture
  88688. * @param height define the height of the texture
  88689. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88690. * @param scene define the scene the texture belongs to
  88691. * @param generateMipMaps define whether mip maps should be generated or not
  88692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88695. */
  88696. constructor(data: ArrayBufferView, width: number, height: number,
  88697. /**
  88698. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88699. */
  88700. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  88701. /**
  88702. * Updates the texture underlying data.
  88703. * @param data Define the new data of the texture
  88704. */
  88705. update(data: ArrayBufferView): void;
  88706. /**
  88707. * Creates a luminance texture from some data.
  88708. * @param data Define the texture data
  88709. * @param width Define the width of the texture
  88710. * @param height Define the height of the texture
  88711. * @param scene Define the scene the texture belongs to
  88712. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88715. * @returns the luminance texture
  88716. */
  88717. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88718. /**
  88719. * Creates a luminance alpha texture from some data.
  88720. * @param data Define the texture data
  88721. * @param width Define the width of the texture
  88722. * @param height Define the height of the texture
  88723. * @param scene Define the scene the texture belongs to
  88724. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88727. * @returns the luminance alpha texture
  88728. */
  88729. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88730. /**
  88731. * Creates an alpha texture from some data.
  88732. * @param data Define the texture data
  88733. * @param width Define the width of the texture
  88734. * @param height Define the height of the texture
  88735. * @param scene Define the scene the texture belongs to
  88736. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88737. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88738. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88739. * @returns the alpha texture
  88740. */
  88741. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88742. /**
  88743. * Creates a RGB texture from some data.
  88744. * @param data Define the texture data
  88745. * @param width Define the width of the texture
  88746. * @param height Define the height of the texture
  88747. * @param scene Define the scene the texture belongs to
  88748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88752. * @returns the RGB alpha texture
  88753. */
  88754. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88755. /**
  88756. * Creates a RGBA texture from some data.
  88757. * @param data Define the texture data
  88758. * @param width Define the width of the texture
  88759. * @param height Define the height of the texture
  88760. * @param scene Define the scene the texture belongs to
  88761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88765. * @returns the RGBA texture
  88766. */
  88767. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88768. /**
  88769. * Creates a R texture from some data.
  88770. * @param data Define the texture data
  88771. * @param width Define the width of the texture
  88772. * @param height Define the height of the texture
  88773. * @param scene Define the scene the texture belongs to
  88774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88778. * @returns the R texture
  88779. */
  88780. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88781. }
  88782. }
  88783. declare module BABYLON {
  88784. interface AbstractScene {
  88785. /**
  88786. * The list of procedural textures added to the scene
  88787. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88788. */
  88789. proceduralTextures: Array<ProceduralTexture>;
  88790. }
  88791. /**
  88792. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88793. * in a given scene.
  88794. */
  88795. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88796. /**
  88797. * The component name helpfull to identify the component in the list of scene components.
  88798. */
  88799. readonly name: string;
  88800. /**
  88801. * The scene the component belongs to.
  88802. */
  88803. scene: Scene;
  88804. /**
  88805. * Creates a new instance of the component for the given scene
  88806. * @param scene Defines the scene to register the component in
  88807. */
  88808. constructor(scene: Scene);
  88809. /**
  88810. * Registers the component in a given scene
  88811. */
  88812. register(): void;
  88813. /**
  88814. * Rebuilds the elements related to this component in case of
  88815. * context lost for instance.
  88816. */
  88817. rebuild(): void;
  88818. /**
  88819. * Disposes the component and the associated ressources.
  88820. */
  88821. dispose(): void;
  88822. private _beforeClear;
  88823. }
  88824. }
  88825. declare module BABYLON {
  88826. interface ThinEngine {
  88827. /**
  88828. * Creates a new render target cube texture
  88829. * @param size defines the size of the texture
  88830. * @param options defines the options used to create the texture
  88831. * @returns a new render target cube texture stored in an InternalTexture
  88832. */
  88833. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88834. }
  88835. }
  88836. declare module BABYLON {
  88837. /** @hidden */
  88838. export var proceduralVertexShader: {
  88839. name: string;
  88840. shader: string;
  88841. };
  88842. }
  88843. declare module BABYLON {
  88844. /**
  88845. * 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.
  88846. * This is the base class of any Procedural texture and contains most of the shareable code.
  88847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88848. */
  88849. export class ProceduralTexture extends Texture {
  88850. isCube: boolean;
  88851. /**
  88852. * Define if the texture is enabled or not (disabled texture will not render)
  88853. */
  88854. isEnabled: boolean;
  88855. /**
  88856. * Define if the texture must be cleared before rendering (default is true)
  88857. */
  88858. autoClear: boolean;
  88859. /**
  88860. * Callback called when the texture is generated
  88861. */
  88862. onGenerated: () => void;
  88863. /**
  88864. * Event raised when the texture is generated
  88865. */
  88866. onGeneratedObservable: Observable<ProceduralTexture>;
  88867. /** @hidden */
  88868. _generateMipMaps: boolean;
  88869. /** @hidden **/
  88870. _effect: Effect;
  88871. /** @hidden */
  88872. _textures: {
  88873. [key: string]: Texture;
  88874. };
  88875. /** @hidden */
  88876. protected _fallbackTexture: Nullable<Texture>;
  88877. private _size;
  88878. private _currentRefreshId;
  88879. private _frameId;
  88880. private _refreshRate;
  88881. private _vertexBuffers;
  88882. private _indexBuffer;
  88883. private _uniforms;
  88884. private _samplers;
  88885. private _fragment;
  88886. private _floats;
  88887. private _ints;
  88888. private _floatsArrays;
  88889. private _colors3;
  88890. private _colors4;
  88891. private _vectors2;
  88892. private _vectors3;
  88893. private _matrices;
  88894. private _fallbackTextureUsed;
  88895. private _fullEngine;
  88896. private _cachedDefines;
  88897. private _contentUpdateId;
  88898. private _contentData;
  88899. /**
  88900. * Instantiates a new procedural texture.
  88901. * 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.
  88902. * This is the base class of any Procedural texture and contains most of the shareable code.
  88903. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88904. * @param name Define the name of the texture
  88905. * @param size Define the size of the texture to create
  88906. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88907. * @param scene Define the scene the texture belongs to
  88908. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88909. * @param generateMipMaps Define if the texture should creates mip maps or not
  88910. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88911. */
  88912. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88913. /**
  88914. * The effect that is created when initializing the post process.
  88915. * @returns The created effect corresponding the the postprocess.
  88916. */
  88917. getEffect(): Effect;
  88918. /**
  88919. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88920. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88921. */
  88922. getContent(): Nullable<ArrayBufferView>;
  88923. private _createIndexBuffer;
  88924. /** @hidden */
  88925. _rebuild(): void;
  88926. /**
  88927. * Resets the texture in order to recreate its associated resources.
  88928. * This can be called in case of context loss
  88929. */
  88930. reset(): void;
  88931. protected _getDefines(): string;
  88932. /**
  88933. * Is the texture ready to be used ? (rendered at least once)
  88934. * @returns true if ready, otherwise, false.
  88935. */
  88936. isReady(): boolean;
  88937. /**
  88938. * Resets the refresh counter of the texture and start bak from scratch.
  88939. * Could be useful to regenerate the texture if it is setup to render only once.
  88940. */
  88941. resetRefreshCounter(): void;
  88942. /**
  88943. * Set the fragment shader to use in order to render the texture.
  88944. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88945. */
  88946. setFragment(fragment: any): void;
  88947. /**
  88948. * Define the refresh rate of the texture or the rendering frequency.
  88949. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88950. */
  88951. get refreshRate(): number;
  88952. set refreshRate(value: number);
  88953. /** @hidden */
  88954. _shouldRender(): boolean;
  88955. /**
  88956. * Get the size the texture is rendering at.
  88957. * @returns the size (texture is always squared)
  88958. */
  88959. getRenderSize(): number;
  88960. /**
  88961. * Resize the texture to new value.
  88962. * @param size Define the new size the texture should have
  88963. * @param generateMipMaps Define whether the new texture should create mip maps
  88964. */
  88965. resize(size: number, generateMipMaps: boolean): void;
  88966. private _checkUniform;
  88967. /**
  88968. * Set a texture in the shader program used to render.
  88969. * @param name Define the name of the uniform samplers as defined in the shader
  88970. * @param texture Define the texture to bind to this sampler
  88971. * @return the texture itself allowing "fluent" like uniform updates
  88972. */
  88973. setTexture(name: string, texture: Texture): ProceduralTexture;
  88974. /**
  88975. * Set a float in the shader.
  88976. * @param name Define the name of the uniform as defined in the shader
  88977. * @param value Define the value to give to the uniform
  88978. * @return the texture itself allowing "fluent" like uniform updates
  88979. */
  88980. setFloat(name: string, value: number): ProceduralTexture;
  88981. /**
  88982. * Set a int in the shader.
  88983. * @param name Define the name of the uniform as defined in the shader
  88984. * @param value Define the value to give to the uniform
  88985. * @return the texture itself allowing "fluent" like uniform updates
  88986. */
  88987. setInt(name: string, value: number): ProceduralTexture;
  88988. /**
  88989. * Set an array of floats in the shader.
  88990. * @param name Define the name of the uniform as defined in the shader
  88991. * @param value Define the value to give to the uniform
  88992. * @return the texture itself allowing "fluent" like uniform updates
  88993. */
  88994. setFloats(name: string, value: number[]): ProceduralTexture;
  88995. /**
  88996. * Set a vec3 in the shader from a Color3.
  88997. * @param name Define the name of the uniform as defined in the shader
  88998. * @param value Define the value to give to the uniform
  88999. * @return the texture itself allowing "fluent" like uniform updates
  89000. */
  89001. setColor3(name: string, value: Color3): ProceduralTexture;
  89002. /**
  89003. * Set a vec4 in the shader from a Color4.
  89004. * @param name Define the name of the uniform as defined in the shader
  89005. * @param value Define the value to give to the uniform
  89006. * @return the texture itself allowing "fluent" like uniform updates
  89007. */
  89008. setColor4(name: string, value: Color4): ProceduralTexture;
  89009. /**
  89010. * Set a vec2 in the shader from a Vector2.
  89011. * @param name Define the name of the uniform as defined in the shader
  89012. * @param value Define the value to give to the uniform
  89013. * @return the texture itself allowing "fluent" like uniform updates
  89014. */
  89015. setVector2(name: string, value: Vector2): ProceduralTexture;
  89016. /**
  89017. * Set a vec3 in the shader from a Vector3.
  89018. * @param name Define the name of the uniform as defined in the shader
  89019. * @param value Define the value to give to the uniform
  89020. * @return the texture itself allowing "fluent" like uniform updates
  89021. */
  89022. setVector3(name: string, value: Vector3): ProceduralTexture;
  89023. /**
  89024. * Set a mat4 in the shader from a MAtrix.
  89025. * @param name Define the name of the uniform as defined in the shader
  89026. * @param value Define the value to give to the uniform
  89027. * @return the texture itself allowing "fluent" like uniform updates
  89028. */
  89029. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89030. /**
  89031. * Render the texture to its associated render target.
  89032. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89033. */
  89034. render(useCameraPostProcess?: boolean): void;
  89035. /**
  89036. * Clone the texture.
  89037. * @returns the cloned texture
  89038. */
  89039. clone(): ProceduralTexture;
  89040. /**
  89041. * Dispose the texture and release its asoociated resources.
  89042. */
  89043. dispose(): void;
  89044. }
  89045. }
  89046. declare module BABYLON {
  89047. /**
  89048. * This represents the base class for particle system in Babylon.
  89049. * 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.
  89050. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89051. * @example https://doc.babylonjs.com/babylon101/particles
  89052. */
  89053. export class BaseParticleSystem {
  89054. /**
  89055. * Source color is added to the destination color without alpha affecting the result
  89056. */
  89057. static BLENDMODE_ONEONE: number;
  89058. /**
  89059. * Blend current color and particle color using particle’s alpha
  89060. */
  89061. static BLENDMODE_STANDARD: number;
  89062. /**
  89063. * Add current color and particle color multiplied by particle’s alpha
  89064. */
  89065. static BLENDMODE_ADD: number;
  89066. /**
  89067. * Multiply current color with particle color
  89068. */
  89069. static BLENDMODE_MULTIPLY: number;
  89070. /**
  89071. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89072. */
  89073. static BLENDMODE_MULTIPLYADD: number;
  89074. /**
  89075. * List of animations used by the particle system.
  89076. */
  89077. animations: Animation[];
  89078. /**
  89079. * Gets or sets the unique id of the particle system
  89080. */
  89081. uniqueId: number;
  89082. /**
  89083. * The id of the Particle system.
  89084. */
  89085. id: string;
  89086. /**
  89087. * The friendly name of the Particle system.
  89088. */
  89089. name: string;
  89090. /**
  89091. * Snippet ID if the particle system was created from the snippet server
  89092. */
  89093. snippetId: string;
  89094. /**
  89095. * The rendering group used by the Particle system to chose when to render.
  89096. */
  89097. renderingGroupId: number;
  89098. /**
  89099. * The emitter represents the Mesh or position we are attaching the particle system to.
  89100. */
  89101. emitter: Nullable<AbstractMesh | Vector3>;
  89102. /**
  89103. * The maximum number of particles to emit per frame
  89104. */
  89105. emitRate: number;
  89106. /**
  89107. * If you want to launch only a few particles at once, that can be done, as well.
  89108. */
  89109. manualEmitCount: number;
  89110. /**
  89111. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89112. */
  89113. updateSpeed: number;
  89114. /**
  89115. * The amount of time the particle system is running (depends of the overall update speed).
  89116. */
  89117. targetStopDuration: number;
  89118. /**
  89119. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89120. */
  89121. disposeOnStop: boolean;
  89122. /**
  89123. * Minimum power of emitting particles.
  89124. */
  89125. minEmitPower: number;
  89126. /**
  89127. * Maximum power of emitting particles.
  89128. */
  89129. maxEmitPower: number;
  89130. /**
  89131. * Minimum life time of emitting particles.
  89132. */
  89133. minLifeTime: number;
  89134. /**
  89135. * Maximum life time of emitting particles.
  89136. */
  89137. maxLifeTime: number;
  89138. /**
  89139. * Minimum Size of emitting particles.
  89140. */
  89141. minSize: number;
  89142. /**
  89143. * Maximum Size of emitting particles.
  89144. */
  89145. maxSize: number;
  89146. /**
  89147. * Minimum scale of emitting particles on X axis.
  89148. */
  89149. minScaleX: number;
  89150. /**
  89151. * Maximum scale of emitting particles on X axis.
  89152. */
  89153. maxScaleX: number;
  89154. /**
  89155. * Minimum scale of emitting particles on Y axis.
  89156. */
  89157. minScaleY: number;
  89158. /**
  89159. * Maximum scale of emitting particles on Y axis.
  89160. */
  89161. maxScaleY: number;
  89162. /**
  89163. * Gets or sets the minimal initial rotation in radians.
  89164. */
  89165. minInitialRotation: number;
  89166. /**
  89167. * Gets or sets the maximal initial rotation in radians.
  89168. */
  89169. maxInitialRotation: number;
  89170. /**
  89171. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89172. */
  89173. minAngularSpeed: number;
  89174. /**
  89175. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89176. */
  89177. maxAngularSpeed: number;
  89178. /**
  89179. * The texture used to render each particle. (this can be a spritesheet)
  89180. */
  89181. particleTexture: Nullable<Texture>;
  89182. /**
  89183. * The layer mask we are rendering the particles through.
  89184. */
  89185. layerMask: number;
  89186. /**
  89187. * This can help using your own shader to render the particle system.
  89188. * The according effect will be created
  89189. */
  89190. customShader: any;
  89191. /**
  89192. * By default particle system starts as soon as they are created. This prevents the
  89193. * automatic start to happen and let you decide when to start emitting particles.
  89194. */
  89195. preventAutoStart: boolean;
  89196. private _noiseTexture;
  89197. /**
  89198. * Gets or sets a texture used to add random noise to particle positions
  89199. */
  89200. get noiseTexture(): Nullable<ProceduralTexture>;
  89201. set noiseTexture(value: Nullable<ProceduralTexture>);
  89202. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89203. noiseStrength: Vector3;
  89204. /**
  89205. * Callback triggered when the particle animation is ending.
  89206. */
  89207. onAnimationEnd: Nullable<() => void>;
  89208. /**
  89209. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89210. */
  89211. blendMode: number;
  89212. /**
  89213. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89214. * to override the particles.
  89215. */
  89216. forceDepthWrite: boolean;
  89217. /** 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 */
  89218. preWarmCycles: number;
  89219. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89220. preWarmStepOffset: number;
  89221. /**
  89222. * 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)
  89223. */
  89224. spriteCellChangeSpeed: number;
  89225. /**
  89226. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89227. */
  89228. startSpriteCellID: number;
  89229. /**
  89230. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89231. */
  89232. endSpriteCellID: number;
  89233. /**
  89234. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89235. */
  89236. spriteCellWidth: number;
  89237. /**
  89238. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89239. */
  89240. spriteCellHeight: number;
  89241. /**
  89242. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89243. */
  89244. spriteRandomStartCell: boolean;
  89245. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89246. translationPivot: Vector2;
  89247. /** @hidden */
  89248. protected _isAnimationSheetEnabled: boolean;
  89249. /**
  89250. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89251. */
  89252. beginAnimationOnStart: boolean;
  89253. /**
  89254. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89255. */
  89256. beginAnimationFrom: number;
  89257. /**
  89258. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89259. */
  89260. beginAnimationTo: number;
  89261. /**
  89262. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89263. */
  89264. beginAnimationLoop: boolean;
  89265. /**
  89266. * Gets or sets a world offset applied to all particles
  89267. */
  89268. worldOffset: Vector3;
  89269. /**
  89270. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89271. */
  89272. get isAnimationSheetEnabled(): boolean;
  89273. set isAnimationSheetEnabled(value: boolean);
  89274. /**
  89275. * Get hosting scene
  89276. * @returns the scene
  89277. */
  89278. getScene(): Scene;
  89279. /**
  89280. * You can use gravity if you want to give an orientation to your particles.
  89281. */
  89282. gravity: Vector3;
  89283. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89284. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89285. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89286. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89287. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89288. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89289. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89290. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89291. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89292. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89293. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89294. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89295. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89296. /**
  89297. * Defines the delay in milliseconds before starting the system (0 by default)
  89298. */
  89299. startDelay: number;
  89300. /**
  89301. * Gets the current list of drag gradients.
  89302. * You must use addDragGradient and removeDragGradient to udpate this list
  89303. * @returns the list of drag gradients
  89304. */
  89305. getDragGradients(): Nullable<Array<FactorGradient>>;
  89306. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89307. limitVelocityDamping: number;
  89308. /**
  89309. * Gets the current list of limit velocity gradients.
  89310. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89311. * @returns the list of limit velocity gradients
  89312. */
  89313. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89314. /**
  89315. * Gets the current list of color gradients.
  89316. * You must use addColorGradient and removeColorGradient to udpate this list
  89317. * @returns the list of color gradients
  89318. */
  89319. getColorGradients(): Nullable<Array<ColorGradient>>;
  89320. /**
  89321. * Gets the current list of size gradients.
  89322. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89323. * @returns the list of size gradients
  89324. */
  89325. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89326. /**
  89327. * Gets the current list of color remap gradients.
  89328. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89329. * @returns the list of color remap gradients
  89330. */
  89331. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89332. /**
  89333. * Gets the current list of alpha remap gradients.
  89334. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89335. * @returns the list of alpha remap gradients
  89336. */
  89337. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89338. /**
  89339. * Gets the current list of life time gradients.
  89340. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89341. * @returns the list of life time gradients
  89342. */
  89343. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89344. /**
  89345. * Gets the current list of angular speed gradients.
  89346. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89347. * @returns the list of angular speed gradients
  89348. */
  89349. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89350. /**
  89351. * Gets the current list of velocity gradients.
  89352. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89353. * @returns the list of velocity gradients
  89354. */
  89355. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89356. /**
  89357. * Gets the current list of start size gradients.
  89358. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89359. * @returns the list of start size gradients
  89360. */
  89361. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89362. /**
  89363. * Gets the current list of emit rate gradients.
  89364. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89365. * @returns the list of emit rate gradients
  89366. */
  89367. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89368. /**
  89369. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89370. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89371. */
  89372. get direction1(): Vector3;
  89373. set direction1(value: Vector3);
  89374. /**
  89375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89376. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89377. */
  89378. get direction2(): Vector3;
  89379. set direction2(value: Vector3);
  89380. /**
  89381. * 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.
  89382. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89383. */
  89384. get minEmitBox(): Vector3;
  89385. set minEmitBox(value: Vector3);
  89386. /**
  89387. * 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.
  89388. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89389. */
  89390. get maxEmitBox(): Vector3;
  89391. set maxEmitBox(value: Vector3);
  89392. /**
  89393. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89394. */
  89395. color1: Color4;
  89396. /**
  89397. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89398. */
  89399. color2: Color4;
  89400. /**
  89401. * Color the particle will have at the end of its lifetime
  89402. */
  89403. colorDead: Color4;
  89404. /**
  89405. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89406. */
  89407. textureMask: Color4;
  89408. /**
  89409. * The particle emitter type defines the emitter used by the particle system.
  89410. * It can be for example box, sphere, or cone...
  89411. */
  89412. particleEmitterType: IParticleEmitterType;
  89413. /** @hidden */
  89414. _isSubEmitter: boolean;
  89415. /**
  89416. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89417. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89418. */
  89419. billboardMode: number;
  89420. protected _isBillboardBased: boolean;
  89421. /**
  89422. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89423. */
  89424. get isBillboardBased(): boolean;
  89425. set isBillboardBased(value: boolean);
  89426. /**
  89427. * The scene the particle system belongs to.
  89428. */
  89429. protected _scene: Scene;
  89430. /**
  89431. * Local cache of defines for image processing.
  89432. */
  89433. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89434. /**
  89435. * Default configuration related to image processing available in the standard Material.
  89436. */
  89437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89438. /**
  89439. * Gets the image processing configuration used either in this material.
  89440. */
  89441. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89442. /**
  89443. * Sets the Default image processing configuration used either in the this material.
  89444. *
  89445. * If sets to null, the scene one is in use.
  89446. */
  89447. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89448. /**
  89449. * Attaches a new image processing configuration to the Standard Material.
  89450. * @param configuration
  89451. */
  89452. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89453. /** @hidden */
  89454. protected _reset(): void;
  89455. /** @hidden */
  89456. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89457. /**
  89458. * Instantiates a particle system.
  89459. * 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.
  89460. * @param name The name of the particle system
  89461. */
  89462. constructor(name: string);
  89463. /**
  89464. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89467. * @returns the emitter
  89468. */
  89469. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89470. /**
  89471. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89472. * @param radius The radius of the hemisphere to emit from
  89473. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89474. * @returns the emitter
  89475. */
  89476. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89477. /**
  89478. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89479. * @param radius The radius of the sphere to emit from
  89480. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89481. * @returns the emitter
  89482. */
  89483. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89484. /**
  89485. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89486. * @param radius The radius of the sphere to emit from
  89487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89489. * @returns the emitter
  89490. */
  89491. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89492. /**
  89493. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89494. * @param radius The radius of the emission cylinder
  89495. * @param height The height of the emission cylinder
  89496. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89497. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89498. * @returns the emitter
  89499. */
  89500. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89501. /**
  89502. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89503. * @param radius The radius of the cylinder to emit from
  89504. * @param height The height of the emission cylinder
  89505. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89508. * @returns the emitter
  89509. */
  89510. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89511. /**
  89512. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89513. * @param radius The radius of the cone to emit from
  89514. * @param angle The base angle of the cone
  89515. * @returns the emitter
  89516. */
  89517. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89518. /**
  89519. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89522. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89523. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89524. * @returns the emitter
  89525. */
  89526. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89527. }
  89528. }
  89529. declare module BABYLON {
  89530. /**
  89531. * Type of sub emitter
  89532. */
  89533. export enum SubEmitterType {
  89534. /**
  89535. * Attached to the particle over it's lifetime
  89536. */
  89537. ATTACHED = 0,
  89538. /**
  89539. * Created when the particle dies
  89540. */
  89541. END = 1
  89542. }
  89543. /**
  89544. * Sub emitter class used to emit particles from an existing particle
  89545. */
  89546. export class SubEmitter {
  89547. /**
  89548. * the particle system to be used by the sub emitter
  89549. */
  89550. particleSystem: ParticleSystem;
  89551. /**
  89552. * Type of the submitter (Default: END)
  89553. */
  89554. type: SubEmitterType;
  89555. /**
  89556. * 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)
  89557. * Note: This only is supported when using an emitter of type Mesh
  89558. */
  89559. inheritDirection: boolean;
  89560. /**
  89561. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89562. */
  89563. inheritedVelocityAmount: number;
  89564. /**
  89565. * Creates a sub emitter
  89566. * @param particleSystem the particle system to be used by the sub emitter
  89567. */
  89568. constructor(
  89569. /**
  89570. * the particle system to be used by the sub emitter
  89571. */
  89572. particleSystem: ParticleSystem);
  89573. /**
  89574. * Clones the sub emitter
  89575. * @returns the cloned sub emitter
  89576. */
  89577. clone(): SubEmitter;
  89578. /**
  89579. * Serialize current object to a JSON object
  89580. * @returns the serialized object
  89581. */
  89582. serialize(): any;
  89583. /** @hidden */
  89584. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89585. /**
  89586. * Creates a new SubEmitter from a serialized JSON version
  89587. * @param serializationObject defines the JSON object to read from
  89588. * @param scene defines the hosting scene
  89589. * @param rootUrl defines the rootUrl for data loading
  89590. * @returns a new SubEmitter
  89591. */
  89592. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89593. /** Release associated resources */
  89594. dispose(): void;
  89595. }
  89596. }
  89597. declare module BABYLON {
  89598. /** @hidden */
  89599. export var imageProcessingDeclaration: {
  89600. name: string;
  89601. shader: string;
  89602. };
  89603. }
  89604. declare module BABYLON {
  89605. /** @hidden */
  89606. export var imageProcessingFunctions: {
  89607. name: string;
  89608. shader: string;
  89609. };
  89610. }
  89611. declare module BABYLON {
  89612. /** @hidden */
  89613. export var particlesPixelShader: {
  89614. name: string;
  89615. shader: string;
  89616. };
  89617. }
  89618. declare module BABYLON {
  89619. /** @hidden */
  89620. export var particlesVertexShader: {
  89621. name: string;
  89622. shader: string;
  89623. };
  89624. }
  89625. declare module BABYLON {
  89626. /**
  89627. * This represents a particle system in Babylon.
  89628. * 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.
  89629. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89630. * @example https://doc.babylonjs.com/babylon101/particles
  89631. */
  89632. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89633. /**
  89634. * Billboard mode will only apply to Y axis
  89635. */
  89636. static readonly BILLBOARDMODE_Y: number;
  89637. /**
  89638. * Billboard mode will apply to all axes
  89639. */
  89640. static readonly BILLBOARDMODE_ALL: number;
  89641. /**
  89642. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89643. */
  89644. static readonly BILLBOARDMODE_STRETCHED: number;
  89645. /**
  89646. * This function can be defined to provide custom update for active particles.
  89647. * This function will be called instead of regular update (age, position, color, etc.).
  89648. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89649. */
  89650. updateFunction: (particles: Particle[]) => void;
  89651. private _emitterWorldMatrix;
  89652. /**
  89653. * This function can be defined to specify initial direction for every new particle.
  89654. * It by default use the emitterType defined function
  89655. */
  89656. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89657. /**
  89658. * This function can be defined to specify initial position for every new particle.
  89659. * It by default use the emitterType defined function
  89660. */
  89661. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89662. /**
  89663. * @hidden
  89664. */
  89665. _inheritedVelocityOffset: Vector3;
  89666. /**
  89667. * An event triggered when the system is disposed
  89668. */
  89669. onDisposeObservable: Observable<IParticleSystem>;
  89670. private _onDisposeObserver;
  89671. /**
  89672. * Sets a callback that will be triggered when the system is disposed
  89673. */
  89674. set onDispose(callback: () => void);
  89675. private _particles;
  89676. private _epsilon;
  89677. private _capacity;
  89678. private _stockParticles;
  89679. private _newPartsExcess;
  89680. private _vertexData;
  89681. private _vertexBuffer;
  89682. private _vertexBuffers;
  89683. private _spriteBuffer;
  89684. private _indexBuffer;
  89685. private _effect;
  89686. private _customEffect;
  89687. private _cachedDefines;
  89688. private _scaledColorStep;
  89689. private _colorDiff;
  89690. private _scaledDirection;
  89691. private _scaledGravity;
  89692. private _currentRenderId;
  89693. private _alive;
  89694. private _useInstancing;
  89695. private _started;
  89696. private _stopped;
  89697. private _actualFrame;
  89698. private _scaledUpdateSpeed;
  89699. private _vertexBufferSize;
  89700. /** @hidden */
  89701. _currentEmitRateGradient: Nullable<FactorGradient>;
  89702. /** @hidden */
  89703. _currentEmitRate1: number;
  89704. /** @hidden */
  89705. _currentEmitRate2: number;
  89706. /** @hidden */
  89707. _currentStartSizeGradient: Nullable<FactorGradient>;
  89708. /** @hidden */
  89709. _currentStartSize1: number;
  89710. /** @hidden */
  89711. _currentStartSize2: number;
  89712. private readonly _rawTextureWidth;
  89713. private _rampGradientsTexture;
  89714. private _useRampGradients;
  89715. /** Gets or sets a boolean indicating that ramp gradients must be used
  89716. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89717. */
  89718. get useRampGradients(): boolean;
  89719. set useRampGradients(value: boolean);
  89720. /**
  89721. * 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.
  89722. * 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: [])
  89723. */
  89724. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89725. private _subEmitters;
  89726. /**
  89727. * @hidden
  89728. * If the particle systems emitter should be disposed when the particle system is disposed
  89729. */
  89730. _disposeEmitterOnDispose: boolean;
  89731. /**
  89732. * The current active Sub-systems, this property is used by the root particle system only.
  89733. */
  89734. activeSubSystems: Array<ParticleSystem>;
  89735. /**
  89736. * Specifies if the particles are updated in emitter local space or world space
  89737. */
  89738. isLocal: boolean;
  89739. private _rootParticleSystem;
  89740. /**
  89741. * Gets the current list of active particles
  89742. */
  89743. get particles(): Particle[];
  89744. /**
  89745. * Gets the number of particles active at the same time.
  89746. * @returns The number of active particles.
  89747. */
  89748. getActiveCount(): number;
  89749. /**
  89750. * Returns the string "ParticleSystem"
  89751. * @returns a string containing the class name
  89752. */
  89753. getClassName(): string;
  89754. /**
  89755. * Gets a boolean indicating that the system is stopping
  89756. * @returns true if the system is currently stopping
  89757. */
  89758. isStopping(): boolean;
  89759. /**
  89760. * Gets the custom effect used to render the particles
  89761. * @param blendMode Blend mode for which the effect should be retrieved
  89762. * @returns The effect
  89763. */
  89764. getCustomEffect(blendMode?: number): Nullable<Effect>;
  89765. /**
  89766. * Sets the custom effect used to render the particles
  89767. * @param effect The effect to set
  89768. * @param blendMode Blend mode for which the effect should be set
  89769. */
  89770. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  89771. /** @hidden */
  89772. private _onBeforeDrawParticlesObservable;
  89773. /**
  89774. * Observable that will be called just before the particles are drawn
  89775. */
  89776. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  89777. /**
  89778. * Gets the name of the particle vertex shader
  89779. */
  89780. get vertexShaderName(): string;
  89781. /**
  89782. * Instantiates a particle system.
  89783. * 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.
  89784. * @param name The name of the particle system
  89785. * @param capacity The max number of particles alive at the same time
  89786. * @param scene The scene the particle system belongs to
  89787. * @param customEffect a custom effect used to change the way particles are rendered by default
  89788. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89789. * @param epsilon Offset used to render the particles
  89790. */
  89791. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89792. private _addFactorGradient;
  89793. private _removeFactorGradient;
  89794. /**
  89795. * Adds a new life time gradient
  89796. * @param gradient defines the gradient to use (between 0 and 1)
  89797. * @param factor defines the life time factor to affect to the specified gradient
  89798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89799. * @returns the current particle system
  89800. */
  89801. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89802. /**
  89803. * Remove a specific life time gradient
  89804. * @param gradient defines the gradient to remove
  89805. * @returns the current particle system
  89806. */
  89807. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89808. /**
  89809. * Adds a new size gradient
  89810. * @param gradient defines the gradient to use (between 0 and 1)
  89811. * @param factor defines the size factor to affect to the specified gradient
  89812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89813. * @returns the current particle system
  89814. */
  89815. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89816. /**
  89817. * Remove a specific size gradient
  89818. * @param gradient defines the gradient to remove
  89819. * @returns the current particle system
  89820. */
  89821. removeSizeGradient(gradient: number): IParticleSystem;
  89822. /**
  89823. * Adds a new color remap gradient
  89824. * @param gradient defines the gradient to use (between 0 and 1)
  89825. * @param min defines the color remap minimal range
  89826. * @param max defines the color remap maximal range
  89827. * @returns the current particle system
  89828. */
  89829. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89830. /**
  89831. * Remove a specific color remap gradient
  89832. * @param gradient defines the gradient to remove
  89833. * @returns the current particle system
  89834. */
  89835. removeColorRemapGradient(gradient: number): IParticleSystem;
  89836. /**
  89837. * Adds a new alpha remap gradient
  89838. * @param gradient defines the gradient to use (between 0 and 1)
  89839. * @param min defines the alpha remap minimal range
  89840. * @param max defines the alpha remap maximal range
  89841. * @returns the current particle system
  89842. */
  89843. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89844. /**
  89845. * Remove a specific alpha remap gradient
  89846. * @param gradient defines the gradient to remove
  89847. * @returns the current particle system
  89848. */
  89849. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  89850. /**
  89851. * Adds a new angular speed gradient
  89852. * @param gradient defines the gradient to use (between 0 and 1)
  89853. * @param factor defines the angular speed to affect to the specified gradient
  89854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89855. * @returns the current particle system
  89856. */
  89857. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89858. /**
  89859. * Remove a specific angular speed gradient
  89860. * @param gradient defines the gradient to remove
  89861. * @returns the current particle system
  89862. */
  89863. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89864. /**
  89865. * Adds a new velocity gradient
  89866. * @param gradient defines the gradient to use (between 0 and 1)
  89867. * @param factor defines the velocity to affect to the specified gradient
  89868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89869. * @returns the current particle system
  89870. */
  89871. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89872. /**
  89873. * Remove a specific velocity gradient
  89874. * @param gradient defines the gradient to remove
  89875. * @returns the current particle system
  89876. */
  89877. removeVelocityGradient(gradient: number): IParticleSystem;
  89878. /**
  89879. * Adds a new limit velocity gradient
  89880. * @param gradient defines the gradient to use (between 0 and 1)
  89881. * @param factor defines the limit velocity value to affect to the specified gradient
  89882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89883. * @returns the current particle system
  89884. */
  89885. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89886. /**
  89887. * Remove a specific limit velocity gradient
  89888. * @param gradient defines the gradient to remove
  89889. * @returns the current particle system
  89890. */
  89891. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89892. /**
  89893. * Adds a new drag gradient
  89894. * @param gradient defines the gradient to use (between 0 and 1)
  89895. * @param factor defines the drag value to affect to the specified gradient
  89896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89897. * @returns the current particle system
  89898. */
  89899. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89900. /**
  89901. * Remove a specific drag gradient
  89902. * @param gradient defines the gradient to remove
  89903. * @returns the current particle system
  89904. */
  89905. removeDragGradient(gradient: number): IParticleSystem;
  89906. /**
  89907. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89908. * @param gradient defines the gradient to use (between 0 and 1)
  89909. * @param factor defines the emit rate value to affect to the specified gradient
  89910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89911. * @returns the current particle system
  89912. */
  89913. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89914. /**
  89915. * Remove a specific emit rate gradient
  89916. * @param gradient defines the gradient to remove
  89917. * @returns the current particle system
  89918. */
  89919. removeEmitRateGradient(gradient: number): IParticleSystem;
  89920. /**
  89921. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89922. * @param gradient defines the gradient to use (between 0 and 1)
  89923. * @param factor defines the start size value to affect to the specified gradient
  89924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89925. * @returns the current particle system
  89926. */
  89927. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89928. /**
  89929. * Remove a specific start size gradient
  89930. * @param gradient defines the gradient to remove
  89931. * @returns the current particle system
  89932. */
  89933. removeStartSizeGradient(gradient: number): IParticleSystem;
  89934. private _createRampGradientTexture;
  89935. /**
  89936. * Gets the current list of ramp gradients.
  89937. * You must use addRampGradient and removeRampGradient to udpate this list
  89938. * @returns the list of ramp gradients
  89939. */
  89940. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89941. /** Force the system to rebuild all gradients that need to be resync */
  89942. forceRefreshGradients(): void;
  89943. private _syncRampGradientTexture;
  89944. /**
  89945. * Adds a new ramp gradient used to remap particle colors
  89946. * @param gradient defines the gradient to use (between 0 and 1)
  89947. * @param color defines the color to affect to the specified gradient
  89948. * @returns the current particle system
  89949. */
  89950. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89951. /**
  89952. * Remove a specific ramp gradient
  89953. * @param gradient defines the gradient to remove
  89954. * @returns the current particle system
  89955. */
  89956. removeRampGradient(gradient: number): ParticleSystem;
  89957. /**
  89958. * Adds a new color gradient
  89959. * @param gradient defines the gradient to use (between 0 and 1)
  89960. * @param color1 defines the color to affect to the specified gradient
  89961. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89962. * @returns this particle system
  89963. */
  89964. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89965. /**
  89966. * Remove a specific color gradient
  89967. * @param gradient defines the gradient to remove
  89968. * @returns this particle system
  89969. */
  89970. removeColorGradient(gradient: number): IParticleSystem;
  89971. private _fetchR;
  89972. protected _reset(): void;
  89973. private _resetEffect;
  89974. private _createVertexBuffers;
  89975. private _createIndexBuffer;
  89976. /**
  89977. * Gets the maximum number of particles active at the same time.
  89978. * @returns The max number of active particles.
  89979. */
  89980. getCapacity(): number;
  89981. /**
  89982. * Gets whether there are still active particles in the system.
  89983. * @returns True if it is alive, otherwise false.
  89984. */
  89985. isAlive(): boolean;
  89986. /**
  89987. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89988. * @returns True if it has been started, otherwise false.
  89989. */
  89990. isStarted(): boolean;
  89991. private _prepareSubEmitterInternalArray;
  89992. /**
  89993. * Starts the particle system and begins to emit
  89994. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89995. */
  89996. start(delay?: number): void;
  89997. /**
  89998. * Stops the particle system.
  89999. * @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.
  90000. */
  90001. stop(stopSubEmitters?: boolean): void;
  90002. /**
  90003. * Remove all active particles
  90004. */
  90005. reset(): void;
  90006. /**
  90007. * @hidden (for internal use only)
  90008. */
  90009. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90010. /**
  90011. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90012. * Its lifetime will start back at 0.
  90013. */
  90014. recycleParticle: (particle: Particle) => void;
  90015. private _stopSubEmitters;
  90016. private _createParticle;
  90017. private _removeFromRoot;
  90018. private _emitFromParticle;
  90019. private _update;
  90020. /** @hidden */
  90021. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90022. /** @hidden */
  90023. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90024. /**
  90025. * Fill the defines array according to the current settings of the particle system
  90026. * @param defines Array to be updated
  90027. * @param blendMode blend mode to take into account when updating the array
  90028. */
  90029. fillDefines(defines: Array<string>, blendMode: number): void;
  90030. /**
  90031. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90032. * @param uniforms Uniforms array to fill
  90033. * @param attributes Attributes array to fill
  90034. * @param samplers Samplers array to fill
  90035. */
  90036. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90037. /** @hidden */
  90038. private _getEffect;
  90039. /**
  90040. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90041. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90042. */
  90043. animate(preWarmOnly?: boolean): void;
  90044. private _appendParticleVertices;
  90045. /**
  90046. * Rebuilds the particle system.
  90047. */
  90048. rebuild(): void;
  90049. /**
  90050. * Is this system ready to be used/rendered
  90051. * @return true if the system is ready
  90052. */
  90053. isReady(): boolean;
  90054. private _render;
  90055. /**
  90056. * Renders the particle system in its current state.
  90057. * @returns the current number of particles
  90058. */
  90059. render(): number;
  90060. /**
  90061. * Disposes the particle system and free the associated resources
  90062. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90063. */
  90064. dispose(disposeTexture?: boolean): void;
  90065. /**
  90066. * Clones the particle system.
  90067. * @param name The name of the cloned object
  90068. * @param newEmitter The new emitter to use
  90069. * @returns the cloned particle system
  90070. */
  90071. clone(name: string, newEmitter: any): ParticleSystem;
  90072. /**
  90073. * Serializes the particle system to a JSON object
  90074. * @param serializeTexture defines if the texture must be serialized as well
  90075. * @returns the JSON object
  90076. */
  90077. serialize(serializeTexture?: boolean): any;
  90078. /** @hidden */
  90079. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90080. /** @hidden */
  90081. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90082. /**
  90083. * Parses a JSON object to create a particle system.
  90084. * @param parsedParticleSystem The JSON object to parse
  90085. * @param scene The scene to create the particle system in
  90086. * @param rootUrl The root url to use to load external dependencies like texture
  90087. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90088. * @returns the Parsed particle system
  90089. */
  90090. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90091. }
  90092. }
  90093. declare module BABYLON {
  90094. /**
  90095. * A particle represents one of the element emitted by a particle system.
  90096. * This is mainly define by its coordinates, direction, velocity and age.
  90097. */
  90098. export class Particle {
  90099. /**
  90100. * The particle system the particle belongs to.
  90101. */
  90102. particleSystem: ParticleSystem;
  90103. private static _Count;
  90104. /**
  90105. * Unique ID of the particle
  90106. */
  90107. id: number;
  90108. /**
  90109. * The world position of the particle in the scene.
  90110. */
  90111. position: Vector3;
  90112. /**
  90113. * The world direction of the particle in the scene.
  90114. */
  90115. direction: Vector3;
  90116. /**
  90117. * The color of the particle.
  90118. */
  90119. color: Color4;
  90120. /**
  90121. * The color change of the particle per step.
  90122. */
  90123. colorStep: Color4;
  90124. /**
  90125. * Defines how long will the life of the particle be.
  90126. */
  90127. lifeTime: number;
  90128. /**
  90129. * The current age of the particle.
  90130. */
  90131. age: number;
  90132. /**
  90133. * The current size of the particle.
  90134. */
  90135. size: number;
  90136. /**
  90137. * The current scale of the particle.
  90138. */
  90139. scale: Vector2;
  90140. /**
  90141. * The current angle of the particle.
  90142. */
  90143. angle: number;
  90144. /**
  90145. * Defines how fast is the angle changing.
  90146. */
  90147. angularSpeed: number;
  90148. /**
  90149. * Defines the cell index used by the particle to be rendered from a sprite.
  90150. */
  90151. cellIndex: number;
  90152. /**
  90153. * The information required to support color remapping
  90154. */
  90155. remapData: Vector4;
  90156. /** @hidden */
  90157. _randomCellOffset?: number;
  90158. /** @hidden */
  90159. _initialDirection: Nullable<Vector3>;
  90160. /** @hidden */
  90161. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90162. /** @hidden */
  90163. _initialStartSpriteCellID: number;
  90164. /** @hidden */
  90165. _initialEndSpriteCellID: number;
  90166. /** @hidden */
  90167. _currentColorGradient: Nullable<ColorGradient>;
  90168. /** @hidden */
  90169. _currentColor1: Color4;
  90170. /** @hidden */
  90171. _currentColor2: Color4;
  90172. /** @hidden */
  90173. _currentSizeGradient: Nullable<FactorGradient>;
  90174. /** @hidden */
  90175. _currentSize1: number;
  90176. /** @hidden */
  90177. _currentSize2: number;
  90178. /** @hidden */
  90179. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90180. /** @hidden */
  90181. _currentAngularSpeed1: number;
  90182. /** @hidden */
  90183. _currentAngularSpeed2: number;
  90184. /** @hidden */
  90185. _currentVelocityGradient: Nullable<FactorGradient>;
  90186. /** @hidden */
  90187. _currentVelocity1: number;
  90188. /** @hidden */
  90189. _currentVelocity2: number;
  90190. /** @hidden */
  90191. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90192. /** @hidden */
  90193. _currentLimitVelocity1: number;
  90194. /** @hidden */
  90195. _currentLimitVelocity2: number;
  90196. /** @hidden */
  90197. _currentDragGradient: Nullable<FactorGradient>;
  90198. /** @hidden */
  90199. _currentDrag1: number;
  90200. /** @hidden */
  90201. _currentDrag2: number;
  90202. /** @hidden */
  90203. _randomNoiseCoordinates1: Vector3;
  90204. /** @hidden */
  90205. _randomNoiseCoordinates2: Vector3;
  90206. /** @hidden */
  90207. _localPosition?: Vector3;
  90208. /**
  90209. * Creates a new instance Particle
  90210. * @param particleSystem the particle system the particle belongs to
  90211. */
  90212. constructor(
  90213. /**
  90214. * The particle system the particle belongs to.
  90215. */
  90216. particleSystem: ParticleSystem);
  90217. private updateCellInfoFromSystem;
  90218. /**
  90219. * Defines how the sprite cell index is updated for the particle
  90220. */
  90221. updateCellIndex(): void;
  90222. /** @hidden */
  90223. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90224. /** @hidden */
  90225. _inheritParticleInfoToSubEmitters(): void;
  90226. /** @hidden */
  90227. _reset(): void;
  90228. /**
  90229. * Copy the properties of particle to another one.
  90230. * @param other the particle to copy the information to.
  90231. */
  90232. copyTo(other: Particle): void;
  90233. }
  90234. }
  90235. declare module BABYLON {
  90236. /**
  90237. * Particle emitter represents a volume emitting particles.
  90238. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90239. */
  90240. export interface IParticleEmitterType {
  90241. /**
  90242. * Called by the particle System when the direction is computed for the created particle.
  90243. * @param worldMatrix is the world matrix of the particle system
  90244. * @param directionToUpdate is the direction vector to update with the result
  90245. * @param particle is the particle we are computed the direction for
  90246. * @param isLocal defines if the direction should be set in local space
  90247. */
  90248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90249. /**
  90250. * Called by the particle System when the position is computed for the created particle.
  90251. * @param worldMatrix is the world matrix of the particle system
  90252. * @param positionToUpdate is the position vector to update with the result
  90253. * @param particle is the particle we are computed the position for
  90254. * @param isLocal defines if the position should be set in local space
  90255. */
  90256. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90257. /**
  90258. * Clones the current emitter and returns a copy of it
  90259. * @returns the new emitter
  90260. */
  90261. clone(): IParticleEmitterType;
  90262. /**
  90263. * Called by the GPUParticleSystem to setup the update shader
  90264. * @param effect defines the update shader
  90265. */
  90266. applyToShader(effect: Effect): void;
  90267. /**
  90268. * Returns a string to use to update the GPU particles update shader
  90269. * @returns the effect defines string
  90270. */
  90271. getEffectDefines(): string;
  90272. /**
  90273. * Returns a string representing the class name
  90274. * @returns a string containing the class name
  90275. */
  90276. getClassName(): string;
  90277. /**
  90278. * Serializes the particle system to a JSON object.
  90279. * @returns the JSON object
  90280. */
  90281. serialize(): any;
  90282. /**
  90283. * Parse properties from a JSON object
  90284. * @param serializationObject defines the JSON object
  90285. * @param scene defines the hosting scene
  90286. */
  90287. parse(serializationObject: any, scene: Scene): void;
  90288. }
  90289. }
  90290. declare module BABYLON {
  90291. /**
  90292. * Particle emitter emitting particles from the inside of a box.
  90293. * It emits the particles randomly between 2 given directions.
  90294. */
  90295. export class BoxParticleEmitter implements IParticleEmitterType {
  90296. /**
  90297. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90298. */
  90299. direction1: Vector3;
  90300. /**
  90301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90302. */
  90303. direction2: Vector3;
  90304. /**
  90305. * 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.
  90306. */
  90307. minEmitBox: Vector3;
  90308. /**
  90309. * 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.
  90310. */
  90311. maxEmitBox: Vector3;
  90312. /**
  90313. * Creates a new instance BoxParticleEmitter
  90314. */
  90315. constructor();
  90316. /**
  90317. * Called by the particle System when the direction is computed for the created particle.
  90318. * @param worldMatrix is the world matrix of the particle system
  90319. * @param directionToUpdate is the direction vector to update with the result
  90320. * @param particle is the particle we are computed the direction for
  90321. * @param isLocal defines if the direction should be set in local space
  90322. */
  90323. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90324. /**
  90325. * Called by the particle System when the position is computed for the created particle.
  90326. * @param worldMatrix is the world matrix of the particle system
  90327. * @param positionToUpdate is the position vector to update with the result
  90328. * @param particle is the particle we are computed the position for
  90329. * @param isLocal defines if the position should be set in local space
  90330. */
  90331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90332. /**
  90333. * Clones the current emitter and returns a copy of it
  90334. * @returns the new emitter
  90335. */
  90336. clone(): BoxParticleEmitter;
  90337. /**
  90338. * Called by the GPUParticleSystem to setup the update shader
  90339. * @param effect defines the update shader
  90340. */
  90341. applyToShader(effect: Effect): void;
  90342. /**
  90343. * Returns a string to use to update the GPU particles update shader
  90344. * @returns a string containng the defines string
  90345. */
  90346. getEffectDefines(): string;
  90347. /**
  90348. * Returns the string "BoxParticleEmitter"
  90349. * @returns a string containing the class name
  90350. */
  90351. getClassName(): string;
  90352. /**
  90353. * Serializes the particle system to a JSON object.
  90354. * @returns the JSON object
  90355. */
  90356. serialize(): any;
  90357. /**
  90358. * Parse properties from a JSON object
  90359. * @param serializationObject defines the JSON object
  90360. */
  90361. parse(serializationObject: any): void;
  90362. }
  90363. }
  90364. declare module BABYLON {
  90365. /**
  90366. * Particle emitter emitting particles from the inside of a cone.
  90367. * It emits the particles alongside the cone volume from the base to the particle.
  90368. * The emission direction might be randomized.
  90369. */
  90370. export class ConeParticleEmitter implements IParticleEmitterType {
  90371. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90372. directionRandomizer: number;
  90373. private _radius;
  90374. private _angle;
  90375. private _height;
  90376. /**
  90377. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90378. */
  90379. radiusRange: number;
  90380. /**
  90381. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90382. */
  90383. heightRange: number;
  90384. /**
  90385. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90386. */
  90387. emitFromSpawnPointOnly: boolean;
  90388. /**
  90389. * Gets or sets the radius of the emission cone
  90390. */
  90391. get radius(): number;
  90392. set radius(value: number);
  90393. /**
  90394. * Gets or sets the angle of the emission cone
  90395. */
  90396. get angle(): number;
  90397. set angle(value: number);
  90398. private _buildHeight;
  90399. /**
  90400. * Creates a new instance ConeParticleEmitter
  90401. * @param radius the radius of the emission cone (1 by default)
  90402. * @param angle the cone base angle (PI by default)
  90403. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90404. */
  90405. constructor(radius?: number, angle?: number,
  90406. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90407. directionRandomizer?: number);
  90408. /**
  90409. * Called by the particle System when the direction is computed for the created particle.
  90410. * @param worldMatrix is the world matrix of the particle system
  90411. * @param directionToUpdate is the direction vector to update with the result
  90412. * @param particle is the particle we are computed the direction for
  90413. * @param isLocal defines if the direction should be set in local space
  90414. */
  90415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90416. /**
  90417. * Called by the particle System when the position is computed for the created particle.
  90418. * @param worldMatrix is the world matrix of the particle system
  90419. * @param positionToUpdate is the position vector to update with the result
  90420. * @param particle is the particle we are computed the position for
  90421. * @param isLocal defines if the position should be set in local space
  90422. */
  90423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90424. /**
  90425. * Clones the current emitter and returns a copy of it
  90426. * @returns the new emitter
  90427. */
  90428. clone(): ConeParticleEmitter;
  90429. /**
  90430. * Called by the GPUParticleSystem to setup the update shader
  90431. * @param effect defines the update shader
  90432. */
  90433. applyToShader(effect: Effect): void;
  90434. /**
  90435. * Returns a string to use to update the GPU particles update shader
  90436. * @returns a string containng the defines string
  90437. */
  90438. getEffectDefines(): string;
  90439. /**
  90440. * Returns the string "ConeParticleEmitter"
  90441. * @returns a string containing the class name
  90442. */
  90443. getClassName(): string;
  90444. /**
  90445. * Serializes the particle system to a JSON object.
  90446. * @returns the JSON object
  90447. */
  90448. serialize(): any;
  90449. /**
  90450. * Parse properties from a JSON object
  90451. * @param serializationObject defines the JSON object
  90452. */
  90453. parse(serializationObject: any): void;
  90454. }
  90455. }
  90456. declare module BABYLON {
  90457. /**
  90458. * Particle emitter emitting particles from the inside of a cylinder.
  90459. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90460. */
  90461. export class CylinderParticleEmitter implements IParticleEmitterType {
  90462. /**
  90463. * The radius of the emission cylinder.
  90464. */
  90465. radius: number;
  90466. /**
  90467. * The height of the emission cylinder.
  90468. */
  90469. height: number;
  90470. /**
  90471. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90472. */
  90473. radiusRange: number;
  90474. /**
  90475. * How much to randomize the particle direction [0-1].
  90476. */
  90477. directionRandomizer: number;
  90478. /**
  90479. * Creates a new instance CylinderParticleEmitter
  90480. * @param radius the radius of the emission cylinder (1 by default)
  90481. * @param height the height of the emission cylinder (1 by default)
  90482. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90483. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90484. */
  90485. constructor(
  90486. /**
  90487. * The radius of the emission cylinder.
  90488. */
  90489. radius?: number,
  90490. /**
  90491. * The height of the emission cylinder.
  90492. */
  90493. height?: number,
  90494. /**
  90495. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90496. */
  90497. radiusRange?: number,
  90498. /**
  90499. * How much to randomize the particle direction [0-1].
  90500. */
  90501. directionRandomizer?: number);
  90502. /**
  90503. * Called by the particle System when the direction is computed for the created particle.
  90504. * @param worldMatrix is the world matrix of the particle system
  90505. * @param directionToUpdate is the direction vector to update with the result
  90506. * @param particle is the particle we are computed the direction for
  90507. * @param isLocal defines if the direction should be set in local space
  90508. */
  90509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90510. /**
  90511. * Called by the particle System when the position is computed for the created particle.
  90512. * @param worldMatrix is the world matrix of the particle system
  90513. * @param positionToUpdate is the position vector to update with the result
  90514. * @param particle is the particle we are computed the position for
  90515. * @param isLocal defines if the position should be set in local space
  90516. */
  90517. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90518. /**
  90519. * Clones the current emitter and returns a copy of it
  90520. * @returns the new emitter
  90521. */
  90522. clone(): CylinderParticleEmitter;
  90523. /**
  90524. * Called by the GPUParticleSystem to setup the update shader
  90525. * @param effect defines the update shader
  90526. */
  90527. applyToShader(effect: Effect): void;
  90528. /**
  90529. * Returns a string to use to update the GPU particles update shader
  90530. * @returns a string containng the defines string
  90531. */
  90532. getEffectDefines(): string;
  90533. /**
  90534. * Returns the string "CylinderParticleEmitter"
  90535. * @returns a string containing the class name
  90536. */
  90537. getClassName(): string;
  90538. /**
  90539. * Serializes the particle system to a JSON object.
  90540. * @returns the JSON object
  90541. */
  90542. serialize(): any;
  90543. /**
  90544. * Parse properties from a JSON object
  90545. * @param serializationObject defines the JSON object
  90546. */
  90547. parse(serializationObject: any): void;
  90548. }
  90549. /**
  90550. * Particle emitter emitting particles from the inside of a cylinder.
  90551. * It emits the particles randomly between two vectors.
  90552. */
  90553. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90554. /**
  90555. * The min limit of the emission direction.
  90556. */
  90557. direction1: Vector3;
  90558. /**
  90559. * The max limit of the emission direction.
  90560. */
  90561. direction2: Vector3;
  90562. /**
  90563. * Creates a new instance CylinderDirectedParticleEmitter
  90564. * @param radius the radius of the emission cylinder (1 by default)
  90565. * @param height the height of the emission cylinder (1 by default)
  90566. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90567. * @param direction1 the min limit of the emission direction (up vector by default)
  90568. * @param direction2 the max limit of the emission direction (up vector by default)
  90569. */
  90570. constructor(radius?: number, height?: number, radiusRange?: number,
  90571. /**
  90572. * The min limit of the emission direction.
  90573. */
  90574. direction1?: Vector3,
  90575. /**
  90576. * The max limit of the emission direction.
  90577. */
  90578. direction2?: Vector3);
  90579. /**
  90580. * Called by the particle System when the direction is computed for the created particle.
  90581. * @param worldMatrix is the world matrix of the particle system
  90582. * @param directionToUpdate is the direction vector to update with the result
  90583. * @param particle is the particle we are computed the direction for
  90584. */
  90585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90586. /**
  90587. * Clones the current emitter and returns a copy of it
  90588. * @returns the new emitter
  90589. */
  90590. clone(): CylinderDirectedParticleEmitter;
  90591. /**
  90592. * Called by the GPUParticleSystem to setup the update shader
  90593. * @param effect defines the update shader
  90594. */
  90595. applyToShader(effect: Effect): void;
  90596. /**
  90597. * Returns a string to use to update the GPU particles update shader
  90598. * @returns a string containng the defines string
  90599. */
  90600. getEffectDefines(): string;
  90601. /**
  90602. * Returns the string "CylinderDirectedParticleEmitter"
  90603. * @returns a string containing the class name
  90604. */
  90605. getClassName(): string;
  90606. /**
  90607. * Serializes the particle system to a JSON object.
  90608. * @returns the JSON object
  90609. */
  90610. serialize(): any;
  90611. /**
  90612. * Parse properties from a JSON object
  90613. * @param serializationObject defines the JSON object
  90614. */
  90615. parse(serializationObject: any): void;
  90616. }
  90617. }
  90618. declare module BABYLON {
  90619. /**
  90620. * Particle emitter emitting particles from the inside of a hemisphere.
  90621. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90622. */
  90623. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90624. /**
  90625. * The radius of the emission hemisphere.
  90626. */
  90627. radius: number;
  90628. /**
  90629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90630. */
  90631. radiusRange: number;
  90632. /**
  90633. * How much to randomize the particle direction [0-1].
  90634. */
  90635. directionRandomizer: number;
  90636. /**
  90637. * Creates a new instance HemisphericParticleEmitter
  90638. * @param radius the radius of the emission hemisphere (1 by default)
  90639. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90640. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90641. */
  90642. constructor(
  90643. /**
  90644. * The radius of the emission hemisphere.
  90645. */
  90646. radius?: number,
  90647. /**
  90648. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90649. */
  90650. radiusRange?: number,
  90651. /**
  90652. * How much to randomize the particle direction [0-1].
  90653. */
  90654. directionRandomizer?: number);
  90655. /**
  90656. * Called by the particle System when the direction is computed for the created particle.
  90657. * @param worldMatrix is the world matrix of the particle system
  90658. * @param directionToUpdate is the direction vector to update with the result
  90659. * @param particle is the particle we are computed the direction for
  90660. * @param isLocal defines if the direction should be set in local space
  90661. */
  90662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90663. /**
  90664. * Called by the particle System when the position is computed for the created particle.
  90665. * @param worldMatrix is the world matrix of the particle system
  90666. * @param positionToUpdate is the position vector to update with the result
  90667. * @param particle is the particle we are computed the position for
  90668. * @param isLocal defines if the position should be set in local space
  90669. */
  90670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90671. /**
  90672. * Clones the current emitter and returns a copy of it
  90673. * @returns the new emitter
  90674. */
  90675. clone(): HemisphericParticleEmitter;
  90676. /**
  90677. * Called by the GPUParticleSystem to setup the update shader
  90678. * @param effect defines the update shader
  90679. */
  90680. applyToShader(effect: Effect): void;
  90681. /**
  90682. * Returns a string to use to update the GPU particles update shader
  90683. * @returns a string containng the defines string
  90684. */
  90685. getEffectDefines(): string;
  90686. /**
  90687. * Returns the string "HemisphericParticleEmitter"
  90688. * @returns a string containing the class name
  90689. */
  90690. getClassName(): string;
  90691. /**
  90692. * Serializes the particle system to a JSON object.
  90693. * @returns the JSON object
  90694. */
  90695. serialize(): any;
  90696. /**
  90697. * Parse properties from a JSON object
  90698. * @param serializationObject defines the JSON object
  90699. */
  90700. parse(serializationObject: any): void;
  90701. }
  90702. }
  90703. declare module BABYLON {
  90704. /**
  90705. * Particle emitter emitting particles from a point.
  90706. * It emits the particles randomly between 2 given directions.
  90707. */
  90708. export class PointParticleEmitter implements IParticleEmitterType {
  90709. /**
  90710. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90711. */
  90712. direction1: Vector3;
  90713. /**
  90714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90715. */
  90716. direction2: Vector3;
  90717. /**
  90718. * Creates a new instance PointParticleEmitter
  90719. */
  90720. constructor();
  90721. /**
  90722. * Called by the particle System when the direction is computed for the created particle.
  90723. * @param worldMatrix is the world matrix of the particle system
  90724. * @param directionToUpdate is the direction vector to update with the result
  90725. * @param particle is the particle we are computed the direction for
  90726. * @param isLocal defines if the direction should be set in local space
  90727. */
  90728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90729. /**
  90730. * Called by the particle System when the position is computed for the created particle.
  90731. * @param worldMatrix is the world matrix of the particle system
  90732. * @param positionToUpdate is the position vector to update with the result
  90733. * @param particle is the particle we are computed the position for
  90734. * @param isLocal defines if the position should be set in local space
  90735. */
  90736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90737. /**
  90738. * Clones the current emitter and returns a copy of it
  90739. * @returns the new emitter
  90740. */
  90741. clone(): PointParticleEmitter;
  90742. /**
  90743. * Called by the GPUParticleSystem to setup the update shader
  90744. * @param effect defines the update shader
  90745. */
  90746. applyToShader(effect: Effect): void;
  90747. /**
  90748. * Returns a string to use to update the GPU particles update shader
  90749. * @returns a string containng the defines string
  90750. */
  90751. getEffectDefines(): string;
  90752. /**
  90753. * Returns the string "PointParticleEmitter"
  90754. * @returns a string containing the class name
  90755. */
  90756. getClassName(): string;
  90757. /**
  90758. * Serializes the particle system to a JSON object.
  90759. * @returns the JSON object
  90760. */
  90761. serialize(): any;
  90762. /**
  90763. * Parse properties from a JSON object
  90764. * @param serializationObject defines the JSON object
  90765. */
  90766. parse(serializationObject: any): void;
  90767. }
  90768. }
  90769. declare module BABYLON {
  90770. /**
  90771. * Particle emitter emitting particles from the inside of a sphere.
  90772. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90773. */
  90774. export class SphereParticleEmitter implements IParticleEmitterType {
  90775. /**
  90776. * The radius of the emission sphere.
  90777. */
  90778. radius: number;
  90779. /**
  90780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90781. */
  90782. radiusRange: number;
  90783. /**
  90784. * How much to randomize the particle direction [0-1].
  90785. */
  90786. directionRandomizer: number;
  90787. /**
  90788. * Creates a new instance SphereParticleEmitter
  90789. * @param radius the radius of the emission sphere (1 by default)
  90790. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90791. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90792. */
  90793. constructor(
  90794. /**
  90795. * The radius of the emission sphere.
  90796. */
  90797. radius?: number,
  90798. /**
  90799. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90800. */
  90801. radiusRange?: number,
  90802. /**
  90803. * How much to randomize the particle direction [0-1].
  90804. */
  90805. directionRandomizer?: number);
  90806. /**
  90807. * Called by the particle System when the direction is computed for the created particle.
  90808. * @param worldMatrix is the world matrix of the particle system
  90809. * @param directionToUpdate is the direction vector to update with the result
  90810. * @param particle is the particle we are computed the direction for
  90811. * @param isLocal defines if the direction should be set in local space
  90812. */
  90813. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90814. /**
  90815. * Called by the particle System when the position is computed for the created particle.
  90816. * @param worldMatrix is the world matrix of the particle system
  90817. * @param positionToUpdate is the position vector to update with the result
  90818. * @param particle is the particle we are computed the position for
  90819. * @param isLocal defines if the position should be set in local space
  90820. */
  90821. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90822. /**
  90823. * Clones the current emitter and returns a copy of it
  90824. * @returns the new emitter
  90825. */
  90826. clone(): SphereParticleEmitter;
  90827. /**
  90828. * Called by the GPUParticleSystem to setup the update shader
  90829. * @param effect defines the update shader
  90830. */
  90831. applyToShader(effect: Effect): void;
  90832. /**
  90833. * Returns a string to use to update the GPU particles update shader
  90834. * @returns a string containng the defines string
  90835. */
  90836. getEffectDefines(): string;
  90837. /**
  90838. * Returns the string "SphereParticleEmitter"
  90839. * @returns a string containing the class name
  90840. */
  90841. getClassName(): string;
  90842. /**
  90843. * Serializes the particle system to a JSON object.
  90844. * @returns the JSON object
  90845. */
  90846. serialize(): any;
  90847. /**
  90848. * Parse properties from a JSON object
  90849. * @param serializationObject defines the JSON object
  90850. */
  90851. parse(serializationObject: any): void;
  90852. }
  90853. /**
  90854. * Particle emitter emitting particles from the inside of a sphere.
  90855. * It emits the particles randomly between two vectors.
  90856. */
  90857. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90858. /**
  90859. * The min limit of the emission direction.
  90860. */
  90861. direction1: Vector3;
  90862. /**
  90863. * The max limit of the emission direction.
  90864. */
  90865. direction2: Vector3;
  90866. /**
  90867. * Creates a new instance SphereDirectedParticleEmitter
  90868. * @param radius the radius of the emission sphere (1 by default)
  90869. * @param direction1 the min limit of the emission direction (up vector by default)
  90870. * @param direction2 the max limit of the emission direction (up vector by default)
  90871. */
  90872. constructor(radius?: number,
  90873. /**
  90874. * The min limit of the emission direction.
  90875. */
  90876. direction1?: Vector3,
  90877. /**
  90878. * The max limit of the emission direction.
  90879. */
  90880. direction2?: Vector3);
  90881. /**
  90882. * Called by the particle System when the direction is computed for the created particle.
  90883. * @param worldMatrix is the world matrix of the particle system
  90884. * @param directionToUpdate is the direction vector to update with the result
  90885. * @param particle is the particle we are computed the direction for
  90886. */
  90887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90888. /**
  90889. * Clones the current emitter and returns a copy of it
  90890. * @returns the new emitter
  90891. */
  90892. clone(): SphereDirectedParticleEmitter;
  90893. /**
  90894. * Called by the GPUParticleSystem to setup the update shader
  90895. * @param effect defines the update shader
  90896. */
  90897. applyToShader(effect: Effect): void;
  90898. /**
  90899. * Returns a string to use to update the GPU particles update shader
  90900. * @returns a string containng the defines string
  90901. */
  90902. getEffectDefines(): string;
  90903. /**
  90904. * Returns the string "SphereDirectedParticleEmitter"
  90905. * @returns a string containing the class name
  90906. */
  90907. getClassName(): string;
  90908. /**
  90909. * Serializes the particle system to a JSON object.
  90910. * @returns the JSON object
  90911. */
  90912. serialize(): any;
  90913. /**
  90914. * Parse properties from a JSON object
  90915. * @param serializationObject defines the JSON object
  90916. */
  90917. parse(serializationObject: any): void;
  90918. }
  90919. }
  90920. declare module BABYLON {
  90921. /**
  90922. * Particle emitter emitting particles from a custom list of positions.
  90923. */
  90924. export class CustomParticleEmitter implements IParticleEmitterType {
  90925. /**
  90926. * Gets or sets the position generator that will create the inital position of each particle.
  90927. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90928. */
  90929. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  90930. /**
  90931. * Gets or sets the destination generator that will create the final destination of each particle.
  90932. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90933. */
  90934. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  90935. /**
  90936. * Creates a new instance CustomParticleEmitter
  90937. */
  90938. constructor();
  90939. /**
  90940. * Called by the particle System when the direction is computed for the created particle.
  90941. * @param worldMatrix is the world matrix of the particle system
  90942. * @param directionToUpdate is the direction vector to update with the result
  90943. * @param particle is the particle we are computed the direction for
  90944. * @param isLocal defines if the direction should be set in local space
  90945. */
  90946. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90947. /**
  90948. * Called by the particle System when the position is computed for the created particle.
  90949. * @param worldMatrix is the world matrix of the particle system
  90950. * @param positionToUpdate is the position vector to update with the result
  90951. * @param particle is the particle we are computed the position for
  90952. * @param isLocal defines if the position should be set in local space
  90953. */
  90954. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90955. /**
  90956. * Clones the current emitter and returns a copy of it
  90957. * @returns the new emitter
  90958. */
  90959. clone(): CustomParticleEmitter;
  90960. /**
  90961. * Called by the GPUParticleSystem to setup the update shader
  90962. * @param effect defines the update shader
  90963. */
  90964. applyToShader(effect: Effect): void;
  90965. /**
  90966. * Returns a string to use to update the GPU particles update shader
  90967. * @returns a string containng the defines string
  90968. */
  90969. getEffectDefines(): string;
  90970. /**
  90971. * Returns the string "PointParticleEmitter"
  90972. * @returns a string containing the class name
  90973. */
  90974. getClassName(): string;
  90975. /**
  90976. * Serializes the particle system to a JSON object.
  90977. * @returns the JSON object
  90978. */
  90979. serialize(): any;
  90980. /**
  90981. * Parse properties from a JSON object
  90982. * @param serializationObject defines the JSON object
  90983. */
  90984. parse(serializationObject: any): void;
  90985. }
  90986. }
  90987. declare module BABYLON {
  90988. /**
  90989. * Particle emitter emitting particles from the inside of a box.
  90990. * It emits the particles randomly between 2 given directions.
  90991. */
  90992. export class MeshParticleEmitter implements IParticleEmitterType {
  90993. private _indices;
  90994. private _positions;
  90995. private _normals;
  90996. private _storedNormal;
  90997. private _mesh;
  90998. /**
  90999. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91000. */
  91001. direction1: Vector3;
  91002. /**
  91003. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91004. */
  91005. direction2: Vector3;
  91006. /**
  91007. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91008. */
  91009. useMeshNormalsForDirection: boolean;
  91010. /** Defines the mesh to use as source */
  91011. get mesh(): Nullable<AbstractMesh>;
  91012. set mesh(value: Nullable<AbstractMesh>);
  91013. /**
  91014. * Creates a new instance MeshParticleEmitter
  91015. * @param mesh defines the mesh to use as source
  91016. */
  91017. constructor(mesh?: Nullable<AbstractMesh>);
  91018. /**
  91019. * Called by the particle System when the direction is computed for the created particle.
  91020. * @param worldMatrix is the world matrix of the particle system
  91021. * @param directionToUpdate is the direction vector to update with the result
  91022. * @param particle is the particle we are computed the direction for
  91023. * @param isLocal defines if the direction should be set in local space
  91024. */
  91025. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91026. /**
  91027. * Called by the particle System when the position is computed for the created particle.
  91028. * @param worldMatrix is the world matrix of the particle system
  91029. * @param positionToUpdate is the position vector to update with the result
  91030. * @param particle is the particle we are computed the position for
  91031. * @param isLocal defines if the position should be set in local space
  91032. */
  91033. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91034. /**
  91035. * Clones the current emitter and returns a copy of it
  91036. * @returns the new emitter
  91037. */
  91038. clone(): MeshParticleEmitter;
  91039. /**
  91040. * Called by the GPUParticleSystem to setup the update shader
  91041. * @param effect defines the update shader
  91042. */
  91043. applyToShader(effect: Effect): void;
  91044. /**
  91045. * Returns a string to use to update the GPU particles update shader
  91046. * @returns a string containng the defines string
  91047. */
  91048. getEffectDefines(): string;
  91049. /**
  91050. * Returns the string "BoxParticleEmitter"
  91051. * @returns a string containing the class name
  91052. */
  91053. getClassName(): string;
  91054. /**
  91055. * Serializes the particle system to a JSON object.
  91056. * @returns the JSON object
  91057. */
  91058. serialize(): any;
  91059. /**
  91060. * Parse properties from a JSON object
  91061. * @param serializationObject defines the JSON object
  91062. * @param scene defines the hosting scene
  91063. */
  91064. parse(serializationObject: any, scene: Scene): void;
  91065. }
  91066. }
  91067. declare module BABYLON {
  91068. /**
  91069. * Interface representing a particle system in Babylon.js.
  91070. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91071. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91072. */
  91073. export interface IParticleSystem {
  91074. /**
  91075. * List of animations used by the particle system.
  91076. */
  91077. animations: Animation[];
  91078. /**
  91079. * The id of the Particle system.
  91080. */
  91081. id: string;
  91082. /**
  91083. * The name of the Particle system.
  91084. */
  91085. name: string;
  91086. /**
  91087. * The emitter represents the Mesh or position we are attaching the particle system to.
  91088. */
  91089. emitter: Nullable<AbstractMesh | Vector3>;
  91090. /**
  91091. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91092. */
  91093. isBillboardBased: boolean;
  91094. /**
  91095. * The rendering group used by the Particle system to chose when to render.
  91096. */
  91097. renderingGroupId: number;
  91098. /**
  91099. * The layer mask we are rendering the particles through.
  91100. */
  91101. layerMask: number;
  91102. /**
  91103. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91104. */
  91105. updateSpeed: number;
  91106. /**
  91107. * The amount of time the particle system is running (depends of the overall update speed).
  91108. */
  91109. targetStopDuration: number;
  91110. /**
  91111. * The texture used to render each particle. (this can be a spritesheet)
  91112. */
  91113. particleTexture: Nullable<Texture>;
  91114. /**
  91115. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91116. */
  91117. blendMode: number;
  91118. /**
  91119. * Minimum life time of emitting particles.
  91120. */
  91121. minLifeTime: number;
  91122. /**
  91123. * Maximum life time of emitting particles.
  91124. */
  91125. maxLifeTime: number;
  91126. /**
  91127. * Minimum Size of emitting particles.
  91128. */
  91129. minSize: number;
  91130. /**
  91131. * Maximum Size of emitting particles.
  91132. */
  91133. maxSize: number;
  91134. /**
  91135. * Minimum scale of emitting particles on X axis.
  91136. */
  91137. minScaleX: number;
  91138. /**
  91139. * Maximum scale of emitting particles on X axis.
  91140. */
  91141. maxScaleX: number;
  91142. /**
  91143. * Minimum scale of emitting particles on Y axis.
  91144. */
  91145. minScaleY: number;
  91146. /**
  91147. * Maximum scale of emitting particles on Y axis.
  91148. */
  91149. maxScaleY: number;
  91150. /**
  91151. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91152. */
  91153. color1: Color4;
  91154. /**
  91155. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91156. */
  91157. color2: Color4;
  91158. /**
  91159. * Color the particle will have at the end of its lifetime.
  91160. */
  91161. colorDead: Color4;
  91162. /**
  91163. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91164. */
  91165. emitRate: number;
  91166. /**
  91167. * You can use gravity if you want to give an orientation to your particles.
  91168. */
  91169. gravity: Vector3;
  91170. /**
  91171. * Minimum power of emitting particles.
  91172. */
  91173. minEmitPower: number;
  91174. /**
  91175. * Maximum power of emitting particles.
  91176. */
  91177. maxEmitPower: number;
  91178. /**
  91179. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91180. */
  91181. minAngularSpeed: number;
  91182. /**
  91183. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91184. */
  91185. maxAngularSpeed: number;
  91186. /**
  91187. * Gets or sets the minimal initial rotation in radians.
  91188. */
  91189. minInitialRotation: number;
  91190. /**
  91191. * Gets or sets the maximal initial rotation in radians.
  91192. */
  91193. maxInitialRotation: number;
  91194. /**
  91195. * The particle emitter type defines the emitter used by the particle system.
  91196. * It can be for example box, sphere, or cone...
  91197. */
  91198. particleEmitterType: Nullable<IParticleEmitterType>;
  91199. /**
  91200. * Defines the delay in milliseconds before starting the system (0 by default)
  91201. */
  91202. startDelay: number;
  91203. /**
  91204. * 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
  91205. */
  91206. preWarmCycles: number;
  91207. /**
  91208. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91209. */
  91210. preWarmStepOffset: number;
  91211. /**
  91212. * 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)
  91213. */
  91214. spriteCellChangeSpeed: number;
  91215. /**
  91216. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91217. */
  91218. startSpriteCellID: number;
  91219. /**
  91220. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91221. */
  91222. endSpriteCellID: number;
  91223. /**
  91224. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91225. */
  91226. spriteCellWidth: number;
  91227. /**
  91228. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91229. */
  91230. spriteCellHeight: number;
  91231. /**
  91232. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91233. */
  91234. spriteRandomStartCell: boolean;
  91235. /**
  91236. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91237. */
  91238. isAnimationSheetEnabled: boolean;
  91239. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91240. translationPivot: Vector2;
  91241. /**
  91242. * Gets or sets a texture used to add random noise to particle positions
  91243. */
  91244. noiseTexture: Nullable<BaseTexture>;
  91245. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91246. noiseStrength: Vector3;
  91247. /**
  91248. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91249. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91250. */
  91251. billboardMode: number;
  91252. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91253. limitVelocityDamping: number;
  91254. /**
  91255. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91256. */
  91257. beginAnimationOnStart: boolean;
  91258. /**
  91259. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91260. */
  91261. beginAnimationFrom: number;
  91262. /**
  91263. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91264. */
  91265. beginAnimationTo: number;
  91266. /**
  91267. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91268. */
  91269. beginAnimationLoop: boolean;
  91270. /**
  91271. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91272. */
  91273. disposeOnStop: boolean;
  91274. /**
  91275. * Specifies if the particles are updated in emitter local space or world space
  91276. */
  91277. isLocal: boolean;
  91278. /** Snippet ID if the particle system was created from the snippet server */
  91279. snippetId: string;
  91280. /**
  91281. * Gets the maximum number of particles active at the same time.
  91282. * @returns The max number of active particles.
  91283. */
  91284. getCapacity(): number;
  91285. /**
  91286. * Gets the number of particles active at the same time.
  91287. * @returns The number of active particles.
  91288. */
  91289. getActiveCount(): number;
  91290. /**
  91291. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91292. * @returns True if it has been started, otherwise false.
  91293. */
  91294. isStarted(): boolean;
  91295. /**
  91296. * Animates the particle system for this frame.
  91297. */
  91298. animate(): void;
  91299. /**
  91300. * Renders the particle system in its current state.
  91301. * @returns the current number of particles
  91302. */
  91303. render(): number;
  91304. /**
  91305. * Dispose the particle system and frees its associated resources.
  91306. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91307. */
  91308. dispose(disposeTexture?: boolean): void;
  91309. /**
  91310. * An event triggered when the system is disposed
  91311. */
  91312. onDisposeObservable: Observable<IParticleSystem>;
  91313. /**
  91314. * Clones the particle system.
  91315. * @param name The name of the cloned object
  91316. * @param newEmitter The new emitter to use
  91317. * @returns the cloned particle system
  91318. */
  91319. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91320. /**
  91321. * Serializes the particle system to a JSON object
  91322. * @param serializeTexture defines if the texture must be serialized as well
  91323. * @returns the JSON object
  91324. */
  91325. serialize(serializeTexture: boolean): any;
  91326. /**
  91327. * Rebuild the particle system
  91328. */
  91329. rebuild(): void;
  91330. /** Force the system to rebuild all gradients that need to be resync */
  91331. forceRefreshGradients(): void;
  91332. /**
  91333. * Starts the particle system and begins to emit
  91334. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91335. */
  91336. start(delay?: number): void;
  91337. /**
  91338. * Stops the particle system.
  91339. */
  91340. stop(): void;
  91341. /**
  91342. * Remove all active particles
  91343. */
  91344. reset(): void;
  91345. /**
  91346. * Gets a boolean indicating that the system is stopping
  91347. * @returns true if the system is currently stopping
  91348. */
  91349. isStopping(): boolean;
  91350. /**
  91351. * Is this system ready to be used/rendered
  91352. * @return true if the system is ready
  91353. */
  91354. isReady(): boolean;
  91355. /**
  91356. * Returns the string "ParticleSystem"
  91357. * @returns a string containing the class name
  91358. */
  91359. getClassName(): string;
  91360. /**
  91361. * Gets the custom effect used to render the particles
  91362. * @param blendMode Blend mode for which the effect should be retrieved
  91363. * @returns The effect
  91364. */
  91365. getCustomEffect(blendMode: number): Nullable<Effect>;
  91366. /**
  91367. * Sets the custom effect used to render the particles
  91368. * @param effect The effect to set
  91369. * @param blendMode Blend mode for which the effect should be set
  91370. */
  91371. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91372. /**
  91373. * Fill the defines array according to the current settings of the particle system
  91374. * @param defines Array to be updated
  91375. * @param blendMode blend mode to take into account when updating the array
  91376. */
  91377. fillDefines(defines: Array<string>, blendMode: number): void;
  91378. /**
  91379. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91380. * @param uniforms Uniforms array to fill
  91381. * @param attributes Attributes array to fill
  91382. * @param samplers Samplers array to fill
  91383. */
  91384. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91385. /**
  91386. * Observable that will be called just before the particles are drawn
  91387. */
  91388. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91389. /**
  91390. * Gets the name of the particle vertex shader
  91391. */
  91392. vertexShaderName: string;
  91393. /**
  91394. * Adds a new color gradient
  91395. * @param gradient defines the gradient to use (between 0 and 1)
  91396. * @param color1 defines the color to affect to the specified gradient
  91397. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91398. * @returns the current particle system
  91399. */
  91400. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91401. /**
  91402. * Remove a specific color gradient
  91403. * @param gradient defines the gradient to remove
  91404. * @returns the current particle system
  91405. */
  91406. removeColorGradient(gradient: number): IParticleSystem;
  91407. /**
  91408. * Adds a new size gradient
  91409. * @param gradient defines the gradient to use (between 0 and 1)
  91410. * @param factor defines the size factor to affect to the specified gradient
  91411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91412. * @returns the current particle system
  91413. */
  91414. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91415. /**
  91416. * Remove a specific size gradient
  91417. * @param gradient defines the gradient to remove
  91418. * @returns the current particle system
  91419. */
  91420. removeSizeGradient(gradient: number): IParticleSystem;
  91421. /**
  91422. * Gets the current list of color gradients.
  91423. * You must use addColorGradient and removeColorGradient to udpate this list
  91424. * @returns the list of color gradients
  91425. */
  91426. getColorGradients(): Nullable<Array<ColorGradient>>;
  91427. /**
  91428. * Gets the current list of size gradients.
  91429. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91430. * @returns the list of size gradients
  91431. */
  91432. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91433. /**
  91434. * Gets the current list of angular speed gradients.
  91435. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91436. * @returns the list of angular speed gradients
  91437. */
  91438. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91439. /**
  91440. * Adds a new angular speed gradient
  91441. * @param gradient defines the gradient to use (between 0 and 1)
  91442. * @param factor defines the angular speed to affect to the specified gradient
  91443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91444. * @returns the current particle system
  91445. */
  91446. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91447. /**
  91448. * Remove a specific angular speed gradient
  91449. * @param gradient defines the gradient to remove
  91450. * @returns the current particle system
  91451. */
  91452. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91453. /**
  91454. * Gets the current list of velocity gradients.
  91455. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91456. * @returns the list of velocity gradients
  91457. */
  91458. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91459. /**
  91460. * Adds a new velocity gradient
  91461. * @param gradient defines the gradient to use (between 0 and 1)
  91462. * @param factor defines the velocity to affect to the specified gradient
  91463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91464. * @returns the current particle system
  91465. */
  91466. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91467. /**
  91468. * Remove a specific velocity gradient
  91469. * @param gradient defines the gradient to remove
  91470. * @returns the current particle system
  91471. */
  91472. removeVelocityGradient(gradient: number): IParticleSystem;
  91473. /**
  91474. * Gets the current list of limit velocity gradients.
  91475. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91476. * @returns the list of limit velocity gradients
  91477. */
  91478. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91479. /**
  91480. * Adds a new limit velocity gradient
  91481. * @param gradient defines the gradient to use (between 0 and 1)
  91482. * @param factor defines the limit velocity to affect to the specified gradient
  91483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91484. * @returns the current particle system
  91485. */
  91486. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91487. /**
  91488. * Remove a specific limit velocity gradient
  91489. * @param gradient defines the gradient to remove
  91490. * @returns the current particle system
  91491. */
  91492. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91493. /**
  91494. * Adds a new drag gradient
  91495. * @param gradient defines the gradient to use (between 0 and 1)
  91496. * @param factor defines the drag to affect to the specified gradient
  91497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91498. * @returns the current particle system
  91499. */
  91500. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91501. /**
  91502. * Remove a specific drag gradient
  91503. * @param gradient defines the gradient to remove
  91504. * @returns the current particle system
  91505. */
  91506. removeDragGradient(gradient: number): IParticleSystem;
  91507. /**
  91508. * Gets the current list of drag gradients.
  91509. * You must use addDragGradient and removeDragGradient to udpate this list
  91510. * @returns the list of drag gradients
  91511. */
  91512. getDragGradients(): Nullable<Array<FactorGradient>>;
  91513. /**
  91514. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91515. * @param gradient defines the gradient to use (between 0 and 1)
  91516. * @param factor defines the emit rate to affect to the specified gradient
  91517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91518. * @returns the current particle system
  91519. */
  91520. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91521. /**
  91522. * Remove a specific emit rate gradient
  91523. * @param gradient defines the gradient to remove
  91524. * @returns the current particle system
  91525. */
  91526. removeEmitRateGradient(gradient: number): IParticleSystem;
  91527. /**
  91528. * Gets the current list of emit rate gradients.
  91529. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91530. * @returns the list of emit rate gradients
  91531. */
  91532. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91533. /**
  91534. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91535. * @param gradient defines the gradient to use (between 0 and 1)
  91536. * @param factor defines the start size to affect to the specified gradient
  91537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91538. * @returns the current particle system
  91539. */
  91540. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91541. /**
  91542. * Remove a specific start size gradient
  91543. * @param gradient defines the gradient to remove
  91544. * @returns the current particle system
  91545. */
  91546. removeStartSizeGradient(gradient: number): IParticleSystem;
  91547. /**
  91548. * Gets the current list of start size gradients.
  91549. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91550. * @returns the list of start size gradients
  91551. */
  91552. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91553. /**
  91554. * Adds a new life time gradient
  91555. * @param gradient defines the gradient to use (between 0 and 1)
  91556. * @param factor defines the life time factor to affect to the specified gradient
  91557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91558. * @returns the current particle system
  91559. */
  91560. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91561. /**
  91562. * Remove a specific life time gradient
  91563. * @param gradient defines the gradient to remove
  91564. * @returns the current particle system
  91565. */
  91566. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91567. /**
  91568. * Gets the current list of life time gradients.
  91569. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91570. * @returns the list of life time gradients
  91571. */
  91572. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91573. /**
  91574. * Gets the current list of color gradients.
  91575. * You must use addColorGradient and removeColorGradient to udpate this list
  91576. * @returns the list of color gradients
  91577. */
  91578. getColorGradients(): Nullable<Array<ColorGradient>>;
  91579. /**
  91580. * Adds a new ramp gradient used to remap particle colors
  91581. * @param gradient defines the gradient to use (between 0 and 1)
  91582. * @param color defines the color to affect to the specified gradient
  91583. * @returns the current particle system
  91584. */
  91585. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91586. /**
  91587. * Gets the current list of ramp gradients.
  91588. * You must use addRampGradient and removeRampGradient to udpate this list
  91589. * @returns the list of ramp gradients
  91590. */
  91591. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91592. /** Gets or sets a boolean indicating that ramp gradients must be used
  91593. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91594. */
  91595. useRampGradients: boolean;
  91596. /**
  91597. * Adds a new color remap gradient
  91598. * @param gradient defines the gradient to use (between 0 and 1)
  91599. * @param min defines the color remap minimal range
  91600. * @param max defines the color remap maximal range
  91601. * @returns the current particle system
  91602. */
  91603. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91604. /**
  91605. * Gets the current list of color remap gradients.
  91606. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91607. * @returns the list of color remap gradients
  91608. */
  91609. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91610. /**
  91611. * Adds a new alpha remap gradient
  91612. * @param gradient defines the gradient to use (between 0 and 1)
  91613. * @param min defines the alpha remap minimal range
  91614. * @param max defines the alpha remap maximal range
  91615. * @returns the current particle system
  91616. */
  91617. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91618. /**
  91619. * Gets the current list of alpha remap gradients.
  91620. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91621. * @returns the list of alpha remap gradients
  91622. */
  91623. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91624. /**
  91625. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91628. * @returns the emitter
  91629. */
  91630. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91631. /**
  91632. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91633. * @param radius The radius of the hemisphere to emit from
  91634. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91635. * @returns the emitter
  91636. */
  91637. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91638. /**
  91639. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91640. * @param radius The radius of the sphere to emit from
  91641. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91642. * @returns the emitter
  91643. */
  91644. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91645. /**
  91646. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91647. * @param radius The radius of the sphere to emit from
  91648. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91649. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91650. * @returns the emitter
  91651. */
  91652. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91653. /**
  91654. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91655. * @param radius The radius of the emission cylinder
  91656. * @param height The height of the emission cylinder
  91657. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91658. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91659. * @returns the emitter
  91660. */
  91661. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91662. /**
  91663. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91664. * @param radius The radius of the cylinder to emit from
  91665. * @param height The height of the emission cylinder
  91666. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91669. * @returns the emitter
  91670. */
  91671. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91672. /**
  91673. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91674. * @param radius The radius of the cone to emit from
  91675. * @param angle The base angle of the cone
  91676. * @returns the emitter
  91677. */
  91678. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91679. /**
  91680. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91681. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91682. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91683. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91684. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91685. * @returns the emitter
  91686. */
  91687. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91688. /**
  91689. * Get hosting scene
  91690. * @returns the scene
  91691. */
  91692. getScene(): Scene;
  91693. }
  91694. }
  91695. declare module BABYLON {
  91696. /**
  91697. * 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.
  91698. * @see https://doc.babylonjs.com/how_to/transformnode
  91699. */
  91700. export class TransformNode extends Node {
  91701. /**
  91702. * Object will not rotate to face the camera
  91703. */
  91704. static BILLBOARDMODE_NONE: number;
  91705. /**
  91706. * Object will rotate to face the camera but only on the x axis
  91707. */
  91708. static BILLBOARDMODE_X: number;
  91709. /**
  91710. * Object will rotate to face the camera but only on the y axis
  91711. */
  91712. static BILLBOARDMODE_Y: number;
  91713. /**
  91714. * Object will rotate to face the camera but only on the z axis
  91715. */
  91716. static BILLBOARDMODE_Z: number;
  91717. /**
  91718. * Object will rotate to face the camera
  91719. */
  91720. static BILLBOARDMODE_ALL: number;
  91721. /**
  91722. * Object will rotate to face the camera's position instead of orientation
  91723. */
  91724. static BILLBOARDMODE_USE_POSITION: number;
  91725. private _forward;
  91726. private _forwardInverted;
  91727. private _up;
  91728. private _right;
  91729. private _rightInverted;
  91730. private _position;
  91731. private _rotation;
  91732. private _rotationQuaternion;
  91733. protected _scaling: Vector3;
  91734. protected _isDirty: boolean;
  91735. private _transformToBoneReferal;
  91736. private _isAbsoluteSynced;
  91737. private _billboardMode;
  91738. /**
  91739. * Gets or sets the billboard mode. Default is 0.
  91740. *
  91741. * | Value | Type | Description |
  91742. * | --- | --- | --- |
  91743. * | 0 | BILLBOARDMODE_NONE | |
  91744. * | 1 | BILLBOARDMODE_X | |
  91745. * | 2 | BILLBOARDMODE_Y | |
  91746. * | 4 | BILLBOARDMODE_Z | |
  91747. * | 7 | BILLBOARDMODE_ALL | |
  91748. *
  91749. */
  91750. get billboardMode(): number;
  91751. set billboardMode(value: number);
  91752. private _preserveParentRotationForBillboard;
  91753. /**
  91754. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  91755. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  91756. */
  91757. get preserveParentRotationForBillboard(): boolean;
  91758. set preserveParentRotationForBillboard(value: boolean);
  91759. /**
  91760. * 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
  91761. */
  91762. scalingDeterminant: number;
  91763. private _infiniteDistance;
  91764. /**
  91765. * Gets or sets the distance of the object to max, often used by skybox
  91766. */
  91767. get infiniteDistance(): boolean;
  91768. set infiniteDistance(value: boolean);
  91769. /**
  91770. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  91771. * By default the system will update normals to compensate
  91772. */
  91773. ignoreNonUniformScaling: boolean;
  91774. /**
  91775. * 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
  91776. */
  91777. reIntegrateRotationIntoRotationQuaternion: boolean;
  91778. /** @hidden */
  91779. _poseMatrix: Nullable<Matrix>;
  91780. /** @hidden */
  91781. _localMatrix: Matrix;
  91782. private _usePivotMatrix;
  91783. private _absolutePosition;
  91784. private _absoluteScaling;
  91785. private _absoluteRotationQuaternion;
  91786. private _pivotMatrix;
  91787. private _pivotMatrixInverse;
  91788. protected _postMultiplyPivotMatrix: boolean;
  91789. protected _isWorldMatrixFrozen: boolean;
  91790. /** @hidden */
  91791. _indexInSceneTransformNodesArray: number;
  91792. /**
  91793. * An event triggered after the world matrix is updated
  91794. */
  91795. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  91796. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  91797. /**
  91798. * Gets a string identifying the name of the class
  91799. * @returns "TransformNode" string
  91800. */
  91801. getClassName(): string;
  91802. /**
  91803. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  91804. */
  91805. get position(): Vector3;
  91806. set position(newPosition: Vector3);
  91807. /**
  91808. * 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)).
  91809. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  91810. */
  91811. get rotation(): Vector3;
  91812. set rotation(newRotation: Vector3);
  91813. /**
  91814. * 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)).
  91815. */
  91816. get scaling(): Vector3;
  91817. set scaling(newScaling: Vector3);
  91818. /**
  91819. * 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).
  91820. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  91821. */
  91822. get rotationQuaternion(): Nullable<Quaternion>;
  91823. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  91824. /**
  91825. * The forward direction of that transform in world space.
  91826. */
  91827. get forward(): Vector3;
  91828. /**
  91829. * The up direction of that transform in world space.
  91830. */
  91831. get up(): Vector3;
  91832. /**
  91833. * The right direction of that transform in world space.
  91834. */
  91835. get right(): Vector3;
  91836. /**
  91837. * Copies the parameter passed Matrix into the mesh Pose matrix.
  91838. * @param matrix the matrix to copy the pose from
  91839. * @returns this TransformNode.
  91840. */
  91841. updatePoseMatrix(matrix: Matrix): TransformNode;
  91842. /**
  91843. * Returns the mesh Pose matrix.
  91844. * @returns the pose matrix
  91845. */
  91846. getPoseMatrix(): Matrix;
  91847. /** @hidden */
  91848. _isSynchronized(): boolean;
  91849. /** @hidden */
  91850. _initCache(): void;
  91851. /**
  91852. * Flag the transform node as dirty (Forcing it to update everything)
  91853. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91854. * @returns this transform node
  91855. */
  91856. markAsDirty(property: string): TransformNode;
  91857. /**
  91858. * Returns the current mesh absolute position.
  91859. * Returns a Vector3.
  91860. */
  91861. get absolutePosition(): Vector3;
  91862. /**
  91863. * Returns the current mesh absolute scaling.
  91864. * Returns a Vector3.
  91865. */
  91866. get absoluteScaling(): Vector3;
  91867. /**
  91868. * Returns the current mesh absolute rotation.
  91869. * Returns a Quaternion.
  91870. */
  91871. get absoluteRotationQuaternion(): Quaternion;
  91872. /**
  91873. * Sets a new matrix to apply before all other transformation
  91874. * @param matrix defines the transform matrix
  91875. * @returns the current TransformNode
  91876. */
  91877. setPreTransformMatrix(matrix: Matrix): TransformNode;
  91878. /**
  91879. * Sets a new pivot matrix to the current node
  91880. * @param matrix defines the new pivot matrix to use
  91881. * @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
  91882. * @returns the current TransformNode
  91883. */
  91884. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  91885. /**
  91886. * Returns the mesh pivot matrix.
  91887. * Default : Identity.
  91888. * @returns the matrix
  91889. */
  91890. getPivotMatrix(): Matrix;
  91891. /**
  91892. * Instantiate (when possible) or clone that node with its hierarchy
  91893. * @param newParent defines the new parent to use for the instance (or clone)
  91894. * @param options defines options to configure how copy is done
  91895. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  91896. * @returns an instance (or a clone) of the current node with its hiearchy
  91897. */
  91898. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91899. doNotInstantiate: boolean;
  91900. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91901. /**
  91902. * Prevents the World matrix to be computed any longer
  91903. * @param newWorldMatrix defines an optional matrix to use as world matrix
  91904. * @returns the TransformNode.
  91905. */
  91906. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  91907. /**
  91908. * Allows back the World matrix computation.
  91909. * @returns the TransformNode.
  91910. */
  91911. unfreezeWorldMatrix(): this;
  91912. /**
  91913. * True if the World matrix has been frozen.
  91914. */
  91915. get isWorldMatrixFrozen(): boolean;
  91916. /**
  91917. * Retuns the mesh absolute position in the World.
  91918. * @returns a Vector3.
  91919. */
  91920. getAbsolutePosition(): Vector3;
  91921. /**
  91922. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  91923. * @param absolutePosition the absolute position to set
  91924. * @returns the TransformNode.
  91925. */
  91926. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91927. /**
  91928. * Sets the mesh position in its local space.
  91929. * @param vector3 the position to set in localspace
  91930. * @returns the TransformNode.
  91931. */
  91932. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  91933. /**
  91934. * Returns the mesh position in the local space from the current World matrix values.
  91935. * @returns a new Vector3.
  91936. */
  91937. getPositionExpressedInLocalSpace(): Vector3;
  91938. /**
  91939. * Translates the mesh along the passed Vector3 in its local space.
  91940. * @param vector3 the distance to translate in localspace
  91941. * @returns the TransformNode.
  91942. */
  91943. locallyTranslate(vector3: Vector3): TransformNode;
  91944. private static _lookAtVectorCache;
  91945. /**
  91946. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  91947. * @param targetPoint the position (must be in same space as current mesh) to look at
  91948. * @param yawCor optional yaw (y-axis) correction in radians
  91949. * @param pitchCor optional pitch (x-axis) correction in radians
  91950. * @param rollCor optional roll (z-axis) correction in radians
  91951. * @param space the choosen space of the target
  91952. * @returns the TransformNode.
  91953. */
  91954. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  91955. /**
  91956. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91957. * This Vector3 is expressed in the World space.
  91958. * @param localAxis axis to rotate
  91959. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91960. */
  91961. getDirection(localAxis: Vector3): Vector3;
  91962. /**
  91963. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  91964. * localAxis is expressed in the mesh local space.
  91965. * result is computed in the Wordl space from the mesh World matrix.
  91966. * @param localAxis axis to rotate
  91967. * @param result the resulting transformnode
  91968. * @returns this TransformNode.
  91969. */
  91970. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  91971. /**
  91972. * Sets this transform node rotation to the given local axis.
  91973. * @param localAxis the axis in local space
  91974. * @param yawCor optional yaw (y-axis) correction in radians
  91975. * @param pitchCor optional pitch (x-axis) correction in radians
  91976. * @param rollCor optional roll (z-axis) correction in radians
  91977. * @returns this TransformNode
  91978. */
  91979. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  91980. /**
  91981. * Sets a new pivot point to the current node
  91982. * @param point defines the new pivot point to use
  91983. * @param space defines if the point is in world or local space (local by default)
  91984. * @returns the current TransformNode
  91985. */
  91986. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  91987. /**
  91988. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  91989. * @returns the pivot point
  91990. */
  91991. getPivotPoint(): Vector3;
  91992. /**
  91993. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  91994. * @param result the vector3 to store the result
  91995. * @returns this TransformNode.
  91996. */
  91997. getPivotPointToRef(result: Vector3): TransformNode;
  91998. /**
  91999. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92000. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92001. */
  92002. getAbsolutePivotPoint(): Vector3;
  92003. /**
  92004. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92005. * @param result vector3 to store the result
  92006. * @returns this TransformNode.
  92007. */
  92008. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92009. /**
  92010. * Defines the passed node as the parent of the current node.
  92011. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92012. * @see https://doc.babylonjs.com/how_to/parenting
  92013. * @param node the node ot set as the parent
  92014. * @returns this TransformNode.
  92015. */
  92016. setParent(node: Nullable<Node>): TransformNode;
  92017. private _nonUniformScaling;
  92018. /**
  92019. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92020. */
  92021. get nonUniformScaling(): boolean;
  92022. /** @hidden */
  92023. _updateNonUniformScalingState(value: boolean): boolean;
  92024. /**
  92025. * Attach the current TransformNode to another TransformNode associated with a bone
  92026. * @param bone Bone affecting the TransformNode
  92027. * @param affectedTransformNode TransformNode associated with the bone
  92028. * @returns this object
  92029. */
  92030. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92031. /**
  92032. * Detach the transform node if its associated with a bone
  92033. * @returns this object
  92034. */
  92035. detachFromBone(): TransformNode;
  92036. private static _rotationAxisCache;
  92037. /**
  92038. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92039. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92040. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92041. * The passed axis is also normalized.
  92042. * @param axis the axis to rotate around
  92043. * @param amount the amount to rotate in radians
  92044. * @param space Space to rotate in (Default: local)
  92045. * @returns the TransformNode.
  92046. */
  92047. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92048. /**
  92049. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92050. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92051. * The passed axis is also normalized. .
  92052. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92053. * @param point the point to rotate around
  92054. * @param axis the axis to rotate around
  92055. * @param amount the amount to rotate in radians
  92056. * @returns the TransformNode
  92057. */
  92058. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92059. /**
  92060. * Translates the mesh along the axis vector for the passed distance in the given space.
  92061. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92062. * @param axis the axis to translate in
  92063. * @param distance the distance to translate
  92064. * @param space Space to rotate in (Default: local)
  92065. * @returns the TransformNode.
  92066. */
  92067. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92068. /**
  92069. * Adds a rotation step to the mesh current rotation.
  92070. * x, y, z are Euler angles expressed in radians.
  92071. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92072. * This means this rotation is made in the mesh local space only.
  92073. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92074. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92075. * ```javascript
  92076. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92077. * ```
  92078. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92079. * 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.
  92080. * @param x Rotation to add
  92081. * @param y Rotation to add
  92082. * @param z Rotation to add
  92083. * @returns the TransformNode.
  92084. */
  92085. addRotation(x: number, y: number, z: number): TransformNode;
  92086. /**
  92087. * @hidden
  92088. */
  92089. protected _getEffectiveParent(): Nullable<Node>;
  92090. /**
  92091. * Computes the world matrix of the node
  92092. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92093. * @returns the world matrix
  92094. */
  92095. computeWorldMatrix(force?: boolean): Matrix;
  92096. /**
  92097. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92098. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92099. */
  92100. resetLocalMatrix(independentOfChildren?: boolean): void;
  92101. protected _afterComputeWorldMatrix(): void;
  92102. /**
  92103. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92104. * @param func callback function to add
  92105. *
  92106. * @returns the TransformNode.
  92107. */
  92108. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92109. /**
  92110. * Removes a registered callback function.
  92111. * @param func callback function to remove
  92112. * @returns the TransformNode.
  92113. */
  92114. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92115. /**
  92116. * Gets the position of the current mesh in camera space
  92117. * @param camera defines the camera to use
  92118. * @returns a position
  92119. */
  92120. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92121. /**
  92122. * Returns the distance from the mesh to the active camera
  92123. * @param camera defines the camera to use
  92124. * @returns the distance
  92125. */
  92126. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92127. /**
  92128. * Clone the current transform node
  92129. * @param name Name of the new clone
  92130. * @param newParent New parent for the clone
  92131. * @param doNotCloneChildren Do not clone children hierarchy
  92132. * @returns the new transform node
  92133. */
  92134. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92135. /**
  92136. * Serializes the objects information.
  92137. * @param currentSerializationObject defines the object to serialize in
  92138. * @returns the serialized object
  92139. */
  92140. serialize(currentSerializationObject?: any): any;
  92141. /**
  92142. * Returns a new TransformNode object parsed from the source provided.
  92143. * @param parsedTransformNode is the source.
  92144. * @param scene the scne the object belongs to
  92145. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92146. * @returns a new TransformNode object parsed from the source provided.
  92147. */
  92148. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92149. /**
  92150. * Get all child-transformNodes of this node
  92151. * @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
  92152. * @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
  92153. * @returns an array of TransformNode
  92154. */
  92155. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92156. /**
  92157. * Releases resources associated with this transform node.
  92158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92160. */
  92161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92162. /**
  92163. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92164. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92165. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92166. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92167. * @returns the current mesh
  92168. */
  92169. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92170. private _syncAbsoluteScalingAndRotation;
  92171. }
  92172. }
  92173. declare module BABYLON {
  92174. /**
  92175. * Class used to override all child animations of a given target
  92176. */
  92177. export class AnimationPropertiesOverride {
  92178. /**
  92179. * Gets or sets a value indicating if animation blending must be used
  92180. */
  92181. enableBlending: boolean;
  92182. /**
  92183. * Gets or sets the blending speed to use when enableBlending is true
  92184. */
  92185. blendingSpeed: number;
  92186. /**
  92187. * Gets or sets the default loop mode to use
  92188. */
  92189. loopMode: number;
  92190. }
  92191. }
  92192. declare module BABYLON {
  92193. /**
  92194. * Class used to store bone information
  92195. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92196. */
  92197. export class Bone extends Node {
  92198. /**
  92199. * defines the bone name
  92200. */
  92201. name: string;
  92202. private static _tmpVecs;
  92203. private static _tmpQuat;
  92204. private static _tmpMats;
  92205. /**
  92206. * Gets the list of child bones
  92207. */
  92208. children: Bone[];
  92209. /** Gets the animations associated with this bone */
  92210. animations: Animation[];
  92211. /**
  92212. * Gets or sets bone length
  92213. */
  92214. length: number;
  92215. /**
  92216. * @hidden Internal only
  92217. * Set this value to map this bone to a different index in the transform matrices
  92218. * Set this value to -1 to exclude the bone from the transform matrices
  92219. */
  92220. _index: Nullable<number>;
  92221. private _skeleton;
  92222. private _localMatrix;
  92223. private _restPose;
  92224. private _baseMatrix;
  92225. private _absoluteTransform;
  92226. private _invertedAbsoluteTransform;
  92227. private _parent;
  92228. private _scalingDeterminant;
  92229. private _worldTransform;
  92230. private _localScaling;
  92231. private _localRotation;
  92232. private _localPosition;
  92233. private _needToDecompose;
  92234. private _needToCompose;
  92235. /** @hidden */
  92236. _linkedTransformNode: Nullable<TransformNode>;
  92237. /** @hidden */
  92238. _waitingTransformNodeId: Nullable<string>;
  92239. /** @hidden */
  92240. get _matrix(): Matrix;
  92241. /** @hidden */
  92242. set _matrix(value: Matrix);
  92243. /**
  92244. * Create a new bone
  92245. * @param name defines the bone name
  92246. * @param skeleton defines the parent skeleton
  92247. * @param parentBone defines the parent (can be null if the bone is the root)
  92248. * @param localMatrix defines the local matrix
  92249. * @param restPose defines the rest pose matrix
  92250. * @param baseMatrix defines the base matrix
  92251. * @param index defines index of the bone in the hiearchy
  92252. */
  92253. constructor(
  92254. /**
  92255. * defines the bone name
  92256. */
  92257. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92258. /**
  92259. * Gets the current object class name.
  92260. * @return the class name
  92261. */
  92262. getClassName(): string;
  92263. /**
  92264. * Gets the parent skeleton
  92265. * @returns a skeleton
  92266. */
  92267. getSkeleton(): Skeleton;
  92268. /**
  92269. * Gets parent bone
  92270. * @returns a bone or null if the bone is the root of the bone hierarchy
  92271. */
  92272. getParent(): Nullable<Bone>;
  92273. /**
  92274. * Returns an array containing the root bones
  92275. * @returns an array containing the root bones
  92276. */
  92277. getChildren(): Array<Bone>;
  92278. /**
  92279. * Gets the node index in matrix array generated for rendering
  92280. * @returns the node index
  92281. */
  92282. getIndex(): number;
  92283. /**
  92284. * Sets the parent bone
  92285. * @param parent defines the parent (can be null if the bone is the root)
  92286. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92287. */
  92288. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92289. /**
  92290. * Gets the local matrix
  92291. * @returns a matrix
  92292. */
  92293. getLocalMatrix(): Matrix;
  92294. /**
  92295. * Gets the base matrix (initial matrix which remains unchanged)
  92296. * @returns a matrix
  92297. */
  92298. getBaseMatrix(): Matrix;
  92299. /**
  92300. * Gets the rest pose matrix
  92301. * @returns a matrix
  92302. */
  92303. getRestPose(): Matrix;
  92304. /**
  92305. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92306. */
  92307. getWorldMatrix(): Matrix;
  92308. /**
  92309. * Sets the local matrix to rest pose matrix
  92310. */
  92311. returnToRest(): void;
  92312. /**
  92313. * Gets the inverse of the absolute transform matrix.
  92314. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92315. * @returns a matrix
  92316. */
  92317. getInvertedAbsoluteTransform(): Matrix;
  92318. /**
  92319. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92320. * @returns a matrix
  92321. */
  92322. getAbsoluteTransform(): Matrix;
  92323. /**
  92324. * Links with the given transform node.
  92325. * The local matrix of this bone is copied from the transform node every frame.
  92326. * @param transformNode defines the transform node to link to
  92327. */
  92328. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92329. /**
  92330. * Gets the node used to drive the bone's transformation
  92331. * @returns a transform node or null
  92332. */
  92333. getTransformNode(): Nullable<TransformNode>;
  92334. /** Gets or sets current position (in local space) */
  92335. get position(): Vector3;
  92336. set position(newPosition: Vector3);
  92337. /** Gets or sets current rotation (in local space) */
  92338. get rotation(): Vector3;
  92339. set rotation(newRotation: Vector3);
  92340. /** Gets or sets current rotation quaternion (in local space) */
  92341. get rotationQuaternion(): Quaternion;
  92342. set rotationQuaternion(newRotation: Quaternion);
  92343. /** Gets or sets current scaling (in local space) */
  92344. get scaling(): Vector3;
  92345. set scaling(newScaling: Vector3);
  92346. /**
  92347. * Gets the animation properties override
  92348. */
  92349. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92350. private _decompose;
  92351. private _compose;
  92352. /**
  92353. * Update the base and local matrices
  92354. * @param matrix defines the new base or local matrix
  92355. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92356. * @param updateLocalMatrix defines if the local matrix should be updated
  92357. */
  92358. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92359. /** @hidden */
  92360. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92361. /**
  92362. * Flag the bone as dirty (Forcing it to update everything)
  92363. */
  92364. markAsDirty(): void;
  92365. /** @hidden */
  92366. _markAsDirtyAndCompose(): void;
  92367. private _markAsDirtyAndDecompose;
  92368. /**
  92369. * Translate the bone in local or world space
  92370. * @param vec The amount to translate the bone
  92371. * @param space The space that the translation is in
  92372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92373. */
  92374. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92375. /**
  92376. * Set the postion of the bone in local or world space
  92377. * @param position The position to set the bone
  92378. * @param space The space that the position is in
  92379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92380. */
  92381. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92382. /**
  92383. * Set the absolute position of the bone (world space)
  92384. * @param position The position to set the bone
  92385. * @param mesh The mesh that this bone is attached to
  92386. */
  92387. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92388. /**
  92389. * Scale the bone on the x, y and z axes (in local space)
  92390. * @param x The amount to scale the bone on the x axis
  92391. * @param y The amount to scale the bone on the y axis
  92392. * @param z The amount to scale the bone on the z axis
  92393. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92394. */
  92395. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92396. /**
  92397. * Set the bone scaling in local space
  92398. * @param scale defines the scaling vector
  92399. */
  92400. setScale(scale: Vector3): void;
  92401. /**
  92402. * Gets the current scaling in local space
  92403. * @returns the current scaling vector
  92404. */
  92405. getScale(): Vector3;
  92406. /**
  92407. * Gets the current scaling in local space and stores it in a target vector
  92408. * @param result defines the target vector
  92409. */
  92410. getScaleToRef(result: Vector3): void;
  92411. /**
  92412. * Set the yaw, pitch, and roll of the bone in local or world space
  92413. * @param yaw The rotation of the bone on the y axis
  92414. * @param pitch The rotation of the bone on the x axis
  92415. * @param roll The rotation of the bone on the z axis
  92416. * @param space The space that the axes of rotation are in
  92417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92418. */
  92419. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92420. /**
  92421. * Add a rotation to the bone on an axis in local or world space
  92422. * @param axis The axis to rotate the bone on
  92423. * @param amount The amount to rotate the bone
  92424. * @param space The space that the axis is in
  92425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92426. */
  92427. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92428. /**
  92429. * Set the rotation of the bone to a particular axis angle in local or world space
  92430. * @param axis The axis to rotate the bone on
  92431. * @param angle The angle that the bone should be rotated to
  92432. * @param space The space that the axis is in
  92433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92434. */
  92435. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92436. /**
  92437. * Set the euler rotation of the bone in local of world space
  92438. * @param rotation The euler rotation that the bone should be set to
  92439. * @param space The space that the rotation is in
  92440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92441. */
  92442. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92443. /**
  92444. * Set the quaternion rotation of the bone in local of world space
  92445. * @param quat The quaternion rotation that the bone should be set to
  92446. * @param space The space that the rotation is in
  92447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92448. */
  92449. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92450. /**
  92451. * Set the rotation matrix of the bone in local of world space
  92452. * @param rotMat The rotation matrix that the bone should be set to
  92453. * @param space The space that the rotation is in
  92454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92455. */
  92456. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92457. private _rotateWithMatrix;
  92458. private _getNegativeRotationToRef;
  92459. /**
  92460. * Get the position of the bone in local or world space
  92461. * @param space The space that the returned position is in
  92462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92463. * @returns The position of the bone
  92464. */
  92465. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92466. /**
  92467. * Copy the position of the bone to a vector3 in local or world space
  92468. * @param space The space that the returned position is in
  92469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92470. * @param result The vector3 to copy the position to
  92471. */
  92472. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92473. /**
  92474. * Get the absolute position of the bone (world space)
  92475. * @param mesh The mesh that this bone is attached to
  92476. * @returns The absolute position of the bone
  92477. */
  92478. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92479. /**
  92480. * Copy the absolute position of the bone (world space) to the result param
  92481. * @param mesh The mesh that this bone is attached to
  92482. * @param result The vector3 to copy the absolute position to
  92483. */
  92484. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92485. /**
  92486. * Compute the absolute transforms of this bone and its children
  92487. */
  92488. computeAbsoluteTransforms(): void;
  92489. /**
  92490. * Get the world direction from an axis that is in the local space of the bone
  92491. * @param localAxis The local direction that is used to compute the world direction
  92492. * @param mesh The mesh that this bone is attached to
  92493. * @returns The world direction
  92494. */
  92495. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92496. /**
  92497. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92498. * @param localAxis The local direction that is used to compute the world direction
  92499. * @param mesh The mesh that this bone is attached to
  92500. * @param result The vector3 that the world direction will be copied to
  92501. */
  92502. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92503. /**
  92504. * Get the euler rotation of the bone in local or world space
  92505. * @param space The space that the rotation should be in
  92506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92507. * @returns The euler rotation
  92508. */
  92509. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92510. /**
  92511. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92512. * @param space The space that the rotation should be in
  92513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92514. * @param result The vector3 that the rotation should be copied to
  92515. */
  92516. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92517. /**
  92518. * Get the quaternion rotation of the bone in either local or world space
  92519. * @param space The space that the rotation should be in
  92520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92521. * @returns The quaternion rotation
  92522. */
  92523. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92524. /**
  92525. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92526. * @param space The space that the rotation should be in
  92527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92528. * @param result The quaternion that the rotation should be copied to
  92529. */
  92530. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92531. /**
  92532. * Get the rotation matrix of the bone in local or world space
  92533. * @param space The space that the rotation should be in
  92534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92535. * @returns The rotation matrix
  92536. */
  92537. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92538. /**
  92539. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92540. * @param space The space that the rotation should be in
  92541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92542. * @param result The quaternion that the rotation should be copied to
  92543. */
  92544. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92545. /**
  92546. * Get the world position of a point that is in the local space of the bone
  92547. * @param position The local position
  92548. * @param mesh The mesh that this bone is attached to
  92549. * @returns The world position
  92550. */
  92551. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92552. /**
  92553. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92554. * @param position The local position
  92555. * @param mesh The mesh that this bone is attached to
  92556. * @param result The vector3 that the world position should be copied to
  92557. */
  92558. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92559. /**
  92560. * Get the local position of a point that is in world space
  92561. * @param position The world position
  92562. * @param mesh The mesh that this bone is attached to
  92563. * @returns The local position
  92564. */
  92565. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92566. /**
  92567. * Get the local position of a point that is in world space and copy it to the result param
  92568. * @param position The world position
  92569. * @param mesh The mesh that this bone is attached to
  92570. * @param result The vector3 that the local position should be copied to
  92571. */
  92572. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92573. }
  92574. }
  92575. declare module BABYLON {
  92576. /**
  92577. * Defines a runtime animation
  92578. */
  92579. export class RuntimeAnimation {
  92580. private _events;
  92581. /**
  92582. * The current frame of the runtime animation
  92583. */
  92584. private _currentFrame;
  92585. /**
  92586. * The animation used by the runtime animation
  92587. */
  92588. private _animation;
  92589. /**
  92590. * The target of the runtime animation
  92591. */
  92592. private _target;
  92593. /**
  92594. * The initiating animatable
  92595. */
  92596. private _host;
  92597. /**
  92598. * The original value of the runtime animation
  92599. */
  92600. private _originalValue;
  92601. /**
  92602. * The original blend value of the runtime animation
  92603. */
  92604. private _originalBlendValue;
  92605. /**
  92606. * The offsets cache of the runtime animation
  92607. */
  92608. private _offsetsCache;
  92609. /**
  92610. * The high limits cache of the runtime animation
  92611. */
  92612. private _highLimitsCache;
  92613. /**
  92614. * Specifies if the runtime animation has been stopped
  92615. */
  92616. private _stopped;
  92617. /**
  92618. * The blending factor of the runtime animation
  92619. */
  92620. private _blendingFactor;
  92621. /**
  92622. * The BabylonJS scene
  92623. */
  92624. private _scene;
  92625. /**
  92626. * The current value of the runtime animation
  92627. */
  92628. private _currentValue;
  92629. /** @hidden */
  92630. _animationState: _IAnimationState;
  92631. /**
  92632. * The active target of the runtime animation
  92633. */
  92634. private _activeTargets;
  92635. private _currentActiveTarget;
  92636. private _directTarget;
  92637. /**
  92638. * The target path of the runtime animation
  92639. */
  92640. private _targetPath;
  92641. /**
  92642. * The weight of the runtime animation
  92643. */
  92644. private _weight;
  92645. /**
  92646. * The ratio offset of the runtime animation
  92647. */
  92648. private _ratioOffset;
  92649. /**
  92650. * The previous delay of the runtime animation
  92651. */
  92652. private _previousDelay;
  92653. /**
  92654. * The previous ratio of the runtime animation
  92655. */
  92656. private _previousRatio;
  92657. private _enableBlending;
  92658. private _keys;
  92659. private _minFrame;
  92660. private _maxFrame;
  92661. private _minValue;
  92662. private _maxValue;
  92663. private _targetIsArray;
  92664. /**
  92665. * Gets the current frame of the runtime animation
  92666. */
  92667. get currentFrame(): number;
  92668. /**
  92669. * Gets the weight of the runtime animation
  92670. */
  92671. get weight(): number;
  92672. /**
  92673. * Gets the current value of the runtime animation
  92674. */
  92675. get currentValue(): any;
  92676. /**
  92677. * Gets the target path of the runtime animation
  92678. */
  92679. get targetPath(): string;
  92680. /**
  92681. * Gets the actual target of the runtime animation
  92682. */
  92683. get target(): any;
  92684. /**
  92685. * Gets the additive state of the runtime animation
  92686. */
  92687. get isAdditive(): boolean;
  92688. /** @hidden */
  92689. _onLoop: () => void;
  92690. /**
  92691. * Create a new RuntimeAnimation object
  92692. * @param target defines the target of the animation
  92693. * @param animation defines the source animation object
  92694. * @param scene defines the hosting scene
  92695. * @param host defines the initiating Animatable
  92696. */
  92697. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  92698. private _preparePath;
  92699. /**
  92700. * Gets the animation from the runtime animation
  92701. */
  92702. get animation(): Animation;
  92703. /**
  92704. * Resets the runtime animation to the beginning
  92705. * @param restoreOriginal defines whether to restore the target property to the original value
  92706. */
  92707. reset(restoreOriginal?: boolean): void;
  92708. /**
  92709. * Specifies if the runtime animation is stopped
  92710. * @returns Boolean specifying if the runtime animation is stopped
  92711. */
  92712. isStopped(): boolean;
  92713. /**
  92714. * Disposes of the runtime animation
  92715. */
  92716. dispose(): void;
  92717. /**
  92718. * Apply the interpolated value to the target
  92719. * @param currentValue defines the value computed by the animation
  92720. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  92721. */
  92722. setValue(currentValue: any, weight: number): void;
  92723. private _getOriginalValues;
  92724. private _setValue;
  92725. /**
  92726. * Gets the loop pmode of the runtime animation
  92727. * @returns Loop Mode
  92728. */
  92729. private _getCorrectLoopMode;
  92730. /**
  92731. * Move the current animation to a given frame
  92732. * @param frame defines the frame to move to
  92733. */
  92734. goToFrame(frame: number): void;
  92735. /**
  92736. * @hidden Internal use only
  92737. */
  92738. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  92739. /**
  92740. * Execute the current animation
  92741. * @param delay defines the delay to add to the current frame
  92742. * @param from defines the lower bound of the animation range
  92743. * @param to defines the upper bound of the animation range
  92744. * @param loop defines if the current animation must loop
  92745. * @param speedRatio defines the current speed ratio
  92746. * @param weight defines the weight of the animation (default is -1 so no weight)
  92747. * @param onLoop optional callback called when animation loops
  92748. * @returns a boolean indicating if the animation is running
  92749. */
  92750. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  92751. }
  92752. }
  92753. declare module BABYLON {
  92754. /**
  92755. * Class used to store an actual running animation
  92756. */
  92757. export class Animatable {
  92758. /** defines the target object */
  92759. target: any;
  92760. /** defines the starting frame number (default is 0) */
  92761. fromFrame: number;
  92762. /** defines the ending frame number (default is 100) */
  92763. toFrame: number;
  92764. /** defines if the animation must loop (default is false) */
  92765. loopAnimation: boolean;
  92766. /** defines a callback to call when animation ends if it is not looping */
  92767. onAnimationEnd?: (() => void) | null | undefined;
  92768. /** defines a callback to call when animation loops */
  92769. onAnimationLoop?: (() => void) | null | undefined;
  92770. /** defines whether the animation should be evaluated additively */
  92771. isAdditive: boolean;
  92772. private _localDelayOffset;
  92773. private _pausedDelay;
  92774. private _runtimeAnimations;
  92775. private _paused;
  92776. private _scene;
  92777. private _speedRatio;
  92778. private _weight;
  92779. private _syncRoot;
  92780. /**
  92781. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  92782. * This will only apply for non looping animation (default is true)
  92783. */
  92784. disposeOnEnd: boolean;
  92785. /**
  92786. * Gets a boolean indicating if the animation has started
  92787. */
  92788. animationStarted: boolean;
  92789. /**
  92790. * Observer raised when the animation ends
  92791. */
  92792. onAnimationEndObservable: Observable<Animatable>;
  92793. /**
  92794. * Observer raised when the animation loops
  92795. */
  92796. onAnimationLoopObservable: Observable<Animatable>;
  92797. /**
  92798. * Gets the root Animatable used to synchronize and normalize animations
  92799. */
  92800. get syncRoot(): Nullable<Animatable>;
  92801. /**
  92802. * Gets the current frame of the first RuntimeAnimation
  92803. * Used to synchronize Animatables
  92804. */
  92805. get masterFrame(): number;
  92806. /**
  92807. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  92808. */
  92809. get weight(): number;
  92810. set weight(value: number);
  92811. /**
  92812. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  92813. */
  92814. get speedRatio(): number;
  92815. set speedRatio(value: number);
  92816. /**
  92817. * Creates a new Animatable
  92818. * @param scene defines the hosting scene
  92819. * @param target defines the target object
  92820. * @param fromFrame defines the starting frame number (default is 0)
  92821. * @param toFrame defines the ending frame number (default is 100)
  92822. * @param loopAnimation defines if the animation must loop (default is false)
  92823. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  92824. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  92825. * @param animations defines a group of animation to add to the new Animatable
  92826. * @param onAnimationLoop defines a callback to call when animation loops
  92827. * @param isAdditive defines whether the animation should be evaluated additively
  92828. */
  92829. constructor(scene: Scene,
  92830. /** defines the target object */
  92831. target: any,
  92832. /** defines the starting frame number (default is 0) */
  92833. fromFrame?: number,
  92834. /** defines the ending frame number (default is 100) */
  92835. toFrame?: number,
  92836. /** defines if the animation must loop (default is false) */
  92837. loopAnimation?: boolean, speedRatio?: number,
  92838. /** defines a callback to call when animation ends if it is not looping */
  92839. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  92840. /** defines a callback to call when animation loops */
  92841. onAnimationLoop?: (() => void) | null | undefined,
  92842. /** defines whether the animation should be evaluated additively */
  92843. isAdditive?: boolean);
  92844. /**
  92845. * Synchronize and normalize current Animatable with a source Animatable
  92846. * This is useful when using animation weights and when animations are not of the same length
  92847. * @param root defines the root Animatable to synchronize with
  92848. * @returns the current Animatable
  92849. */
  92850. syncWith(root: Animatable): Animatable;
  92851. /**
  92852. * Gets the list of runtime animations
  92853. * @returns an array of RuntimeAnimation
  92854. */
  92855. getAnimations(): RuntimeAnimation[];
  92856. /**
  92857. * Adds more animations to the current animatable
  92858. * @param target defines the target of the animations
  92859. * @param animations defines the new animations to add
  92860. */
  92861. appendAnimations(target: any, animations: Animation[]): void;
  92862. /**
  92863. * Gets the source animation for a specific property
  92864. * @param property defines the propertyu to look for
  92865. * @returns null or the source animation for the given property
  92866. */
  92867. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  92868. /**
  92869. * Gets the runtime animation for a specific property
  92870. * @param property defines the propertyu to look for
  92871. * @returns null or the runtime animation for the given property
  92872. */
  92873. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  92874. /**
  92875. * Resets the animatable to its original state
  92876. */
  92877. reset(): void;
  92878. /**
  92879. * Allows the animatable to blend with current running animations
  92880. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92881. * @param blendingSpeed defines the blending speed to use
  92882. */
  92883. enableBlending(blendingSpeed: number): void;
  92884. /**
  92885. * Disable animation blending
  92886. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92887. */
  92888. disableBlending(): void;
  92889. /**
  92890. * Jump directly to a given frame
  92891. * @param frame defines the frame to jump to
  92892. */
  92893. goToFrame(frame: number): void;
  92894. /**
  92895. * Pause the animation
  92896. */
  92897. pause(): void;
  92898. /**
  92899. * Restart the animation
  92900. */
  92901. restart(): void;
  92902. private _raiseOnAnimationEnd;
  92903. /**
  92904. * Stop and delete the current animation
  92905. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  92906. * @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)
  92907. */
  92908. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  92909. /**
  92910. * Wait asynchronously for the animation to end
  92911. * @returns a promise which will be fullfilled when the animation ends
  92912. */
  92913. waitAsync(): Promise<Animatable>;
  92914. /** @hidden */
  92915. _animate(delay: number): boolean;
  92916. }
  92917. interface Scene {
  92918. /** @hidden */
  92919. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  92920. /** @hidden */
  92921. _processLateAnimationBindingsForMatrices(holder: {
  92922. totalWeight: number;
  92923. totalAdditiveWeight: number;
  92924. animations: RuntimeAnimation[];
  92925. additiveAnimations: RuntimeAnimation[];
  92926. originalValue: Matrix;
  92927. }): any;
  92928. /** @hidden */
  92929. _processLateAnimationBindingsForQuaternions(holder: {
  92930. totalWeight: number;
  92931. totalAdditiveWeight: number;
  92932. animations: RuntimeAnimation[];
  92933. additiveAnimations: RuntimeAnimation[];
  92934. originalValue: Quaternion;
  92935. }, refQuaternion: Quaternion): Quaternion;
  92936. /** @hidden */
  92937. _processLateAnimationBindings(): void;
  92938. /**
  92939. * Will start the animation sequence of a given target
  92940. * @param target defines the target
  92941. * @param from defines from which frame should animation start
  92942. * @param to defines until which frame should animation run.
  92943. * @param weight defines the weight to apply to the animation (1.0 by default)
  92944. * @param loop defines if the animation loops
  92945. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92946. * @param onAnimationEnd defines the function to be executed when the animation ends
  92947. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92948. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92949. * @param onAnimationLoop defines the callback to call when an animation loops
  92950. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92951. * @returns the animatable object created for this animation
  92952. */
  92953. 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;
  92954. /**
  92955. * Will start the animation sequence of a given target
  92956. * @param target defines the target
  92957. * @param from defines from which frame should animation start
  92958. * @param to defines until which frame should animation run.
  92959. * @param loop defines if the animation loops
  92960. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92961. * @param onAnimationEnd defines the function to be executed when the animation ends
  92962. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92963. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92964. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  92965. * @param onAnimationLoop defines the callback to call when an animation loops
  92966. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92967. * @returns the animatable object created for this animation
  92968. */
  92969. 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;
  92970. /**
  92971. * Will start the animation sequence of a given target and its hierarchy
  92972. * @param target defines the target
  92973. * @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.
  92974. * @param from defines from which frame should animation start
  92975. * @param to defines until which frame should animation run.
  92976. * @param loop defines if the animation loops
  92977. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92978. * @param onAnimationEnd defines the function to be executed when the animation ends
  92979. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92980. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92981. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92982. * @param onAnimationLoop defines the callback to call when an animation loops
  92983. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92984. * @returns the list of created animatables
  92985. */
  92986. 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[];
  92987. /**
  92988. * Begin a new animation on a given node
  92989. * @param target defines the target where the animation will take place
  92990. * @param animations defines the list of animations to start
  92991. * @param from defines the initial value
  92992. * @param to defines the final value
  92993. * @param loop defines if you want animation to loop (off by default)
  92994. * @param speedRatio defines the speed ratio to apply to all animations
  92995. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92996. * @param onAnimationLoop defines the callback to call when an animation loops
  92997. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92998. * @returns the list of created animatables
  92999. */
  93000. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93001. /**
  93002. * Begin a new animation on a given node and its hierarchy
  93003. * @param target defines the root node where the animation will take place
  93004. * @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.
  93005. * @param animations defines the list of animations to start
  93006. * @param from defines the initial value
  93007. * @param to defines the final value
  93008. * @param loop defines if you want animation to loop (off by default)
  93009. * @param speedRatio defines the speed ratio to apply to all animations
  93010. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93011. * @param onAnimationLoop defines the callback to call when an animation loops
  93012. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93013. * @returns the list of animatables created for all nodes
  93014. */
  93015. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93016. /**
  93017. * Gets the animatable associated with a specific target
  93018. * @param target defines the target of the animatable
  93019. * @returns the required animatable if found
  93020. */
  93021. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93022. /**
  93023. * Gets all animatables associated with a given target
  93024. * @param target defines the target to look animatables for
  93025. * @returns an array of Animatables
  93026. */
  93027. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93028. /**
  93029. * Stops and removes all animations that have been applied to the scene
  93030. */
  93031. stopAllAnimations(): void;
  93032. /**
  93033. * Gets the current delta time used by animation engine
  93034. */
  93035. deltaTime: number;
  93036. }
  93037. interface Bone {
  93038. /**
  93039. * Copy an animation range from another bone
  93040. * @param source defines the source bone
  93041. * @param rangeName defines the range name to copy
  93042. * @param frameOffset defines the frame offset
  93043. * @param rescaleAsRequired defines if rescaling must be applied if required
  93044. * @param skelDimensionsRatio defines the scaling ratio
  93045. * @returns true if operation was successful
  93046. */
  93047. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93048. }
  93049. }
  93050. declare module BABYLON {
  93051. /**
  93052. * Class used to handle skinning animations
  93053. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93054. */
  93055. export class Skeleton implements IAnimatable {
  93056. /** defines the skeleton name */
  93057. name: string;
  93058. /** defines the skeleton Id */
  93059. id: string;
  93060. /**
  93061. * Defines the list of child bones
  93062. */
  93063. bones: Bone[];
  93064. /**
  93065. * Defines an estimate of the dimension of the skeleton at rest
  93066. */
  93067. dimensionsAtRest: Vector3;
  93068. /**
  93069. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93070. */
  93071. needInitialSkinMatrix: boolean;
  93072. /**
  93073. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93074. */
  93075. overrideMesh: Nullable<AbstractMesh>;
  93076. /**
  93077. * Gets the list of animations attached to this skeleton
  93078. */
  93079. animations: Array<Animation>;
  93080. private _scene;
  93081. private _isDirty;
  93082. private _transformMatrices;
  93083. private _transformMatrixTexture;
  93084. private _meshesWithPoseMatrix;
  93085. private _animatables;
  93086. private _identity;
  93087. private _synchronizedWithMesh;
  93088. private _ranges;
  93089. private _lastAbsoluteTransformsUpdateId;
  93090. private _canUseTextureForBones;
  93091. private _uniqueId;
  93092. /** @hidden */
  93093. _numBonesWithLinkedTransformNode: number;
  93094. /** @hidden */
  93095. _hasWaitingData: Nullable<boolean>;
  93096. /**
  93097. * Specifies if the skeleton should be serialized
  93098. */
  93099. doNotSerialize: boolean;
  93100. private _useTextureToStoreBoneMatrices;
  93101. /**
  93102. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93103. * Please note that this option is not available if the hardware does not support it
  93104. */
  93105. get useTextureToStoreBoneMatrices(): boolean;
  93106. set useTextureToStoreBoneMatrices(value: boolean);
  93107. private _animationPropertiesOverride;
  93108. /**
  93109. * Gets or sets the animation properties override
  93110. */
  93111. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93112. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93113. /**
  93114. * List of inspectable custom properties (used by the Inspector)
  93115. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93116. */
  93117. inspectableCustomProperties: IInspectable[];
  93118. /**
  93119. * An observable triggered before computing the skeleton's matrices
  93120. */
  93121. onBeforeComputeObservable: Observable<Skeleton>;
  93122. /**
  93123. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93124. */
  93125. get isUsingTextureForMatrices(): boolean;
  93126. /**
  93127. * Gets the unique ID of this skeleton
  93128. */
  93129. get uniqueId(): number;
  93130. /**
  93131. * Creates a new skeleton
  93132. * @param name defines the skeleton name
  93133. * @param id defines the skeleton Id
  93134. * @param scene defines the hosting scene
  93135. */
  93136. constructor(
  93137. /** defines the skeleton name */
  93138. name: string,
  93139. /** defines the skeleton Id */
  93140. id: string, scene: Scene);
  93141. /**
  93142. * Gets the current object class name.
  93143. * @return the class name
  93144. */
  93145. getClassName(): string;
  93146. /**
  93147. * Returns an array containing the root bones
  93148. * @returns an array containing the root bones
  93149. */
  93150. getChildren(): Array<Bone>;
  93151. /**
  93152. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93153. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93154. * @returns a Float32Array containing matrices data
  93155. */
  93156. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93157. /**
  93158. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93159. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93160. * @returns a raw texture containing the data
  93161. */
  93162. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93163. /**
  93164. * Gets the current hosting scene
  93165. * @returns a scene object
  93166. */
  93167. getScene(): Scene;
  93168. /**
  93169. * Gets a string representing the current skeleton data
  93170. * @param fullDetails defines a boolean indicating if we want a verbose version
  93171. * @returns a string representing the current skeleton data
  93172. */
  93173. toString(fullDetails?: boolean): string;
  93174. /**
  93175. * Get bone's index searching by name
  93176. * @param name defines bone's name to search for
  93177. * @return the indice of the bone. Returns -1 if not found
  93178. */
  93179. getBoneIndexByName(name: string): number;
  93180. /**
  93181. * Creater a new animation range
  93182. * @param name defines the name of the range
  93183. * @param from defines the start key
  93184. * @param to defines the end key
  93185. */
  93186. createAnimationRange(name: string, from: number, to: number): void;
  93187. /**
  93188. * Delete a specific animation range
  93189. * @param name defines the name of the range
  93190. * @param deleteFrames defines if frames must be removed as well
  93191. */
  93192. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93193. /**
  93194. * Gets a specific animation range
  93195. * @param name defines the name of the range to look for
  93196. * @returns the requested animation range or null if not found
  93197. */
  93198. getAnimationRange(name: string): Nullable<AnimationRange>;
  93199. /**
  93200. * Gets the list of all animation ranges defined on this skeleton
  93201. * @returns an array
  93202. */
  93203. getAnimationRanges(): Nullable<AnimationRange>[];
  93204. /**
  93205. * Copy animation range from a source skeleton.
  93206. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93207. * @param source defines the source skeleton
  93208. * @param name defines the name of the range to copy
  93209. * @param rescaleAsRequired defines if rescaling must be applied if required
  93210. * @returns true if operation was successful
  93211. */
  93212. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93213. /**
  93214. * Forces the skeleton to go to rest pose
  93215. */
  93216. returnToRest(): void;
  93217. private _getHighestAnimationFrame;
  93218. /**
  93219. * Begin a specific animation range
  93220. * @param name defines the name of the range to start
  93221. * @param loop defines if looping must be turned on (false by default)
  93222. * @param speedRatio defines the speed ratio to apply (1 by default)
  93223. * @param onAnimationEnd defines a callback which will be called when animation will end
  93224. * @returns a new animatable
  93225. */
  93226. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93227. /**
  93228. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93229. * @param skeleton defines the Skeleton containing the animation range to convert
  93230. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93231. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93232. * @returns the original skeleton
  93233. */
  93234. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93235. /** @hidden */
  93236. _markAsDirty(): void;
  93237. /** @hidden */
  93238. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93239. /** @hidden */
  93240. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93241. private _computeTransformMatrices;
  93242. /**
  93243. * Build all resources required to render a skeleton
  93244. */
  93245. prepare(): void;
  93246. /**
  93247. * Gets the list of animatables currently running for this skeleton
  93248. * @returns an array of animatables
  93249. */
  93250. getAnimatables(): IAnimatable[];
  93251. /**
  93252. * Clone the current skeleton
  93253. * @param name defines the name of the new skeleton
  93254. * @param id defines the id of the new skeleton
  93255. * @returns the new skeleton
  93256. */
  93257. clone(name: string, id?: string): Skeleton;
  93258. /**
  93259. * Enable animation blending for this skeleton
  93260. * @param blendingSpeed defines the blending speed to apply
  93261. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93262. */
  93263. enableBlending(blendingSpeed?: number): void;
  93264. /**
  93265. * Releases all resources associated with the current skeleton
  93266. */
  93267. dispose(): void;
  93268. /**
  93269. * Serialize the skeleton in a JSON object
  93270. * @returns a JSON object
  93271. */
  93272. serialize(): any;
  93273. /**
  93274. * Creates a new skeleton from serialized data
  93275. * @param parsedSkeleton defines the serialized data
  93276. * @param scene defines the hosting scene
  93277. * @returns a new skeleton
  93278. */
  93279. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93280. /**
  93281. * Compute all node absolute transforms
  93282. * @param forceUpdate defines if computation must be done even if cache is up to date
  93283. */
  93284. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93285. /**
  93286. * Gets the root pose matrix
  93287. * @returns a matrix
  93288. */
  93289. getPoseMatrix(): Nullable<Matrix>;
  93290. /**
  93291. * Sorts bones per internal index
  93292. */
  93293. sortBones(): void;
  93294. private _sortBones;
  93295. }
  93296. }
  93297. declare module BABYLON {
  93298. /**
  93299. * Creates an instance based on a source mesh.
  93300. */
  93301. export class InstancedMesh extends AbstractMesh {
  93302. private _sourceMesh;
  93303. private _currentLOD;
  93304. /** @hidden */
  93305. _indexInSourceMeshInstanceArray: number;
  93306. constructor(name: string, source: Mesh);
  93307. /**
  93308. * Returns the string "InstancedMesh".
  93309. */
  93310. getClassName(): string;
  93311. /** Gets the list of lights affecting that mesh */
  93312. get lightSources(): Light[];
  93313. _resyncLightSources(): void;
  93314. _resyncLightSource(light: Light): void;
  93315. _removeLightSource(light: Light, dispose: boolean): void;
  93316. /**
  93317. * If the source mesh receives shadows
  93318. */
  93319. get receiveShadows(): boolean;
  93320. /**
  93321. * The material of the source mesh
  93322. */
  93323. get material(): Nullable<Material>;
  93324. /**
  93325. * Visibility of the source mesh
  93326. */
  93327. get visibility(): number;
  93328. /**
  93329. * Skeleton of the source mesh
  93330. */
  93331. get skeleton(): Nullable<Skeleton>;
  93332. /**
  93333. * Rendering ground id of the source mesh
  93334. */
  93335. get renderingGroupId(): number;
  93336. set renderingGroupId(value: number);
  93337. /**
  93338. * Returns the total number of vertices (integer).
  93339. */
  93340. getTotalVertices(): number;
  93341. /**
  93342. * Returns a positive integer : the total number of indices in this mesh geometry.
  93343. * @returns the numner of indices or zero if the mesh has no geometry.
  93344. */
  93345. getTotalIndices(): number;
  93346. /**
  93347. * The source mesh of the instance
  93348. */
  93349. get sourceMesh(): Mesh;
  93350. /**
  93351. * Creates a new InstancedMesh object from the mesh model.
  93352. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93353. * @param name defines the name of the new instance
  93354. * @returns a new InstancedMesh
  93355. */
  93356. createInstance(name: string): InstancedMesh;
  93357. /**
  93358. * Is this node ready to be used/rendered
  93359. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93360. * @return {boolean} is it ready
  93361. */
  93362. isReady(completeCheck?: boolean): boolean;
  93363. /**
  93364. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93365. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93366. * @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.
  93367. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93368. */
  93369. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93370. /**
  93371. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93372. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93373. * The `data` are either a numeric array either a Float32Array.
  93374. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93375. * 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).
  93376. * Note that a new underlying VertexBuffer object is created each call.
  93377. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93378. *
  93379. * Possible `kind` values :
  93380. * - VertexBuffer.PositionKind
  93381. * - VertexBuffer.UVKind
  93382. * - VertexBuffer.UV2Kind
  93383. * - VertexBuffer.UV3Kind
  93384. * - VertexBuffer.UV4Kind
  93385. * - VertexBuffer.UV5Kind
  93386. * - VertexBuffer.UV6Kind
  93387. * - VertexBuffer.ColorKind
  93388. * - VertexBuffer.MatricesIndicesKind
  93389. * - VertexBuffer.MatricesIndicesExtraKind
  93390. * - VertexBuffer.MatricesWeightsKind
  93391. * - VertexBuffer.MatricesWeightsExtraKind
  93392. *
  93393. * Returns the Mesh.
  93394. */
  93395. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93396. /**
  93397. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93398. * If the mesh has no geometry, it is simply returned as it is.
  93399. * The `data` are either a numeric array either a Float32Array.
  93400. * No new underlying VertexBuffer object is created.
  93401. * 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.
  93402. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93403. *
  93404. * Possible `kind` values :
  93405. * - VertexBuffer.PositionKind
  93406. * - VertexBuffer.UVKind
  93407. * - VertexBuffer.UV2Kind
  93408. * - VertexBuffer.UV3Kind
  93409. * - VertexBuffer.UV4Kind
  93410. * - VertexBuffer.UV5Kind
  93411. * - VertexBuffer.UV6Kind
  93412. * - VertexBuffer.ColorKind
  93413. * - VertexBuffer.MatricesIndicesKind
  93414. * - VertexBuffer.MatricesIndicesExtraKind
  93415. * - VertexBuffer.MatricesWeightsKind
  93416. * - VertexBuffer.MatricesWeightsExtraKind
  93417. *
  93418. * Returns the Mesh.
  93419. */
  93420. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93421. /**
  93422. * Sets the mesh indices.
  93423. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93424. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93425. * This method creates a new index buffer each call.
  93426. * Returns the Mesh.
  93427. */
  93428. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93429. /**
  93430. * Boolean : True if the mesh owns the requested kind of data.
  93431. */
  93432. isVerticesDataPresent(kind: string): boolean;
  93433. /**
  93434. * Returns an array of indices (IndicesArray).
  93435. */
  93436. getIndices(): Nullable<IndicesArray>;
  93437. get _positions(): Nullable<Vector3[]>;
  93438. /**
  93439. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93440. * This means the mesh underlying bounding box and sphere are recomputed.
  93441. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93442. * @returns the current mesh
  93443. */
  93444. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93445. /** @hidden */
  93446. _preActivate(): InstancedMesh;
  93447. /** @hidden */
  93448. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93449. /** @hidden */
  93450. _postActivate(): void;
  93451. getWorldMatrix(): Matrix;
  93452. get isAnInstance(): boolean;
  93453. /**
  93454. * Returns the current associated LOD AbstractMesh.
  93455. */
  93456. getLOD(camera: Camera): AbstractMesh;
  93457. /** @hidden */
  93458. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93459. /** @hidden */
  93460. _syncSubMeshes(): InstancedMesh;
  93461. /** @hidden */
  93462. _generatePointsArray(): boolean;
  93463. /**
  93464. * Creates a new InstancedMesh from the current mesh.
  93465. * - name (string) : the cloned mesh name
  93466. * - newParent (optional Node) : the optional Node to parent the clone to.
  93467. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93468. *
  93469. * Returns the clone.
  93470. */
  93471. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93472. /**
  93473. * Disposes the InstancedMesh.
  93474. * Returns nothing.
  93475. */
  93476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93477. }
  93478. interface Mesh {
  93479. /**
  93480. * Register a custom buffer that will be instanced
  93481. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93482. * @param kind defines the buffer kind
  93483. * @param stride defines the stride in floats
  93484. */
  93485. registerInstancedBuffer(kind: string, stride: number): void;
  93486. /** @hidden */
  93487. _userInstancedBuffersStorage: {
  93488. data: {
  93489. [key: string]: Float32Array;
  93490. };
  93491. sizes: {
  93492. [key: string]: number;
  93493. };
  93494. vertexBuffers: {
  93495. [key: string]: Nullable<VertexBuffer>;
  93496. };
  93497. strides: {
  93498. [key: string]: number;
  93499. };
  93500. };
  93501. }
  93502. interface AbstractMesh {
  93503. /**
  93504. * Object used to store instanced buffers defined by user
  93505. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93506. */
  93507. instancedBuffers: {
  93508. [key: string]: any;
  93509. };
  93510. }
  93511. }
  93512. declare module BABYLON {
  93513. /**
  93514. * Defines the options associated with the creation of a shader material.
  93515. */
  93516. export interface IShaderMaterialOptions {
  93517. /**
  93518. * Does the material work in alpha blend mode
  93519. */
  93520. needAlphaBlending: boolean;
  93521. /**
  93522. * Does the material work in alpha test mode
  93523. */
  93524. needAlphaTesting: boolean;
  93525. /**
  93526. * The list of attribute names used in the shader
  93527. */
  93528. attributes: string[];
  93529. /**
  93530. * The list of unifrom names used in the shader
  93531. */
  93532. uniforms: string[];
  93533. /**
  93534. * The list of UBO names used in the shader
  93535. */
  93536. uniformBuffers: string[];
  93537. /**
  93538. * The list of sampler names used in the shader
  93539. */
  93540. samplers: string[];
  93541. /**
  93542. * The list of defines used in the shader
  93543. */
  93544. defines: string[];
  93545. }
  93546. /**
  93547. * 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.
  93548. *
  93549. * This returned material effects how the mesh will look based on the code in the shaders.
  93550. *
  93551. * @see http://doc.babylonjs.com/how_to/shader_material
  93552. */
  93553. export class ShaderMaterial extends Material {
  93554. private _shaderPath;
  93555. private _options;
  93556. private _textures;
  93557. private _textureArrays;
  93558. private _floats;
  93559. private _ints;
  93560. private _floatsArrays;
  93561. private _colors3;
  93562. private _colors3Arrays;
  93563. private _colors4;
  93564. private _colors4Arrays;
  93565. private _vectors2;
  93566. private _vectors3;
  93567. private _vectors4;
  93568. private _matrices;
  93569. private _matrixArrays;
  93570. private _matrices3x3;
  93571. private _matrices2x2;
  93572. private _vectors2Arrays;
  93573. private _vectors3Arrays;
  93574. private _vectors4Arrays;
  93575. private _cachedWorldViewMatrix;
  93576. private _cachedWorldViewProjectionMatrix;
  93577. private _renderId;
  93578. private _multiview;
  93579. private _cachedDefines;
  93580. /**
  93581. * Instantiate a new shader material.
  93582. * 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.
  93583. * This returned material effects how the mesh will look based on the code in the shaders.
  93584. * @see http://doc.babylonjs.com/how_to/shader_material
  93585. * @param name Define the name of the material in the scene
  93586. * @param scene Define the scene the material belongs to
  93587. * @param shaderPath Defines the route to the shader code in one of three ways:
  93588. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  93589. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  93590. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  93591. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  93592. * @param options Define the options used to create the shader
  93593. */
  93594. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  93595. /**
  93596. * Gets the shader path used to define the shader code
  93597. * It can be modified to trigger a new compilation
  93598. */
  93599. get shaderPath(): any;
  93600. /**
  93601. * Sets the shader path used to define the shader code
  93602. * It can be modified to trigger a new compilation
  93603. */
  93604. set shaderPath(shaderPath: any);
  93605. /**
  93606. * Gets the options used to compile the shader.
  93607. * They can be modified to trigger a new compilation
  93608. */
  93609. get options(): IShaderMaterialOptions;
  93610. /**
  93611. * Gets the current class name of the material e.g. "ShaderMaterial"
  93612. * Mainly use in serialization.
  93613. * @returns the class name
  93614. */
  93615. getClassName(): string;
  93616. /**
  93617. * Specifies if the material will require alpha blending
  93618. * @returns a boolean specifying if alpha blending is needed
  93619. */
  93620. needAlphaBlending(): boolean;
  93621. /**
  93622. * Specifies if this material should be rendered in alpha test mode
  93623. * @returns a boolean specifying if an alpha test is needed.
  93624. */
  93625. needAlphaTesting(): boolean;
  93626. private _checkUniform;
  93627. /**
  93628. * Set a texture in the shader.
  93629. * @param name Define the name of the uniform samplers as defined in the shader
  93630. * @param texture Define the texture to bind to this sampler
  93631. * @return the material itself allowing "fluent" like uniform updates
  93632. */
  93633. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  93634. /**
  93635. * Set a texture array in the shader.
  93636. * @param name Define the name of the uniform sampler array as defined in the shader
  93637. * @param textures Define the list of textures to bind to this sampler
  93638. * @return the material itself allowing "fluent" like uniform updates
  93639. */
  93640. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  93641. /**
  93642. * Set a float in the shader.
  93643. * @param name Define the name of the uniform as defined in the shader
  93644. * @param value Define the value to give to the uniform
  93645. * @return the material itself allowing "fluent" like uniform updates
  93646. */
  93647. setFloat(name: string, value: number): ShaderMaterial;
  93648. /**
  93649. * Set a int in the shader.
  93650. * @param name Define the name of the uniform as defined in the shader
  93651. * @param value Define the value to give to the uniform
  93652. * @return the material itself allowing "fluent" like uniform updates
  93653. */
  93654. setInt(name: string, value: number): ShaderMaterial;
  93655. /**
  93656. * Set an array of floats in the shader.
  93657. * @param name Define the name of the uniform as defined in the shader
  93658. * @param value Define the value to give to the uniform
  93659. * @return the material itself allowing "fluent" like uniform updates
  93660. */
  93661. setFloats(name: string, value: number[]): ShaderMaterial;
  93662. /**
  93663. * Set a vec3 in the shader from a Color3.
  93664. * @param name Define the name of the uniform as defined in the shader
  93665. * @param value Define the value to give to the uniform
  93666. * @return the material itself allowing "fluent" like uniform updates
  93667. */
  93668. setColor3(name: string, value: Color3): ShaderMaterial;
  93669. /**
  93670. * Set a vec3 array in the shader from a Color3 array.
  93671. * @param name Define the name of the uniform as defined in the shader
  93672. * @param value Define the value to give to the uniform
  93673. * @return the material itself allowing "fluent" like uniform updates
  93674. */
  93675. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  93676. /**
  93677. * Set a vec4 in the shader from a Color4.
  93678. * @param name Define the name of the uniform as defined in the shader
  93679. * @param value Define the value to give to the uniform
  93680. * @return the material itself allowing "fluent" like uniform updates
  93681. */
  93682. setColor4(name: string, value: Color4): ShaderMaterial;
  93683. /**
  93684. * Set a vec4 array in the shader from a Color4 array.
  93685. * @param name Define the name of the uniform as defined in the shader
  93686. * @param value Define the value to give to the uniform
  93687. * @return the material itself allowing "fluent" like uniform updates
  93688. */
  93689. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  93690. /**
  93691. * Set a vec2 in the shader from a Vector2.
  93692. * @param name Define the name of the uniform as defined in the shader
  93693. * @param value Define the value to give to the uniform
  93694. * @return the material itself allowing "fluent" like uniform updates
  93695. */
  93696. setVector2(name: string, value: Vector2): ShaderMaterial;
  93697. /**
  93698. * Set a vec3 in the shader from a Vector3.
  93699. * @param name Define the name of the uniform as defined in the shader
  93700. * @param value Define the value to give to the uniform
  93701. * @return the material itself allowing "fluent" like uniform updates
  93702. */
  93703. setVector3(name: string, value: Vector3): ShaderMaterial;
  93704. /**
  93705. * Set a vec4 in the shader from a Vector4.
  93706. * @param name Define the name of the uniform as defined in the shader
  93707. * @param value Define the value to give to the uniform
  93708. * @return the material itself allowing "fluent" like uniform updates
  93709. */
  93710. setVector4(name: string, value: Vector4): ShaderMaterial;
  93711. /**
  93712. * Set a mat4 in the shader from a Matrix.
  93713. * @param name Define the name of the uniform as defined in the shader
  93714. * @param value Define the value to give to the uniform
  93715. * @return the material itself allowing "fluent" like uniform updates
  93716. */
  93717. setMatrix(name: string, value: Matrix): ShaderMaterial;
  93718. /**
  93719. * Set a float32Array in the shader from a matrix array.
  93720. * @param name Define the name of the uniform as defined in the shader
  93721. * @param value Define the value to give to the uniform
  93722. * @return the material itself allowing "fluent" like uniform updates
  93723. */
  93724. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  93725. /**
  93726. * Set a mat3 in the shader from a Float32Array.
  93727. * @param name Define the name of the uniform as defined in the shader
  93728. * @param value Define the value to give to the uniform
  93729. * @return the material itself allowing "fluent" like uniform updates
  93730. */
  93731. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  93732. /**
  93733. * Set a mat2 in the shader from a Float32Array.
  93734. * @param name Define the name of the uniform as defined in the shader
  93735. * @param value Define the value to give to the uniform
  93736. * @return the material itself allowing "fluent" like uniform updates
  93737. */
  93738. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  93739. /**
  93740. * Set a vec2 array in the shader from a number array.
  93741. * @param name Define the name of the uniform as defined in the shader
  93742. * @param value Define the value to give to the uniform
  93743. * @return the material itself allowing "fluent" like uniform updates
  93744. */
  93745. setArray2(name: string, value: number[]): ShaderMaterial;
  93746. /**
  93747. * Set a vec3 array in the shader from a number array.
  93748. * @param name Define the name of the uniform as defined in the shader
  93749. * @param value Define the value to give to the uniform
  93750. * @return the material itself allowing "fluent" like uniform updates
  93751. */
  93752. setArray3(name: string, value: number[]): ShaderMaterial;
  93753. /**
  93754. * Set a vec4 array in the shader from a number array.
  93755. * @param name Define the name of the uniform as defined in the shader
  93756. * @param value Define the value to give to the uniform
  93757. * @return the material itself allowing "fluent" like uniform updates
  93758. */
  93759. setArray4(name: string, value: number[]): ShaderMaterial;
  93760. private _checkCache;
  93761. /**
  93762. * Specifies that the submesh is ready to be used
  93763. * @param mesh defines the mesh to check
  93764. * @param subMesh defines which submesh to check
  93765. * @param useInstances specifies that instances should be used
  93766. * @returns a boolean indicating that the submesh is ready or not
  93767. */
  93768. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  93769. /**
  93770. * Checks if the material is ready to render the requested mesh
  93771. * @param mesh Define the mesh to render
  93772. * @param useInstances Define whether or not the material is used with instances
  93773. * @returns true if ready, otherwise false
  93774. */
  93775. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93776. /**
  93777. * Binds the world matrix to the material
  93778. * @param world defines the world transformation matrix
  93779. * @param effectOverride - If provided, use this effect instead of internal effect
  93780. */
  93781. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  93782. /**
  93783. * Binds the submesh to this material by preparing the effect and shader to draw
  93784. * @param world defines the world transformation matrix
  93785. * @param mesh defines the mesh containing the submesh
  93786. * @param subMesh defines the submesh to bind the material to
  93787. */
  93788. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93789. /**
  93790. * Binds the material to the mesh
  93791. * @param world defines the world transformation matrix
  93792. * @param mesh defines the mesh to bind the material to
  93793. * @param effectOverride - If provided, use this effect instead of internal effect
  93794. */
  93795. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  93796. protected _afterBind(mesh?: Mesh): void;
  93797. /**
  93798. * Gets the active textures from the material
  93799. * @returns an array of textures
  93800. */
  93801. getActiveTextures(): BaseTexture[];
  93802. /**
  93803. * Specifies if the material uses a texture
  93804. * @param texture defines the texture to check against the material
  93805. * @returns a boolean specifying if the material uses the texture
  93806. */
  93807. hasTexture(texture: BaseTexture): boolean;
  93808. /**
  93809. * Makes a duplicate of the material, and gives it a new name
  93810. * @param name defines the new name for the duplicated material
  93811. * @returns the cloned material
  93812. */
  93813. clone(name: string): ShaderMaterial;
  93814. /**
  93815. * Disposes the material
  93816. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93817. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93818. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93819. */
  93820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93821. /**
  93822. * Serializes this material in a JSON representation
  93823. * @returns the serialized material object
  93824. */
  93825. serialize(): any;
  93826. /**
  93827. * Creates a shader material from parsed shader material data
  93828. * @param source defines the JSON represnetation of the material
  93829. * @param scene defines the hosting scene
  93830. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93831. * @returns a new material
  93832. */
  93833. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  93834. }
  93835. }
  93836. declare module BABYLON {
  93837. /** @hidden */
  93838. export var colorPixelShader: {
  93839. name: string;
  93840. shader: string;
  93841. };
  93842. }
  93843. declare module BABYLON {
  93844. /** @hidden */
  93845. export var colorVertexShader: {
  93846. name: string;
  93847. shader: string;
  93848. };
  93849. }
  93850. declare module BABYLON {
  93851. /**
  93852. * Line mesh
  93853. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  93854. */
  93855. export class LinesMesh extends Mesh {
  93856. /**
  93857. * If vertex color should be applied to the mesh
  93858. */
  93859. readonly useVertexColor?: boolean | undefined;
  93860. /**
  93861. * If vertex alpha should be applied to the mesh
  93862. */
  93863. readonly useVertexAlpha?: boolean | undefined;
  93864. /**
  93865. * Color of the line (Default: White)
  93866. */
  93867. color: Color3;
  93868. /**
  93869. * Alpha of the line (Default: 1)
  93870. */
  93871. alpha: number;
  93872. /**
  93873. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93874. * This margin is expressed in world space coordinates, so its value may vary.
  93875. * Default value is 0.1
  93876. */
  93877. intersectionThreshold: number;
  93878. private _colorShader;
  93879. private color4;
  93880. /**
  93881. * Creates a new LinesMesh
  93882. * @param name defines the name
  93883. * @param scene defines the hosting scene
  93884. * @param parent defines the parent mesh if any
  93885. * @param source defines the optional source LinesMesh used to clone data from
  93886. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93887. * When false, achieved by calling a clone(), also passing False.
  93888. * This will make creation of children, recursive.
  93889. * @param useVertexColor defines if this LinesMesh supports vertex color
  93890. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  93891. */
  93892. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  93893. /**
  93894. * If vertex color should be applied to the mesh
  93895. */
  93896. useVertexColor?: boolean | undefined,
  93897. /**
  93898. * If vertex alpha should be applied to the mesh
  93899. */
  93900. useVertexAlpha?: boolean | undefined);
  93901. private _addClipPlaneDefine;
  93902. private _removeClipPlaneDefine;
  93903. isReady(): boolean;
  93904. /**
  93905. * Returns the string "LineMesh"
  93906. */
  93907. getClassName(): string;
  93908. /**
  93909. * @hidden
  93910. */
  93911. get material(): Material;
  93912. /**
  93913. * @hidden
  93914. */
  93915. set material(value: Material);
  93916. /**
  93917. * @hidden
  93918. */
  93919. get checkCollisions(): boolean;
  93920. /** @hidden */
  93921. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93922. /** @hidden */
  93923. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93924. /**
  93925. * Disposes of the line mesh
  93926. * @param doNotRecurse If children should be disposed
  93927. */
  93928. dispose(doNotRecurse?: boolean): void;
  93929. /**
  93930. * Returns a new LineMesh object cloned from the current one.
  93931. */
  93932. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  93933. /**
  93934. * Creates a new InstancedLinesMesh object from the mesh model.
  93935. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93936. * @param name defines the name of the new instance
  93937. * @returns a new InstancedLinesMesh
  93938. */
  93939. createInstance(name: string): InstancedLinesMesh;
  93940. }
  93941. /**
  93942. * Creates an instance based on a source LinesMesh
  93943. */
  93944. export class InstancedLinesMesh extends InstancedMesh {
  93945. /**
  93946. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93947. * This margin is expressed in world space coordinates, so its value may vary.
  93948. * Initilized with the intersectionThreshold value of the source LinesMesh
  93949. */
  93950. intersectionThreshold: number;
  93951. constructor(name: string, source: LinesMesh);
  93952. /**
  93953. * Returns the string "InstancedLinesMesh".
  93954. */
  93955. getClassName(): string;
  93956. }
  93957. }
  93958. declare module BABYLON {
  93959. /** @hidden */
  93960. export var linePixelShader: {
  93961. name: string;
  93962. shader: string;
  93963. };
  93964. }
  93965. declare module BABYLON {
  93966. /** @hidden */
  93967. export var lineVertexShader: {
  93968. name: string;
  93969. shader: string;
  93970. };
  93971. }
  93972. declare module BABYLON {
  93973. interface AbstractMesh {
  93974. /**
  93975. * Gets the edgesRenderer associated with the mesh
  93976. */
  93977. edgesRenderer: Nullable<EdgesRenderer>;
  93978. }
  93979. interface LinesMesh {
  93980. /**
  93981. * Enables the edge rendering mode on the mesh.
  93982. * This mode makes the mesh edges visible
  93983. * @param epsilon defines the maximal distance between two angles to detect a face
  93984. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93985. * @returns the currentAbstractMesh
  93986. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93987. */
  93988. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93989. }
  93990. interface InstancedLinesMesh {
  93991. /**
  93992. * Enables the edge rendering mode on the mesh.
  93993. * This mode makes the mesh edges visible
  93994. * @param epsilon defines the maximal distance between two angles to detect a face
  93995. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93996. * @returns the current InstancedLinesMesh
  93997. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93998. */
  93999. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94000. }
  94001. /**
  94002. * Defines the minimum contract an Edges renderer should follow.
  94003. */
  94004. export interface IEdgesRenderer extends IDisposable {
  94005. /**
  94006. * Gets or sets a boolean indicating if the edgesRenderer is active
  94007. */
  94008. isEnabled: boolean;
  94009. /**
  94010. * Renders the edges of the attached mesh,
  94011. */
  94012. render(): void;
  94013. /**
  94014. * Checks wether or not the edges renderer is ready to render.
  94015. * @return true if ready, otherwise false.
  94016. */
  94017. isReady(): boolean;
  94018. }
  94019. /**
  94020. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94021. */
  94022. export class EdgesRenderer implements IEdgesRenderer {
  94023. /**
  94024. * Define the size of the edges with an orthographic camera
  94025. */
  94026. edgesWidthScalerForOrthographic: number;
  94027. /**
  94028. * Define the size of the edges with a perspective camera
  94029. */
  94030. edgesWidthScalerForPerspective: number;
  94031. protected _source: AbstractMesh;
  94032. protected _linesPositions: number[];
  94033. protected _linesNormals: number[];
  94034. protected _linesIndices: number[];
  94035. protected _epsilon: number;
  94036. protected _indicesCount: number;
  94037. protected _lineShader: ShaderMaterial;
  94038. protected _ib: DataBuffer;
  94039. protected _buffers: {
  94040. [key: string]: Nullable<VertexBuffer>;
  94041. };
  94042. protected _checkVerticesInsteadOfIndices: boolean;
  94043. private _meshRebuildObserver;
  94044. private _meshDisposeObserver;
  94045. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94046. isEnabled: boolean;
  94047. /**
  94048. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94049. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94050. * @param source Mesh used to create edges
  94051. * @param epsilon sum of angles in adjacency to check for edge
  94052. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94053. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94054. */
  94055. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94056. protected _prepareRessources(): void;
  94057. /** @hidden */
  94058. _rebuild(): void;
  94059. /**
  94060. * Releases the required resources for the edges renderer
  94061. */
  94062. dispose(): void;
  94063. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94064. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94065. /**
  94066. * Checks if the pair of p0 and p1 is en edge
  94067. * @param faceIndex
  94068. * @param edge
  94069. * @param faceNormals
  94070. * @param p0
  94071. * @param p1
  94072. * @private
  94073. */
  94074. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94075. /**
  94076. * push line into the position, normal and index buffer
  94077. * @protected
  94078. */
  94079. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94080. /**
  94081. * Generates lines edges from adjacencjes
  94082. * @private
  94083. */
  94084. _generateEdgesLines(): void;
  94085. /**
  94086. * Checks wether or not the edges renderer is ready to render.
  94087. * @return true if ready, otherwise false.
  94088. */
  94089. isReady(): boolean;
  94090. /**
  94091. * Renders the edges of the attached mesh,
  94092. */
  94093. render(): void;
  94094. }
  94095. /**
  94096. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94097. */
  94098. export class LineEdgesRenderer extends EdgesRenderer {
  94099. /**
  94100. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94101. * @param source LineMesh used to generate edges
  94102. * @param epsilon not important (specified angle for edge detection)
  94103. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94104. */
  94105. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94106. /**
  94107. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94108. */
  94109. _generateEdgesLines(): void;
  94110. }
  94111. }
  94112. declare module BABYLON {
  94113. /**
  94114. * This represents the object necessary to create a rendering group.
  94115. * This is exclusively used and created by the rendering manager.
  94116. * To modify the behavior, you use the available helpers in your scene or meshes.
  94117. * @hidden
  94118. */
  94119. export class RenderingGroup {
  94120. index: number;
  94121. private static _zeroVector;
  94122. private _scene;
  94123. private _opaqueSubMeshes;
  94124. private _transparentSubMeshes;
  94125. private _alphaTestSubMeshes;
  94126. private _depthOnlySubMeshes;
  94127. private _particleSystems;
  94128. private _spriteManagers;
  94129. private _opaqueSortCompareFn;
  94130. private _alphaTestSortCompareFn;
  94131. private _transparentSortCompareFn;
  94132. private _renderOpaque;
  94133. private _renderAlphaTest;
  94134. private _renderTransparent;
  94135. /** @hidden */
  94136. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94137. onBeforeTransparentRendering: () => void;
  94138. /**
  94139. * Set the opaque sort comparison function.
  94140. * If null the sub meshes will be render in the order they were created
  94141. */
  94142. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94143. /**
  94144. * Set the alpha test sort comparison function.
  94145. * If null the sub meshes will be render in the order they were created
  94146. */
  94147. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94148. /**
  94149. * Set the transparent sort comparison function.
  94150. * If null the sub meshes will be render in the order they were created
  94151. */
  94152. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94153. /**
  94154. * Creates a new rendering group.
  94155. * @param index The rendering group index
  94156. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94157. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94158. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94159. */
  94160. 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>);
  94161. /**
  94162. * Render all the sub meshes contained in the group.
  94163. * @param customRenderFunction Used to override the default render behaviour of the group.
  94164. * @returns true if rendered some submeshes.
  94165. */
  94166. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94167. /**
  94168. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94169. * @param subMeshes The submeshes to render
  94170. */
  94171. private renderOpaqueSorted;
  94172. /**
  94173. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94174. * @param subMeshes The submeshes to render
  94175. */
  94176. private renderAlphaTestSorted;
  94177. /**
  94178. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94179. * @param subMeshes The submeshes to render
  94180. */
  94181. private renderTransparentSorted;
  94182. /**
  94183. * Renders the submeshes in a specified order.
  94184. * @param subMeshes The submeshes to sort before render
  94185. * @param sortCompareFn The comparison function use to sort
  94186. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94187. * @param transparent Specifies to activate blending if true
  94188. */
  94189. private static renderSorted;
  94190. /**
  94191. * Renders the submeshes in the order they were dispatched (no sort applied).
  94192. * @param subMeshes The submeshes to render
  94193. */
  94194. private static renderUnsorted;
  94195. /**
  94196. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94197. * are rendered back to front if in the same alpha index.
  94198. *
  94199. * @param a The first submesh
  94200. * @param b The second submesh
  94201. * @returns The result of the comparison
  94202. */
  94203. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94204. /**
  94205. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94206. * are rendered back to front.
  94207. *
  94208. * @param a The first submesh
  94209. * @param b The second submesh
  94210. * @returns The result of the comparison
  94211. */
  94212. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94213. /**
  94214. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94215. * are rendered front to back (prevent overdraw).
  94216. *
  94217. * @param a The first submesh
  94218. * @param b The second submesh
  94219. * @returns The result of the comparison
  94220. */
  94221. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94222. /**
  94223. * Resets the different lists of submeshes to prepare a new frame.
  94224. */
  94225. prepare(): void;
  94226. dispose(): void;
  94227. /**
  94228. * Inserts the submesh in its correct queue depending on its material.
  94229. * @param subMesh The submesh to dispatch
  94230. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94231. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94232. */
  94233. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94234. dispatchSprites(spriteManager: ISpriteManager): void;
  94235. dispatchParticles(particleSystem: IParticleSystem): void;
  94236. private _renderParticles;
  94237. private _renderSprites;
  94238. }
  94239. }
  94240. declare module BABYLON {
  94241. /**
  94242. * Interface describing the different options available in the rendering manager
  94243. * regarding Auto Clear between groups.
  94244. */
  94245. export interface IRenderingManagerAutoClearSetup {
  94246. /**
  94247. * Defines whether or not autoclear is enable.
  94248. */
  94249. autoClear: boolean;
  94250. /**
  94251. * Defines whether or not to autoclear the depth buffer.
  94252. */
  94253. depth: boolean;
  94254. /**
  94255. * Defines whether or not to autoclear the stencil buffer.
  94256. */
  94257. stencil: boolean;
  94258. }
  94259. /**
  94260. * This class is used by the onRenderingGroupObservable
  94261. */
  94262. export class RenderingGroupInfo {
  94263. /**
  94264. * The Scene that being rendered
  94265. */
  94266. scene: Scene;
  94267. /**
  94268. * The camera currently used for the rendering pass
  94269. */
  94270. camera: Nullable<Camera>;
  94271. /**
  94272. * The ID of the renderingGroup being processed
  94273. */
  94274. renderingGroupId: number;
  94275. }
  94276. /**
  94277. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94278. * It is enable to manage the different groups as well as the different necessary sort functions.
  94279. * This should not be used directly aside of the few static configurations
  94280. */
  94281. export class RenderingManager {
  94282. /**
  94283. * The max id used for rendering groups (not included)
  94284. */
  94285. static MAX_RENDERINGGROUPS: number;
  94286. /**
  94287. * The min id used for rendering groups (included)
  94288. */
  94289. static MIN_RENDERINGGROUPS: number;
  94290. /**
  94291. * Used to globally prevent autoclearing scenes.
  94292. */
  94293. static AUTOCLEAR: boolean;
  94294. /**
  94295. * @hidden
  94296. */
  94297. _useSceneAutoClearSetup: boolean;
  94298. private _scene;
  94299. private _renderingGroups;
  94300. private _depthStencilBufferAlreadyCleaned;
  94301. private _autoClearDepthStencil;
  94302. private _customOpaqueSortCompareFn;
  94303. private _customAlphaTestSortCompareFn;
  94304. private _customTransparentSortCompareFn;
  94305. private _renderingGroupInfo;
  94306. /**
  94307. * Instantiates a new rendering group for a particular scene
  94308. * @param scene Defines the scene the groups belongs to
  94309. */
  94310. constructor(scene: Scene);
  94311. private _clearDepthStencilBuffer;
  94312. /**
  94313. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94314. * @hidden
  94315. */
  94316. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94317. /**
  94318. * Resets the different information of the group to prepare a new frame
  94319. * @hidden
  94320. */
  94321. reset(): void;
  94322. /**
  94323. * Dispose and release the group and its associated resources.
  94324. * @hidden
  94325. */
  94326. dispose(): void;
  94327. /**
  94328. * Clear the info related to rendering groups preventing retention points during dispose.
  94329. */
  94330. freeRenderingGroups(): void;
  94331. private _prepareRenderingGroup;
  94332. /**
  94333. * Add a sprite manager to the rendering manager in order to render it this frame.
  94334. * @param spriteManager Define the sprite manager to render
  94335. */
  94336. dispatchSprites(spriteManager: ISpriteManager): void;
  94337. /**
  94338. * Add a particle system to the rendering manager in order to render it this frame.
  94339. * @param particleSystem Define the particle system to render
  94340. */
  94341. dispatchParticles(particleSystem: IParticleSystem): void;
  94342. /**
  94343. * Add a submesh to the manager in order to render it this frame
  94344. * @param subMesh The submesh to dispatch
  94345. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94346. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94347. */
  94348. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94349. /**
  94350. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94351. * This allowed control for front to back rendering or reversly depending of the special needs.
  94352. *
  94353. * @param renderingGroupId The rendering group id corresponding to its index
  94354. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94355. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94356. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94357. */
  94358. 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;
  94359. /**
  94360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94361. *
  94362. * @param renderingGroupId The rendering group id corresponding to its index
  94363. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94364. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94365. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94366. */
  94367. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94368. /**
  94369. * Gets the current auto clear configuration for one rendering group of the rendering
  94370. * manager.
  94371. * @param index the rendering group index to get the information for
  94372. * @returns The auto clear setup for the requested rendering group
  94373. */
  94374. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94375. }
  94376. }
  94377. declare module BABYLON {
  94378. /**
  94379. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94380. */
  94381. export interface ICustomShaderOptions {
  94382. /**
  94383. * Gets or sets the custom shader name to use
  94384. */
  94385. shaderName: string;
  94386. /**
  94387. * The list of attribute names used in the shader
  94388. */
  94389. attributes?: string[];
  94390. /**
  94391. * The list of unifrom names used in the shader
  94392. */
  94393. uniforms?: string[];
  94394. /**
  94395. * The list of sampler names used in the shader
  94396. */
  94397. samplers?: string[];
  94398. /**
  94399. * The list of defines used in the shader
  94400. */
  94401. defines?: string[];
  94402. }
  94403. /**
  94404. * Interface to implement to create a shadow generator compatible with BJS.
  94405. */
  94406. export interface IShadowGenerator {
  94407. /**
  94408. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94409. * @returns The render target texture if present otherwise, null
  94410. */
  94411. getShadowMap(): Nullable<RenderTargetTexture>;
  94412. /**
  94413. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94414. * @param subMesh The submesh we want to render in the shadow map
  94415. * @param useInstances Defines wether will draw in the map using instances
  94416. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94417. * @returns true if ready otherwise, false
  94418. */
  94419. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94420. /**
  94421. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94422. * @param defines Defines of the material we want to update
  94423. * @param lightIndex Index of the light in the enabled light list of the material
  94424. */
  94425. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94426. /**
  94427. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94428. * defined in the generator but impacting the effect).
  94429. * It implies the unifroms available on the materials are the standard BJS ones.
  94430. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94431. * @param effect The effect we are binfing the information for
  94432. */
  94433. bindShadowLight(lightIndex: string, effect: Effect): void;
  94434. /**
  94435. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94436. * (eq to shadow prjection matrix * light transform matrix)
  94437. * @returns The transform matrix used to create the shadow map
  94438. */
  94439. getTransformMatrix(): Matrix;
  94440. /**
  94441. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94442. * Cube and 2D textures for instance.
  94443. */
  94444. recreateShadowMap(): void;
  94445. /**
  94446. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94447. * @param onCompiled Callback triggered at the and of the effects compilation
  94448. * @param options Sets of optional options forcing the compilation with different modes
  94449. */
  94450. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94451. useInstances: boolean;
  94452. }>): void;
  94453. /**
  94454. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94455. * @param options Sets of optional options forcing the compilation with different modes
  94456. * @returns A promise that resolves when the compilation completes
  94457. */
  94458. forceCompilationAsync(options?: Partial<{
  94459. useInstances: boolean;
  94460. }>): Promise<void>;
  94461. /**
  94462. * Serializes the shadow generator setup to a json object.
  94463. * @returns The serialized JSON object
  94464. */
  94465. serialize(): any;
  94466. /**
  94467. * Disposes the Shadow map and related Textures and effects.
  94468. */
  94469. dispose(): void;
  94470. }
  94471. /**
  94472. * Default implementation IShadowGenerator.
  94473. * This is the main object responsible of generating shadows in the framework.
  94474. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94475. */
  94476. export class ShadowGenerator implements IShadowGenerator {
  94477. /**
  94478. * Name of the shadow generator class
  94479. */
  94480. static CLASSNAME: string;
  94481. /**
  94482. * Shadow generator mode None: no filtering applied.
  94483. */
  94484. static readonly FILTER_NONE: number;
  94485. /**
  94486. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94487. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94488. */
  94489. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94490. /**
  94491. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94492. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94493. */
  94494. static readonly FILTER_POISSONSAMPLING: number;
  94495. /**
  94496. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94497. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94498. */
  94499. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94500. /**
  94501. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94502. * edge artifacts on steep falloff.
  94503. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94504. */
  94505. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94506. /**
  94507. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94508. * edge artifacts on steep falloff.
  94509. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94510. */
  94511. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94512. /**
  94513. * Shadow generator mode PCF: Percentage Closer Filtering
  94514. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94515. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94516. */
  94517. static readonly FILTER_PCF: number;
  94518. /**
  94519. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94520. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94521. * Contact Hardening
  94522. */
  94523. static readonly FILTER_PCSS: number;
  94524. /**
  94525. * Reserved for PCF and PCSS
  94526. * Highest Quality.
  94527. *
  94528. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94529. *
  94530. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94531. */
  94532. static readonly QUALITY_HIGH: number;
  94533. /**
  94534. * Reserved for PCF and PCSS
  94535. * Good tradeoff for quality/perf cross devices
  94536. *
  94537. * Execute PCF on a 3*3 kernel.
  94538. *
  94539. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94540. */
  94541. static readonly QUALITY_MEDIUM: number;
  94542. /**
  94543. * Reserved for PCF and PCSS
  94544. * The lowest quality but the fastest.
  94545. *
  94546. * Execute PCF on a 1*1 kernel.
  94547. *
  94548. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  94549. */
  94550. static readonly QUALITY_LOW: number;
  94551. /** Gets or sets the custom shader name to use */
  94552. customShaderOptions: ICustomShaderOptions;
  94553. /**
  94554. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  94555. */
  94556. onBeforeShadowMapRenderObservable: Observable<Effect>;
  94557. /**
  94558. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  94559. */
  94560. onAfterShadowMapRenderObservable: Observable<Effect>;
  94561. /**
  94562. * Observable triggered before a mesh is rendered in the shadow map.
  94563. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  94564. */
  94565. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  94566. /**
  94567. * Observable triggered after a mesh is rendered in the shadow map.
  94568. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  94569. */
  94570. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  94571. protected _bias: number;
  94572. /**
  94573. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  94574. */
  94575. get bias(): number;
  94576. /**
  94577. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  94578. */
  94579. set bias(bias: number);
  94580. protected _normalBias: number;
  94581. /**
  94582. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94583. */
  94584. get normalBias(): number;
  94585. /**
  94586. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94587. */
  94588. set normalBias(normalBias: number);
  94589. protected _blurBoxOffset: number;
  94590. /**
  94591. * Gets the blur box offset: offset applied during the blur pass.
  94592. * Only useful if useKernelBlur = false
  94593. */
  94594. get blurBoxOffset(): number;
  94595. /**
  94596. * Sets the blur box offset: offset applied during the blur pass.
  94597. * Only useful if useKernelBlur = false
  94598. */
  94599. set blurBoxOffset(value: number);
  94600. protected _blurScale: number;
  94601. /**
  94602. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  94603. * 2 means half of the size.
  94604. */
  94605. get blurScale(): number;
  94606. /**
  94607. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  94608. * 2 means half of the size.
  94609. */
  94610. set blurScale(value: number);
  94611. protected _blurKernel: number;
  94612. /**
  94613. * Gets the blur kernel: kernel size of the blur pass.
  94614. * Only useful if useKernelBlur = true
  94615. */
  94616. get blurKernel(): number;
  94617. /**
  94618. * Sets the blur kernel: kernel size of the blur pass.
  94619. * Only useful if useKernelBlur = true
  94620. */
  94621. set blurKernel(value: number);
  94622. protected _useKernelBlur: boolean;
  94623. /**
  94624. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  94625. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94626. */
  94627. get useKernelBlur(): boolean;
  94628. /**
  94629. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  94630. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94631. */
  94632. set useKernelBlur(value: boolean);
  94633. protected _depthScale: number;
  94634. /**
  94635. * Gets the depth scale used in ESM mode.
  94636. */
  94637. get depthScale(): number;
  94638. /**
  94639. * Sets the depth scale used in ESM mode.
  94640. * This can override the scale stored on the light.
  94641. */
  94642. set depthScale(value: number);
  94643. protected _validateFilter(filter: number): number;
  94644. protected _filter: number;
  94645. /**
  94646. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  94647. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94648. */
  94649. get filter(): number;
  94650. /**
  94651. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  94652. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94653. */
  94654. set filter(value: number);
  94655. /**
  94656. * Gets if the current filter is set to Poisson Sampling.
  94657. */
  94658. get usePoissonSampling(): boolean;
  94659. /**
  94660. * Sets the current filter to Poisson Sampling.
  94661. */
  94662. set usePoissonSampling(value: boolean);
  94663. /**
  94664. * Gets if the current filter is set to ESM.
  94665. */
  94666. get useExponentialShadowMap(): boolean;
  94667. /**
  94668. * Sets the current filter is to ESM.
  94669. */
  94670. set useExponentialShadowMap(value: boolean);
  94671. /**
  94672. * Gets if the current filter is set to filtered ESM.
  94673. */
  94674. get useBlurExponentialShadowMap(): boolean;
  94675. /**
  94676. * Gets if the current filter is set to filtered ESM.
  94677. */
  94678. set useBlurExponentialShadowMap(value: boolean);
  94679. /**
  94680. * Gets if the current filter is set to "close ESM" (using the inverse of the
  94681. * exponential to prevent steep falloff artifacts).
  94682. */
  94683. get useCloseExponentialShadowMap(): boolean;
  94684. /**
  94685. * Sets the current filter to "close ESM" (using the inverse of the
  94686. * exponential to prevent steep falloff artifacts).
  94687. */
  94688. set useCloseExponentialShadowMap(value: boolean);
  94689. /**
  94690. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  94691. * exponential to prevent steep falloff artifacts).
  94692. */
  94693. get useBlurCloseExponentialShadowMap(): boolean;
  94694. /**
  94695. * Sets the current filter to filtered "close ESM" (using the inverse of the
  94696. * exponential to prevent steep falloff artifacts).
  94697. */
  94698. set useBlurCloseExponentialShadowMap(value: boolean);
  94699. /**
  94700. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  94701. */
  94702. get usePercentageCloserFiltering(): boolean;
  94703. /**
  94704. * Sets the current filter to "PCF" (percentage closer filtering).
  94705. */
  94706. set usePercentageCloserFiltering(value: boolean);
  94707. protected _filteringQuality: number;
  94708. /**
  94709. * Gets the PCF or PCSS Quality.
  94710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94711. */
  94712. get filteringQuality(): number;
  94713. /**
  94714. * Sets the PCF or PCSS Quality.
  94715. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94716. */
  94717. set filteringQuality(filteringQuality: number);
  94718. /**
  94719. * Gets if the current filter is set to "PCSS" (contact hardening).
  94720. */
  94721. get useContactHardeningShadow(): boolean;
  94722. /**
  94723. * Sets the current filter to "PCSS" (contact hardening).
  94724. */
  94725. set useContactHardeningShadow(value: boolean);
  94726. protected _contactHardeningLightSizeUVRatio: number;
  94727. /**
  94728. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94729. * Using a ratio helps keeping shape stability independently of the map size.
  94730. *
  94731. * It does not account for the light projection as it was having too much
  94732. * instability during the light setup or during light position changes.
  94733. *
  94734. * Only valid if useContactHardeningShadow is true.
  94735. */
  94736. get contactHardeningLightSizeUVRatio(): number;
  94737. /**
  94738. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94739. * Using a ratio helps keeping shape stability independently of the map size.
  94740. *
  94741. * It does not account for the light projection as it was having too much
  94742. * instability during the light setup or during light position changes.
  94743. *
  94744. * Only valid if useContactHardeningShadow is true.
  94745. */
  94746. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  94747. protected _darkness: number;
  94748. /** Gets or sets the actual darkness of a shadow */
  94749. get darkness(): number;
  94750. set darkness(value: number);
  94751. /**
  94752. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  94753. * 0 means strongest and 1 would means no shadow.
  94754. * @returns the darkness.
  94755. */
  94756. getDarkness(): number;
  94757. /**
  94758. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  94759. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  94760. * @returns the shadow generator allowing fluent coding.
  94761. */
  94762. setDarkness(darkness: number): ShadowGenerator;
  94763. protected _transparencyShadow: boolean;
  94764. /** Gets or sets the ability to have transparent shadow */
  94765. get transparencyShadow(): boolean;
  94766. set transparencyShadow(value: boolean);
  94767. /**
  94768. * Sets the ability to have transparent shadow (boolean).
  94769. * @param transparent True if transparent else False
  94770. * @returns the shadow generator allowing fluent coding
  94771. */
  94772. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  94773. /**
  94774. * Enables or disables shadows with varying strength based on the transparency
  94775. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  94776. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  94777. * mesh.visibility * alphaTexture.a
  94778. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  94779. */
  94780. enableSoftTransparentShadow: boolean;
  94781. protected _shadowMap: Nullable<RenderTargetTexture>;
  94782. protected _shadowMap2: Nullable<RenderTargetTexture>;
  94783. /**
  94784. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94785. * @returns The render target texture if present otherwise, null
  94786. */
  94787. getShadowMap(): Nullable<RenderTargetTexture>;
  94788. /**
  94789. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  94790. * @returns The render target texture if the shadow map is present otherwise, null
  94791. */
  94792. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  94793. /**
  94794. * Gets the class name of that object
  94795. * @returns "ShadowGenerator"
  94796. */
  94797. getClassName(): string;
  94798. /**
  94799. * Helper function to add a mesh and its descendants to the list of shadow casters.
  94800. * @param mesh Mesh to add
  94801. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  94802. * @returns the Shadow Generator itself
  94803. */
  94804. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94805. /**
  94806. * Helper function to remove a mesh and its descendants from the list of shadow casters
  94807. * @param mesh Mesh to remove
  94808. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  94809. * @returns the Shadow Generator itself
  94810. */
  94811. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94812. /**
  94813. * Controls the extent to which the shadows fade out at the edge of the frustum
  94814. */
  94815. frustumEdgeFalloff: number;
  94816. protected _light: IShadowLight;
  94817. /**
  94818. * Returns the associated light object.
  94819. * @returns the light generating the shadow
  94820. */
  94821. getLight(): IShadowLight;
  94822. /**
  94823. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  94824. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  94825. * It might on the other hand introduce peter panning.
  94826. */
  94827. forceBackFacesOnly: boolean;
  94828. protected _scene: Scene;
  94829. protected _lightDirection: Vector3;
  94830. protected _effect: Effect;
  94831. protected _viewMatrix: Matrix;
  94832. protected _projectionMatrix: Matrix;
  94833. protected _transformMatrix: Matrix;
  94834. protected _cachedPosition: Vector3;
  94835. protected _cachedDirection: Vector3;
  94836. protected _cachedDefines: string;
  94837. protected _currentRenderID: number;
  94838. protected _boxBlurPostprocess: Nullable<PostProcess>;
  94839. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  94840. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  94841. protected _blurPostProcesses: PostProcess[];
  94842. protected _mapSize: number;
  94843. protected _currentFaceIndex: number;
  94844. protected _currentFaceIndexCache: number;
  94845. protected _textureType: number;
  94846. protected _defaultTextureMatrix: Matrix;
  94847. protected _storedUniqueId: Nullable<number>;
  94848. /** @hidden */
  94849. static _SceneComponentInitialization: (scene: Scene) => void;
  94850. /**
  94851. * Creates a ShadowGenerator object.
  94852. * A ShadowGenerator is the required tool to use the shadows.
  94853. * Each light casting shadows needs to use its own ShadowGenerator.
  94854. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  94855. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  94856. * @param light The light object generating the shadows.
  94857. * @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.
  94858. */
  94859. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  94860. protected _initializeGenerator(): void;
  94861. protected _createTargetRenderTexture(): void;
  94862. protected _initializeShadowMap(): void;
  94863. protected _initializeBlurRTTAndPostProcesses(): void;
  94864. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  94865. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  94866. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  94867. protected _applyFilterValues(): void;
  94868. /**
  94869. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94870. * @param onCompiled Callback triggered at the and of the effects compilation
  94871. * @param options Sets of optional options forcing the compilation with different modes
  94872. */
  94873. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94874. useInstances: boolean;
  94875. }>): void;
  94876. /**
  94877. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94878. * @param options Sets of optional options forcing the compilation with different modes
  94879. * @returns A promise that resolves when the compilation completes
  94880. */
  94881. forceCompilationAsync(options?: Partial<{
  94882. useInstances: boolean;
  94883. }>): Promise<void>;
  94884. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  94885. private _prepareShadowDefines;
  94886. /**
  94887. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94888. * @param subMesh The submesh we want to render in the shadow map
  94889. * @param useInstances Defines wether will draw in the map using instances
  94890. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94891. * @returns true if ready otherwise, false
  94892. */
  94893. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94894. /**
  94895. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94896. * @param defines Defines of the material we want to update
  94897. * @param lightIndex Index of the light in the enabled light list of the material
  94898. */
  94899. prepareDefines(defines: any, lightIndex: number): void;
  94900. /**
  94901. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94902. * defined in the generator but impacting the effect).
  94903. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94904. * @param effect The effect we are binfing the information for
  94905. */
  94906. bindShadowLight(lightIndex: string, effect: Effect): void;
  94907. /**
  94908. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94909. * (eq to shadow prjection matrix * light transform matrix)
  94910. * @returns The transform matrix used to create the shadow map
  94911. */
  94912. getTransformMatrix(): Matrix;
  94913. /**
  94914. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94915. * Cube and 2D textures for instance.
  94916. */
  94917. recreateShadowMap(): void;
  94918. protected _disposeBlurPostProcesses(): void;
  94919. protected _disposeRTTandPostProcesses(): void;
  94920. /**
  94921. * Disposes the ShadowGenerator.
  94922. * Returns nothing.
  94923. */
  94924. dispose(): void;
  94925. /**
  94926. * Serializes the shadow generator setup to a json object.
  94927. * @returns The serialized JSON object
  94928. */
  94929. serialize(): any;
  94930. /**
  94931. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  94932. * @param parsedShadowGenerator The JSON object to parse
  94933. * @param scene The scene to create the shadow map for
  94934. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  94935. * @returns The parsed shadow generator
  94936. */
  94937. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  94938. }
  94939. }
  94940. declare module BABYLON {
  94941. /**
  94942. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  94943. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  94944. * 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.
  94945. */
  94946. export abstract class Light extends Node {
  94947. /**
  94948. * Falloff Default: light is falling off following the material specification:
  94949. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  94950. */
  94951. static readonly FALLOFF_DEFAULT: number;
  94952. /**
  94953. * Falloff Physical: light is falling off following the inverse squared distance law.
  94954. */
  94955. static readonly FALLOFF_PHYSICAL: number;
  94956. /**
  94957. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  94958. * to enhance interoperability with other engines.
  94959. */
  94960. static readonly FALLOFF_GLTF: number;
  94961. /**
  94962. * Falloff Standard: light is falling off like in the standard material
  94963. * to enhance interoperability with other materials.
  94964. */
  94965. static readonly FALLOFF_STANDARD: number;
  94966. /**
  94967. * If every light affecting the material is in this lightmapMode,
  94968. * material.lightmapTexture adds or multiplies
  94969. * (depends on material.useLightmapAsShadowmap)
  94970. * after every other light calculations.
  94971. */
  94972. static readonly LIGHTMAP_DEFAULT: number;
  94973. /**
  94974. * material.lightmapTexture as only diffuse lighting from this light
  94975. * adds only specular lighting from this light
  94976. * adds dynamic shadows
  94977. */
  94978. static readonly LIGHTMAP_SPECULAR: number;
  94979. /**
  94980. * material.lightmapTexture as only lighting
  94981. * no light calculation from this light
  94982. * only adds dynamic shadows from this light
  94983. */
  94984. static readonly LIGHTMAP_SHADOWSONLY: number;
  94985. /**
  94986. * Each light type uses the default quantity according to its type:
  94987. * point/spot lights use luminous intensity
  94988. * directional lights use illuminance
  94989. */
  94990. static readonly INTENSITYMODE_AUTOMATIC: number;
  94991. /**
  94992. * lumen (lm)
  94993. */
  94994. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  94995. /**
  94996. * candela (lm/sr)
  94997. */
  94998. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  94999. /**
  95000. * lux (lm/m^2)
  95001. */
  95002. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95003. /**
  95004. * nit (cd/m^2)
  95005. */
  95006. static readonly INTENSITYMODE_LUMINANCE: number;
  95007. /**
  95008. * Light type const id of the point light.
  95009. */
  95010. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95011. /**
  95012. * Light type const id of the directional light.
  95013. */
  95014. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95015. /**
  95016. * Light type const id of the spot light.
  95017. */
  95018. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95019. /**
  95020. * Light type const id of the hemispheric light.
  95021. */
  95022. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95023. /**
  95024. * Diffuse gives the basic color to an object.
  95025. */
  95026. diffuse: Color3;
  95027. /**
  95028. * Specular produces a highlight color on an object.
  95029. * Note: This is note affecting PBR materials.
  95030. */
  95031. specular: Color3;
  95032. /**
  95033. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95034. * falling off base on range or angle.
  95035. * This can be set to any values in Light.FALLOFF_x.
  95036. *
  95037. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95038. * other types of materials.
  95039. */
  95040. falloffType: number;
  95041. /**
  95042. * Strength of the light.
  95043. * Note: By default it is define in the framework own unit.
  95044. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95045. */
  95046. intensity: number;
  95047. private _range;
  95048. protected _inverseSquaredRange: number;
  95049. /**
  95050. * Defines how far from the source the light is impacting in scene units.
  95051. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95052. */
  95053. get range(): number;
  95054. /**
  95055. * Defines how far from the source the light is impacting in scene units.
  95056. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95057. */
  95058. set range(value: number);
  95059. /**
  95060. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95061. * of light.
  95062. */
  95063. private _photometricScale;
  95064. private _intensityMode;
  95065. /**
  95066. * Gets the photometric scale used to interpret the intensity.
  95067. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95068. */
  95069. get intensityMode(): number;
  95070. /**
  95071. * Sets the photometric scale used to interpret the intensity.
  95072. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95073. */
  95074. set intensityMode(value: number);
  95075. private _radius;
  95076. /**
  95077. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95078. */
  95079. get radius(): number;
  95080. /**
  95081. * sets the light radius used by PBR Materials to simulate soft area lights.
  95082. */
  95083. set radius(value: number);
  95084. private _renderPriority;
  95085. /**
  95086. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95087. * exceeding the number allowed of the materials.
  95088. */
  95089. renderPriority: number;
  95090. private _shadowEnabled;
  95091. /**
  95092. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95093. * the current shadow generator.
  95094. */
  95095. get shadowEnabled(): boolean;
  95096. /**
  95097. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95098. * the current shadow generator.
  95099. */
  95100. set shadowEnabled(value: boolean);
  95101. private _includedOnlyMeshes;
  95102. /**
  95103. * Gets the only meshes impacted by this light.
  95104. */
  95105. get includedOnlyMeshes(): AbstractMesh[];
  95106. /**
  95107. * Sets the only meshes impacted by this light.
  95108. */
  95109. set includedOnlyMeshes(value: AbstractMesh[]);
  95110. private _excludedMeshes;
  95111. /**
  95112. * Gets the meshes not impacted by this light.
  95113. */
  95114. get excludedMeshes(): AbstractMesh[];
  95115. /**
  95116. * Sets the meshes not impacted by this light.
  95117. */
  95118. set excludedMeshes(value: AbstractMesh[]);
  95119. private _excludeWithLayerMask;
  95120. /**
  95121. * Gets the layer id use to find what meshes are not impacted by the light.
  95122. * Inactive if 0
  95123. */
  95124. get excludeWithLayerMask(): number;
  95125. /**
  95126. * Sets the layer id use to find what meshes are not impacted by the light.
  95127. * Inactive if 0
  95128. */
  95129. set excludeWithLayerMask(value: number);
  95130. private _includeOnlyWithLayerMask;
  95131. /**
  95132. * Gets the layer id use to find what meshes are impacted by the light.
  95133. * Inactive if 0
  95134. */
  95135. get includeOnlyWithLayerMask(): number;
  95136. /**
  95137. * Sets the layer id use to find what meshes are impacted by the light.
  95138. * Inactive if 0
  95139. */
  95140. set includeOnlyWithLayerMask(value: number);
  95141. private _lightmapMode;
  95142. /**
  95143. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95144. */
  95145. get lightmapMode(): number;
  95146. /**
  95147. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95148. */
  95149. set lightmapMode(value: number);
  95150. /**
  95151. * Shadow generator associted to the light.
  95152. * @hidden Internal use only.
  95153. */
  95154. _shadowGenerator: Nullable<IShadowGenerator>;
  95155. /**
  95156. * @hidden Internal use only.
  95157. */
  95158. _excludedMeshesIds: string[];
  95159. /**
  95160. * @hidden Internal use only.
  95161. */
  95162. _includedOnlyMeshesIds: string[];
  95163. /**
  95164. * The current light unifom buffer.
  95165. * @hidden Internal use only.
  95166. */
  95167. _uniformBuffer: UniformBuffer;
  95168. /** @hidden */
  95169. _renderId: number;
  95170. /**
  95171. * Creates a Light object in the scene.
  95172. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95173. * @param name The firendly name of the light
  95174. * @param scene The scene the light belongs too
  95175. */
  95176. constructor(name: string, scene: Scene);
  95177. protected abstract _buildUniformLayout(): void;
  95178. /**
  95179. * Sets the passed Effect "effect" with the Light information.
  95180. * @param effect The effect to update
  95181. * @param lightIndex The index of the light in the effect to update
  95182. * @returns The light
  95183. */
  95184. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95185. /**
  95186. * Sets the passed Effect "effect" with the Light textures.
  95187. * @param effect The effect to update
  95188. * @param lightIndex The index of the light in the effect to update
  95189. * @returns The light
  95190. */
  95191. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95192. /**
  95193. * Binds the lights information from the scene to the effect for the given mesh.
  95194. * @param lightIndex Light index
  95195. * @param scene The scene where the light belongs to
  95196. * @param effect The effect we are binding the data to
  95197. * @param useSpecular Defines if specular is supported
  95198. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95199. */
  95200. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95201. /**
  95202. * Sets the passed Effect "effect" with the Light information.
  95203. * @param effect The effect to update
  95204. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95205. * @returns The light
  95206. */
  95207. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95208. /**
  95209. * Returns the string "Light".
  95210. * @returns the class name
  95211. */
  95212. getClassName(): string;
  95213. /** @hidden */
  95214. readonly _isLight: boolean;
  95215. /**
  95216. * Converts the light information to a readable string for debug purpose.
  95217. * @param fullDetails Supports for multiple levels of logging within scene loading
  95218. * @returns the human readable light info
  95219. */
  95220. toString(fullDetails?: boolean): string;
  95221. /** @hidden */
  95222. protected _syncParentEnabledState(): void;
  95223. /**
  95224. * Set the enabled state of this node.
  95225. * @param value - the new enabled state
  95226. */
  95227. setEnabled(value: boolean): void;
  95228. /**
  95229. * Returns the Light associated shadow generator if any.
  95230. * @return the associated shadow generator.
  95231. */
  95232. getShadowGenerator(): Nullable<IShadowGenerator>;
  95233. /**
  95234. * Returns a Vector3, the absolute light position in the World.
  95235. * @returns the world space position of the light
  95236. */
  95237. getAbsolutePosition(): Vector3;
  95238. /**
  95239. * Specifies if the light will affect the passed mesh.
  95240. * @param mesh The mesh to test against the light
  95241. * @return true the mesh is affected otherwise, false.
  95242. */
  95243. canAffectMesh(mesh: AbstractMesh): boolean;
  95244. /**
  95245. * Sort function to order lights for rendering.
  95246. * @param a First Light object to compare to second.
  95247. * @param b Second Light object to compare first.
  95248. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95249. */
  95250. static CompareLightsPriority(a: Light, b: Light): number;
  95251. /**
  95252. * Releases resources associated with this node.
  95253. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95254. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95255. */
  95256. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95257. /**
  95258. * Returns the light type ID (integer).
  95259. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95260. */
  95261. getTypeID(): number;
  95262. /**
  95263. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95264. * @returns the scaled intensity in intensity mode unit
  95265. */
  95266. getScaledIntensity(): number;
  95267. /**
  95268. * Returns a new Light object, named "name", from the current one.
  95269. * @param name The name of the cloned light
  95270. * @param newParent The parent of this light, if it has one
  95271. * @returns the new created light
  95272. */
  95273. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95274. /**
  95275. * Serializes the current light into a Serialization object.
  95276. * @returns the serialized object.
  95277. */
  95278. serialize(): any;
  95279. /**
  95280. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95281. * This new light is named "name" and added to the passed scene.
  95282. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95283. * @param name The friendly name of the light
  95284. * @param scene The scene the new light will belong to
  95285. * @returns the constructor function
  95286. */
  95287. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95288. /**
  95289. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95290. * @param parsedLight The JSON representation of the light
  95291. * @param scene The scene to create the parsed light in
  95292. * @returns the created light after parsing
  95293. */
  95294. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95295. private _hookArrayForExcluded;
  95296. private _hookArrayForIncludedOnly;
  95297. private _resyncMeshes;
  95298. /**
  95299. * Forces the meshes to update their light related information in their rendering used effects
  95300. * @hidden Internal Use Only
  95301. */
  95302. _markMeshesAsLightDirty(): void;
  95303. /**
  95304. * Recomputes the cached photometric scale if needed.
  95305. */
  95306. private _computePhotometricScale;
  95307. /**
  95308. * Returns the Photometric Scale according to the light type and intensity mode.
  95309. */
  95310. private _getPhotometricScale;
  95311. /**
  95312. * Reorder the light in the scene according to their defined priority.
  95313. * @hidden Internal Use Only
  95314. */
  95315. _reorderLightsInScene(): void;
  95316. /**
  95317. * Prepares the list of defines specific to the light type.
  95318. * @param defines the list of defines
  95319. * @param lightIndex defines the index of the light for the effect
  95320. */
  95321. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95322. }
  95323. }
  95324. declare module BABYLON {
  95325. /**
  95326. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95327. * This is the base of the follow, arc rotate cameras and Free camera
  95328. * @see http://doc.babylonjs.com/features/cameras
  95329. */
  95330. export class TargetCamera extends Camera {
  95331. private static _RigCamTransformMatrix;
  95332. private static _TargetTransformMatrix;
  95333. private static _TargetFocalPoint;
  95334. /**
  95335. * Define the current direction the camera is moving to
  95336. */
  95337. cameraDirection: Vector3;
  95338. /**
  95339. * Define the current rotation the camera is rotating to
  95340. */
  95341. cameraRotation: Vector2;
  95342. /**
  95343. * When set, the up vector of the camera will be updated by the rotation of the camera
  95344. */
  95345. updateUpVectorFromRotation: boolean;
  95346. private _tmpQuaternion;
  95347. /**
  95348. * Define the current rotation of the camera
  95349. */
  95350. rotation: Vector3;
  95351. /**
  95352. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95353. */
  95354. rotationQuaternion: Quaternion;
  95355. /**
  95356. * Define the current speed of the camera
  95357. */
  95358. speed: number;
  95359. /**
  95360. * Add constraint to the camera to prevent it to move freely in all directions and
  95361. * around all axis.
  95362. */
  95363. noRotationConstraint: boolean;
  95364. /**
  95365. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95366. * panning
  95367. */
  95368. invertRotation: boolean;
  95369. /**
  95370. * Speed multiplier for inverse camera panning
  95371. */
  95372. inverseRotationSpeed: number;
  95373. /**
  95374. * Define the current target of the camera as an object or a position.
  95375. */
  95376. lockedTarget: any;
  95377. /** @hidden */
  95378. _currentTarget: Vector3;
  95379. /** @hidden */
  95380. _initialFocalDistance: number;
  95381. /** @hidden */
  95382. _viewMatrix: Matrix;
  95383. /** @hidden */
  95384. _camMatrix: Matrix;
  95385. /** @hidden */
  95386. _cameraTransformMatrix: Matrix;
  95387. /** @hidden */
  95388. _cameraRotationMatrix: Matrix;
  95389. /** @hidden */
  95390. _referencePoint: Vector3;
  95391. /** @hidden */
  95392. _transformedReferencePoint: Vector3;
  95393. protected _globalCurrentTarget: Vector3;
  95394. protected _globalCurrentUpVector: Vector3;
  95395. /** @hidden */
  95396. _reset: () => void;
  95397. private _defaultUp;
  95398. /**
  95399. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95400. * This is the base of the follow, arc rotate cameras and Free camera
  95401. * @see http://doc.babylonjs.com/features/cameras
  95402. * @param name Defines the name of the camera in the scene
  95403. * @param position Defines the start position of the camera in the scene
  95404. * @param scene Defines the scene the camera belongs to
  95405. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95406. */
  95407. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95408. /**
  95409. * Gets the position in front of the camera at a given distance.
  95410. * @param distance The distance from the camera we want the position to be
  95411. * @returns the position
  95412. */
  95413. getFrontPosition(distance: number): Vector3;
  95414. /** @hidden */
  95415. _getLockedTargetPosition(): Nullable<Vector3>;
  95416. private _storedPosition;
  95417. private _storedRotation;
  95418. private _storedRotationQuaternion;
  95419. /**
  95420. * Store current camera state of the camera (fov, position, rotation, etc..)
  95421. * @returns the camera
  95422. */
  95423. storeState(): Camera;
  95424. /**
  95425. * Restored camera state. You must call storeState() first
  95426. * @returns whether it was successful or not
  95427. * @hidden
  95428. */
  95429. _restoreStateValues(): boolean;
  95430. /** @hidden */
  95431. _initCache(): void;
  95432. /** @hidden */
  95433. _updateCache(ignoreParentClass?: boolean): void;
  95434. /** @hidden */
  95435. _isSynchronizedViewMatrix(): boolean;
  95436. /** @hidden */
  95437. _computeLocalCameraSpeed(): number;
  95438. /**
  95439. * Defines the target the camera should look at.
  95440. * @param target Defines the new target as a Vector or a mesh
  95441. */
  95442. setTarget(target: Vector3): void;
  95443. /**
  95444. * Return the current target position of the camera. This value is expressed in local space.
  95445. * @returns the target position
  95446. */
  95447. getTarget(): Vector3;
  95448. /** @hidden */
  95449. _decideIfNeedsToMove(): boolean;
  95450. /** @hidden */
  95451. _updatePosition(): void;
  95452. /** @hidden */
  95453. _checkInputs(): void;
  95454. protected _updateCameraRotationMatrix(): void;
  95455. /**
  95456. * 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)
  95457. * @returns the current camera
  95458. */
  95459. private _rotateUpVectorWithCameraRotationMatrix;
  95460. private _cachedRotationZ;
  95461. private _cachedQuaternionRotationZ;
  95462. /** @hidden */
  95463. _getViewMatrix(): Matrix;
  95464. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95465. /**
  95466. * @hidden
  95467. */
  95468. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95469. /**
  95470. * @hidden
  95471. */
  95472. _updateRigCameras(): void;
  95473. private _getRigCamPositionAndTarget;
  95474. /**
  95475. * Gets the current object class name.
  95476. * @return the class name
  95477. */
  95478. getClassName(): string;
  95479. }
  95480. }
  95481. declare module BABYLON {
  95482. /**
  95483. * Gather the list of keyboard event types as constants.
  95484. */
  95485. export class KeyboardEventTypes {
  95486. /**
  95487. * The keydown event is fired when a key becomes active (pressed).
  95488. */
  95489. static readonly KEYDOWN: number;
  95490. /**
  95491. * The keyup event is fired when a key has been released.
  95492. */
  95493. static readonly KEYUP: number;
  95494. }
  95495. /**
  95496. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95497. */
  95498. export class KeyboardInfo {
  95499. /**
  95500. * Defines the type of event (KeyboardEventTypes)
  95501. */
  95502. type: number;
  95503. /**
  95504. * Defines the related dom event
  95505. */
  95506. event: KeyboardEvent;
  95507. /**
  95508. * Instantiates a new keyboard info.
  95509. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95510. * @param type Defines the type of event (KeyboardEventTypes)
  95511. * @param event Defines the related dom event
  95512. */
  95513. constructor(
  95514. /**
  95515. * Defines the type of event (KeyboardEventTypes)
  95516. */
  95517. type: number,
  95518. /**
  95519. * Defines the related dom event
  95520. */
  95521. event: KeyboardEvent);
  95522. }
  95523. /**
  95524. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95525. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95526. */
  95527. export class KeyboardInfoPre extends KeyboardInfo {
  95528. /**
  95529. * Defines the type of event (KeyboardEventTypes)
  95530. */
  95531. type: number;
  95532. /**
  95533. * Defines the related dom event
  95534. */
  95535. event: KeyboardEvent;
  95536. /**
  95537. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95538. */
  95539. skipOnPointerObservable: boolean;
  95540. /**
  95541. * Instantiates a new keyboard pre info.
  95542. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95543. * @param type Defines the type of event (KeyboardEventTypes)
  95544. * @param event Defines the related dom event
  95545. */
  95546. constructor(
  95547. /**
  95548. * Defines the type of event (KeyboardEventTypes)
  95549. */
  95550. type: number,
  95551. /**
  95552. * Defines the related dom event
  95553. */
  95554. event: KeyboardEvent);
  95555. }
  95556. }
  95557. declare module BABYLON {
  95558. /**
  95559. * Manage the keyboard inputs to control the movement of a free camera.
  95560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95561. */
  95562. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95563. /**
  95564. * Defines the camera the input is attached to.
  95565. */
  95566. camera: FreeCamera;
  95567. /**
  95568. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95569. */
  95570. keysUp: number[];
  95571. /**
  95572. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95573. */
  95574. keysUpward: number[];
  95575. /**
  95576. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95577. */
  95578. keysDown: number[];
  95579. /**
  95580. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95581. */
  95582. keysDownward: number[];
  95583. /**
  95584. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95585. */
  95586. keysLeft: number[];
  95587. /**
  95588. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95589. */
  95590. keysRight: number[];
  95591. private _keys;
  95592. private _onCanvasBlurObserver;
  95593. private _onKeyboardObserver;
  95594. private _engine;
  95595. private _scene;
  95596. /**
  95597. * Attach the input controls to a specific dom element to get the input from.
  95598. * @param element Defines the element the controls should be listened from
  95599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95600. */
  95601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95602. /**
  95603. * Detach the current controls from the specified dom element.
  95604. * @param element Defines the element to stop listening the inputs from
  95605. */
  95606. detachControl(element: Nullable<HTMLElement>): void;
  95607. /**
  95608. * Update the current camera state depending on the inputs that have been used this frame.
  95609. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95610. */
  95611. checkInputs(): void;
  95612. /**
  95613. * Gets the class name of the current intput.
  95614. * @returns the class name
  95615. */
  95616. getClassName(): string;
  95617. /** @hidden */
  95618. _onLostFocus(): void;
  95619. /**
  95620. * Get the friendly name associated with the input class.
  95621. * @returns the input friendly name
  95622. */
  95623. getSimpleName(): string;
  95624. }
  95625. }
  95626. declare module BABYLON {
  95627. /**
  95628. * Gather the list of pointer event types as constants.
  95629. */
  95630. export class PointerEventTypes {
  95631. /**
  95632. * 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.
  95633. */
  95634. static readonly POINTERDOWN: number;
  95635. /**
  95636. * The pointerup event is fired when a pointer is no longer active.
  95637. */
  95638. static readonly POINTERUP: number;
  95639. /**
  95640. * The pointermove event is fired when a pointer changes coordinates.
  95641. */
  95642. static readonly POINTERMOVE: number;
  95643. /**
  95644. * The pointerwheel event is fired when a mouse wheel has been rotated.
  95645. */
  95646. static readonly POINTERWHEEL: number;
  95647. /**
  95648. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  95649. */
  95650. static readonly POINTERPICK: number;
  95651. /**
  95652. * The pointertap event is fired when a the object has been touched and released without drag.
  95653. */
  95654. static readonly POINTERTAP: number;
  95655. /**
  95656. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  95657. */
  95658. static readonly POINTERDOUBLETAP: number;
  95659. }
  95660. /**
  95661. * Base class of pointer info types.
  95662. */
  95663. export class PointerInfoBase {
  95664. /**
  95665. * Defines the type of event (PointerEventTypes)
  95666. */
  95667. type: number;
  95668. /**
  95669. * Defines the related dom event
  95670. */
  95671. event: PointerEvent | MouseWheelEvent;
  95672. /**
  95673. * Instantiates the base class of pointers info.
  95674. * @param type Defines the type of event (PointerEventTypes)
  95675. * @param event Defines the related dom event
  95676. */
  95677. constructor(
  95678. /**
  95679. * Defines the type of event (PointerEventTypes)
  95680. */
  95681. type: number,
  95682. /**
  95683. * Defines the related dom event
  95684. */
  95685. event: PointerEvent | MouseWheelEvent);
  95686. }
  95687. /**
  95688. * This class is used to store pointer related info for the onPrePointerObservable event.
  95689. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  95690. */
  95691. export class PointerInfoPre extends PointerInfoBase {
  95692. /**
  95693. * Ray from a pointer if availible (eg. 6dof controller)
  95694. */
  95695. ray: Nullable<Ray>;
  95696. /**
  95697. * Defines the local position of the pointer on the canvas.
  95698. */
  95699. localPosition: Vector2;
  95700. /**
  95701. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  95702. */
  95703. skipOnPointerObservable: boolean;
  95704. /**
  95705. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  95706. * @param type Defines the type of event (PointerEventTypes)
  95707. * @param event Defines the related dom event
  95708. * @param localX Defines the local x coordinates of the pointer when the event occured
  95709. * @param localY Defines the local y coordinates of the pointer when the event occured
  95710. */
  95711. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  95712. }
  95713. /**
  95714. * This type contains all the data related to a pointer event in Babylon.js.
  95715. * 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.
  95716. */
  95717. export class PointerInfo extends PointerInfoBase {
  95718. /**
  95719. * Defines the picking info associated to the info (if any)\
  95720. */
  95721. pickInfo: Nullable<PickingInfo>;
  95722. /**
  95723. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  95724. * @param type Defines the type of event (PointerEventTypes)
  95725. * @param event Defines the related dom event
  95726. * @param pickInfo Defines the picking info associated to the info (if any)\
  95727. */
  95728. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  95729. /**
  95730. * Defines the picking info associated to the info (if any)\
  95731. */
  95732. pickInfo: Nullable<PickingInfo>);
  95733. }
  95734. /**
  95735. * Data relating to a touch event on the screen.
  95736. */
  95737. export interface PointerTouch {
  95738. /**
  95739. * X coordinate of touch.
  95740. */
  95741. x: number;
  95742. /**
  95743. * Y coordinate of touch.
  95744. */
  95745. y: number;
  95746. /**
  95747. * Id of touch. Unique for each finger.
  95748. */
  95749. pointerId: number;
  95750. /**
  95751. * Event type passed from DOM.
  95752. */
  95753. type: any;
  95754. }
  95755. }
  95756. declare module BABYLON {
  95757. /**
  95758. * Manage the mouse inputs to control the movement of a free camera.
  95759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95760. */
  95761. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  95762. /**
  95763. * Define if touch is enabled in the mouse input
  95764. */
  95765. touchEnabled: boolean;
  95766. /**
  95767. * Defines the camera the input is attached to.
  95768. */
  95769. camera: FreeCamera;
  95770. /**
  95771. * Defines the buttons associated with the input to handle camera move.
  95772. */
  95773. buttons: number[];
  95774. /**
  95775. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  95776. */
  95777. angularSensibility: number;
  95778. private _pointerInput;
  95779. private _onMouseMove;
  95780. private _observer;
  95781. private previousPosition;
  95782. /**
  95783. * Observable for when a pointer move event occurs containing the move offset
  95784. */
  95785. onPointerMovedObservable: Observable<{
  95786. offsetX: number;
  95787. offsetY: number;
  95788. }>;
  95789. /**
  95790. * @hidden
  95791. * If the camera should be rotated automatically based on pointer movement
  95792. */
  95793. _allowCameraRotation: boolean;
  95794. /**
  95795. * Manage the mouse inputs to control the movement of a free camera.
  95796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95797. * @param touchEnabled Defines if touch is enabled or not
  95798. */
  95799. constructor(
  95800. /**
  95801. * Define if touch is enabled in the mouse input
  95802. */
  95803. touchEnabled?: boolean);
  95804. /**
  95805. * Attach the input controls to a specific dom element to get the input from.
  95806. * @param element Defines the element the controls should be listened from
  95807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95808. */
  95809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95810. /**
  95811. * Called on JS contextmenu event.
  95812. * Override this method to provide functionality.
  95813. */
  95814. protected onContextMenu(evt: PointerEvent): void;
  95815. /**
  95816. * Detach the current controls from the specified dom element.
  95817. * @param element Defines the element to stop listening the inputs from
  95818. */
  95819. detachControl(element: Nullable<HTMLElement>): void;
  95820. /**
  95821. * Gets the class name of the current intput.
  95822. * @returns the class name
  95823. */
  95824. getClassName(): string;
  95825. /**
  95826. * Get the friendly name associated with the input class.
  95827. * @returns the input friendly name
  95828. */
  95829. getSimpleName(): string;
  95830. }
  95831. }
  95832. declare module BABYLON {
  95833. /**
  95834. * Manage the touch inputs to control the movement of a free camera.
  95835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95836. */
  95837. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  95838. /**
  95839. * Defines the camera the input is attached to.
  95840. */
  95841. camera: FreeCamera;
  95842. /**
  95843. * Defines the touch sensibility for rotation.
  95844. * The higher the faster.
  95845. */
  95846. touchAngularSensibility: number;
  95847. /**
  95848. * Defines the touch sensibility for move.
  95849. * The higher the faster.
  95850. */
  95851. touchMoveSensibility: number;
  95852. private _offsetX;
  95853. private _offsetY;
  95854. private _pointerPressed;
  95855. private _pointerInput;
  95856. private _observer;
  95857. private _onLostFocus;
  95858. /**
  95859. * Attach the input controls to a specific dom element to get the input from.
  95860. * @param element Defines the element the controls should be listened from
  95861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95862. */
  95863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95864. /**
  95865. * Detach the current controls from the specified dom element.
  95866. * @param element Defines the element to stop listening the inputs from
  95867. */
  95868. detachControl(element: Nullable<HTMLElement>): void;
  95869. /**
  95870. * Update the current camera state depending on the inputs that have been used this frame.
  95871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95872. */
  95873. checkInputs(): void;
  95874. /**
  95875. * Gets the class name of the current intput.
  95876. * @returns the class name
  95877. */
  95878. getClassName(): string;
  95879. /**
  95880. * Get the friendly name associated with the input class.
  95881. * @returns the input friendly name
  95882. */
  95883. getSimpleName(): string;
  95884. }
  95885. }
  95886. declare module BABYLON {
  95887. /**
  95888. * Default Inputs manager for the FreeCamera.
  95889. * It groups all the default supported inputs for ease of use.
  95890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95891. */
  95892. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  95893. /**
  95894. * @hidden
  95895. */
  95896. _mouseInput: Nullable<FreeCameraMouseInput>;
  95897. /**
  95898. * Instantiates a new FreeCameraInputsManager.
  95899. * @param camera Defines the camera the inputs belong to
  95900. */
  95901. constructor(camera: FreeCamera);
  95902. /**
  95903. * Add keyboard input support to the input manager.
  95904. * @returns the current input manager
  95905. */
  95906. addKeyboard(): FreeCameraInputsManager;
  95907. /**
  95908. * Add mouse input support to the input manager.
  95909. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  95910. * @returns the current input manager
  95911. */
  95912. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  95913. /**
  95914. * Removes the mouse input support from the manager
  95915. * @returns the current input manager
  95916. */
  95917. removeMouse(): FreeCameraInputsManager;
  95918. /**
  95919. * Add touch input support to the input manager.
  95920. * @returns the current input manager
  95921. */
  95922. addTouch(): FreeCameraInputsManager;
  95923. /**
  95924. * Remove all attached input methods from a camera
  95925. */
  95926. clear(): void;
  95927. }
  95928. }
  95929. declare module BABYLON {
  95930. /**
  95931. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95932. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  95933. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95934. */
  95935. export class FreeCamera extends TargetCamera {
  95936. /**
  95937. * Define the collision ellipsoid of the camera.
  95938. * This is helpful to simulate a camera body like the player body around the camera
  95939. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95940. */
  95941. ellipsoid: Vector3;
  95942. /**
  95943. * Define an offset for the position of the ellipsoid around the camera.
  95944. * This can be helpful to determine the center of the body near the gravity center of the body
  95945. * instead of its head.
  95946. */
  95947. ellipsoidOffset: Vector3;
  95948. /**
  95949. * Enable or disable collisions of the camera with the rest of the scene objects.
  95950. */
  95951. checkCollisions: boolean;
  95952. /**
  95953. * Enable or disable gravity on the camera.
  95954. */
  95955. applyGravity: boolean;
  95956. /**
  95957. * Define the input manager associated to the camera.
  95958. */
  95959. inputs: FreeCameraInputsManager;
  95960. /**
  95961. * Gets the input sensibility for a mouse input. (default is 2000.0)
  95962. * Higher values reduce sensitivity.
  95963. */
  95964. get angularSensibility(): number;
  95965. /**
  95966. * Sets the input sensibility for a mouse input. (default is 2000.0)
  95967. * Higher values reduce sensitivity.
  95968. */
  95969. set angularSensibility(value: number);
  95970. /**
  95971. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95972. */
  95973. get keysUp(): number[];
  95974. set keysUp(value: number[]);
  95975. /**
  95976. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95977. */
  95978. get keysUpward(): number[];
  95979. set keysUpward(value: number[]);
  95980. /**
  95981. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95982. */
  95983. get keysDown(): number[];
  95984. set keysDown(value: number[]);
  95985. /**
  95986. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95987. */
  95988. get keysDownward(): number[];
  95989. set keysDownward(value: number[]);
  95990. /**
  95991. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95992. */
  95993. get keysLeft(): number[];
  95994. set keysLeft(value: number[]);
  95995. /**
  95996. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95997. */
  95998. get keysRight(): number[];
  95999. set keysRight(value: number[]);
  96000. /**
  96001. * Event raised when the camera collide with a mesh in the scene.
  96002. */
  96003. onCollide: (collidedMesh: AbstractMesh) => void;
  96004. private _collider;
  96005. private _needMoveForGravity;
  96006. private _oldPosition;
  96007. private _diffPosition;
  96008. private _newPosition;
  96009. /** @hidden */
  96010. _localDirection: Vector3;
  96011. /** @hidden */
  96012. _transformedDirection: Vector3;
  96013. /**
  96014. * Instantiates a Free Camera.
  96015. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96016. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96018. * @param name Define the name of the camera in the scene
  96019. * @param position Define the start position of the camera in the scene
  96020. * @param scene Define the scene the camera belongs to
  96021. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96022. */
  96023. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96024. /**
  96025. * Attached controls to the current camera.
  96026. * @param element Defines the element the controls should be listened from
  96027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96028. */
  96029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96030. /**
  96031. * Detach the current controls from the camera.
  96032. * The camera will stop reacting to inputs.
  96033. * @param element Defines the element to stop listening the inputs from
  96034. */
  96035. detachControl(element: HTMLElement): void;
  96036. private _collisionMask;
  96037. /**
  96038. * Define a collision mask to limit the list of object the camera can collide with
  96039. */
  96040. get collisionMask(): number;
  96041. set collisionMask(mask: number);
  96042. /** @hidden */
  96043. _collideWithWorld(displacement: Vector3): void;
  96044. private _onCollisionPositionChange;
  96045. /** @hidden */
  96046. _checkInputs(): void;
  96047. /** @hidden */
  96048. _decideIfNeedsToMove(): boolean;
  96049. /** @hidden */
  96050. _updatePosition(): void;
  96051. /**
  96052. * Destroy the camera and release the current resources hold by it.
  96053. */
  96054. dispose(): void;
  96055. /**
  96056. * Gets the current object class name.
  96057. * @return the class name
  96058. */
  96059. getClassName(): string;
  96060. }
  96061. }
  96062. declare module BABYLON {
  96063. /**
  96064. * Represents a gamepad control stick position
  96065. */
  96066. export class StickValues {
  96067. /**
  96068. * The x component of the control stick
  96069. */
  96070. x: number;
  96071. /**
  96072. * The y component of the control stick
  96073. */
  96074. y: number;
  96075. /**
  96076. * Initializes the gamepad x and y control stick values
  96077. * @param x The x component of the gamepad control stick value
  96078. * @param y The y component of the gamepad control stick value
  96079. */
  96080. constructor(
  96081. /**
  96082. * The x component of the control stick
  96083. */
  96084. x: number,
  96085. /**
  96086. * The y component of the control stick
  96087. */
  96088. y: number);
  96089. }
  96090. /**
  96091. * An interface which manages callbacks for gamepad button changes
  96092. */
  96093. export interface GamepadButtonChanges {
  96094. /**
  96095. * Called when a gamepad has been changed
  96096. */
  96097. changed: boolean;
  96098. /**
  96099. * Called when a gamepad press event has been triggered
  96100. */
  96101. pressChanged: boolean;
  96102. /**
  96103. * Called when a touch event has been triggered
  96104. */
  96105. touchChanged: boolean;
  96106. /**
  96107. * Called when a value has changed
  96108. */
  96109. valueChanged: boolean;
  96110. }
  96111. /**
  96112. * Represents a gamepad
  96113. */
  96114. export class Gamepad {
  96115. /**
  96116. * The id of the gamepad
  96117. */
  96118. id: string;
  96119. /**
  96120. * The index of the gamepad
  96121. */
  96122. index: number;
  96123. /**
  96124. * The browser gamepad
  96125. */
  96126. browserGamepad: any;
  96127. /**
  96128. * Specifies what type of gamepad this represents
  96129. */
  96130. type: number;
  96131. private _leftStick;
  96132. private _rightStick;
  96133. /** @hidden */
  96134. _isConnected: boolean;
  96135. private _leftStickAxisX;
  96136. private _leftStickAxisY;
  96137. private _rightStickAxisX;
  96138. private _rightStickAxisY;
  96139. /**
  96140. * Triggered when the left control stick has been changed
  96141. */
  96142. private _onleftstickchanged;
  96143. /**
  96144. * Triggered when the right control stick has been changed
  96145. */
  96146. private _onrightstickchanged;
  96147. /**
  96148. * Represents a gamepad controller
  96149. */
  96150. static GAMEPAD: number;
  96151. /**
  96152. * Represents a generic controller
  96153. */
  96154. static GENERIC: number;
  96155. /**
  96156. * Represents an XBox controller
  96157. */
  96158. static XBOX: number;
  96159. /**
  96160. * Represents a pose-enabled controller
  96161. */
  96162. static POSE_ENABLED: number;
  96163. /**
  96164. * Represents an Dual Shock controller
  96165. */
  96166. static DUALSHOCK: number;
  96167. /**
  96168. * Specifies whether the left control stick should be Y-inverted
  96169. */
  96170. protected _invertLeftStickY: boolean;
  96171. /**
  96172. * Specifies if the gamepad has been connected
  96173. */
  96174. get isConnected(): boolean;
  96175. /**
  96176. * Initializes the gamepad
  96177. * @param id The id of the gamepad
  96178. * @param index The index of the gamepad
  96179. * @param browserGamepad The browser gamepad
  96180. * @param leftStickX The x component of the left joystick
  96181. * @param leftStickY The y component of the left joystick
  96182. * @param rightStickX The x component of the right joystick
  96183. * @param rightStickY The y component of the right joystick
  96184. */
  96185. constructor(
  96186. /**
  96187. * The id of the gamepad
  96188. */
  96189. id: string,
  96190. /**
  96191. * The index of the gamepad
  96192. */
  96193. index: number,
  96194. /**
  96195. * The browser gamepad
  96196. */
  96197. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96198. /**
  96199. * Callback triggered when the left joystick has changed
  96200. * @param callback
  96201. */
  96202. onleftstickchanged(callback: (values: StickValues) => void): void;
  96203. /**
  96204. * Callback triggered when the right joystick has changed
  96205. * @param callback
  96206. */
  96207. onrightstickchanged(callback: (values: StickValues) => void): void;
  96208. /**
  96209. * Gets the left joystick
  96210. */
  96211. get leftStick(): StickValues;
  96212. /**
  96213. * Sets the left joystick values
  96214. */
  96215. set leftStick(newValues: StickValues);
  96216. /**
  96217. * Gets the right joystick
  96218. */
  96219. get rightStick(): StickValues;
  96220. /**
  96221. * Sets the right joystick value
  96222. */
  96223. set rightStick(newValues: StickValues);
  96224. /**
  96225. * Updates the gamepad joystick positions
  96226. */
  96227. update(): void;
  96228. /**
  96229. * Disposes the gamepad
  96230. */
  96231. dispose(): void;
  96232. }
  96233. /**
  96234. * Represents a generic gamepad
  96235. */
  96236. export class GenericPad extends Gamepad {
  96237. private _buttons;
  96238. private _onbuttondown;
  96239. private _onbuttonup;
  96240. /**
  96241. * Observable triggered when a button has been pressed
  96242. */
  96243. onButtonDownObservable: Observable<number>;
  96244. /**
  96245. * Observable triggered when a button has been released
  96246. */
  96247. onButtonUpObservable: Observable<number>;
  96248. /**
  96249. * Callback triggered when a button has been pressed
  96250. * @param callback Called when a button has been pressed
  96251. */
  96252. onbuttondown(callback: (buttonPressed: number) => void): void;
  96253. /**
  96254. * Callback triggered when a button has been released
  96255. * @param callback Called when a button has been released
  96256. */
  96257. onbuttonup(callback: (buttonReleased: number) => void): void;
  96258. /**
  96259. * Initializes the generic gamepad
  96260. * @param id The id of the generic gamepad
  96261. * @param index The index of the generic gamepad
  96262. * @param browserGamepad The browser gamepad
  96263. */
  96264. constructor(id: string, index: number, browserGamepad: any);
  96265. private _setButtonValue;
  96266. /**
  96267. * Updates the generic gamepad
  96268. */
  96269. update(): void;
  96270. /**
  96271. * Disposes the generic gamepad
  96272. */
  96273. dispose(): void;
  96274. }
  96275. }
  96276. declare module BABYLON {
  96277. /**
  96278. * Defines the types of pose enabled controllers that are supported
  96279. */
  96280. export enum PoseEnabledControllerType {
  96281. /**
  96282. * HTC Vive
  96283. */
  96284. VIVE = 0,
  96285. /**
  96286. * Oculus Rift
  96287. */
  96288. OCULUS = 1,
  96289. /**
  96290. * Windows mixed reality
  96291. */
  96292. WINDOWS = 2,
  96293. /**
  96294. * Samsung gear VR
  96295. */
  96296. GEAR_VR = 3,
  96297. /**
  96298. * Google Daydream
  96299. */
  96300. DAYDREAM = 4,
  96301. /**
  96302. * Generic
  96303. */
  96304. GENERIC = 5
  96305. }
  96306. /**
  96307. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96308. */
  96309. export interface MutableGamepadButton {
  96310. /**
  96311. * Value of the button/trigger
  96312. */
  96313. value: number;
  96314. /**
  96315. * If the button/trigger is currently touched
  96316. */
  96317. touched: boolean;
  96318. /**
  96319. * If the button/trigger is currently pressed
  96320. */
  96321. pressed: boolean;
  96322. }
  96323. /**
  96324. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96325. * @hidden
  96326. */
  96327. export interface ExtendedGamepadButton extends GamepadButton {
  96328. /**
  96329. * If the button/trigger is currently pressed
  96330. */
  96331. readonly pressed: boolean;
  96332. /**
  96333. * If the button/trigger is currently touched
  96334. */
  96335. readonly touched: boolean;
  96336. /**
  96337. * Value of the button/trigger
  96338. */
  96339. readonly value: number;
  96340. }
  96341. /** @hidden */
  96342. export interface _GamePadFactory {
  96343. /**
  96344. * Returns whether or not the current gamepad can be created for this type of controller.
  96345. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96346. * @returns true if it can be created, otherwise false
  96347. */
  96348. canCreate(gamepadInfo: any): boolean;
  96349. /**
  96350. * Creates a new instance of the Gamepad.
  96351. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96352. * @returns the new gamepad instance
  96353. */
  96354. create(gamepadInfo: any): Gamepad;
  96355. }
  96356. /**
  96357. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96358. */
  96359. export class PoseEnabledControllerHelper {
  96360. /** @hidden */
  96361. static _ControllerFactories: _GamePadFactory[];
  96362. /** @hidden */
  96363. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96364. /**
  96365. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96366. * @param vrGamepad the gamepad to initialized
  96367. * @returns a vr controller of the type the gamepad identified as
  96368. */
  96369. static InitiateController(vrGamepad: any): Gamepad;
  96370. }
  96371. /**
  96372. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96373. */
  96374. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96375. /**
  96376. * If the controller is used in a webXR session
  96377. */
  96378. isXR: boolean;
  96379. private _deviceRoomPosition;
  96380. private _deviceRoomRotationQuaternion;
  96381. /**
  96382. * The device position in babylon space
  96383. */
  96384. devicePosition: Vector3;
  96385. /**
  96386. * The device rotation in babylon space
  96387. */
  96388. deviceRotationQuaternion: Quaternion;
  96389. /**
  96390. * The scale factor of the device in babylon space
  96391. */
  96392. deviceScaleFactor: number;
  96393. /**
  96394. * (Likely devicePosition should be used instead) The device position in its room space
  96395. */
  96396. position: Vector3;
  96397. /**
  96398. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96399. */
  96400. rotationQuaternion: Quaternion;
  96401. /**
  96402. * The type of controller (Eg. Windows mixed reality)
  96403. */
  96404. controllerType: PoseEnabledControllerType;
  96405. protected _calculatedPosition: Vector3;
  96406. private _calculatedRotation;
  96407. /**
  96408. * The raw pose from the device
  96409. */
  96410. rawPose: DevicePose;
  96411. private _trackPosition;
  96412. private _maxRotationDistFromHeadset;
  96413. private _draggedRoomRotation;
  96414. /**
  96415. * @hidden
  96416. */
  96417. _disableTrackPosition(fixedPosition: Vector3): void;
  96418. /**
  96419. * Internal, the mesh attached to the controller
  96420. * @hidden
  96421. */
  96422. _mesh: Nullable<AbstractMesh>;
  96423. private _poseControlledCamera;
  96424. private _leftHandSystemQuaternion;
  96425. /**
  96426. * Internal, matrix used to convert room space to babylon space
  96427. * @hidden
  96428. */
  96429. _deviceToWorld: Matrix;
  96430. /**
  96431. * Node to be used when casting a ray from the controller
  96432. * @hidden
  96433. */
  96434. _pointingPoseNode: Nullable<TransformNode>;
  96435. /**
  96436. * Name of the child mesh that can be used to cast a ray from the controller
  96437. */
  96438. static readonly POINTING_POSE: string;
  96439. /**
  96440. * Creates a new PoseEnabledController from a gamepad
  96441. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96442. */
  96443. constructor(browserGamepad: any);
  96444. private _workingMatrix;
  96445. /**
  96446. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96447. */
  96448. update(): void;
  96449. /**
  96450. * Updates only the pose device and mesh without doing any button event checking
  96451. */
  96452. protected _updatePoseAndMesh(): void;
  96453. /**
  96454. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96455. * @param poseData raw pose fromthe device
  96456. */
  96457. updateFromDevice(poseData: DevicePose): void;
  96458. /**
  96459. * @hidden
  96460. */
  96461. _meshAttachedObservable: Observable<AbstractMesh>;
  96462. /**
  96463. * Attaches a mesh to the controller
  96464. * @param mesh the mesh to be attached
  96465. */
  96466. attachToMesh(mesh: AbstractMesh): void;
  96467. /**
  96468. * Attaches the controllers mesh to a camera
  96469. * @param camera the camera the mesh should be attached to
  96470. */
  96471. attachToPoseControlledCamera(camera: TargetCamera): void;
  96472. /**
  96473. * Disposes of the controller
  96474. */
  96475. dispose(): void;
  96476. /**
  96477. * The mesh that is attached to the controller
  96478. */
  96479. get mesh(): Nullable<AbstractMesh>;
  96480. /**
  96481. * Gets the ray of the controller in the direction the controller is pointing
  96482. * @param length the length the resulting ray should be
  96483. * @returns a ray in the direction the controller is pointing
  96484. */
  96485. getForwardRay(length?: number): Ray;
  96486. }
  96487. }
  96488. declare module BABYLON {
  96489. /**
  96490. * Defines the WebVRController object that represents controllers tracked in 3D space
  96491. */
  96492. export abstract class WebVRController extends PoseEnabledController {
  96493. /**
  96494. * Internal, the default controller model for the controller
  96495. */
  96496. protected _defaultModel: Nullable<AbstractMesh>;
  96497. /**
  96498. * Fired when the trigger state has changed
  96499. */
  96500. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96501. /**
  96502. * Fired when the main button state has changed
  96503. */
  96504. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96505. /**
  96506. * Fired when the secondary button state has changed
  96507. */
  96508. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96509. /**
  96510. * Fired when the pad state has changed
  96511. */
  96512. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96513. /**
  96514. * Fired when controllers stick values have changed
  96515. */
  96516. onPadValuesChangedObservable: Observable<StickValues>;
  96517. /**
  96518. * Array of button availible on the controller
  96519. */
  96520. protected _buttons: Array<MutableGamepadButton>;
  96521. private _onButtonStateChange;
  96522. /**
  96523. * Fired when a controller button's state has changed
  96524. * @param callback the callback containing the button that was modified
  96525. */
  96526. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96527. /**
  96528. * X and Y axis corresponding to the controllers joystick
  96529. */
  96530. pad: StickValues;
  96531. /**
  96532. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96533. */
  96534. hand: string;
  96535. /**
  96536. * The default controller model for the controller
  96537. */
  96538. get defaultModel(): Nullable<AbstractMesh>;
  96539. /**
  96540. * Creates a new WebVRController from a gamepad
  96541. * @param vrGamepad the gamepad that the WebVRController should be created from
  96542. */
  96543. constructor(vrGamepad: any);
  96544. /**
  96545. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  96546. */
  96547. update(): void;
  96548. /**
  96549. * Function to be called when a button is modified
  96550. */
  96551. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96552. /**
  96553. * Loads a mesh and attaches it to the controller
  96554. * @param scene the scene the mesh should be added to
  96555. * @param meshLoaded callback for when the mesh has been loaded
  96556. */
  96557. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96558. private _setButtonValue;
  96559. private _changes;
  96560. private _checkChanges;
  96561. /**
  96562. * Disposes of th webVRCOntroller
  96563. */
  96564. dispose(): void;
  96565. }
  96566. }
  96567. declare module BABYLON {
  96568. /**
  96569. * The HemisphericLight simulates the ambient environment light,
  96570. * so the passed direction is the light reflection direction, not the incoming direction.
  96571. */
  96572. export class HemisphericLight extends Light {
  96573. /**
  96574. * The groundColor is the light in the opposite direction to the one specified during creation.
  96575. * 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.
  96576. */
  96577. groundColor: Color3;
  96578. /**
  96579. * The light reflection direction, not the incoming direction.
  96580. */
  96581. direction: Vector3;
  96582. /**
  96583. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  96584. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  96585. * The HemisphericLight can't cast shadows.
  96586. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96587. * @param name The friendly name of the light
  96588. * @param direction The direction of the light reflection
  96589. * @param scene The scene the light belongs to
  96590. */
  96591. constructor(name: string, direction: Vector3, scene: Scene);
  96592. protected _buildUniformLayout(): void;
  96593. /**
  96594. * Returns the string "HemisphericLight".
  96595. * @return The class name
  96596. */
  96597. getClassName(): string;
  96598. /**
  96599. * Sets the HemisphericLight direction towards the passed target (Vector3).
  96600. * Returns the updated direction.
  96601. * @param target The target the direction should point to
  96602. * @return The computed direction
  96603. */
  96604. setDirectionToTarget(target: Vector3): Vector3;
  96605. /**
  96606. * Returns the shadow generator associated to the light.
  96607. * @returns Always null for hemispheric lights because it does not support shadows.
  96608. */
  96609. getShadowGenerator(): Nullable<IShadowGenerator>;
  96610. /**
  96611. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  96612. * @param effect The effect to update
  96613. * @param lightIndex The index of the light in the effect to update
  96614. * @returns The hemispheric light
  96615. */
  96616. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  96617. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  96618. /**
  96619. * Computes the world matrix of the node
  96620. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96621. * @param useWasUpdatedFlag defines a reserved property
  96622. * @returns the world matrix
  96623. */
  96624. computeWorldMatrix(): Matrix;
  96625. /**
  96626. * Returns the integer 3.
  96627. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96628. */
  96629. getTypeID(): number;
  96630. /**
  96631. * Prepares the list of defines specific to the light type.
  96632. * @param defines the list of defines
  96633. * @param lightIndex defines the index of the light for the effect
  96634. */
  96635. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96636. }
  96637. }
  96638. declare module BABYLON {
  96639. /** @hidden */
  96640. export var vrMultiviewToSingleviewPixelShader: {
  96641. name: string;
  96642. shader: string;
  96643. };
  96644. }
  96645. declare module BABYLON {
  96646. /**
  96647. * Renders to multiple views with a single draw call
  96648. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  96649. */
  96650. export class MultiviewRenderTarget extends RenderTargetTexture {
  96651. /**
  96652. * Creates a multiview render target
  96653. * @param scene scene used with the render target
  96654. * @param size the size of the render target (used for each view)
  96655. */
  96656. constructor(scene: Scene, size?: number | {
  96657. width: number;
  96658. height: number;
  96659. } | {
  96660. ratio: number;
  96661. });
  96662. /**
  96663. * @hidden
  96664. * @param faceIndex the face index, if its a cube texture
  96665. */
  96666. _bindFrameBuffer(faceIndex?: number): void;
  96667. /**
  96668. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96669. * @returns the view count
  96670. */
  96671. getViewCount(): number;
  96672. }
  96673. }
  96674. declare module BABYLON {
  96675. interface Engine {
  96676. /**
  96677. * Creates a new multiview render target
  96678. * @param width defines the width of the texture
  96679. * @param height defines the height of the texture
  96680. * @returns the created multiview texture
  96681. */
  96682. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  96683. /**
  96684. * Binds a multiview framebuffer to be drawn to
  96685. * @param multiviewTexture texture to bind
  96686. */
  96687. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  96688. }
  96689. interface Camera {
  96690. /**
  96691. * @hidden
  96692. * 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)
  96693. */
  96694. _useMultiviewToSingleView: boolean;
  96695. /**
  96696. * @hidden
  96697. * 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)
  96698. */
  96699. _multiviewTexture: Nullable<RenderTargetTexture>;
  96700. /**
  96701. * @hidden
  96702. * ensures the multiview texture of the camera exists and has the specified width/height
  96703. * @param width height to set on the multiview texture
  96704. * @param height width to set on the multiview texture
  96705. */
  96706. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  96707. }
  96708. interface Scene {
  96709. /** @hidden */
  96710. _transformMatrixR: Matrix;
  96711. /** @hidden */
  96712. _multiviewSceneUbo: Nullable<UniformBuffer>;
  96713. /** @hidden */
  96714. _createMultiviewUbo(): void;
  96715. /** @hidden */
  96716. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  96717. /** @hidden */
  96718. _renderMultiviewToSingleView(camera: Camera): void;
  96719. }
  96720. }
  96721. declare module BABYLON {
  96722. /**
  96723. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  96724. * This will not be used for webXR as it supports displaying texture arrays directly
  96725. */
  96726. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  96727. /**
  96728. * Initializes a VRMultiviewToSingleview
  96729. * @param name name of the post process
  96730. * @param camera camera to be applied to
  96731. * @param scaleFactor scaling factor to the size of the output texture
  96732. */
  96733. constructor(name: string, camera: Camera, scaleFactor: number);
  96734. }
  96735. }
  96736. declare module BABYLON {
  96737. /**
  96738. * Interface used to define additional presentation attributes
  96739. */
  96740. export interface IVRPresentationAttributes {
  96741. /**
  96742. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  96743. */
  96744. highRefreshRate: boolean;
  96745. /**
  96746. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  96747. */
  96748. foveationLevel: number;
  96749. }
  96750. interface Engine {
  96751. /** @hidden */
  96752. _vrDisplay: any;
  96753. /** @hidden */
  96754. _vrSupported: boolean;
  96755. /** @hidden */
  96756. _oldSize: Size;
  96757. /** @hidden */
  96758. _oldHardwareScaleFactor: number;
  96759. /** @hidden */
  96760. _vrExclusivePointerMode: boolean;
  96761. /** @hidden */
  96762. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  96763. /** @hidden */
  96764. _onVRDisplayPointerRestricted: () => void;
  96765. /** @hidden */
  96766. _onVRDisplayPointerUnrestricted: () => void;
  96767. /** @hidden */
  96768. _onVrDisplayConnect: Nullable<(display: any) => void>;
  96769. /** @hidden */
  96770. _onVrDisplayDisconnect: Nullable<() => void>;
  96771. /** @hidden */
  96772. _onVrDisplayPresentChange: Nullable<() => void>;
  96773. /**
  96774. * Observable signaled when VR display mode changes
  96775. */
  96776. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  96777. /**
  96778. * Observable signaled when VR request present is complete
  96779. */
  96780. onVRRequestPresentComplete: Observable<boolean>;
  96781. /**
  96782. * Observable signaled when VR request present starts
  96783. */
  96784. onVRRequestPresentStart: Observable<Engine>;
  96785. /**
  96786. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  96787. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  96788. */
  96789. isInVRExclusivePointerMode: boolean;
  96790. /**
  96791. * Gets a boolean indicating if a webVR device was detected
  96792. * @returns true if a webVR device was detected
  96793. */
  96794. isVRDevicePresent(): boolean;
  96795. /**
  96796. * Gets the current webVR device
  96797. * @returns the current webVR device (or null)
  96798. */
  96799. getVRDevice(): any;
  96800. /**
  96801. * Initializes a webVR display and starts listening to display change events
  96802. * The onVRDisplayChangedObservable will be notified upon these changes
  96803. * @returns A promise containing a VRDisplay and if vr is supported
  96804. */
  96805. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  96806. /** @hidden */
  96807. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  96808. /**
  96809. * Gets or sets the presentation attributes used to configure VR rendering
  96810. */
  96811. vrPresentationAttributes?: IVRPresentationAttributes;
  96812. /**
  96813. * Call this function to switch to webVR mode
  96814. * Will do nothing if webVR is not supported or if there is no webVR device
  96815. * @param options the webvr options provided to the camera. mainly used for multiview
  96816. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96817. */
  96818. enableVR(options: WebVROptions): void;
  96819. /** @hidden */
  96820. _onVRFullScreenTriggered(): void;
  96821. }
  96822. }
  96823. declare module BABYLON {
  96824. /**
  96825. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  96826. * IMPORTANT!! The data is right-hand data.
  96827. * @export
  96828. * @interface DevicePose
  96829. */
  96830. export interface DevicePose {
  96831. /**
  96832. * The position of the device, values in array are [x,y,z].
  96833. */
  96834. readonly position: Nullable<Float32Array>;
  96835. /**
  96836. * The linearVelocity of the device, values in array are [x,y,z].
  96837. */
  96838. readonly linearVelocity: Nullable<Float32Array>;
  96839. /**
  96840. * The linearAcceleration of the device, values in array are [x,y,z].
  96841. */
  96842. readonly linearAcceleration: Nullable<Float32Array>;
  96843. /**
  96844. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  96845. */
  96846. readonly orientation: Nullable<Float32Array>;
  96847. /**
  96848. * The angularVelocity of the device, values in array are [x,y,z].
  96849. */
  96850. readonly angularVelocity: Nullable<Float32Array>;
  96851. /**
  96852. * The angularAcceleration of the device, values in array are [x,y,z].
  96853. */
  96854. readonly angularAcceleration: Nullable<Float32Array>;
  96855. }
  96856. /**
  96857. * Interface representing a pose controlled object in Babylon.
  96858. * A pose controlled object has both regular pose values as well as pose values
  96859. * from an external device such as a VR head mounted display
  96860. */
  96861. export interface PoseControlled {
  96862. /**
  96863. * The position of the object in babylon space.
  96864. */
  96865. position: Vector3;
  96866. /**
  96867. * The rotation quaternion of the object in babylon space.
  96868. */
  96869. rotationQuaternion: Quaternion;
  96870. /**
  96871. * The position of the device in babylon space.
  96872. */
  96873. devicePosition?: Vector3;
  96874. /**
  96875. * The rotation quaternion of the device in babylon space.
  96876. */
  96877. deviceRotationQuaternion: Quaternion;
  96878. /**
  96879. * The raw pose coming from the device.
  96880. */
  96881. rawPose: Nullable<DevicePose>;
  96882. /**
  96883. * The scale of the device to be used when translating from device space to babylon space.
  96884. */
  96885. deviceScaleFactor: number;
  96886. /**
  96887. * Updates the poseControlled values based on the input device pose.
  96888. * @param poseData the pose data to update the object with
  96889. */
  96890. updateFromDevice(poseData: DevicePose): void;
  96891. }
  96892. /**
  96893. * Set of options to customize the webVRCamera
  96894. */
  96895. export interface WebVROptions {
  96896. /**
  96897. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  96898. */
  96899. trackPosition?: boolean;
  96900. /**
  96901. * Sets the scale of the vrDevice in babylon space. (default: 1)
  96902. */
  96903. positionScale?: number;
  96904. /**
  96905. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  96906. */
  96907. displayName?: string;
  96908. /**
  96909. * Should the native controller meshes be initialized. (default: true)
  96910. */
  96911. controllerMeshes?: boolean;
  96912. /**
  96913. * Creating a default HemiLight only on controllers. (default: true)
  96914. */
  96915. defaultLightingOnControllers?: boolean;
  96916. /**
  96917. * If you don't want to use the default VR button of the helper. (default: false)
  96918. */
  96919. useCustomVRButton?: boolean;
  96920. /**
  96921. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  96922. */
  96923. customVRButton?: HTMLButtonElement;
  96924. /**
  96925. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  96926. */
  96927. rayLength?: number;
  96928. /**
  96929. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  96930. */
  96931. defaultHeight?: number;
  96932. /**
  96933. * If multiview should be used if availible (default: false)
  96934. */
  96935. useMultiview?: boolean;
  96936. }
  96937. /**
  96938. * This represents a WebVR camera.
  96939. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  96940. * @example http://doc.babylonjs.com/how_to/webvr_camera
  96941. */
  96942. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  96943. private webVROptions;
  96944. /**
  96945. * @hidden
  96946. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  96947. */
  96948. _vrDevice: any;
  96949. /**
  96950. * The rawPose of the vrDevice.
  96951. */
  96952. rawPose: Nullable<DevicePose>;
  96953. private _onVREnabled;
  96954. private _specsVersion;
  96955. private _attached;
  96956. private _frameData;
  96957. protected _descendants: Array<Node>;
  96958. private _deviceRoomPosition;
  96959. /** @hidden */
  96960. _deviceRoomRotationQuaternion: Quaternion;
  96961. private _standingMatrix;
  96962. /**
  96963. * Represents device position in babylon space.
  96964. */
  96965. devicePosition: Vector3;
  96966. /**
  96967. * Represents device rotation in babylon space.
  96968. */
  96969. deviceRotationQuaternion: Quaternion;
  96970. /**
  96971. * The scale of the device to be used when translating from device space to babylon space.
  96972. */
  96973. deviceScaleFactor: number;
  96974. private _deviceToWorld;
  96975. private _worldToDevice;
  96976. /**
  96977. * References to the webVR controllers for the vrDevice.
  96978. */
  96979. controllers: Array<WebVRController>;
  96980. /**
  96981. * Emits an event when a controller is attached.
  96982. */
  96983. onControllersAttachedObservable: Observable<WebVRController[]>;
  96984. /**
  96985. * Emits an event when a controller's mesh has been loaded;
  96986. */
  96987. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96988. /**
  96989. * Emits an event when the HMD's pose has been updated.
  96990. */
  96991. onPoseUpdatedFromDeviceObservable: Observable<any>;
  96992. private _poseSet;
  96993. /**
  96994. * If the rig cameras be used as parent instead of this camera.
  96995. */
  96996. rigParenting: boolean;
  96997. private _lightOnControllers;
  96998. private _defaultHeight?;
  96999. /**
  97000. * Instantiates a WebVRFreeCamera.
  97001. * @param name The name of the WebVRFreeCamera
  97002. * @param position The starting anchor position for the camera
  97003. * @param scene The scene the camera belongs to
  97004. * @param webVROptions a set of customizable options for the webVRCamera
  97005. */
  97006. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97007. /**
  97008. * Gets the device distance from the ground in meters.
  97009. * @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.
  97010. */
  97011. deviceDistanceToRoomGround(): number;
  97012. /**
  97013. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97014. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97015. */
  97016. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97017. /**
  97018. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97019. * @returns A promise with a boolean set to if the standing matrix is supported.
  97020. */
  97021. useStandingMatrixAsync(): Promise<boolean>;
  97022. /**
  97023. * Disposes the camera
  97024. */
  97025. dispose(): void;
  97026. /**
  97027. * Gets a vrController by name.
  97028. * @param name The name of the controller to retreive
  97029. * @returns the controller matching the name specified or null if not found
  97030. */
  97031. getControllerByName(name: string): Nullable<WebVRController>;
  97032. private _leftController;
  97033. /**
  97034. * The controller corresponding to the users left hand.
  97035. */
  97036. get leftController(): Nullable<WebVRController>;
  97037. private _rightController;
  97038. /**
  97039. * The controller corresponding to the users right hand.
  97040. */
  97041. get rightController(): Nullable<WebVRController>;
  97042. /**
  97043. * Casts a ray forward from the vrCamera's gaze.
  97044. * @param length Length of the ray (default: 100)
  97045. * @returns the ray corresponding to the gaze
  97046. */
  97047. getForwardRay(length?: number): Ray;
  97048. /**
  97049. * @hidden
  97050. * Updates the camera based on device's frame data
  97051. */
  97052. _checkInputs(): void;
  97053. /**
  97054. * Updates the poseControlled values based on the input device pose.
  97055. * @param poseData Pose coming from the device
  97056. */
  97057. updateFromDevice(poseData: DevicePose): void;
  97058. private _htmlElementAttached;
  97059. private _detachIfAttached;
  97060. /**
  97061. * WebVR's attach control will start broadcasting frames to the device.
  97062. * Note that in certain browsers (chrome for example) this function must be called
  97063. * within a user-interaction callback. Example:
  97064. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97065. *
  97066. * @param element html element to attach the vrDevice to
  97067. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97068. */
  97069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97070. /**
  97071. * Detaches the camera from the html element and disables VR
  97072. *
  97073. * @param element html element to detach from
  97074. */
  97075. detachControl(element: HTMLElement): void;
  97076. /**
  97077. * @returns the name of this class
  97078. */
  97079. getClassName(): string;
  97080. /**
  97081. * Calls resetPose on the vrDisplay
  97082. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97083. */
  97084. resetToCurrentRotation(): void;
  97085. /**
  97086. * @hidden
  97087. * Updates the rig cameras (left and right eye)
  97088. */
  97089. _updateRigCameras(): void;
  97090. private _workingVector;
  97091. private _oneVector;
  97092. private _workingMatrix;
  97093. private updateCacheCalled;
  97094. private _correctPositionIfNotTrackPosition;
  97095. /**
  97096. * @hidden
  97097. * Updates the cached values of the camera
  97098. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97099. */
  97100. _updateCache(ignoreParentClass?: boolean): void;
  97101. /**
  97102. * @hidden
  97103. * Get current device position in babylon world
  97104. */
  97105. _computeDevicePosition(): void;
  97106. /**
  97107. * Updates the current device position and rotation in the babylon world
  97108. */
  97109. update(): void;
  97110. /**
  97111. * @hidden
  97112. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97113. * @returns an identity matrix
  97114. */
  97115. _getViewMatrix(): Matrix;
  97116. private _tmpMatrix;
  97117. /**
  97118. * This function is called by the two RIG cameras.
  97119. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97120. * @hidden
  97121. */
  97122. _getWebVRViewMatrix(): Matrix;
  97123. /** @hidden */
  97124. _getWebVRProjectionMatrix(): Matrix;
  97125. private _onGamepadConnectedObserver;
  97126. private _onGamepadDisconnectedObserver;
  97127. private _updateCacheWhenTrackingDisabledObserver;
  97128. /**
  97129. * Initializes the controllers and their meshes
  97130. */
  97131. initControllers(): void;
  97132. }
  97133. }
  97134. declare module BABYLON {
  97135. /**
  97136. * "Static Class" containing the most commonly used helper while dealing with material for
  97137. * rendering purpose.
  97138. *
  97139. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97140. *
  97141. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97142. */
  97143. export class MaterialHelper {
  97144. /**
  97145. * Bind the current view position to an effect.
  97146. * @param effect The effect to be bound
  97147. * @param scene The scene the eyes position is used from
  97148. * @param variableName name of the shader variable that will hold the eye position
  97149. */
  97150. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97151. /**
  97152. * Helps preparing the defines values about the UVs in used in the effect.
  97153. * UVs are shared as much as we can accross channels in the shaders.
  97154. * @param texture The texture we are preparing the UVs for
  97155. * @param defines The defines to update
  97156. * @param key The channel key "diffuse", "specular"... used in the shader
  97157. */
  97158. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97159. /**
  97160. * Binds a texture matrix value to its corrsponding uniform
  97161. * @param texture The texture to bind the matrix for
  97162. * @param uniformBuffer The uniform buffer receivin the data
  97163. * @param key The channel key "diffuse", "specular"... used in the shader
  97164. */
  97165. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97166. /**
  97167. * Gets the current status of the fog (should it be enabled?)
  97168. * @param mesh defines the mesh to evaluate for fog support
  97169. * @param scene defines the hosting scene
  97170. * @returns true if fog must be enabled
  97171. */
  97172. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97173. /**
  97174. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97175. * @param mesh defines the current mesh
  97176. * @param scene defines the current scene
  97177. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97178. * @param pointsCloud defines if point cloud rendering has to be turned on
  97179. * @param fogEnabled defines if fog has to be turned on
  97180. * @param alphaTest defines if alpha testing has to be turned on
  97181. * @param defines defines the current list of defines
  97182. */
  97183. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97184. /**
  97185. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97186. * @param scene defines the current scene
  97187. * @param engine defines the current engine
  97188. * @param defines specifies the list of active defines
  97189. * @param useInstances defines if instances have to be turned on
  97190. * @param useClipPlane defines if clip plane have to be turned on
  97191. * @param useInstances defines if instances have to be turned on
  97192. * @param useThinInstances defines if thin instances have to be turned on
  97193. */
  97194. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97195. /**
  97196. * Prepares the defines for bones
  97197. * @param mesh The mesh containing the geometry data we will draw
  97198. * @param defines The defines to update
  97199. */
  97200. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97201. /**
  97202. * Prepares the defines for morph targets
  97203. * @param mesh The mesh containing the geometry data we will draw
  97204. * @param defines The defines to update
  97205. */
  97206. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97207. /**
  97208. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97209. * @param mesh The mesh containing the geometry data we will draw
  97210. * @param defines The defines to update
  97211. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97212. * @param useBones Precise whether bones should be used or not (override mesh info)
  97213. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97214. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97215. * @returns false if defines are considered not dirty and have not been checked
  97216. */
  97217. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97218. /**
  97219. * Prepares the defines related to multiview
  97220. * @param scene The scene we are intending to draw
  97221. * @param defines The defines to update
  97222. */
  97223. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97224. /**
  97225. * Prepares the defines related to the light information passed in parameter
  97226. * @param scene The scene we are intending to draw
  97227. * @param mesh The mesh the effect is compiling for
  97228. * @param light The light the effect is compiling for
  97229. * @param lightIndex The index of the light
  97230. * @param defines The defines to update
  97231. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97232. * @param state Defines the current state regarding what is needed (normals, etc...)
  97233. */
  97234. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97235. needNormals: boolean;
  97236. needRebuild: boolean;
  97237. shadowEnabled: boolean;
  97238. specularEnabled: boolean;
  97239. lightmapMode: boolean;
  97240. }): void;
  97241. /**
  97242. * Prepares the defines related to the light information passed in parameter
  97243. * @param scene The scene we are intending to draw
  97244. * @param mesh The mesh the effect is compiling for
  97245. * @param defines The defines to update
  97246. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97247. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97248. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97249. * @returns true if normals will be required for the rest of the effect
  97250. */
  97251. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97252. /**
  97253. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97254. * @param lightIndex defines the light index
  97255. * @param uniformsList The uniform list
  97256. * @param samplersList The sampler list
  97257. * @param projectedLightTexture defines if projected texture must be used
  97258. * @param uniformBuffersList defines an optional list of uniform buffers
  97259. */
  97260. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97261. /**
  97262. * Prepares the uniforms and samplers list to be used in the effect
  97263. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97264. * @param samplersList The sampler list
  97265. * @param defines The defines helping in the list generation
  97266. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97267. */
  97268. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97269. /**
  97270. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97271. * @param defines The defines to update while falling back
  97272. * @param fallbacks The authorized effect fallbacks
  97273. * @param maxSimultaneousLights The maximum number of lights allowed
  97274. * @param rank the current rank of the Effect
  97275. * @returns The newly affected rank
  97276. */
  97277. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97278. private static _TmpMorphInfluencers;
  97279. /**
  97280. * Prepares the list of attributes required for morph targets according to the effect defines.
  97281. * @param attribs The current list of supported attribs
  97282. * @param mesh The mesh to prepare the morph targets attributes for
  97283. * @param influencers The number of influencers
  97284. */
  97285. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97286. /**
  97287. * Prepares the list of attributes required for morph targets according to the effect defines.
  97288. * @param attribs The current list of supported attribs
  97289. * @param mesh The mesh to prepare the morph targets attributes for
  97290. * @param defines The current Defines of the effect
  97291. */
  97292. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97293. /**
  97294. * Prepares the list of attributes required for bones according to the effect defines.
  97295. * @param attribs The current list of supported attribs
  97296. * @param mesh The mesh to prepare the bones attributes for
  97297. * @param defines The current Defines of the effect
  97298. * @param fallbacks The current efffect fallback strategy
  97299. */
  97300. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97301. /**
  97302. * Check and prepare the list of attributes required for instances according to the effect defines.
  97303. * @param attribs The current list of supported attribs
  97304. * @param defines The current MaterialDefines of the effect
  97305. */
  97306. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97307. /**
  97308. * Add the list of attributes required for instances to the attribs array.
  97309. * @param attribs The current list of supported attribs
  97310. */
  97311. static PushAttributesForInstances(attribs: string[]): void;
  97312. /**
  97313. * Binds the light information to the effect.
  97314. * @param light The light containing the generator
  97315. * @param effect The effect we are binding the data to
  97316. * @param lightIndex The light index in the effect used to render
  97317. */
  97318. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97319. /**
  97320. * Binds the lights information from the scene to the effect for the given mesh.
  97321. * @param light Light to bind
  97322. * @param lightIndex Light index
  97323. * @param scene The scene where the light belongs to
  97324. * @param effect The effect we are binding the data to
  97325. * @param useSpecular Defines if specular is supported
  97326. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97327. */
  97328. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97329. /**
  97330. * Binds the lights information from the scene to the effect for the given mesh.
  97331. * @param scene The scene the lights belongs to
  97332. * @param mesh The mesh we are binding the information to render
  97333. * @param effect The effect we are binding the data to
  97334. * @param defines The generated defines for the effect
  97335. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97336. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97337. */
  97338. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97339. private static _tempFogColor;
  97340. /**
  97341. * Binds the fog information from the scene to the effect for the given mesh.
  97342. * @param scene The scene the lights belongs to
  97343. * @param mesh The mesh we are binding the information to render
  97344. * @param effect The effect we are binding the data to
  97345. * @param linearSpace Defines if the fog effect is applied in linear space
  97346. */
  97347. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97348. /**
  97349. * Binds the bones information from the mesh to the effect.
  97350. * @param mesh The mesh we are binding the information to render
  97351. * @param effect The effect we are binding the data to
  97352. */
  97353. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97354. /**
  97355. * Binds the morph targets information from the mesh to the effect.
  97356. * @param abstractMesh The mesh we are binding the information to render
  97357. * @param effect The effect we are binding the data to
  97358. */
  97359. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97360. /**
  97361. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97362. * @param defines The generated defines used in the effect
  97363. * @param effect The effect we are binding the data to
  97364. * @param scene The scene we are willing to render with logarithmic scale for
  97365. */
  97366. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97367. /**
  97368. * Binds the clip plane information from the scene to the effect.
  97369. * @param scene The scene the clip plane information are extracted from
  97370. * @param effect The effect we are binding the data to
  97371. */
  97372. static BindClipPlane(effect: Effect, scene: Scene): void;
  97373. }
  97374. }
  97375. declare module BABYLON {
  97376. /**
  97377. * Block used to expose an input value
  97378. */
  97379. export class InputBlock extends NodeMaterialBlock {
  97380. private _mode;
  97381. private _associatedVariableName;
  97382. private _storedValue;
  97383. private _valueCallback;
  97384. private _type;
  97385. private _animationType;
  97386. /** Gets or set a value used to limit the range of float values */
  97387. min: number;
  97388. /** Gets or set a value used to limit the range of float values */
  97389. max: number;
  97390. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97391. isBoolean: boolean;
  97392. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97393. matrixMode: number;
  97394. /** @hidden */
  97395. _systemValue: Nullable<NodeMaterialSystemValues>;
  97396. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97397. visibleInInspector: boolean;
  97398. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97399. isConstant: boolean;
  97400. /** Gets or sets the group to use to display this block in the Inspector */
  97401. groupInInspector: string;
  97402. /** Gets an observable raised when the value is changed */
  97403. onValueChangedObservable: Observable<InputBlock>;
  97404. /**
  97405. * Gets or sets the connection point type (default is float)
  97406. */
  97407. get type(): NodeMaterialBlockConnectionPointTypes;
  97408. /**
  97409. * Creates a new InputBlock
  97410. * @param name defines the block name
  97411. * @param target defines the target of that block (Vertex by default)
  97412. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97413. */
  97414. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97415. /**
  97416. * Gets the output component
  97417. */
  97418. get output(): NodeMaterialConnectionPoint;
  97419. /**
  97420. * Set the source of this connection point to a vertex attribute
  97421. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97422. * @returns the current connection point
  97423. */
  97424. setAsAttribute(attributeName?: string): InputBlock;
  97425. /**
  97426. * Set the source of this connection point to a system value
  97427. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97428. * @returns the current connection point
  97429. */
  97430. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97431. /**
  97432. * Gets or sets the value of that point.
  97433. * Please note that this value will be ignored if valueCallback is defined
  97434. */
  97435. get value(): any;
  97436. set value(value: any);
  97437. /**
  97438. * Gets or sets a callback used to get the value of that point.
  97439. * Please note that setting this value will force the connection point to ignore the value property
  97440. */
  97441. get valueCallback(): () => any;
  97442. set valueCallback(value: () => any);
  97443. /**
  97444. * Gets or sets the associated variable name in the shader
  97445. */
  97446. get associatedVariableName(): string;
  97447. set associatedVariableName(value: string);
  97448. /** Gets or sets the type of animation applied to the input */
  97449. get animationType(): AnimatedInputBlockTypes;
  97450. set animationType(value: AnimatedInputBlockTypes);
  97451. /**
  97452. * Gets a boolean indicating that this connection point not defined yet
  97453. */
  97454. get isUndefined(): boolean;
  97455. /**
  97456. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97457. * In this case the connection point name must be the name of the uniform to use.
  97458. * Can only be set on inputs
  97459. */
  97460. get isUniform(): boolean;
  97461. set isUniform(value: boolean);
  97462. /**
  97463. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97464. * In this case the connection point name must be the name of the attribute to use
  97465. * Can only be set on inputs
  97466. */
  97467. get isAttribute(): boolean;
  97468. set isAttribute(value: boolean);
  97469. /**
  97470. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97471. * Can only be set on exit points
  97472. */
  97473. get isVarying(): boolean;
  97474. set isVarying(value: boolean);
  97475. /**
  97476. * Gets a boolean indicating that the current connection point is a system value
  97477. */
  97478. get isSystemValue(): boolean;
  97479. /**
  97480. * Gets or sets the current well known value or null if not defined as a system value
  97481. */
  97482. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97483. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97484. /**
  97485. * Gets the current class name
  97486. * @returns the class name
  97487. */
  97488. getClassName(): string;
  97489. /**
  97490. * Animate the input if animationType !== None
  97491. * @param scene defines the rendering scene
  97492. */
  97493. animate(scene: Scene): void;
  97494. private _emitDefine;
  97495. initialize(state: NodeMaterialBuildState): void;
  97496. /**
  97497. * Set the input block to its default value (based on its type)
  97498. */
  97499. setDefaultValue(): void;
  97500. private _emitConstant;
  97501. /** @hidden */
  97502. get _noContextSwitch(): boolean;
  97503. private _emit;
  97504. /** @hidden */
  97505. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97506. /** @hidden */
  97507. _transmit(effect: Effect, scene: Scene): void;
  97508. protected _buildBlock(state: NodeMaterialBuildState): void;
  97509. protected _dumpPropertiesCode(): string;
  97510. dispose(): void;
  97511. serialize(): any;
  97512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97513. }
  97514. }
  97515. declare module BABYLON {
  97516. /**
  97517. * Enum used to define the compatibility state between two connection points
  97518. */
  97519. export enum NodeMaterialConnectionPointCompatibilityStates {
  97520. /** Points are compatibles */
  97521. Compatible = 0,
  97522. /** Points are incompatible because of their types */
  97523. TypeIncompatible = 1,
  97524. /** Points are incompatible because of their targets (vertex vs fragment) */
  97525. TargetIncompatible = 2
  97526. }
  97527. /**
  97528. * Defines the direction of a connection point
  97529. */
  97530. export enum NodeMaterialConnectionPointDirection {
  97531. /** Input */
  97532. Input = 0,
  97533. /** Output */
  97534. Output = 1
  97535. }
  97536. /**
  97537. * Defines a connection point for a block
  97538. */
  97539. export class NodeMaterialConnectionPoint {
  97540. /** @hidden */
  97541. _ownerBlock: NodeMaterialBlock;
  97542. /** @hidden */
  97543. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97544. private _endpoints;
  97545. private _associatedVariableName;
  97546. private _direction;
  97547. /** @hidden */
  97548. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97549. /** @hidden */
  97550. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97551. private _type;
  97552. /** @hidden */
  97553. _enforceAssociatedVariableName: boolean;
  97554. /** Gets the direction of the point */
  97555. get direction(): NodeMaterialConnectionPointDirection;
  97556. /** Indicates that this connection point needs dual validation before being connected to another point */
  97557. needDualDirectionValidation: boolean;
  97558. /**
  97559. * Gets or sets the additional types supported by this connection point
  97560. */
  97561. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97562. /**
  97563. * Gets or sets the additional types excluded by this connection point
  97564. */
  97565. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97566. /**
  97567. * Observable triggered when this point is connected
  97568. */
  97569. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97570. /**
  97571. * Gets or sets the associated variable name in the shader
  97572. */
  97573. get associatedVariableName(): string;
  97574. set associatedVariableName(value: string);
  97575. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97576. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97577. /**
  97578. * Gets or sets the connection point type (default is float)
  97579. */
  97580. get type(): NodeMaterialBlockConnectionPointTypes;
  97581. set type(value: NodeMaterialBlockConnectionPointTypes);
  97582. /**
  97583. * Gets or sets the connection point name
  97584. */
  97585. name: string;
  97586. /**
  97587. * Gets or sets the connection point name
  97588. */
  97589. displayName: string;
  97590. /**
  97591. * Gets or sets a boolean indicating that this connection point can be omitted
  97592. */
  97593. isOptional: boolean;
  97594. /**
  97595. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97596. */
  97597. define: string;
  97598. /** @hidden */
  97599. _prioritizeVertex: boolean;
  97600. private _target;
  97601. /** Gets or sets the target of that connection point */
  97602. get target(): NodeMaterialBlockTargets;
  97603. set target(value: NodeMaterialBlockTargets);
  97604. /**
  97605. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97606. */
  97607. get isConnected(): boolean;
  97608. /**
  97609. * Gets a boolean indicating that the current point is connected to an input block
  97610. */
  97611. get isConnectedToInputBlock(): boolean;
  97612. /**
  97613. * Gets a the connected input block (if any)
  97614. */
  97615. get connectInputBlock(): Nullable<InputBlock>;
  97616. /** Get the other side of the connection (if any) */
  97617. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97618. /** Get the block that owns this connection point */
  97619. get ownerBlock(): NodeMaterialBlock;
  97620. /** Get the block connected on the other side of this connection (if any) */
  97621. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97622. /** Get the block connected on the endpoints of this connection (if any) */
  97623. get connectedBlocks(): Array<NodeMaterialBlock>;
  97624. /** Gets the list of connected endpoints */
  97625. get endpoints(): NodeMaterialConnectionPoint[];
  97626. /** Gets a boolean indicating if that output point is connected to at least one input */
  97627. get hasEndpoints(): boolean;
  97628. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97629. get isConnectedInVertexShader(): boolean;
  97630. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97631. get isConnectedInFragmentShader(): boolean;
  97632. /**
  97633. * Creates a block suitable to be used as an input for this input point.
  97634. * If null is returned, a block based on the point type will be created.
  97635. * @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
  97636. */
  97637. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97638. /**
  97639. * Creates a new connection point
  97640. * @param name defines the connection point name
  97641. * @param ownerBlock defines the block hosting this connection point
  97642. * @param direction defines the direction of the connection point
  97643. */
  97644. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97645. /**
  97646. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97647. * @returns the class name
  97648. */
  97649. getClassName(): string;
  97650. /**
  97651. * Gets a boolean indicating if the current point can be connected to another point
  97652. * @param connectionPoint defines the other connection point
  97653. * @returns a boolean
  97654. */
  97655. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97656. /**
  97657. * Gets a number indicating if the current point can be connected to another point
  97658. * @param connectionPoint defines the other connection point
  97659. * @returns a number defining the compatibility state
  97660. */
  97661. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97662. /**
  97663. * Connect this point to another connection point
  97664. * @param connectionPoint defines the other connection point
  97665. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97666. * @returns the current connection point
  97667. */
  97668. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97669. /**
  97670. * Disconnect this point from one of his endpoint
  97671. * @param endpoint defines the other connection point
  97672. * @returns the current connection point
  97673. */
  97674. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97675. /**
  97676. * Serializes this point in a JSON representation
  97677. * @param isInput defines if the connection point is an input (default is true)
  97678. * @returns the serialized point object
  97679. */
  97680. serialize(isInput?: boolean): any;
  97681. /**
  97682. * Release resources
  97683. */
  97684. dispose(): void;
  97685. }
  97686. }
  97687. declare module BABYLON {
  97688. /**
  97689. * Enum used to define the material modes
  97690. */
  97691. export enum NodeMaterialModes {
  97692. /** Regular material */
  97693. Material = 0,
  97694. /** For post process */
  97695. PostProcess = 1,
  97696. /** For particle system */
  97697. Particle = 2
  97698. }
  97699. }
  97700. declare module BABYLON {
  97701. /**
  97702. * Block used to read a texture from a sampler
  97703. */
  97704. export class TextureBlock extends NodeMaterialBlock {
  97705. private _defineName;
  97706. private _linearDefineName;
  97707. private _gammaDefineName;
  97708. private _tempTextureRead;
  97709. private _samplerName;
  97710. private _transformedUVName;
  97711. private _textureTransformName;
  97712. private _textureInfoName;
  97713. private _mainUVName;
  97714. private _mainUVDefineName;
  97715. private _fragmentOnly;
  97716. /**
  97717. * Gets or sets the texture associated with the node
  97718. */
  97719. texture: Nullable<Texture>;
  97720. /**
  97721. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97722. */
  97723. convertToGammaSpace: boolean;
  97724. /**
  97725. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97726. */
  97727. convertToLinearSpace: boolean;
  97728. /**
  97729. * Create a new TextureBlock
  97730. * @param name defines the block name
  97731. */
  97732. constructor(name: string, fragmentOnly?: boolean);
  97733. /**
  97734. * Gets the current class name
  97735. * @returns the class name
  97736. */
  97737. getClassName(): string;
  97738. /**
  97739. * Gets the uv input component
  97740. */
  97741. get uv(): NodeMaterialConnectionPoint;
  97742. /**
  97743. * Gets the rgba output component
  97744. */
  97745. get rgba(): NodeMaterialConnectionPoint;
  97746. /**
  97747. * Gets the rgb output component
  97748. */
  97749. get rgb(): NodeMaterialConnectionPoint;
  97750. /**
  97751. * Gets the r output component
  97752. */
  97753. get r(): NodeMaterialConnectionPoint;
  97754. /**
  97755. * Gets the g output component
  97756. */
  97757. get g(): NodeMaterialConnectionPoint;
  97758. /**
  97759. * Gets the b output component
  97760. */
  97761. get b(): NodeMaterialConnectionPoint;
  97762. /**
  97763. * Gets the a output component
  97764. */
  97765. get a(): NodeMaterialConnectionPoint;
  97766. get target(): NodeMaterialBlockTargets;
  97767. autoConfigure(material: NodeMaterial): void;
  97768. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97770. isReady(): boolean;
  97771. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97772. private get _isMixed();
  97773. private _injectVertexCode;
  97774. private _writeTextureRead;
  97775. private _writeOutput;
  97776. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97777. protected _dumpPropertiesCode(): string;
  97778. serialize(): any;
  97779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97780. }
  97781. }
  97782. declare module BABYLON {
  97783. /** @hidden */
  97784. export var reflectionFunction: {
  97785. name: string;
  97786. shader: string;
  97787. };
  97788. }
  97789. declare module BABYLON {
  97790. /**
  97791. * Base block used to read a reflection texture from a sampler
  97792. */
  97793. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97794. /** @hidden */
  97795. _define3DName: string;
  97796. /** @hidden */
  97797. _defineCubicName: string;
  97798. /** @hidden */
  97799. _defineExplicitName: string;
  97800. /** @hidden */
  97801. _defineProjectionName: string;
  97802. /** @hidden */
  97803. _defineLocalCubicName: string;
  97804. /** @hidden */
  97805. _defineSphericalName: string;
  97806. /** @hidden */
  97807. _definePlanarName: string;
  97808. /** @hidden */
  97809. _defineEquirectangularName: string;
  97810. /** @hidden */
  97811. _defineMirroredEquirectangularFixedName: string;
  97812. /** @hidden */
  97813. _defineEquirectangularFixedName: string;
  97814. /** @hidden */
  97815. _defineSkyboxName: string;
  97816. /** @hidden */
  97817. _defineOppositeZ: string;
  97818. /** @hidden */
  97819. _cubeSamplerName: string;
  97820. /** @hidden */
  97821. _2DSamplerName: string;
  97822. protected _positionUVWName: string;
  97823. protected _directionWName: string;
  97824. protected _reflectionVectorName: string;
  97825. /** @hidden */
  97826. _reflectionCoordsName: string;
  97827. /** @hidden */
  97828. _reflectionMatrixName: string;
  97829. protected _reflectionColorName: string;
  97830. /**
  97831. * Gets or sets the texture associated with the node
  97832. */
  97833. texture: Nullable<BaseTexture>;
  97834. /**
  97835. * Create a new ReflectionTextureBaseBlock
  97836. * @param name defines the block name
  97837. */
  97838. constructor(name: string);
  97839. /**
  97840. * Gets the current class name
  97841. * @returns the class name
  97842. */
  97843. getClassName(): string;
  97844. /**
  97845. * Gets the world position input component
  97846. */
  97847. abstract get position(): NodeMaterialConnectionPoint;
  97848. /**
  97849. * Gets the world position input component
  97850. */
  97851. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97852. /**
  97853. * Gets the world normal input component
  97854. */
  97855. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97856. /**
  97857. * Gets the world input component
  97858. */
  97859. abstract get world(): NodeMaterialConnectionPoint;
  97860. /**
  97861. * Gets the camera (or eye) position component
  97862. */
  97863. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97864. /**
  97865. * Gets the view input component
  97866. */
  97867. abstract get view(): NodeMaterialConnectionPoint;
  97868. protected _getTexture(): Nullable<BaseTexture>;
  97869. autoConfigure(material: NodeMaterial): void;
  97870. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97871. isReady(): boolean;
  97872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97873. /**
  97874. * Gets the code to inject in the vertex shader
  97875. * @param state current state of the node material building
  97876. * @returns the shader code
  97877. */
  97878. handleVertexSide(state: NodeMaterialBuildState): string;
  97879. /**
  97880. * Handles the inits for the fragment code path
  97881. * @param state node material build state
  97882. */
  97883. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97884. /**
  97885. * Generates the reflection coords code for the fragment code path
  97886. * @param worldNormalVarName name of the world normal variable
  97887. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97888. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97889. * @returns the shader code
  97890. */
  97891. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97892. /**
  97893. * Generates the reflection color code for the fragment code path
  97894. * @param lodVarName name of the lod variable
  97895. * @param swizzleLookupTexture swizzle to use for the final color variable
  97896. * @returns the shader code
  97897. */
  97898. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97899. /**
  97900. * Generates the code corresponding to the connected output points
  97901. * @param state node material build state
  97902. * @param varName name of the variable to output
  97903. * @returns the shader code
  97904. */
  97905. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97906. protected _buildBlock(state: NodeMaterialBuildState): this;
  97907. protected _dumpPropertiesCode(): string;
  97908. serialize(): any;
  97909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97910. }
  97911. }
  97912. declare module BABYLON {
  97913. /**
  97914. * Defines a connection point to be used for points with a custom object type
  97915. */
  97916. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97917. private _blockType;
  97918. private _blockName;
  97919. private _nameForCheking?;
  97920. /**
  97921. * Creates a new connection point
  97922. * @param name defines the connection point name
  97923. * @param ownerBlock defines the block hosting this connection point
  97924. * @param direction defines the direction of the connection point
  97925. */
  97926. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97927. /**
  97928. * Gets a number indicating if the current point can be connected to another point
  97929. * @param connectionPoint defines the other connection point
  97930. * @returns a number defining the compatibility state
  97931. */
  97932. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97933. /**
  97934. * Creates a block suitable to be used as an input for this input point.
  97935. * If null is returned, a block based on the point type will be created.
  97936. * @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
  97937. */
  97938. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97939. }
  97940. }
  97941. declare module BABYLON {
  97942. /**
  97943. * Enum defining the type of properties that can be edited in the property pages in the NME
  97944. */
  97945. export enum PropertyTypeForEdition {
  97946. /** property is a boolean */
  97947. Boolean = 0,
  97948. /** property is a float */
  97949. Float = 1,
  97950. /** property is a Vector2 */
  97951. Vector2 = 2,
  97952. /** property is a list of values */
  97953. List = 3
  97954. }
  97955. /**
  97956. * Interface that defines an option in a variable of type list
  97957. */
  97958. export interface IEditablePropertyListOption {
  97959. /** label of the option */
  97960. "label": string;
  97961. /** value of the option */
  97962. "value": number;
  97963. }
  97964. /**
  97965. * Interface that defines the options available for an editable property
  97966. */
  97967. export interface IEditablePropertyOption {
  97968. /** min value */
  97969. "min"?: number;
  97970. /** max value */
  97971. "max"?: number;
  97972. /** notifiers: indicates which actions to take when the property is changed */
  97973. "notifiers"?: {
  97974. /** the material should be rebuilt */
  97975. "rebuild"?: boolean;
  97976. /** the preview should be updated */
  97977. "update"?: boolean;
  97978. };
  97979. /** list of the options for a variable of type list */
  97980. "options"?: IEditablePropertyListOption[];
  97981. }
  97982. /**
  97983. * Interface that describes an editable property
  97984. */
  97985. export interface IPropertyDescriptionForEdition {
  97986. /** name of the property */
  97987. "propertyName": string;
  97988. /** display name of the property */
  97989. "displayName": string;
  97990. /** type of the property */
  97991. "type": PropertyTypeForEdition;
  97992. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97993. "groupName": string;
  97994. /** options for the property */
  97995. "options": IEditablePropertyOption;
  97996. }
  97997. /**
  97998. * Decorator that flags a property in a node material block as being editable
  97999. */
  98000. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98001. }
  98002. declare module BABYLON {
  98003. /**
  98004. * Block used to implement the refraction part of the sub surface module of the PBR material
  98005. */
  98006. export class RefractionBlock extends NodeMaterialBlock {
  98007. /** @hidden */
  98008. _define3DName: string;
  98009. /** @hidden */
  98010. _refractionMatrixName: string;
  98011. /** @hidden */
  98012. _defineLODRefractionAlpha: string;
  98013. /** @hidden */
  98014. _defineLinearSpecularRefraction: string;
  98015. /** @hidden */
  98016. _defineOppositeZ: string;
  98017. /** @hidden */
  98018. _cubeSamplerName: string;
  98019. /** @hidden */
  98020. _2DSamplerName: string;
  98021. /** @hidden */
  98022. _vRefractionMicrosurfaceInfosName: string;
  98023. /** @hidden */
  98024. _vRefractionInfosName: string;
  98025. private _scene;
  98026. /**
  98027. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98028. * Materials half opaque for instance using refraction could benefit from this control.
  98029. */
  98030. linkRefractionWithTransparency: boolean;
  98031. /**
  98032. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98033. */
  98034. invertRefractionY: boolean;
  98035. /**
  98036. * Gets or sets the texture associated with the node
  98037. */
  98038. texture: Nullable<BaseTexture>;
  98039. /**
  98040. * Create a new RefractionBlock
  98041. * @param name defines the block name
  98042. */
  98043. constructor(name: string);
  98044. /**
  98045. * Gets the current class name
  98046. * @returns the class name
  98047. */
  98048. getClassName(): string;
  98049. /**
  98050. * Gets the intensity input component
  98051. */
  98052. get intensity(): NodeMaterialConnectionPoint;
  98053. /**
  98054. * Gets the index of refraction input component
  98055. */
  98056. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98057. /**
  98058. * Gets the tint at distance input component
  98059. */
  98060. get tintAtDistance(): NodeMaterialConnectionPoint;
  98061. /**
  98062. * Gets the view input component
  98063. */
  98064. get view(): NodeMaterialConnectionPoint;
  98065. /**
  98066. * Gets the refraction object output component
  98067. */
  98068. get refraction(): NodeMaterialConnectionPoint;
  98069. /**
  98070. * Returns true if the block has a texture
  98071. */
  98072. get hasTexture(): boolean;
  98073. protected _getTexture(): Nullable<BaseTexture>;
  98074. autoConfigure(material: NodeMaterial): void;
  98075. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98076. isReady(): boolean;
  98077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98078. /**
  98079. * Gets the main code of the block (fragment side)
  98080. * @param state current state of the node material building
  98081. * @returns the shader code
  98082. */
  98083. getCode(state: NodeMaterialBuildState): string;
  98084. protected _buildBlock(state: NodeMaterialBuildState): this;
  98085. protected _dumpPropertiesCode(): string;
  98086. serialize(): any;
  98087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98088. }
  98089. }
  98090. declare module BABYLON {
  98091. /**
  98092. * Base block used as input for post process
  98093. */
  98094. export class CurrentScreenBlock extends NodeMaterialBlock {
  98095. private _samplerName;
  98096. private _linearDefineName;
  98097. private _gammaDefineName;
  98098. private _mainUVName;
  98099. private _tempTextureRead;
  98100. /**
  98101. * Gets or sets the texture associated with the node
  98102. */
  98103. texture: Nullable<BaseTexture>;
  98104. /**
  98105. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98106. */
  98107. convertToGammaSpace: boolean;
  98108. /**
  98109. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98110. */
  98111. convertToLinearSpace: boolean;
  98112. /**
  98113. * Create a new CurrentScreenBlock
  98114. * @param name defines the block name
  98115. */
  98116. constructor(name: string);
  98117. /**
  98118. * Gets the current class name
  98119. * @returns the class name
  98120. */
  98121. getClassName(): string;
  98122. /**
  98123. * Gets the uv input component
  98124. */
  98125. get uv(): NodeMaterialConnectionPoint;
  98126. /**
  98127. * Gets the rgba output component
  98128. */
  98129. get rgba(): NodeMaterialConnectionPoint;
  98130. /**
  98131. * Gets the rgb output component
  98132. */
  98133. get rgb(): NodeMaterialConnectionPoint;
  98134. /**
  98135. * Gets the r output component
  98136. */
  98137. get r(): NodeMaterialConnectionPoint;
  98138. /**
  98139. * Gets the g output component
  98140. */
  98141. get g(): NodeMaterialConnectionPoint;
  98142. /**
  98143. * Gets the b output component
  98144. */
  98145. get b(): NodeMaterialConnectionPoint;
  98146. /**
  98147. * Gets the a output component
  98148. */
  98149. get a(): NodeMaterialConnectionPoint;
  98150. /**
  98151. * Initialize the block and prepare the context for build
  98152. * @param state defines the state that will be used for the build
  98153. */
  98154. initialize(state: NodeMaterialBuildState): void;
  98155. get target(): NodeMaterialBlockTargets;
  98156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98157. isReady(): boolean;
  98158. private _injectVertexCode;
  98159. private _writeTextureRead;
  98160. private _writeOutput;
  98161. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98162. serialize(): any;
  98163. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98164. }
  98165. }
  98166. declare module BABYLON {
  98167. /**
  98168. * Base block used for the particle texture
  98169. */
  98170. export class ParticleTextureBlock extends NodeMaterialBlock {
  98171. private _samplerName;
  98172. private _linearDefineName;
  98173. private _gammaDefineName;
  98174. private _tempTextureRead;
  98175. /**
  98176. * Gets or sets the texture associated with the node
  98177. */
  98178. texture: Nullable<BaseTexture>;
  98179. /**
  98180. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98181. */
  98182. convertToGammaSpace: boolean;
  98183. /**
  98184. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98185. */
  98186. convertToLinearSpace: boolean;
  98187. /**
  98188. * Create a new ParticleTextureBlock
  98189. * @param name defines the block name
  98190. */
  98191. constructor(name: string);
  98192. /**
  98193. * Gets the current class name
  98194. * @returns the class name
  98195. */
  98196. getClassName(): string;
  98197. /**
  98198. * Gets the uv input component
  98199. */
  98200. get uv(): NodeMaterialConnectionPoint;
  98201. /**
  98202. * Gets the rgba output component
  98203. */
  98204. get rgba(): NodeMaterialConnectionPoint;
  98205. /**
  98206. * Gets the rgb output component
  98207. */
  98208. get rgb(): NodeMaterialConnectionPoint;
  98209. /**
  98210. * Gets the r output component
  98211. */
  98212. get r(): NodeMaterialConnectionPoint;
  98213. /**
  98214. * Gets the g output component
  98215. */
  98216. get g(): NodeMaterialConnectionPoint;
  98217. /**
  98218. * Gets the b output component
  98219. */
  98220. get b(): NodeMaterialConnectionPoint;
  98221. /**
  98222. * Gets the a output component
  98223. */
  98224. get a(): NodeMaterialConnectionPoint;
  98225. /**
  98226. * Initialize the block and prepare the context for build
  98227. * @param state defines the state that will be used for the build
  98228. */
  98229. initialize(state: NodeMaterialBuildState): void;
  98230. autoConfigure(material: NodeMaterial): void;
  98231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98232. isReady(): boolean;
  98233. private _writeOutput;
  98234. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98235. serialize(): any;
  98236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98237. }
  98238. }
  98239. declare module BABYLON {
  98240. /**
  98241. * Class used to store shared data between 2 NodeMaterialBuildState
  98242. */
  98243. export class NodeMaterialBuildStateSharedData {
  98244. /**
  98245. * Gets the list of emitted varyings
  98246. */
  98247. temps: string[];
  98248. /**
  98249. * Gets the list of emitted varyings
  98250. */
  98251. varyings: string[];
  98252. /**
  98253. * Gets the varying declaration string
  98254. */
  98255. varyingDeclaration: string;
  98256. /**
  98257. * Input blocks
  98258. */
  98259. inputBlocks: InputBlock[];
  98260. /**
  98261. * Input blocks
  98262. */
  98263. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98264. /**
  98265. * Bindable blocks (Blocks that need to set data to the effect)
  98266. */
  98267. bindableBlocks: NodeMaterialBlock[];
  98268. /**
  98269. * List of blocks that can provide a compilation fallback
  98270. */
  98271. blocksWithFallbacks: NodeMaterialBlock[];
  98272. /**
  98273. * List of blocks that can provide a define update
  98274. */
  98275. blocksWithDefines: NodeMaterialBlock[];
  98276. /**
  98277. * List of blocks that can provide a repeatable content
  98278. */
  98279. repeatableContentBlocks: NodeMaterialBlock[];
  98280. /**
  98281. * List of blocks that can provide a dynamic list of uniforms
  98282. */
  98283. dynamicUniformBlocks: NodeMaterialBlock[];
  98284. /**
  98285. * List of blocks that can block the isReady function for the material
  98286. */
  98287. blockingBlocks: NodeMaterialBlock[];
  98288. /**
  98289. * Gets the list of animated inputs
  98290. */
  98291. animatedInputs: InputBlock[];
  98292. /**
  98293. * Build Id used to avoid multiple recompilations
  98294. */
  98295. buildId: number;
  98296. /** List of emitted variables */
  98297. variableNames: {
  98298. [key: string]: number;
  98299. };
  98300. /** List of emitted defines */
  98301. defineNames: {
  98302. [key: string]: number;
  98303. };
  98304. /** Should emit comments? */
  98305. emitComments: boolean;
  98306. /** Emit build activity */
  98307. verbose: boolean;
  98308. /** Gets or sets the hosting scene */
  98309. scene: Scene;
  98310. /**
  98311. * Gets the compilation hints emitted at compilation time
  98312. */
  98313. hints: {
  98314. needWorldViewMatrix: boolean;
  98315. needWorldViewProjectionMatrix: boolean;
  98316. needAlphaBlending: boolean;
  98317. needAlphaTesting: boolean;
  98318. };
  98319. /**
  98320. * List of compilation checks
  98321. */
  98322. checks: {
  98323. emitVertex: boolean;
  98324. emitFragment: boolean;
  98325. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98326. };
  98327. /**
  98328. * Is vertex program allowed to be empty?
  98329. */
  98330. allowEmptyVertexProgram: boolean;
  98331. /** Creates a new shared data */
  98332. constructor();
  98333. /**
  98334. * Emits console errors and exceptions if there is a failing check
  98335. */
  98336. emitErrors(): void;
  98337. }
  98338. }
  98339. declare module BABYLON {
  98340. /**
  98341. * Class used to store node based material build state
  98342. */
  98343. export class NodeMaterialBuildState {
  98344. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98345. supportUniformBuffers: boolean;
  98346. /**
  98347. * Gets the list of emitted attributes
  98348. */
  98349. attributes: string[];
  98350. /**
  98351. * Gets the list of emitted uniforms
  98352. */
  98353. uniforms: string[];
  98354. /**
  98355. * Gets the list of emitted constants
  98356. */
  98357. constants: string[];
  98358. /**
  98359. * Gets the list of emitted samplers
  98360. */
  98361. samplers: string[];
  98362. /**
  98363. * Gets the list of emitted functions
  98364. */
  98365. functions: {
  98366. [key: string]: string;
  98367. };
  98368. /**
  98369. * Gets the list of emitted extensions
  98370. */
  98371. extensions: {
  98372. [key: string]: string;
  98373. };
  98374. /**
  98375. * Gets the target of the compilation state
  98376. */
  98377. target: NodeMaterialBlockTargets;
  98378. /**
  98379. * Gets the list of emitted counters
  98380. */
  98381. counters: {
  98382. [key: string]: number;
  98383. };
  98384. /**
  98385. * Shared data between multiple NodeMaterialBuildState instances
  98386. */
  98387. sharedData: NodeMaterialBuildStateSharedData;
  98388. /** @hidden */
  98389. _vertexState: NodeMaterialBuildState;
  98390. /** @hidden */
  98391. _attributeDeclaration: string;
  98392. /** @hidden */
  98393. _uniformDeclaration: string;
  98394. /** @hidden */
  98395. _constantDeclaration: string;
  98396. /** @hidden */
  98397. _samplerDeclaration: string;
  98398. /** @hidden */
  98399. _varyingTransfer: string;
  98400. /** @hidden */
  98401. _injectAtEnd: string;
  98402. private _repeatableContentAnchorIndex;
  98403. /** @hidden */
  98404. _builtCompilationString: string;
  98405. /**
  98406. * Gets the emitted compilation strings
  98407. */
  98408. compilationString: string;
  98409. /**
  98410. * Finalize the compilation strings
  98411. * @param state defines the current compilation state
  98412. */
  98413. finalize(state: NodeMaterialBuildState): void;
  98414. /** @hidden */
  98415. get _repeatableContentAnchor(): string;
  98416. /** @hidden */
  98417. _getFreeVariableName(prefix: string): string;
  98418. /** @hidden */
  98419. _getFreeDefineName(prefix: string): string;
  98420. /** @hidden */
  98421. _excludeVariableName(name: string): void;
  98422. /** @hidden */
  98423. _emit2DSampler(name: string): void;
  98424. /** @hidden */
  98425. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98426. /** @hidden */
  98427. _emitExtension(name: string, extension: string, define?: string): void;
  98428. /** @hidden */
  98429. _emitFunction(name: string, code: string, comments: string): void;
  98430. /** @hidden */
  98431. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98432. replaceStrings?: {
  98433. search: RegExp;
  98434. replace: string;
  98435. }[];
  98436. repeatKey?: string;
  98437. }): string;
  98438. /** @hidden */
  98439. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98440. repeatKey?: string;
  98441. removeAttributes?: boolean;
  98442. removeUniforms?: boolean;
  98443. removeVaryings?: boolean;
  98444. removeIfDef?: boolean;
  98445. replaceStrings?: {
  98446. search: RegExp;
  98447. replace: string;
  98448. }[];
  98449. }, storeKey?: string): void;
  98450. /** @hidden */
  98451. _registerTempVariable(name: string): boolean;
  98452. /** @hidden */
  98453. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98454. /** @hidden */
  98455. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98456. /** @hidden */
  98457. _emitFloat(value: number): string;
  98458. }
  98459. }
  98460. declare module BABYLON {
  98461. /**
  98462. * Helper class used to generate session unique ID
  98463. */
  98464. export class UniqueIdGenerator {
  98465. private static _UniqueIdCounter;
  98466. /**
  98467. * Gets an unique (relatively to the current scene) Id
  98468. */
  98469. static get UniqueId(): number;
  98470. }
  98471. }
  98472. declare module BABYLON {
  98473. /**
  98474. * Defines a block that can be used inside a node based material
  98475. */
  98476. export class NodeMaterialBlock {
  98477. private _buildId;
  98478. private _buildTarget;
  98479. private _target;
  98480. private _isFinalMerger;
  98481. private _isInput;
  98482. protected _isUnique: boolean;
  98483. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98484. inputsAreExclusive: boolean;
  98485. /** @hidden */
  98486. _codeVariableName: string;
  98487. /** @hidden */
  98488. _inputs: NodeMaterialConnectionPoint[];
  98489. /** @hidden */
  98490. _outputs: NodeMaterialConnectionPoint[];
  98491. /** @hidden */
  98492. _preparationId: number;
  98493. /**
  98494. * Gets or sets the name of the block
  98495. */
  98496. name: string;
  98497. /**
  98498. * Gets or sets the unique id of the node
  98499. */
  98500. uniqueId: number;
  98501. /**
  98502. * Gets or sets the comments associated with this block
  98503. */
  98504. comments: string;
  98505. /**
  98506. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98507. */
  98508. get isUnique(): boolean;
  98509. /**
  98510. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98511. */
  98512. get isFinalMerger(): boolean;
  98513. /**
  98514. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98515. */
  98516. get isInput(): boolean;
  98517. /**
  98518. * Gets or sets the build Id
  98519. */
  98520. get buildId(): number;
  98521. set buildId(value: number);
  98522. /**
  98523. * Gets or sets the target of the block
  98524. */
  98525. get target(): NodeMaterialBlockTargets;
  98526. set target(value: NodeMaterialBlockTargets);
  98527. /**
  98528. * Gets the list of input points
  98529. */
  98530. get inputs(): NodeMaterialConnectionPoint[];
  98531. /** Gets the list of output points */
  98532. get outputs(): NodeMaterialConnectionPoint[];
  98533. /**
  98534. * Find an input by its name
  98535. * @param name defines the name of the input to look for
  98536. * @returns the input or null if not found
  98537. */
  98538. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98539. /**
  98540. * Find an output by its name
  98541. * @param name defines the name of the outputto look for
  98542. * @returns the output or null if not found
  98543. */
  98544. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98545. /**
  98546. * Creates a new NodeMaterialBlock
  98547. * @param name defines the block name
  98548. * @param target defines the target of that block (Vertex by default)
  98549. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98550. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98551. */
  98552. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98553. /**
  98554. * Initialize the block and prepare the context for build
  98555. * @param state defines the state that will be used for the build
  98556. */
  98557. initialize(state: NodeMaterialBuildState): void;
  98558. /**
  98559. * Bind data to effect. Will only be called for blocks with isBindable === true
  98560. * @param effect defines the effect to bind data to
  98561. * @param nodeMaterial defines the hosting NodeMaterial
  98562. * @param mesh defines the mesh that will be rendered
  98563. * @param subMesh defines the submesh that will be rendered
  98564. */
  98565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98566. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98567. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98568. protected _writeFloat(value: number): string;
  98569. /**
  98570. * Gets the current class name e.g. "NodeMaterialBlock"
  98571. * @returns the class name
  98572. */
  98573. getClassName(): string;
  98574. /**
  98575. * Register a new input. Must be called inside a block constructor
  98576. * @param name defines the connection point name
  98577. * @param type defines the connection point type
  98578. * @param isOptional defines a boolean indicating that this input can be omitted
  98579. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98580. * @param point an already created connection point. If not provided, create a new one
  98581. * @returns the current block
  98582. */
  98583. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98584. /**
  98585. * Register a new output. Must be called inside a block constructor
  98586. * @param name defines the connection point name
  98587. * @param type defines the connection point type
  98588. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98589. * @param point an already created connection point. If not provided, create a new one
  98590. * @returns the current block
  98591. */
  98592. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98593. /**
  98594. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98595. * @param forOutput defines an optional connection point to check compatibility with
  98596. * @returns the first available input or null
  98597. */
  98598. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98599. /**
  98600. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98601. * @param forBlock defines an optional block to check compatibility with
  98602. * @returns the first available input or null
  98603. */
  98604. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98605. /**
  98606. * Gets the sibling of the given output
  98607. * @param current defines the current output
  98608. * @returns the next output in the list or null
  98609. */
  98610. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98611. /**
  98612. * Connect current block with another block
  98613. * @param other defines the block to connect with
  98614. * @param options define the various options to help pick the right connections
  98615. * @returns the current block
  98616. */
  98617. connectTo(other: NodeMaterialBlock, options?: {
  98618. input?: string;
  98619. output?: string;
  98620. outputSwizzle?: string;
  98621. }): this | undefined;
  98622. protected _buildBlock(state: NodeMaterialBuildState): void;
  98623. /**
  98624. * Add uniforms, samplers and uniform buffers at compilation time
  98625. * @param state defines the state to update
  98626. * @param nodeMaterial defines the node material requesting the update
  98627. * @param defines defines the material defines to update
  98628. * @param uniformBuffers defines the list of uniform buffer names
  98629. */
  98630. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98631. /**
  98632. * Add potential fallbacks if shader compilation fails
  98633. * @param mesh defines the mesh to be rendered
  98634. * @param fallbacks defines the current prioritized list of fallbacks
  98635. */
  98636. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98637. /**
  98638. * Initialize defines for shader compilation
  98639. * @param mesh defines the mesh to be rendered
  98640. * @param nodeMaterial defines the node material requesting the update
  98641. * @param defines defines the material defines to update
  98642. * @param useInstances specifies that instances should be used
  98643. */
  98644. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98645. /**
  98646. * Update defines for shader compilation
  98647. * @param mesh defines the mesh to be rendered
  98648. * @param nodeMaterial defines the node material requesting the update
  98649. * @param defines defines the material defines to update
  98650. * @param useInstances specifies that instances should be used
  98651. * @param subMesh defines which submesh to render
  98652. */
  98653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98654. /**
  98655. * Lets the block try to connect some inputs automatically
  98656. * @param material defines the hosting NodeMaterial
  98657. */
  98658. autoConfigure(material: NodeMaterial): void;
  98659. /**
  98660. * Function called when a block is declared as repeatable content generator
  98661. * @param vertexShaderState defines the current compilation state for the vertex shader
  98662. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98663. * @param mesh defines the mesh to be rendered
  98664. * @param defines defines the material defines to update
  98665. */
  98666. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98667. /**
  98668. * Checks if the block is ready
  98669. * @param mesh defines the mesh to be rendered
  98670. * @param nodeMaterial defines the node material requesting the update
  98671. * @param defines defines the material defines to update
  98672. * @param useInstances specifies that instances should be used
  98673. * @returns true if the block is ready
  98674. */
  98675. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98676. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  98677. private _processBuild;
  98678. /**
  98679. * Compile the current node and generate the shader code
  98680. * @param state defines the current compilation state (uniforms, samplers, current string)
  98681. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98682. * @returns true if already built
  98683. */
  98684. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98685. protected _inputRename(name: string): string;
  98686. protected _outputRename(name: string): string;
  98687. protected _dumpPropertiesCode(): string;
  98688. /** @hidden */
  98689. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98690. /** @hidden */
  98691. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98692. /**
  98693. * Clone the current block to a new identical block
  98694. * @param scene defines the hosting scene
  98695. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98696. * @returns a copy of the current block
  98697. */
  98698. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98699. /**
  98700. * Serializes this block in a JSON representation
  98701. * @returns the serialized block object
  98702. */
  98703. serialize(): any;
  98704. /** @hidden */
  98705. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98706. private _deserializePortDisplayNames;
  98707. /**
  98708. * Release resources
  98709. */
  98710. dispose(): void;
  98711. }
  98712. }
  98713. declare module BABYLON {
  98714. /**
  98715. * Base class of materials working in push mode in babylon JS
  98716. * @hidden
  98717. */
  98718. export class PushMaterial extends Material {
  98719. protected _activeEffect: Effect;
  98720. protected _normalMatrix: Matrix;
  98721. /**
  98722. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98723. * This means that the material can keep using a previous shader while a new one is being compiled.
  98724. * This is mostly used when shader parallel compilation is supported (true by default)
  98725. */
  98726. allowShaderHotSwapping: boolean;
  98727. constructor(name: string, scene: Scene);
  98728. getEffect(): Effect;
  98729. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98730. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98731. /**
  98732. * Binds the given world matrix to the active effect
  98733. *
  98734. * @param world the matrix to bind
  98735. */
  98736. bindOnlyWorldMatrix(world: Matrix): void;
  98737. /**
  98738. * Binds the given normal matrix to the active effect
  98739. *
  98740. * @param normalMatrix the matrix to bind
  98741. */
  98742. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98743. bind(world: Matrix, mesh?: Mesh): void;
  98744. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98745. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98746. }
  98747. }
  98748. declare module BABYLON {
  98749. /**
  98750. * Root class for all node material optimizers
  98751. */
  98752. export class NodeMaterialOptimizer {
  98753. /**
  98754. * Function used to optimize a NodeMaterial graph
  98755. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98756. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98757. */
  98758. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98759. }
  98760. }
  98761. declare module BABYLON {
  98762. /**
  98763. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98764. */
  98765. export class TransformBlock extends NodeMaterialBlock {
  98766. /**
  98767. * Defines the value to use to complement W value to transform it to a Vector4
  98768. */
  98769. complementW: number;
  98770. /**
  98771. * Defines the value to use to complement z value to transform it to a Vector4
  98772. */
  98773. complementZ: number;
  98774. /**
  98775. * Creates a new TransformBlock
  98776. * @param name defines the block name
  98777. */
  98778. constructor(name: string);
  98779. /**
  98780. * Gets the current class name
  98781. * @returns the class name
  98782. */
  98783. getClassName(): string;
  98784. /**
  98785. * Gets the vector input
  98786. */
  98787. get vector(): NodeMaterialConnectionPoint;
  98788. /**
  98789. * Gets the output component
  98790. */
  98791. get output(): NodeMaterialConnectionPoint;
  98792. /**
  98793. * Gets the xyz output component
  98794. */
  98795. get xyz(): NodeMaterialConnectionPoint;
  98796. /**
  98797. * Gets the matrix transform input
  98798. */
  98799. get transform(): NodeMaterialConnectionPoint;
  98800. protected _buildBlock(state: NodeMaterialBuildState): this;
  98801. /**
  98802. * Update defines for shader compilation
  98803. * @param mesh defines the mesh to be rendered
  98804. * @param nodeMaterial defines the node material requesting the update
  98805. * @param defines defines the material defines to update
  98806. * @param useInstances specifies that instances should be used
  98807. * @param subMesh defines which submesh to render
  98808. */
  98809. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98810. serialize(): any;
  98811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98812. protected _dumpPropertiesCode(): string;
  98813. }
  98814. }
  98815. declare module BABYLON {
  98816. /**
  98817. * Block used to output the vertex position
  98818. */
  98819. export class VertexOutputBlock extends NodeMaterialBlock {
  98820. /**
  98821. * Creates a new VertexOutputBlock
  98822. * @param name defines the block name
  98823. */
  98824. constructor(name: string);
  98825. /**
  98826. * Gets the current class name
  98827. * @returns the class name
  98828. */
  98829. getClassName(): string;
  98830. /**
  98831. * Gets the vector input component
  98832. */
  98833. get vector(): NodeMaterialConnectionPoint;
  98834. protected _buildBlock(state: NodeMaterialBuildState): this;
  98835. }
  98836. }
  98837. declare module BABYLON {
  98838. /**
  98839. * Block used to output the final color
  98840. */
  98841. export class FragmentOutputBlock extends NodeMaterialBlock {
  98842. /**
  98843. * Create a new FragmentOutputBlock
  98844. * @param name defines the block name
  98845. */
  98846. constructor(name: string);
  98847. /**
  98848. * Gets the current class name
  98849. * @returns the class name
  98850. */
  98851. getClassName(): string;
  98852. /**
  98853. * Gets the rgba input component
  98854. */
  98855. get rgba(): NodeMaterialConnectionPoint;
  98856. /**
  98857. * Gets the rgb input component
  98858. */
  98859. get rgb(): NodeMaterialConnectionPoint;
  98860. /**
  98861. * Gets the a input component
  98862. */
  98863. get a(): NodeMaterialConnectionPoint;
  98864. protected _buildBlock(state: NodeMaterialBuildState): this;
  98865. }
  98866. }
  98867. declare module BABYLON {
  98868. /**
  98869. * Block used for the particle ramp gradient section
  98870. */
  98871. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98872. /**
  98873. * Create a new ParticleRampGradientBlock
  98874. * @param name defines the block name
  98875. */
  98876. constructor(name: string);
  98877. /**
  98878. * Gets the current class name
  98879. * @returns the class name
  98880. */
  98881. getClassName(): string;
  98882. /**
  98883. * Gets the color input component
  98884. */
  98885. get color(): NodeMaterialConnectionPoint;
  98886. /**
  98887. * Gets the rampColor output component
  98888. */
  98889. get rampColor(): NodeMaterialConnectionPoint;
  98890. /**
  98891. * Initialize the block and prepare the context for build
  98892. * @param state defines the state that will be used for the build
  98893. */
  98894. initialize(state: NodeMaterialBuildState): void;
  98895. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98896. }
  98897. }
  98898. declare module BABYLON {
  98899. /**
  98900. * Block used for the particle blend multiply section
  98901. */
  98902. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98903. /**
  98904. * Create a new ParticleBlendMultiplyBlock
  98905. * @param name defines the block name
  98906. */
  98907. constructor(name: string);
  98908. /**
  98909. * Gets the current class name
  98910. * @returns the class name
  98911. */
  98912. getClassName(): string;
  98913. /**
  98914. * Gets the color input component
  98915. */
  98916. get color(): NodeMaterialConnectionPoint;
  98917. /**
  98918. * Gets the alphaTexture input component
  98919. */
  98920. get alphaTexture(): NodeMaterialConnectionPoint;
  98921. /**
  98922. * Gets the alphaColor input component
  98923. */
  98924. get alphaColor(): NodeMaterialConnectionPoint;
  98925. /**
  98926. * Gets the blendColor output component
  98927. */
  98928. get blendColor(): NodeMaterialConnectionPoint;
  98929. /**
  98930. * Initialize the block and prepare the context for build
  98931. * @param state defines the state that will be used for the build
  98932. */
  98933. initialize(state: NodeMaterialBuildState): void;
  98934. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98935. }
  98936. }
  98937. declare module BABYLON {
  98938. /**
  98939. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98940. */
  98941. export class VectorMergerBlock extends NodeMaterialBlock {
  98942. /**
  98943. * Create a new VectorMergerBlock
  98944. * @param name defines the block name
  98945. */
  98946. constructor(name: string);
  98947. /**
  98948. * Gets the current class name
  98949. * @returns the class name
  98950. */
  98951. getClassName(): string;
  98952. /**
  98953. * Gets the xyz component (input)
  98954. */
  98955. get xyzIn(): NodeMaterialConnectionPoint;
  98956. /**
  98957. * Gets the xy component (input)
  98958. */
  98959. get xyIn(): NodeMaterialConnectionPoint;
  98960. /**
  98961. * Gets the x component (input)
  98962. */
  98963. get x(): NodeMaterialConnectionPoint;
  98964. /**
  98965. * Gets the y component (input)
  98966. */
  98967. get y(): NodeMaterialConnectionPoint;
  98968. /**
  98969. * Gets the z component (input)
  98970. */
  98971. get z(): NodeMaterialConnectionPoint;
  98972. /**
  98973. * Gets the w component (input)
  98974. */
  98975. get w(): NodeMaterialConnectionPoint;
  98976. /**
  98977. * Gets the xyzw component (output)
  98978. */
  98979. get xyzw(): NodeMaterialConnectionPoint;
  98980. /**
  98981. * Gets the xyz component (output)
  98982. */
  98983. get xyzOut(): NodeMaterialConnectionPoint;
  98984. /**
  98985. * Gets the xy component (output)
  98986. */
  98987. get xyOut(): NodeMaterialConnectionPoint;
  98988. /**
  98989. * Gets the xy component (output)
  98990. * @deprecated Please use xyOut instead.
  98991. */
  98992. get xy(): NodeMaterialConnectionPoint;
  98993. /**
  98994. * Gets the xyz component (output)
  98995. * @deprecated Please use xyzOut instead.
  98996. */
  98997. get xyz(): NodeMaterialConnectionPoint;
  98998. protected _buildBlock(state: NodeMaterialBuildState): this;
  98999. }
  99000. }
  99001. declare module BABYLON {
  99002. /**
  99003. * Block used to remap a float from a range to a new one
  99004. */
  99005. export class RemapBlock extends NodeMaterialBlock {
  99006. /**
  99007. * Gets or sets the source range
  99008. */
  99009. sourceRange: Vector2;
  99010. /**
  99011. * Gets or sets the target range
  99012. */
  99013. targetRange: Vector2;
  99014. /**
  99015. * Creates a new RemapBlock
  99016. * @param name defines the block name
  99017. */
  99018. constructor(name: string);
  99019. /**
  99020. * Gets the current class name
  99021. * @returns the class name
  99022. */
  99023. getClassName(): string;
  99024. /**
  99025. * Gets the input component
  99026. */
  99027. get input(): NodeMaterialConnectionPoint;
  99028. /**
  99029. * Gets the source min input component
  99030. */
  99031. get sourceMin(): NodeMaterialConnectionPoint;
  99032. /**
  99033. * Gets the source max input component
  99034. */
  99035. get sourceMax(): NodeMaterialConnectionPoint;
  99036. /**
  99037. * Gets the target min input component
  99038. */
  99039. get targetMin(): NodeMaterialConnectionPoint;
  99040. /**
  99041. * Gets the target max input component
  99042. */
  99043. get targetMax(): NodeMaterialConnectionPoint;
  99044. /**
  99045. * Gets the output component
  99046. */
  99047. get output(): NodeMaterialConnectionPoint;
  99048. protected _buildBlock(state: NodeMaterialBuildState): this;
  99049. protected _dumpPropertiesCode(): string;
  99050. serialize(): any;
  99051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99052. }
  99053. }
  99054. declare module BABYLON {
  99055. /**
  99056. * Block used to multiply 2 values
  99057. */
  99058. export class MultiplyBlock extends NodeMaterialBlock {
  99059. /**
  99060. * Creates a new MultiplyBlock
  99061. * @param name defines the block name
  99062. */
  99063. constructor(name: string);
  99064. /**
  99065. * Gets the current class name
  99066. * @returns the class name
  99067. */
  99068. getClassName(): string;
  99069. /**
  99070. * Gets the left operand input component
  99071. */
  99072. get left(): NodeMaterialConnectionPoint;
  99073. /**
  99074. * Gets the right operand input component
  99075. */
  99076. get right(): NodeMaterialConnectionPoint;
  99077. /**
  99078. * Gets the output component
  99079. */
  99080. get output(): NodeMaterialConnectionPoint;
  99081. protected _buildBlock(state: NodeMaterialBuildState): this;
  99082. }
  99083. }
  99084. declare module BABYLON {
  99085. /**
  99086. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99087. */
  99088. export class ColorSplitterBlock extends NodeMaterialBlock {
  99089. /**
  99090. * Create a new ColorSplitterBlock
  99091. * @param name defines the block name
  99092. */
  99093. constructor(name: string);
  99094. /**
  99095. * Gets the current class name
  99096. * @returns the class name
  99097. */
  99098. getClassName(): string;
  99099. /**
  99100. * Gets the rgba component (input)
  99101. */
  99102. get rgba(): NodeMaterialConnectionPoint;
  99103. /**
  99104. * Gets the rgb component (input)
  99105. */
  99106. get rgbIn(): NodeMaterialConnectionPoint;
  99107. /**
  99108. * Gets the rgb component (output)
  99109. */
  99110. get rgbOut(): NodeMaterialConnectionPoint;
  99111. /**
  99112. * Gets the r component (output)
  99113. */
  99114. get r(): NodeMaterialConnectionPoint;
  99115. /**
  99116. * Gets the g component (output)
  99117. */
  99118. get g(): NodeMaterialConnectionPoint;
  99119. /**
  99120. * Gets the b component (output)
  99121. */
  99122. get b(): NodeMaterialConnectionPoint;
  99123. /**
  99124. * Gets the a component (output)
  99125. */
  99126. get a(): NodeMaterialConnectionPoint;
  99127. protected _inputRename(name: string): string;
  99128. protected _outputRename(name: string): string;
  99129. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99130. }
  99131. }
  99132. declare module BABYLON {
  99133. /**
  99134. * Interface used to configure the node material editor
  99135. */
  99136. export interface INodeMaterialEditorOptions {
  99137. /** Define the URl to load node editor script */
  99138. editorURL?: string;
  99139. }
  99140. /** @hidden */
  99141. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99142. NORMAL: boolean;
  99143. TANGENT: boolean;
  99144. UV1: boolean;
  99145. /** BONES */
  99146. NUM_BONE_INFLUENCERS: number;
  99147. BonesPerMesh: number;
  99148. BONETEXTURE: boolean;
  99149. /** MORPH TARGETS */
  99150. MORPHTARGETS: boolean;
  99151. MORPHTARGETS_NORMAL: boolean;
  99152. MORPHTARGETS_TANGENT: boolean;
  99153. MORPHTARGETS_UV: boolean;
  99154. NUM_MORPH_INFLUENCERS: number;
  99155. /** IMAGE PROCESSING */
  99156. IMAGEPROCESSING: boolean;
  99157. VIGNETTE: boolean;
  99158. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99159. VIGNETTEBLENDMODEOPAQUE: boolean;
  99160. TONEMAPPING: boolean;
  99161. TONEMAPPING_ACES: boolean;
  99162. CONTRAST: boolean;
  99163. EXPOSURE: boolean;
  99164. COLORCURVES: boolean;
  99165. COLORGRADING: boolean;
  99166. COLORGRADING3D: boolean;
  99167. SAMPLER3DGREENDEPTH: boolean;
  99168. SAMPLER3DBGRMAP: boolean;
  99169. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99170. /** MISC. */
  99171. BUMPDIRECTUV: number;
  99172. constructor();
  99173. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99174. }
  99175. /**
  99176. * Class used to configure NodeMaterial
  99177. */
  99178. export interface INodeMaterialOptions {
  99179. /**
  99180. * Defines if blocks should emit comments
  99181. */
  99182. emitComments: boolean;
  99183. }
  99184. /**
  99185. * Class used to create a node based material built by assembling shader blocks
  99186. */
  99187. export class NodeMaterial extends PushMaterial {
  99188. private static _BuildIdGenerator;
  99189. private _options;
  99190. private _vertexCompilationState;
  99191. private _fragmentCompilationState;
  99192. private _sharedData;
  99193. private _buildId;
  99194. private _buildWasSuccessful;
  99195. private _cachedWorldViewMatrix;
  99196. private _cachedWorldViewProjectionMatrix;
  99197. private _optimizers;
  99198. private _animationFrame;
  99199. /** Define the Url to load node editor script */
  99200. static EditorURL: string;
  99201. /** Define the Url to load snippets */
  99202. static SnippetUrl: string;
  99203. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99204. static IgnoreTexturesAtLoadTime: boolean;
  99205. private BJSNODEMATERIALEDITOR;
  99206. /** Get the inspector from bundle or global */
  99207. private _getGlobalNodeMaterialEditor;
  99208. /**
  99209. * Snippet ID if the material was created from the snippet server
  99210. */
  99211. snippetId: string;
  99212. /**
  99213. * Gets or sets data used by visual editor
  99214. * @see https://nme.babylonjs.com
  99215. */
  99216. editorData: any;
  99217. /**
  99218. * 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)
  99219. */
  99220. ignoreAlpha: boolean;
  99221. /**
  99222. * Defines the maximum number of lights that can be used in the material
  99223. */
  99224. maxSimultaneousLights: number;
  99225. /**
  99226. * Observable raised when the material is built
  99227. */
  99228. onBuildObservable: Observable<NodeMaterial>;
  99229. /**
  99230. * Gets or sets the root nodes of the material vertex shader
  99231. */
  99232. _vertexOutputNodes: NodeMaterialBlock[];
  99233. /**
  99234. * Gets or sets the root nodes of the material fragment (pixel) shader
  99235. */
  99236. _fragmentOutputNodes: NodeMaterialBlock[];
  99237. /** Gets or sets options to control the node material overall behavior */
  99238. get options(): INodeMaterialOptions;
  99239. set options(options: INodeMaterialOptions);
  99240. /**
  99241. * Default configuration related to image processing available in the standard Material.
  99242. */
  99243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99244. /**
  99245. * Gets the image processing configuration used either in this material.
  99246. */
  99247. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99248. /**
  99249. * Sets the Default image processing configuration used either in the this material.
  99250. *
  99251. * If sets to null, the scene one is in use.
  99252. */
  99253. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99254. /**
  99255. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99256. */
  99257. attachedBlocks: NodeMaterialBlock[];
  99258. /**
  99259. * Specifies the mode of the node material
  99260. * @hidden
  99261. */
  99262. _mode: NodeMaterialModes;
  99263. /**
  99264. * Gets the mode property
  99265. */
  99266. get mode(): NodeMaterialModes;
  99267. /**
  99268. * Create a new node based material
  99269. * @param name defines the material name
  99270. * @param scene defines the hosting scene
  99271. * @param options defines creation option
  99272. */
  99273. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99274. /**
  99275. * Gets the current class name of the material e.g. "NodeMaterial"
  99276. * @returns the class name
  99277. */
  99278. getClassName(): string;
  99279. /**
  99280. * Keep track of the image processing observer to allow dispose and replace.
  99281. */
  99282. private _imageProcessingObserver;
  99283. /**
  99284. * Attaches a new image processing configuration to the Standard Material.
  99285. * @param configuration
  99286. */
  99287. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99288. /**
  99289. * Get a block by its name
  99290. * @param name defines the name of the block to retrieve
  99291. * @returns the required block or null if not found
  99292. */
  99293. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99294. /**
  99295. * Get a block by its name
  99296. * @param predicate defines the predicate used to find the good candidate
  99297. * @returns the required block or null if not found
  99298. */
  99299. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99300. /**
  99301. * Get an input block by its name
  99302. * @param predicate defines the predicate used to find the good candidate
  99303. * @returns the required input block or null if not found
  99304. */
  99305. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99306. /**
  99307. * Gets the list of input blocks attached to this material
  99308. * @returns an array of InputBlocks
  99309. */
  99310. getInputBlocks(): InputBlock[];
  99311. /**
  99312. * Adds a new optimizer to the list of optimizers
  99313. * @param optimizer defines the optimizers to add
  99314. * @returns the current material
  99315. */
  99316. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99317. /**
  99318. * Remove an optimizer from the list of optimizers
  99319. * @param optimizer defines the optimizers to remove
  99320. * @returns the current material
  99321. */
  99322. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99323. /**
  99324. * Add a new block to the list of output nodes
  99325. * @param node defines the node to add
  99326. * @returns the current material
  99327. */
  99328. addOutputNode(node: NodeMaterialBlock): this;
  99329. /**
  99330. * Remove a block from the list of root nodes
  99331. * @param node defines the node to remove
  99332. * @returns the current material
  99333. */
  99334. removeOutputNode(node: NodeMaterialBlock): this;
  99335. private _addVertexOutputNode;
  99336. private _removeVertexOutputNode;
  99337. private _addFragmentOutputNode;
  99338. private _removeFragmentOutputNode;
  99339. /**
  99340. * Specifies if the material will require alpha blending
  99341. * @returns a boolean specifying if alpha blending is needed
  99342. */
  99343. needAlphaBlending(): boolean;
  99344. /**
  99345. * Specifies if this material should be rendered in alpha test mode
  99346. * @returns a boolean specifying if an alpha test is needed.
  99347. */
  99348. needAlphaTesting(): boolean;
  99349. private _initializeBlock;
  99350. private _resetDualBlocks;
  99351. /**
  99352. * Remove a block from the current node material
  99353. * @param block defines the block to remove
  99354. */
  99355. removeBlock(block: NodeMaterialBlock): void;
  99356. /**
  99357. * Build the material and generates the inner effect
  99358. * @param verbose defines if the build should log activity
  99359. */
  99360. build(verbose?: boolean): void;
  99361. /**
  99362. * Runs an otpimization phase to try to improve the shader code
  99363. */
  99364. optimize(): void;
  99365. private _prepareDefinesForAttributes;
  99366. /**
  99367. * Create a post process from the material
  99368. * @param camera The camera to apply the render pass to.
  99369. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99371. * @param engine The engine which the post process will be applied. (default: current engine)
  99372. * @param reusable If the post process can be reused on the same frame. (default: false)
  99373. * @param textureType Type of textures used when performing the post process. (default: 0)
  99374. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99375. * @returns the post process created
  99376. */
  99377. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99378. /**
  99379. * Create the post process effect from the material
  99380. * @param postProcess The post process to create the effect for
  99381. */
  99382. createEffectForPostProcess(postProcess: PostProcess): void;
  99383. private _createEffectOrPostProcess;
  99384. private _createEffectForParticles;
  99385. /**
  99386. * Create the effect to be used as the custom effect for a particle system
  99387. * @param particleSystem Particle system to create the effect for
  99388. * @param onCompiled defines a function to call when the effect creation is successful
  99389. * @param onError defines a function to call when the effect creation has failed
  99390. */
  99391. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99392. private _processDefines;
  99393. /**
  99394. * Get if the submesh is ready to be used and all its information available.
  99395. * Child classes can use it to update shaders
  99396. * @param mesh defines the mesh to check
  99397. * @param subMesh defines which submesh to check
  99398. * @param useInstances specifies that instances should be used
  99399. * @returns a boolean indicating that the submesh is ready or not
  99400. */
  99401. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99402. /**
  99403. * Get a string representing the shaders built by the current node graph
  99404. */
  99405. get compiledShaders(): string;
  99406. /**
  99407. * Binds the world matrix to the material
  99408. * @param world defines the world transformation matrix
  99409. */
  99410. bindOnlyWorldMatrix(world: Matrix): void;
  99411. /**
  99412. * Binds the submesh to this material by preparing the effect and shader to draw
  99413. * @param world defines the world transformation matrix
  99414. * @param mesh defines the mesh containing the submesh
  99415. * @param subMesh defines the submesh to bind the material to
  99416. */
  99417. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99418. /**
  99419. * Gets the active textures from the material
  99420. * @returns an array of textures
  99421. */
  99422. getActiveTextures(): BaseTexture[];
  99423. /**
  99424. * Gets the list of texture blocks
  99425. * @returns an array of texture blocks
  99426. */
  99427. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99428. /**
  99429. * Specifies if the material uses a texture
  99430. * @param texture defines the texture to check against the material
  99431. * @returns a boolean specifying if the material uses the texture
  99432. */
  99433. hasTexture(texture: BaseTexture): boolean;
  99434. /**
  99435. * Disposes the material
  99436. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99437. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99438. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99439. */
  99440. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99441. /** Creates the node editor window. */
  99442. private _createNodeEditor;
  99443. /**
  99444. * Launch the node material editor
  99445. * @param config Define the configuration of the editor
  99446. * @return a promise fulfilled when the node editor is visible
  99447. */
  99448. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99449. /**
  99450. * Clear the current material
  99451. */
  99452. clear(): void;
  99453. /**
  99454. * Clear the current material and set it to a default state
  99455. */
  99456. setToDefault(): void;
  99457. /**
  99458. * Clear the current material and set it to a default state for post process
  99459. */
  99460. setToDefaultPostProcess(): void;
  99461. /**
  99462. * Clear the current material and set it to a default state for particle
  99463. */
  99464. setToDefaultParticle(): void;
  99465. /**
  99466. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99467. * @param url defines the url to load from
  99468. * @returns a promise that will fullfil when the material is fully loaded
  99469. */
  99470. loadAsync(url: string): Promise<void>;
  99471. private _gatherBlocks;
  99472. /**
  99473. * Generate a string containing the code declaration required to create an equivalent of this material
  99474. * @returns a string
  99475. */
  99476. generateCode(): string;
  99477. /**
  99478. * Serializes this material in a JSON representation
  99479. * @returns the serialized material object
  99480. */
  99481. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99482. private _restoreConnections;
  99483. /**
  99484. * Clear the current graph and load a new one from a serialization object
  99485. * @param source defines the JSON representation of the material
  99486. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99487. */
  99488. loadFromSerialization(source: any, rootUrl?: string): void;
  99489. /**
  99490. * Makes a duplicate of the current material.
  99491. * @param name - name to use for the new material.
  99492. */
  99493. clone(name: string): NodeMaterial;
  99494. /**
  99495. * Creates a node material from parsed material data
  99496. * @param source defines the JSON representation of the material
  99497. * @param scene defines the hosting scene
  99498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99499. * @returns a new node material
  99500. */
  99501. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99502. /**
  99503. * Creates a node material from a snippet saved in a remote file
  99504. * @param name defines the name of the material to create
  99505. * @param url defines the url to load from
  99506. * @param scene defines the hosting scene
  99507. * @returns a promise that will resolve to the new node material
  99508. */
  99509. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99510. /**
  99511. * Creates a node material from a snippet saved by the node material editor
  99512. * @param snippetId defines the snippet to load
  99513. * @param scene defines the hosting scene
  99514. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99515. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99516. * @returns a promise that will resolve to the new node material
  99517. */
  99518. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99519. /**
  99520. * Creates a new node material set to default basic configuration
  99521. * @param name defines the name of the material
  99522. * @param scene defines the hosting scene
  99523. * @returns a new NodeMaterial
  99524. */
  99525. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99526. }
  99527. }
  99528. declare module BABYLON {
  99529. /**
  99530. * Size options for a post process
  99531. */
  99532. export type PostProcessOptions = {
  99533. width: number;
  99534. height: number;
  99535. };
  99536. /**
  99537. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99538. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99539. */
  99540. export class PostProcess {
  99541. /** Name of the PostProcess. */
  99542. name: string;
  99543. /**
  99544. * Gets or sets the unique id of the post process
  99545. */
  99546. uniqueId: number;
  99547. /**
  99548. * Width of the texture to apply the post process on
  99549. */
  99550. width: number;
  99551. /**
  99552. * Height of the texture to apply the post process on
  99553. */
  99554. height: number;
  99555. /**
  99556. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  99557. */
  99558. nodeMaterialSource: Nullable<NodeMaterial>;
  99559. /**
  99560. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  99561. * @hidden
  99562. */
  99563. _outputTexture: Nullable<InternalTexture>;
  99564. /**
  99565. * Sampling mode used by the shader
  99566. * See https://doc.babylonjs.com/classes/3.1/texture
  99567. */
  99568. renderTargetSamplingMode: number;
  99569. /**
  99570. * Clear color to use when screen clearing
  99571. */
  99572. clearColor: Color4;
  99573. /**
  99574. * If the buffer needs to be cleared before applying the post process. (default: true)
  99575. * Should be set to false if shader will overwrite all previous pixels.
  99576. */
  99577. autoClear: boolean;
  99578. /**
  99579. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  99580. */
  99581. alphaMode: number;
  99582. /**
  99583. * Sets the setAlphaBlendConstants of the babylon engine
  99584. */
  99585. alphaConstants: Color4;
  99586. /**
  99587. * Animations to be used for the post processing
  99588. */
  99589. animations: Animation[];
  99590. /**
  99591. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  99592. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  99593. */
  99594. enablePixelPerfectMode: boolean;
  99595. /**
  99596. * Force the postprocess to be applied without taking in account viewport
  99597. */
  99598. forceFullscreenViewport: boolean;
  99599. /**
  99600. * List of inspectable custom properties (used by the Inspector)
  99601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99602. */
  99603. inspectableCustomProperties: IInspectable[];
  99604. /**
  99605. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  99606. *
  99607. * | Value | Type | Description |
  99608. * | ----- | ----------------------------------- | ----------- |
  99609. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  99610. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  99611. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  99612. *
  99613. */
  99614. scaleMode: number;
  99615. /**
  99616. * Force textures to be a power of two (default: false)
  99617. */
  99618. alwaysForcePOT: boolean;
  99619. private _samples;
  99620. /**
  99621. * Number of sample textures (default: 1)
  99622. */
  99623. get samples(): number;
  99624. set samples(n: number);
  99625. /**
  99626. * Modify the scale of the post process to be the same as the viewport (default: false)
  99627. */
  99628. adaptScaleToCurrentViewport: boolean;
  99629. private _camera;
  99630. private _scene;
  99631. private _engine;
  99632. private _options;
  99633. private _reusable;
  99634. private _textureType;
  99635. private _textureFormat;
  99636. /**
  99637. * Smart array of input and output textures for the post process.
  99638. * @hidden
  99639. */
  99640. _textures: SmartArray<InternalTexture>;
  99641. /**
  99642. * The index in _textures that corresponds to the output texture.
  99643. * @hidden
  99644. */
  99645. _currentRenderTextureInd: number;
  99646. private _effect;
  99647. private _samplers;
  99648. private _fragmentUrl;
  99649. private _vertexUrl;
  99650. private _parameters;
  99651. private _scaleRatio;
  99652. protected _indexParameters: any;
  99653. private _shareOutputWithPostProcess;
  99654. private _texelSize;
  99655. private _forcedOutputTexture;
  99656. /**
  99657. * Returns the fragment url or shader name used in the post process.
  99658. * @returns the fragment url or name in the shader store.
  99659. */
  99660. getEffectName(): string;
  99661. /**
  99662. * An event triggered when the postprocess is activated.
  99663. */
  99664. onActivateObservable: Observable<Camera>;
  99665. private _onActivateObserver;
  99666. /**
  99667. * A function that is added to the onActivateObservable
  99668. */
  99669. set onActivate(callback: Nullable<(camera: Camera) => void>);
  99670. /**
  99671. * An event triggered when the postprocess changes its size.
  99672. */
  99673. onSizeChangedObservable: Observable<PostProcess>;
  99674. private _onSizeChangedObserver;
  99675. /**
  99676. * A function that is added to the onSizeChangedObservable
  99677. */
  99678. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  99679. /**
  99680. * An event triggered when the postprocess applies its effect.
  99681. */
  99682. onApplyObservable: Observable<Effect>;
  99683. private _onApplyObserver;
  99684. /**
  99685. * A function that is added to the onApplyObservable
  99686. */
  99687. set onApply(callback: (effect: Effect) => void);
  99688. /**
  99689. * An event triggered before rendering the postprocess
  99690. */
  99691. onBeforeRenderObservable: Observable<Effect>;
  99692. private _onBeforeRenderObserver;
  99693. /**
  99694. * A function that is added to the onBeforeRenderObservable
  99695. */
  99696. set onBeforeRender(callback: (effect: Effect) => void);
  99697. /**
  99698. * An event triggered after rendering the postprocess
  99699. */
  99700. onAfterRenderObservable: Observable<Effect>;
  99701. private _onAfterRenderObserver;
  99702. /**
  99703. * A function that is added to the onAfterRenderObservable
  99704. */
  99705. set onAfterRender(callback: (efect: Effect) => void);
  99706. /**
  99707. * 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
  99708. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  99709. */
  99710. get inputTexture(): InternalTexture;
  99711. set inputTexture(value: InternalTexture);
  99712. /**
  99713. * Gets the camera which post process is applied to.
  99714. * @returns The camera the post process is applied to.
  99715. */
  99716. getCamera(): Camera;
  99717. /**
  99718. * Gets the texel size of the postprocess.
  99719. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  99720. */
  99721. get texelSize(): Vector2;
  99722. /**
  99723. * Creates a new instance PostProcess
  99724. * @param name The name of the PostProcess.
  99725. * @param fragmentUrl The url of the fragment shader to be used.
  99726. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  99727. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  99728. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99729. * @param camera The camera to apply the render pass to.
  99730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99731. * @param engine The engine which the post process will be applied. (default: current engine)
  99732. * @param reusable If the post process can be reused on the same frame. (default: false)
  99733. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  99734. * @param textureType Type of textures used when performing the post process. (default: 0)
  99735. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  99736. * @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
  99737. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  99738. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99739. */
  99740. constructor(
  99741. /** Name of the PostProcess. */
  99742. 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);
  99743. /**
  99744. * Gets a string idenfifying the name of the class
  99745. * @returns "PostProcess" string
  99746. */
  99747. getClassName(): string;
  99748. /**
  99749. * Gets the engine which this post process belongs to.
  99750. * @returns The engine the post process was enabled with.
  99751. */
  99752. getEngine(): Engine;
  99753. /**
  99754. * The effect that is created when initializing the post process.
  99755. * @returns The created effect corresponding the the postprocess.
  99756. */
  99757. getEffect(): Effect;
  99758. /**
  99759. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  99760. * @param postProcess The post process to share the output with.
  99761. * @returns This post process.
  99762. */
  99763. shareOutputWith(postProcess: PostProcess): PostProcess;
  99764. /**
  99765. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  99766. * This should be called if the post process that shares output with this post process is disabled/disposed.
  99767. */
  99768. useOwnOutput(): void;
  99769. /**
  99770. * Updates the effect with the current post process compile time values and recompiles the shader.
  99771. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99772. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99773. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99774. * @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
  99775. * @param onCompiled Called when the shader has been compiled.
  99776. * @param onError Called if there is an error when compiling a shader.
  99777. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  99778. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  99779. */
  99780. 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;
  99781. /**
  99782. * The post process is reusable if it can be used multiple times within one frame.
  99783. * @returns If the post process is reusable
  99784. */
  99785. isReusable(): boolean;
  99786. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  99787. markTextureDirty(): void;
  99788. /**
  99789. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  99790. * 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.
  99791. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  99792. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  99793. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  99794. * @returns The target texture that was bound to be written to.
  99795. */
  99796. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  99797. /**
  99798. * If the post process is supported.
  99799. */
  99800. get isSupported(): boolean;
  99801. /**
  99802. * The aspect ratio of the output texture.
  99803. */
  99804. get aspectRatio(): number;
  99805. /**
  99806. * Get a value indicating if the post-process is ready to be used
  99807. * @returns true if the post-process is ready (shader is compiled)
  99808. */
  99809. isReady(): boolean;
  99810. /**
  99811. * Binds all textures and uniforms to the shader, this will be run on every pass.
  99812. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  99813. */
  99814. apply(): Nullable<Effect>;
  99815. private _disposeTextures;
  99816. /**
  99817. * Disposes the post process.
  99818. * @param camera The camera to dispose the post process on.
  99819. */
  99820. dispose(camera?: Camera): void;
  99821. }
  99822. }
  99823. declare module BABYLON {
  99824. /** @hidden */
  99825. export var kernelBlurVaryingDeclaration: {
  99826. name: string;
  99827. shader: string;
  99828. };
  99829. }
  99830. declare module BABYLON {
  99831. /** @hidden */
  99832. export var kernelBlurFragment: {
  99833. name: string;
  99834. shader: string;
  99835. };
  99836. }
  99837. declare module BABYLON {
  99838. /** @hidden */
  99839. export var kernelBlurFragment2: {
  99840. name: string;
  99841. shader: string;
  99842. };
  99843. }
  99844. declare module BABYLON {
  99845. /** @hidden */
  99846. export var kernelBlurPixelShader: {
  99847. name: string;
  99848. shader: string;
  99849. };
  99850. }
  99851. declare module BABYLON {
  99852. /** @hidden */
  99853. export var kernelBlurVertex: {
  99854. name: string;
  99855. shader: string;
  99856. };
  99857. }
  99858. declare module BABYLON {
  99859. /** @hidden */
  99860. export var kernelBlurVertexShader: {
  99861. name: string;
  99862. shader: string;
  99863. };
  99864. }
  99865. declare module BABYLON {
  99866. /**
  99867. * The Blur Post Process which blurs an image based on a kernel and direction.
  99868. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  99869. */
  99870. export class BlurPostProcess extends PostProcess {
  99871. /** The direction in which to blur the image. */
  99872. direction: Vector2;
  99873. private blockCompilation;
  99874. protected _kernel: number;
  99875. protected _idealKernel: number;
  99876. protected _packedFloat: boolean;
  99877. private _staticDefines;
  99878. /**
  99879. * Sets the length in pixels of the blur sample region
  99880. */
  99881. set kernel(v: number);
  99882. /**
  99883. * Gets the length in pixels of the blur sample region
  99884. */
  99885. get kernel(): number;
  99886. /**
  99887. * Sets wether or not the blur needs to unpack/repack floats
  99888. */
  99889. set packedFloat(v: boolean);
  99890. /**
  99891. * Gets wether or not the blur is unpacking/repacking floats
  99892. */
  99893. get packedFloat(): boolean;
  99894. /**
  99895. * Creates a new instance BlurPostProcess
  99896. * @param name The name of the effect.
  99897. * @param direction The direction in which to blur the image.
  99898. * @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.
  99899. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99900. * @param camera The camera to apply the render pass to.
  99901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99902. * @param engine The engine which the post process will be applied. (default: current engine)
  99903. * @param reusable If the post process can be reused on the same frame. (default: false)
  99904. * @param textureType Type of textures used when performing the post process. (default: 0)
  99905. * @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)
  99906. */
  99907. constructor(name: string,
  99908. /** The direction in which to blur the image. */
  99909. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  99910. /**
  99911. * Updates the effect with the current post process compile time values and recompiles the shader.
  99912. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99913. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99914. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99915. * @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
  99916. * @param onCompiled Called when the shader has been compiled.
  99917. * @param onError Called if there is an error when compiling a shader.
  99918. */
  99919. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99920. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99921. /**
  99922. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  99923. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  99924. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  99925. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  99926. * The gaps between physical kernels are compensated for in the weighting of the samples
  99927. * @param idealKernel Ideal blur kernel.
  99928. * @return Nearest best kernel.
  99929. */
  99930. protected _nearestBestKernel(idealKernel: number): number;
  99931. /**
  99932. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  99933. * @param x The point on the Gaussian distribution to sample.
  99934. * @return the value of the Gaussian function at x.
  99935. */
  99936. protected _gaussianWeight(x: number): number;
  99937. /**
  99938. * Generates a string that can be used as a floating point number in GLSL.
  99939. * @param x Value to print.
  99940. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  99941. * @return GLSL float string.
  99942. */
  99943. protected _glslFloat(x: number, decimalFigures?: number): string;
  99944. }
  99945. }
  99946. declare module BABYLON {
  99947. /**
  99948. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99949. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99950. * You can then easily use it as a reflectionTexture on a flat surface.
  99951. * In case the surface is not a plane, please consider relying on reflection probes.
  99952. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99953. */
  99954. export class MirrorTexture extends RenderTargetTexture {
  99955. private scene;
  99956. /**
  99957. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  99958. * 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.
  99959. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99960. */
  99961. mirrorPlane: Plane;
  99962. /**
  99963. * Define the blur ratio used to blur the reflection if needed.
  99964. */
  99965. set blurRatio(value: number);
  99966. get blurRatio(): number;
  99967. /**
  99968. * Define the adaptive blur kernel used to blur the reflection if needed.
  99969. * This will autocompute the closest best match for the `blurKernel`
  99970. */
  99971. set adaptiveBlurKernel(value: number);
  99972. /**
  99973. * Define the blur kernel used to blur the reflection if needed.
  99974. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99975. */
  99976. set blurKernel(value: number);
  99977. /**
  99978. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  99979. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99980. */
  99981. set blurKernelX(value: number);
  99982. get blurKernelX(): number;
  99983. /**
  99984. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  99985. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99986. */
  99987. set blurKernelY(value: number);
  99988. get blurKernelY(): number;
  99989. private _autoComputeBlurKernel;
  99990. protected _onRatioRescale(): void;
  99991. private _updateGammaSpace;
  99992. private _imageProcessingConfigChangeObserver;
  99993. private _transformMatrix;
  99994. private _mirrorMatrix;
  99995. private _savedViewMatrix;
  99996. private _blurX;
  99997. private _blurY;
  99998. private _adaptiveBlurKernel;
  99999. private _blurKernelX;
  100000. private _blurKernelY;
  100001. private _blurRatio;
  100002. /**
  100003. * Instantiates a Mirror Texture.
  100004. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100005. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100006. * You can then easily use it as a reflectionTexture on a flat surface.
  100007. * In case the surface is not a plane, please consider relying on reflection probes.
  100008. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100009. * @param name
  100010. * @param size
  100011. * @param scene
  100012. * @param generateMipMaps
  100013. * @param type
  100014. * @param samplingMode
  100015. * @param generateDepthBuffer
  100016. */
  100017. constructor(name: string, size: number | {
  100018. width: number;
  100019. height: number;
  100020. } | {
  100021. ratio: number;
  100022. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100023. private _preparePostProcesses;
  100024. /**
  100025. * Clone the mirror texture.
  100026. * @returns the cloned texture
  100027. */
  100028. clone(): MirrorTexture;
  100029. /**
  100030. * Serialize the texture to a JSON representation you could use in Parse later on
  100031. * @returns the serialized JSON representation
  100032. */
  100033. serialize(): any;
  100034. /**
  100035. * Dispose the texture and release its associated resources.
  100036. */
  100037. dispose(): void;
  100038. }
  100039. }
  100040. declare module BABYLON {
  100041. /**
  100042. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100043. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100044. */
  100045. export class Texture extends BaseTexture {
  100046. /**
  100047. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100048. */
  100049. static SerializeBuffers: boolean;
  100050. /** @hidden */
  100051. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100052. /** @hidden */
  100053. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100054. /** @hidden */
  100055. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100056. /** nearest is mag = nearest and min = nearest and mip = linear */
  100057. static readonly NEAREST_SAMPLINGMODE: number;
  100058. /** nearest is mag = nearest and min = nearest and mip = linear */
  100059. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100060. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100061. static readonly BILINEAR_SAMPLINGMODE: number;
  100062. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100063. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100064. /** Trilinear is mag = linear and min = linear and mip = linear */
  100065. static readonly TRILINEAR_SAMPLINGMODE: number;
  100066. /** Trilinear is mag = linear and min = linear and mip = linear */
  100067. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100068. /** mag = nearest and min = nearest and mip = nearest */
  100069. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100070. /** mag = nearest and min = linear and mip = nearest */
  100071. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100072. /** mag = nearest and min = linear and mip = linear */
  100073. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100074. /** mag = nearest and min = linear and mip = none */
  100075. static readonly NEAREST_LINEAR: number;
  100076. /** mag = nearest and min = nearest and mip = none */
  100077. static readonly NEAREST_NEAREST: number;
  100078. /** mag = linear and min = nearest and mip = nearest */
  100079. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100080. /** mag = linear and min = nearest and mip = linear */
  100081. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100082. /** mag = linear and min = linear and mip = none */
  100083. static readonly LINEAR_LINEAR: number;
  100084. /** mag = linear and min = nearest and mip = none */
  100085. static readonly LINEAR_NEAREST: number;
  100086. /** Explicit coordinates mode */
  100087. static readonly EXPLICIT_MODE: number;
  100088. /** Spherical coordinates mode */
  100089. static readonly SPHERICAL_MODE: number;
  100090. /** Planar coordinates mode */
  100091. static readonly PLANAR_MODE: number;
  100092. /** Cubic coordinates mode */
  100093. static readonly CUBIC_MODE: number;
  100094. /** Projection coordinates mode */
  100095. static readonly PROJECTION_MODE: number;
  100096. /** Inverse Cubic coordinates mode */
  100097. static readonly SKYBOX_MODE: number;
  100098. /** Inverse Cubic coordinates mode */
  100099. static readonly INVCUBIC_MODE: number;
  100100. /** Equirectangular coordinates mode */
  100101. static readonly EQUIRECTANGULAR_MODE: number;
  100102. /** Equirectangular Fixed coordinates mode */
  100103. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100104. /** Equirectangular Fixed Mirrored coordinates mode */
  100105. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100106. /** Texture is not repeating outside of 0..1 UVs */
  100107. static readonly CLAMP_ADDRESSMODE: number;
  100108. /** Texture is repeating outside of 0..1 UVs */
  100109. static readonly WRAP_ADDRESSMODE: number;
  100110. /** Texture is repeating and mirrored */
  100111. static readonly MIRROR_ADDRESSMODE: number;
  100112. /**
  100113. * 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
  100114. */
  100115. static UseSerializedUrlIfAny: boolean;
  100116. /**
  100117. * Define the url of the texture.
  100118. */
  100119. url: Nullable<string>;
  100120. /**
  100121. * Define an offset on the texture to offset the u coordinates of the UVs
  100122. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100123. */
  100124. uOffset: number;
  100125. /**
  100126. * Define an offset on the texture to offset the v coordinates of the UVs
  100127. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100128. */
  100129. vOffset: number;
  100130. /**
  100131. * Define an offset on the texture to scale the u coordinates of the UVs
  100132. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100133. */
  100134. uScale: number;
  100135. /**
  100136. * Define an offset on the texture to scale the v coordinates of the UVs
  100137. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100138. */
  100139. vScale: number;
  100140. /**
  100141. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100142. * @see http://doc.babylonjs.com/how_to/more_materials
  100143. */
  100144. uAng: number;
  100145. /**
  100146. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100147. * @see http://doc.babylonjs.com/how_to/more_materials
  100148. */
  100149. vAng: number;
  100150. /**
  100151. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100152. * @see http://doc.babylonjs.com/how_to/more_materials
  100153. */
  100154. wAng: number;
  100155. /**
  100156. * Defines the center of rotation (U)
  100157. */
  100158. uRotationCenter: number;
  100159. /**
  100160. * Defines the center of rotation (V)
  100161. */
  100162. vRotationCenter: number;
  100163. /**
  100164. * Defines the center of rotation (W)
  100165. */
  100166. wRotationCenter: number;
  100167. /**
  100168. * Are mip maps generated for this texture or not.
  100169. */
  100170. get noMipmap(): boolean;
  100171. /**
  100172. * List of inspectable custom properties (used by the Inspector)
  100173. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100174. */
  100175. inspectableCustomProperties: Nullable<IInspectable[]>;
  100176. private _noMipmap;
  100177. /** @hidden */
  100178. _invertY: boolean;
  100179. private _rowGenerationMatrix;
  100180. private _cachedTextureMatrix;
  100181. private _projectionModeMatrix;
  100182. private _t0;
  100183. private _t1;
  100184. private _t2;
  100185. private _cachedUOffset;
  100186. private _cachedVOffset;
  100187. private _cachedUScale;
  100188. private _cachedVScale;
  100189. private _cachedUAng;
  100190. private _cachedVAng;
  100191. private _cachedWAng;
  100192. private _cachedProjectionMatrixId;
  100193. private _cachedCoordinatesMode;
  100194. /** @hidden */
  100195. protected _initialSamplingMode: number;
  100196. /** @hidden */
  100197. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100198. private _deleteBuffer;
  100199. protected _format: Nullable<number>;
  100200. private _delayedOnLoad;
  100201. private _delayedOnError;
  100202. private _mimeType?;
  100203. /**
  100204. * Observable triggered once the texture has been loaded.
  100205. */
  100206. onLoadObservable: Observable<Texture>;
  100207. protected _isBlocking: boolean;
  100208. /**
  100209. * Is the texture preventing material to render while loading.
  100210. * If false, a default texture will be used instead of the loading one during the preparation step.
  100211. */
  100212. set isBlocking(value: boolean);
  100213. get isBlocking(): boolean;
  100214. /**
  100215. * Get the current sampling mode associated with the texture.
  100216. */
  100217. get samplingMode(): number;
  100218. /**
  100219. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100220. */
  100221. get invertY(): boolean;
  100222. /**
  100223. * Instantiates a new texture.
  100224. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100225. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100226. * @param url defines the url of the picture to load as a texture
  100227. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100228. * @param noMipmap defines if the texture will require mip maps or not
  100229. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100230. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100231. * @param onLoad defines a callback triggered when the texture has been loaded
  100232. * @param onError defines a callback triggered when an error occurred during the loading session
  100233. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100234. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100235. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100236. * @param mimeType defines an optional mime type information
  100237. */
  100238. 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);
  100239. /**
  100240. * Update the url (and optional buffer) of this texture if url was null during construction.
  100241. * @param url the url of the texture
  100242. * @param buffer the buffer of the texture (defaults to null)
  100243. * @param onLoad callback called when the texture is loaded (defaults to null)
  100244. */
  100245. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100246. /**
  100247. * Finish the loading sequence of a texture flagged as delayed load.
  100248. * @hidden
  100249. */
  100250. delayLoad(): void;
  100251. private _prepareRowForTextureGeneration;
  100252. /**
  100253. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100254. * @returns the transform matrix of the texture.
  100255. */
  100256. getTextureMatrix(uBase?: number): Matrix;
  100257. /**
  100258. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100259. * @returns The reflection texture transform
  100260. */
  100261. getReflectionTextureMatrix(): Matrix;
  100262. /**
  100263. * Clones the texture.
  100264. * @returns the cloned texture
  100265. */
  100266. clone(): Texture;
  100267. /**
  100268. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100269. * @returns The JSON representation of the texture
  100270. */
  100271. serialize(): any;
  100272. /**
  100273. * Get the current class name of the texture useful for serialization or dynamic coding.
  100274. * @returns "Texture"
  100275. */
  100276. getClassName(): string;
  100277. /**
  100278. * Dispose the texture and release its associated resources.
  100279. */
  100280. dispose(): void;
  100281. /**
  100282. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100283. * @param parsedTexture Define the JSON representation of the texture
  100284. * @param scene Define the scene the parsed texture should be instantiated in
  100285. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100286. * @returns The parsed texture if successful
  100287. */
  100288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100289. /**
  100290. * Creates a texture from its base 64 representation.
  100291. * @param data Define the base64 payload without the data: prefix
  100292. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100293. * @param scene Define the scene the texture should belong to
  100294. * @param noMipmap Forces the texture to not create mip map information if true
  100295. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100296. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100297. * @param onLoad define a callback triggered when the texture has been loaded
  100298. * @param onError define a callback triggered when an error occurred during the loading session
  100299. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100300. * @returns the created texture
  100301. */
  100302. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100303. /**
  100304. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100305. * @param data Define the base64 payload without the data: prefix
  100306. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100307. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100308. * @param scene Define the scene the texture should belong to
  100309. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100310. * @param noMipmap Forces the texture to not create mip map information if true
  100311. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100312. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100313. * @param onLoad define a callback triggered when the texture has been loaded
  100314. * @param onError define a callback triggered when an error occurred during the loading session
  100315. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100316. * @returns the created texture
  100317. */
  100318. 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;
  100319. }
  100320. }
  100321. declare module BABYLON {
  100322. /**
  100323. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100324. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100325. */
  100326. export class PostProcessManager {
  100327. private _scene;
  100328. private _indexBuffer;
  100329. private _vertexBuffers;
  100330. /**
  100331. * Creates a new instance PostProcess
  100332. * @param scene The scene that the post process is associated with.
  100333. */
  100334. constructor(scene: Scene);
  100335. private _prepareBuffers;
  100336. private _buildIndexBuffer;
  100337. /**
  100338. * Rebuilds the vertex buffers of the manager.
  100339. * @hidden
  100340. */
  100341. _rebuild(): void;
  100342. /**
  100343. * Prepares a frame to be run through a post process.
  100344. * @param sourceTexture The input texture to the post procesess. (default: null)
  100345. * @param postProcesses An array of post processes to be run. (default: null)
  100346. * @returns True if the post processes were able to be run.
  100347. * @hidden
  100348. */
  100349. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100350. /**
  100351. * Manually render a set of post processes to a texture.
  100352. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100353. * @param postProcesses An array of post processes to be run.
  100354. * @param targetTexture The target texture to render to.
  100355. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100356. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100357. * @param lodLevel defines which lod of the texture to render to
  100358. */
  100359. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100360. /**
  100361. * Finalize the result of the output of the postprocesses.
  100362. * @param doNotPresent If true the result will not be displayed to the screen.
  100363. * @param targetTexture The target texture to render to.
  100364. * @param faceIndex The index of the face to bind the target texture to.
  100365. * @param postProcesses The array of post processes to render.
  100366. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100367. * @hidden
  100368. */
  100369. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100370. /**
  100371. * Disposes of the post process manager.
  100372. */
  100373. dispose(): void;
  100374. }
  100375. }
  100376. declare module BABYLON {
  100377. /**
  100378. * This Helps creating a texture that will be created from a camera in your scene.
  100379. * It is basically a dynamic texture that could be used to create special effects for instance.
  100380. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100381. */
  100382. export class RenderTargetTexture extends Texture {
  100383. isCube: boolean;
  100384. /**
  100385. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100386. */
  100387. static readonly REFRESHRATE_RENDER_ONCE: number;
  100388. /**
  100389. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100390. */
  100391. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100392. /**
  100393. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100394. * the central point of your effect and can save a lot of performances.
  100395. */
  100396. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100397. /**
  100398. * Use this predicate to dynamically define the list of mesh you want to render.
  100399. * If set, the renderList property will be overwritten.
  100400. */
  100401. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100402. private _renderList;
  100403. /**
  100404. * Use this list to define the list of mesh you want to render.
  100405. */
  100406. get renderList(): Nullable<Array<AbstractMesh>>;
  100407. set renderList(value: Nullable<Array<AbstractMesh>>);
  100408. /**
  100409. * Use this function to overload the renderList array at rendering time.
  100410. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100411. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100412. * the cube (if the RTT is a cube, else layerOrFace=0).
  100413. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100414. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100415. * hold dummy elements!
  100416. */
  100417. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100418. private _hookArray;
  100419. /**
  100420. * Define if particles should be rendered in your texture.
  100421. */
  100422. renderParticles: boolean;
  100423. /**
  100424. * Define if sprites should be rendered in your texture.
  100425. */
  100426. renderSprites: boolean;
  100427. /**
  100428. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100429. */
  100430. coordinatesMode: number;
  100431. /**
  100432. * Define the camera used to render the texture.
  100433. */
  100434. activeCamera: Nullable<Camera>;
  100435. /**
  100436. * Override the mesh isReady function with your own one.
  100437. */
  100438. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100439. /**
  100440. * Override the render function of the texture with your own one.
  100441. */
  100442. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100443. /**
  100444. * Define if camera post processes should be use while rendering the texture.
  100445. */
  100446. useCameraPostProcesses: boolean;
  100447. /**
  100448. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100449. */
  100450. ignoreCameraViewport: boolean;
  100451. private _postProcessManager;
  100452. private _postProcesses;
  100453. private _resizeObserver;
  100454. /**
  100455. * An event triggered when the texture is unbind.
  100456. */
  100457. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100458. /**
  100459. * An event triggered when the texture is unbind.
  100460. */
  100461. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100462. private _onAfterUnbindObserver;
  100463. /**
  100464. * Set a after unbind callback in the texture.
  100465. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100466. */
  100467. set onAfterUnbind(callback: () => void);
  100468. /**
  100469. * An event triggered before rendering the texture
  100470. */
  100471. onBeforeRenderObservable: Observable<number>;
  100472. private _onBeforeRenderObserver;
  100473. /**
  100474. * Set a before render callback in the texture.
  100475. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100476. */
  100477. set onBeforeRender(callback: (faceIndex: number) => void);
  100478. /**
  100479. * An event triggered after rendering the texture
  100480. */
  100481. onAfterRenderObservable: Observable<number>;
  100482. private _onAfterRenderObserver;
  100483. /**
  100484. * Set a after render callback in the texture.
  100485. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100486. */
  100487. set onAfterRender(callback: (faceIndex: number) => void);
  100488. /**
  100489. * An event triggered after the texture clear
  100490. */
  100491. onClearObservable: Observable<Engine>;
  100492. private _onClearObserver;
  100493. /**
  100494. * Set a clear callback in the texture.
  100495. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100496. */
  100497. set onClear(callback: (Engine: Engine) => void);
  100498. /**
  100499. * An event triggered when the texture is resized.
  100500. */
  100501. onResizeObservable: Observable<RenderTargetTexture>;
  100502. /**
  100503. * Define the clear color of the Render Target if it should be different from the scene.
  100504. */
  100505. clearColor: Color4;
  100506. protected _size: number | {
  100507. width: number;
  100508. height: number;
  100509. layers?: number;
  100510. };
  100511. protected _initialSizeParameter: number | {
  100512. width: number;
  100513. height: number;
  100514. } | {
  100515. ratio: number;
  100516. };
  100517. protected _sizeRatio: Nullable<number>;
  100518. /** @hidden */
  100519. _generateMipMaps: boolean;
  100520. protected _renderingManager: RenderingManager;
  100521. /** @hidden */
  100522. _waitingRenderList: string[];
  100523. protected _doNotChangeAspectRatio: boolean;
  100524. protected _currentRefreshId: number;
  100525. protected _refreshRate: number;
  100526. protected _textureMatrix: Matrix;
  100527. protected _samples: number;
  100528. protected _renderTargetOptions: RenderTargetCreationOptions;
  100529. /**
  100530. * Gets render target creation options that were used.
  100531. */
  100532. get renderTargetOptions(): RenderTargetCreationOptions;
  100533. protected _onRatioRescale(): void;
  100534. /**
  100535. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100536. * It must define where the camera used to render the texture is set
  100537. */
  100538. boundingBoxPosition: Vector3;
  100539. private _boundingBoxSize;
  100540. /**
  100541. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100542. * When defined, the cubemap will switch to local mode
  100543. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  100544. * @example https://www.babylonjs-playground.com/#RNASML
  100545. */
  100546. set boundingBoxSize(value: Vector3);
  100547. get boundingBoxSize(): Vector3;
  100548. /**
  100549. * In case the RTT has been created with a depth texture, get the associated
  100550. * depth texture.
  100551. * Otherwise, return null.
  100552. */
  100553. get depthStencilTexture(): Nullable<InternalTexture>;
  100554. /**
  100555. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  100556. * or used a shadow, depth texture...
  100557. * @param name The friendly name of the texture
  100558. * @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)
  100559. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  100560. * @param generateMipMaps True if mip maps need to be generated after render.
  100561. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  100562. * @param type The type of the buffer in the RTT (int, half float, float...)
  100563. * @param isCube True if a cube texture needs to be created
  100564. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  100565. * @param generateDepthBuffer True to generate a depth buffer
  100566. * @param generateStencilBuffer True to generate a stencil buffer
  100567. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  100568. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  100569. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100570. */
  100571. constructor(name: string, size: number | {
  100572. width: number;
  100573. height: number;
  100574. layers?: number;
  100575. } | {
  100576. ratio: number;
  100577. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  100578. /**
  100579. * Creates a depth stencil texture.
  100580. * This is only available in WebGL 2 or with the depth texture extension available.
  100581. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  100582. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  100583. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  100584. */
  100585. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  100586. private _processSizeParameter;
  100587. /**
  100588. * Define the number of samples to use in case of MSAA.
  100589. * It defaults to one meaning no MSAA has been enabled.
  100590. */
  100591. get samples(): number;
  100592. set samples(value: number);
  100593. /**
  100594. * Resets the refresh counter of the texture and start bak from scratch.
  100595. * Could be useful to regenerate the texture if it is setup to render only once.
  100596. */
  100597. resetRefreshCounter(): void;
  100598. /**
  100599. * Define the refresh rate of the texture or the rendering frequency.
  100600. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100601. */
  100602. get refreshRate(): number;
  100603. set refreshRate(value: number);
  100604. /**
  100605. * Adds a post process to the render target rendering passes.
  100606. * @param postProcess define the post process to add
  100607. */
  100608. addPostProcess(postProcess: PostProcess): void;
  100609. /**
  100610. * Clear all the post processes attached to the render target
  100611. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  100612. */
  100613. clearPostProcesses(dispose?: boolean): void;
  100614. /**
  100615. * Remove one of the post process from the list of attached post processes to the texture
  100616. * @param postProcess define the post process to remove from the list
  100617. */
  100618. removePostProcess(postProcess: PostProcess): void;
  100619. /** @hidden */
  100620. _shouldRender(): boolean;
  100621. /**
  100622. * Gets the actual render size of the texture.
  100623. * @returns the width of the render size
  100624. */
  100625. getRenderSize(): number;
  100626. /**
  100627. * Gets the actual render width of the texture.
  100628. * @returns the width of the render size
  100629. */
  100630. getRenderWidth(): number;
  100631. /**
  100632. * Gets the actual render height of the texture.
  100633. * @returns the height of the render size
  100634. */
  100635. getRenderHeight(): number;
  100636. /**
  100637. * Gets the actual number of layers of the texture.
  100638. * @returns the number of layers
  100639. */
  100640. getRenderLayers(): number;
  100641. /**
  100642. * Get if the texture can be rescaled or not.
  100643. */
  100644. get canRescale(): boolean;
  100645. /**
  100646. * Resize the texture using a ratio.
  100647. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  100648. */
  100649. scale(ratio: number): void;
  100650. /**
  100651. * Get the texture reflection matrix used to rotate/transform the reflection.
  100652. * @returns the reflection matrix
  100653. */
  100654. getReflectionTextureMatrix(): Matrix;
  100655. /**
  100656. * Resize the texture to a new desired size.
  100657. * Be carrefull as it will recreate all the data in the new texture.
  100658. * @param size Define the new size. It can be:
  100659. * - a number for squared texture,
  100660. * - an object containing { width: number, height: number }
  100661. * - or an object containing a ratio { ratio: number }
  100662. */
  100663. resize(size: number | {
  100664. width: number;
  100665. height: number;
  100666. } | {
  100667. ratio: number;
  100668. }): void;
  100669. private _defaultRenderListPrepared;
  100670. /**
  100671. * Renders all the objects from the render list into the texture.
  100672. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  100673. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  100674. */
  100675. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  100676. private _bestReflectionRenderTargetDimension;
  100677. private _prepareRenderingManager;
  100678. /**
  100679. * @hidden
  100680. * @param faceIndex face index to bind to if this is a cubetexture
  100681. * @param layer defines the index of the texture to bind in the array
  100682. */
  100683. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  100684. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  100685. private renderToTarget;
  100686. /**
  100687. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100688. * This allowed control for front to back rendering or reversly depending of the special needs.
  100689. *
  100690. * @param renderingGroupId The rendering group id corresponding to its index
  100691. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100692. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100693. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100694. */
  100695. 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;
  100696. /**
  100697. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100698. *
  100699. * @param renderingGroupId The rendering group id corresponding to its index
  100700. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100701. */
  100702. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  100703. /**
  100704. * Clones the texture.
  100705. * @returns the cloned texture
  100706. */
  100707. clone(): RenderTargetTexture;
  100708. /**
  100709. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100710. * @returns The JSON representation of the texture
  100711. */
  100712. serialize(): any;
  100713. /**
  100714. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  100715. */
  100716. disposeFramebufferObjects(): void;
  100717. /**
  100718. * Dispose the texture and release its associated resources.
  100719. */
  100720. dispose(): void;
  100721. /** @hidden */
  100722. _rebuild(): void;
  100723. /**
  100724. * Clear the info related to rendering groups preventing retention point in material dispose.
  100725. */
  100726. freeRenderingGroups(): void;
  100727. /**
  100728. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100729. * @returns the view count
  100730. */
  100731. getViewCount(): number;
  100732. }
  100733. }
  100734. declare module BABYLON {
  100735. /**
  100736. * Class used to manipulate GUIDs
  100737. */
  100738. export class GUID {
  100739. /**
  100740. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100741. * Be aware Math.random() could cause collisions, but:
  100742. * "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"
  100743. * @returns a pseudo random id
  100744. */
  100745. static RandomId(): string;
  100746. }
  100747. }
  100748. declare module BABYLON {
  100749. /**
  100750. * Options to be used when creating a shadow depth material
  100751. */
  100752. export interface IIOptionShadowDepthMaterial {
  100753. /** Variables in the vertex shader code that need to have their names remapped.
  100754. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  100755. * "var_name" should be either: worldPos or vNormalW
  100756. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  100757. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  100758. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  100759. */
  100760. remappedVariables?: string[];
  100761. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  100762. standalone?: boolean;
  100763. }
  100764. /**
  100765. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  100766. */
  100767. export class ShadowDepthWrapper {
  100768. private _scene;
  100769. private _options?;
  100770. private _baseMaterial;
  100771. private _onEffectCreatedObserver;
  100772. private _subMeshToEffect;
  100773. private _subMeshToDepthEffect;
  100774. private _meshes;
  100775. /** @hidden */
  100776. _matriceNames: any;
  100777. /** Gets the standalone status of the wrapper */
  100778. get standalone(): boolean;
  100779. /** Gets the base material the wrapper is built upon */
  100780. get baseMaterial(): Material;
  100781. /**
  100782. * Instantiate a new shadow depth wrapper.
  100783. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  100784. * generate the shadow depth map. For more information, please refer to the documentation:
  100785. * https://doc.babylonjs.com/babylon101/shadows
  100786. * @param baseMaterial Material to wrap
  100787. * @param scene Define the scene the material belongs to
  100788. * @param options Options used to create the wrapper
  100789. */
  100790. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  100791. /**
  100792. * Gets the effect to use to generate the depth map
  100793. * @param subMesh subMesh to get the effect for
  100794. * @param shadowGenerator shadow generator to get the effect for
  100795. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  100796. */
  100797. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  100798. /**
  100799. * Specifies that the submesh is ready to be used for depth rendering
  100800. * @param subMesh submesh to check
  100801. * @param defines the list of defines to take into account when checking the effect
  100802. * @param shadowGenerator combined with subMesh, it defines the effect to check
  100803. * @param useInstances specifies that instances should be used
  100804. * @returns a boolean indicating that the submesh is ready or not
  100805. */
  100806. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  100807. /**
  100808. * Disposes the resources
  100809. */
  100810. dispose(): void;
  100811. private _makeEffect;
  100812. }
  100813. }
  100814. declare module BABYLON {
  100815. /**
  100816. * Options for compiling materials.
  100817. */
  100818. export interface IMaterialCompilationOptions {
  100819. /**
  100820. * Defines whether clip planes are enabled.
  100821. */
  100822. clipPlane: boolean;
  100823. /**
  100824. * Defines whether instances are enabled.
  100825. */
  100826. useInstances: boolean;
  100827. }
  100828. /**
  100829. * Options passed when calling customShaderNameResolve
  100830. */
  100831. export interface ICustomShaderNameResolveOptions {
  100832. /**
  100833. * 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
  100834. */
  100835. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  100836. }
  100837. /**
  100838. * Base class for the main features of a material in Babylon.js
  100839. */
  100840. export class Material implements IAnimatable {
  100841. /**
  100842. * Returns the triangle fill mode
  100843. */
  100844. static readonly TriangleFillMode: number;
  100845. /**
  100846. * Returns the wireframe mode
  100847. */
  100848. static readonly WireFrameFillMode: number;
  100849. /**
  100850. * Returns the point fill mode
  100851. */
  100852. static readonly PointFillMode: number;
  100853. /**
  100854. * Returns the point list draw mode
  100855. */
  100856. static readonly PointListDrawMode: number;
  100857. /**
  100858. * Returns the line list draw mode
  100859. */
  100860. static readonly LineListDrawMode: number;
  100861. /**
  100862. * Returns the line loop draw mode
  100863. */
  100864. static readonly LineLoopDrawMode: number;
  100865. /**
  100866. * Returns the line strip draw mode
  100867. */
  100868. static readonly LineStripDrawMode: number;
  100869. /**
  100870. * Returns the triangle strip draw mode
  100871. */
  100872. static readonly TriangleStripDrawMode: number;
  100873. /**
  100874. * Returns the triangle fan draw mode
  100875. */
  100876. static readonly TriangleFanDrawMode: number;
  100877. /**
  100878. * Stores the clock-wise side orientation
  100879. */
  100880. static readonly ClockWiseSideOrientation: number;
  100881. /**
  100882. * Stores the counter clock-wise side orientation
  100883. */
  100884. static readonly CounterClockWiseSideOrientation: number;
  100885. /**
  100886. * The dirty texture flag value
  100887. */
  100888. static readonly TextureDirtyFlag: number;
  100889. /**
  100890. * The dirty light flag value
  100891. */
  100892. static readonly LightDirtyFlag: number;
  100893. /**
  100894. * The dirty fresnel flag value
  100895. */
  100896. static readonly FresnelDirtyFlag: number;
  100897. /**
  100898. * The dirty attribute flag value
  100899. */
  100900. static readonly AttributesDirtyFlag: number;
  100901. /**
  100902. * The dirty misc flag value
  100903. */
  100904. static readonly MiscDirtyFlag: number;
  100905. /**
  100906. * The all dirty flag value
  100907. */
  100908. static readonly AllDirtyFlag: number;
  100909. /**
  100910. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100911. */
  100912. static readonly MATERIAL_OPAQUE: number;
  100913. /**
  100914. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100915. */
  100916. static readonly MATERIAL_ALPHATEST: number;
  100917. /**
  100918. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100919. */
  100920. static readonly MATERIAL_ALPHABLEND: number;
  100921. /**
  100922. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100923. * They are also discarded below the alpha cutoff threshold to improve performances.
  100924. */
  100925. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  100926. /**
  100927. * Custom callback helping to override the default shader used in the material.
  100928. */
  100929. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  100930. /**
  100931. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  100932. */
  100933. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  100934. /**
  100935. * The ID of the material
  100936. */
  100937. id: string;
  100938. /**
  100939. * Gets or sets the unique id of the material
  100940. */
  100941. uniqueId: number;
  100942. /**
  100943. * The name of the material
  100944. */
  100945. name: string;
  100946. /**
  100947. * Gets or sets user defined metadata
  100948. */
  100949. metadata: any;
  100950. /**
  100951. * For internal use only. Please do not use.
  100952. */
  100953. reservedDataStore: any;
  100954. /**
  100955. * Specifies if the ready state should be checked on each call
  100956. */
  100957. checkReadyOnEveryCall: boolean;
  100958. /**
  100959. * Specifies if the ready state should be checked once
  100960. */
  100961. checkReadyOnlyOnce: boolean;
  100962. /**
  100963. * The state of the material
  100964. */
  100965. state: string;
  100966. /**
  100967. * The alpha value of the material
  100968. */
  100969. protected _alpha: number;
  100970. /**
  100971. * List of inspectable custom properties (used by the Inspector)
  100972. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100973. */
  100974. inspectableCustomProperties: IInspectable[];
  100975. /**
  100976. * Sets the alpha value of the material
  100977. */
  100978. set alpha(value: number);
  100979. /**
  100980. * Gets the alpha value of the material
  100981. */
  100982. get alpha(): number;
  100983. /**
  100984. * Specifies if back face culling is enabled
  100985. */
  100986. protected _backFaceCulling: boolean;
  100987. /**
  100988. * Sets the back-face culling state
  100989. */
  100990. set backFaceCulling(value: boolean);
  100991. /**
  100992. * Gets the back-face culling state
  100993. */
  100994. get backFaceCulling(): boolean;
  100995. /**
  100996. * Stores the value for side orientation
  100997. */
  100998. sideOrientation: number;
  100999. /**
  101000. * Callback triggered when the material is compiled
  101001. */
  101002. onCompiled: Nullable<(effect: Effect) => void>;
  101003. /**
  101004. * Callback triggered when an error occurs
  101005. */
  101006. onError: Nullable<(effect: Effect, errors: string) => void>;
  101007. /**
  101008. * Callback triggered to get the render target textures
  101009. */
  101010. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101011. /**
  101012. * Gets a boolean indicating that current material needs to register RTT
  101013. */
  101014. get hasRenderTargetTextures(): boolean;
  101015. /**
  101016. * Specifies if the material should be serialized
  101017. */
  101018. doNotSerialize: boolean;
  101019. /**
  101020. * @hidden
  101021. */
  101022. _storeEffectOnSubMeshes: boolean;
  101023. /**
  101024. * Stores the animations for the material
  101025. */
  101026. animations: Nullable<Array<Animation>>;
  101027. /**
  101028. * An event triggered when the material is disposed
  101029. */
  101030. onDisposeObservable: Observable<Material>;
  101031. /**
  101032. * An observer which watches for dispose events
  101033. */
  101034. private _onDisposeObserver;
  101035. private _onUnBindObservable;
  101036. /**
  101037. * Called during a dispose event
  101038. */
  101039. set onDispose(callback: () => void);
  101040. private _onBindObservable;
  101041. /**
  101042. * An event triggered when the material is bound
  101043. */
  101044. get onBindObservable(): Observable<AbstractMesh>;
  101045. /**
  101046. * An observer which watches for bind events
  101047. */
  101048. private _onBindObserver;
  101049. /**
  101050. * Called during a bind event
  101051. */
  101052. set onBind(callback: (Mesh: AbstractMesh) => void);
  101053. /**
  101054. * An event triggered when the material is unbound
  101055. */
  101056. get onUnBindObservable(): Observable<Material>;
  101057. protected _onEffectCreatedObservable: Nullable<Observable<{
  101058. effect: Effect;
  101059. subMesh: Nullable<SubMesh>;
  101060. }>>;
  101061. /**
  101062. * An event triggered when the effect is (re)created
  101063. */
  101064. get onEffectCreatedObservable(): Observable<{
  101065. effect: Effect;
  101066. subMesh: Nullable<SubMesh>;
  101067. }>;
  101068. /**
  101069. * Stores the value of the alpha mode
  101070. */
  101071. private _alphaMode;
  101072. /**
  101073. * Sets the value of the alpha mode.
  101074. *
  101075. * | Value | Type | Description |
  101076. * | --- | --- | --- |
  101077. * | 0 | ALPHA_DISABLE | |
  101078. * | 1 | ALPHA_ADD | |
  101079. * | 2 | ALPHA_COMBINE | |
  101080. * | 3 | ALPHA_SUBTRACT | |
  101081. * | 4 | ALPHA_MULTIPLY | |
  101082. * | 5 | ALPHA_MAXIMIZED | |
  101083. * | 6 | ALPHA_ONEONE | |
  101084. * | 7 | ALPHA_PREMULTIPLIED | |
  101085. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101086. * | 9 | ALPHA_INTERPOLATE | |
  101087. * | 10 | ALPHA_SCREENMODE | |
  101088. *
  101089. */
  101090. set alphaMode(value: number);
  101091. /**
  101092. * Gets the value of the alpha mode
  101093. */
  101094. get alphaMode(): number;
  101095. /**
  101096. * Stores the state of the need depth pre-pass value
  101097. */
  101098. private _needDepthPrePass;
  101099. /**
  101100. * Sets the need depth pre-pass value
  101101. */
  101102. set needDepthPrePass(value: boolean);
  101103. /**
  101104. * Gets the depth pre-pass value
  101105. */
  101106. get needDepthPrePass(): boolean;
  101107. /**
  101108. * Specifies if depth writing should be disabled
  101109. */
  101110. disableDepthWrite: boolean;
  101111. /**
  101112. * Specifies if color writing should be disabled
  101113. */
  101114. disableColorWrite: boolean;
  101115. /**
  101116. * Specifies if depth writing should be forced
  101117. */
  101118. forceDepthWrite: boolean;
  101119. /**
  101120. * Specifies the depth function that should be used. 0 means the default engine function
  101121. */
  101122. depthFunction: number;
  101123. /**
  101124. * Specifies if there should be a separate pass for culling
  101125. */
  101126. separateCullingPass: boolean;
  101127. /**
  101128. * Stores the state specifing if fog should be enabled
  101129. */
  101130. private _fogEnabled;
  101131. /**
  101132. * Sets the state for enabling fog
  101133. */
  101134. set fogEnabled(value: boolean);
  101135. /**
  101136. * Gets the value of the fog enabled state
  101137. */
  101138. get fogEnabled(): boolean;
  101139. /**
  101140. * Stores the size of points
  101141. */
  101142. pointSize: number;
  101143. /**
  101144. * Stores the z offset value
  101145. */
  101146. zOffset: number;
  101147. get wireframe(): boolean;
  101148. /**
  101149. * Sets the state of wireframe mode
  101150. */
  101151. set wireframe(value: boolean);
  101152. /**
  101153. * Gets the value specifying if point clouds are enabled
  101154. */
  101155. get pointsCloud(): boolean;
  101156. /**
  101157. * Sets the state of point cloud mode
  101158. */
  101159. set pointsCloud(value: boolean);
  101160. /**
  101161. * Gets the material fill mode
  101162. */
  101163. get fillMode(): number;
  101164. /**
  101165. * Sets the material fill mode
  101166. */
  101167. set fillMode(value: number);
  101168. /**
  101169. * @hidden
  101170. * Stores the effects for the material
  101171. */
  101172. _effect: Nullable<Effect>;
  101173. /**
  101174. * Specifies if uniform buffers should be used
  101175. */
  101176. private _useUBO;
  101177. /**
  101178. * Stores a reference to the scene
  101179. */
  101180. private _scene;
  101181. /**
  101182. * Stores the fill mode state
  101183. */
  101184. private _fillMode;
  101185. /**
  101186. * Specifies if the depth write state should be cached
  101187. */
  101188. private _cachedDepthWriteState;
  101189. /**
  101190. * Specifies if the color write state should be cached
  101191. */
  101192. private _cachedColorWriteState;
  101193. /**
  101194. * Specifies if the depth function state should be cached
  101195. */
  101196. private _cachedDepthFunctionState;
  101197. /**
  101198. * Stores the uniform buffer
  101199. */
  101200. protected _uniformBuffer: UniformBuffer;
  101201. /** @hidden */
  101202. _indexInSceneMaterialArray: number;
  101203. /** @hidden */
  101204. meshMap: Nullable<{
  101205. [id: string]: AbstractMesh | undefined;
  101206. }>;
  101207. /**
  101208. * Creates a material instance
  101209. * @param name defines the name of the material
  101210. * @param scene defines the scene to reference
  101211. * @param doNotAdd specifies if the material should be added to the scene
  101212. */
  101213. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101214. /**
  101215. * Returns a string representation of the current material
  101216. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101217. * @returns a string with material information
  101218. */
  101219. toString(fullDetails?: boolean): string;
  101220. /**
  101221. * Gets the class name of the material
  101222. * @returns a string with the class name of the material
  101223. */
  101224. getClassName(): string;
  101225. /**
  101226. * Specifies if updates for the material been locked
  101227. */
  101228. get isFrozen(): boolean;
  101229. /**
  101230. * Locks updates for the material
  101231. */
  101232. freeze(): void;
  101233. /**
  101234. * Unlocks updates for the material
  101235. */
  101236. unfreeze(): void;
  101237. /**
  101238. * Specifies if the material is ready to be used
  101239. * @param mesh defines the mesh to check
  101240. * @param useInstances specifies if instances should be used
  101241. * @returns a boolean indicating if the material is ready to be used
  101242. */
  101243. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101244. /**
  101245. * Specifies that the submesh is ready to be used
  101246. * @param mesh defines the mesh to check
  101247. * @param subMesh defines which submesh to check
  101248. * @param useInstances specifies that instances should be used
  101249. * @returns a boolean indicating that the submesh is ready or not
  101250. */
  101251. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101252. /**
  101253. * Returns the material effect
  101254. * @returns the effect associated with the material
  101255. */
  101256. getEffect(): Nullable<Effect>;
  101257. /**
  101258. * Returns the current scene
  101259. * @returns a Scene
  101260. */
  101261. getScene(): Scene;
  101262. /**
  101263. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101264. */
  101265. protected _forceAlphaTest: boolean;
  101266. /**
  101267. * The transparency mode of the material.
  101268. */
  101269. protected _transparencyMode: Nullable<number>;
  101270. /**
  101271. * Gets the current transparency mode.
  101272. */
  101273. get transparencyMode(): Nullable<number>;
  101274. /**
  101275. * Sets the transparency mode of the material.
  101276. *
  101277. * | Value | Type | Description |
  101278. * | ----- | ----------------------------------- | ----------- |
  101279. * | 0 | OPAQUE | |
  101280. * | 1 | ALPHATEST | |
  101281. * | 2 | ALPHABLEND | |
  101282. * | 3 | ALPHATESTANDBLEND | |
  101283. *
  101284. */
  101285. set transparencyMode(value: Nullable<number>);
  101286. /**
  101287. * Returns true if alpha blending should be disabled.
  101288. */
  101289. protected get _disableAlphaBlending(): boolean;
  101290. /**
  101291. * Specifies whether or not this material should be rendered in alpha blend mode.
  101292. * @returns a boolean specifying if alpha blending is needed
  101293. */
  101294. needAlphaBlending(): boolean;
  101295. /**
  101296. * Specifies if the mesh will require alpha blending
  101297. * @param mesh defines the mesh to check
  101298. * @returns a boolean specifying if alpha blending is needed for the mesh
  101299. */
  101300. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101301. /**
  101302. * Specifies whether or not this material should be rendered in alpha test mode.
  101303. * @returns a boolean specifying if an alpha test is needed.
  101304. */
  101305. needAlphaTesting(): boolean;
  101306. /**
  101307. * Specifies if material alpha testing should be turned on for the mesh
  101308. * @param mesh defines the mesh to check
  101309. */
  101310. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101311. /**
  101312. * Gets the texture used for the alpha test
  101313. * @returns the texture to use for alpha testing
  101314. */
  101315. getAlphaTestTexture(): Nullable<BaseTexture>;
  101316. /**
  101317. * Marks the material to indicate that it needs to be re-calculated
  101318. */
  101319. markDirty(): void;
  101320. /** @hidden */
  101321. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101322. /**
  101323. * Binds the material to the mesh
  101324. * @param world defines the world transformation matrix
  101325. * @param mesh defines the mesh to bind the material to
  101326. */
  101327. bind(world: Matrix, mesh?: Mesh): void;
  101328. /**
  101329. * Binds the submesh to the material
  101330. * @param world defines the world transformation matrix
  101331. * @param mesh defines the mesh containing the submesh
  101332. * @param subMesh defines the submesh to bind the material to
  101333. */
  101334. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101335. /**
  101336. * Binds the world matrix to the material
  101337. * @param world defines the world transformation matrix
  101338. */
  101339. bindOnlyWorldMatrix(world: Matrix): void;
  101340. /**
  101341. * Binds the scene's uniform buffer to the effect.
  101342. * @param effect defines the effect to bind to the scene uniform buffer
  101343. * @param sceneUbo defines the uniform buffer storing scene data
  101344. */
  101345. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101346. /**
  101347. * Binds the view matrix to the effect
  101348. * @param effect defines the effect to bind the view matrix to
  101349. */
  101350. bindView(effect: Effect): void;
  101351. /**
  101352. * Binds the view projection matrix to the effect
  101353. * @param effect defines the effect to bind the view projection matrix to
  101354. */
  101355. bindViewProjection(effect: Effect): void;
  101356. /**
  101357. * Processes to execute after binding the material to a mesh
  101358. * @param mesh defines the rendered mesh
  101359. */
  101360. protected _afterBind(mesh?: Mesh): void;
  101361. /**
  101362. * Unbinds the material from the mesh
  101363. */
  101364. unbind(): void;
  101365. /**
  101366. * Gets the active textures from the material
  101367. * @returns an array of textures
  101368. */
  101369. getActiveTextures(): BaseTexture[];
  101370. /**
  101371. * Specifies if the material uses a texture
  101372. * @param texture defines the texture to check against the material
  101373. * @returns a boolean specifying if the material uses the texture
  101374. */
  101375. hasTexture(texture: BaseTexture): boolean;
  101376. /**
  101377. * Makes a duplicate of the material, and gives it a new name
  101378. * @param name defines the new name for the duplicated material
  101379. * @returns the cloned material
  101380. */
  101381. clone(name: string): Nullable<Material>;
  101382. /**
  101383. * Gets the meshes bound to the material
  101384. * @returns an array of meshes bound to the material
  101385. */
  101386. getBindedMeshes(): AbstractMesh[];
  101387. /**
  101388. * Force shader compilation
  101389. * @param mesh defines the mesh associated with this material
  101390. * @param onCompiled defines a function to execute once the material is compiled
  101391. * @param options defines the options to configure the compilation
  101392. * @param onError defines a function to execute if the material fails compiling
  101393. */
  101394. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101395. /**
  101396. * Force shader compilation
  101397. * @param mesh defines the mesh that will use this material
  101398. * @param options defines additional options for compiling the shaders
  101399. * @returns a promise that resolves when the compilation completes
  101400. */
  101401. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101402. private static readonly _AllDirtyCallBack;
  101403. private static readonly _ImageProcessingDirtyCallBack;
  101404. private static readonly _TextureDirtyCallBack;
  101405. private static readonly _FresnelDirtyCallBack;
  101406. private static readonly _MiscDirtyCallBack;
  101407. private static readonly _LightsDirtyCallBack;
  101408. private static readonly _AttributeDirtyCallBack;
  101409. private static _FresnelAndMiscDirtyCallBack;
  101410. private static _TextureAndMiscDirtyCallBack;
  101411. private static readonly _DirtyCallbackArray;
  101412. private static readonly _RunDirtyCallBacks;
  101413. /**
  101414. * Marks a define in the material to indicate that it needs to be re-computed
  101415. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101416. */
  101417. markAsDirty(flag: number): void;
  101418. /**
  101419. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101420. * @param func defines a function which checks material defines against the submeshes
  101421. */
  101422. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101423. /**
  101424. * Indicates that we need to re-calculated for all submeshes
  101425. */
  101426. protected _markAllSubMeshesAsAllDirty(): void;
  101427. /**
  101428. * Indicates that image processing needs to be re-calculated for all submeshes
  101429. */
  101430. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101431. /**
  101432. * Indicates that textures need to be re-calculated for all submeshes
  101433. */
  101434. protected _markAllSubMeshesAsTexturesDirty(): void;
  101435. /**
  101436. * Indicates that fresnel needs to be re-calculated for all submeshes
  101437. */
  101438. protected _markAllSubMeshesAsFresnelDirty(): void;
  101439. /**
  101440. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101441. */
  101442. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101443. /**
  101444. * Indicates that lights need to be re-calculated for all submeshes
  101445. */
  101446. protected _markAllSubMeshesAsLightsDirty(): void;
  101447. /**
  101448. * Indicates that attributes need to be re-calculated for all submeshes
  101449. */
  101450. protected _markAllSubMeshesAsAttributesDirty(): void;
  101451. /**
  101452. * Indicates that misc needs to be re-calculated for all submeshes
  101453. */
  101454. protected _markAllSubMeshesAsMiscDirty(): void;
  101455. /**
  101456. * Indicates that textures and misc need to be re-calculated for all submeshes
  101457. */
  101458. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101459. /**
  101460. * Disposes the material
  101461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101464. */
  101465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101466. /** @hidden */
  101467. private releaseVertexArrayObject;
  101468. /**
  101469. * Serializes this material
  101470. * @returns the serialized material object
  101471. */
  101472. serialize(): any;
  101473. /**
  101474. * Creates a material from parsed material data
  101475. * @param parsedMaterial defines parsed material data
  101476. * @param scene defines the hosting scene
  101477. * @param rootUrl defines the root URL to use to load textures
  101478. * @returns a new material
  101479. */
  101480. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101481. }
  101482. }
  101483. declare module BABYLON {
  101484. /**
  101485. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101486. * separate meshes. This can be use to improve performances.
  101487. * @see http://doc.babylonjs.com/how_to/multi_materials
  101488. */
  101489. export class MultiMaterial extends Material {
  101490. private _subMaterials;
  101491. /**
  101492. * Gets or Sets the list of Materials used within the multi material.
  101493. * They need to be ordered according to the submeshes order in the associated mesh
  101494. */
  101495. get subMaterials(): Nullable<Material>[];
  101496. set subMaterials(value: Nullable<Material>[]);
  101497. /**
  101498. * Function used to align with Node.getChildren()
  101499. * @returns the list of Materials used within the multi material
  101500. */
  101501. getChildren(): Nullable<Material>[];
  101502. /**
  101503. * Instantiates a new Multi Material
  101504. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101505. * separate meshes. This can be use to improve performances.
  101506. * @see http://doc.babylonjs.com/how_to/multi_materials
  101507. * @param name Define the name in the scene
  101508. * @param scene Define the scene the material belongs to
  101509. */
  101510. constructor(name: string, scene: Scene);
  101511. private _hookArray;
  101512. /**
  101513. * Get one of the submaterial by its index in the submaterials array
  101514. * @param index The index to look the sub material at
  101515. * @returns The Material if the index has been defined
  101516. */
  101517. getSubMaterial(index: number): Nullable<Material>;
  101518. /**
  101519. * Get the list of active textures for the whole sub materials list.
  101520. * @returns All the textures that will be used during the rendering
  101521. */
  101522. getActiveTextures(): BaseTexture[];
  101523. /**
  101524. * Gets the current class name of the material e.g. "MultiMaterial"
  101525. * Mainly use in serialization.
  101526. * @returns the class name
  101527. */
  101528. getClassName(): string;
  101529. /**
  101530. * Checks if the material is ready to render the requested sub mesh
  101531. * @param mesh Define the mesh the submesh belongs to
  101532. * @param subMesh Define the sub mesh to look readyness for
  101533. * @param useInstances Define whether or not the material is used with instances
  101534. * @returns true if ready, otherwise false
  101535. */
  101536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101537. /**
  101538. * Clones the current material and its related sub materials
  101539. * @param name Define the name of the newly cloned material
  101540. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  101541. * @returns the cloned material
  101542. */
  101543. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  101544. /**
  101545. * Serializes the materials into a JSON representation.
  101546. * @returns the JSON representation
  101547. */
  101548. serialize(): any;
  101549. /**
  101550. * Dispose the material and release its associated resources
  101551. * @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)
  101552. * @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)
  101553. * @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)
  101554. */
  101555. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  101556. /**
  101557. * Creates a MultiMaterial from parsed MultiMaterial data.
  101558. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  101559. * @param scene defines the hosting scene
  101560. * @returns a new MultiMaterial
  101561. */
  101562. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  101563. }
  101564. }
  101565. declare module BABYLON {
  101566. /**
  101567. * Defines a subdivision inside a mesh
  101568. */
  101569. export class SubMesh implements ICullable {
  101570. /** the material index to use */
  101571. materialIndex: number;
  101572. /** vertex index start */
  101573. verticesStart: number;
  101574. /** vertices count */
  101575. verticesCount: number;
  101576. /** index start */
  101577. indexStart: number;
  101578. /** indices count */
  101579. indexCount: number;
  101580. /** @hidden */
  101581. _materialDefines: Nullable<MaterialDefines>;
  101582. /** @hidden */
  101583. _materialEffect: Nullable<Effect>;
  101584. /** @hidden */
  101585. _effectOverride: Nullable<Effect>;
  101586. /**
  101587. * Gets material defines used by the effect associated to the sub mesh
  101588. */
  101589. get materialDefines(): Nullable<MaterialDefines>;
  101590. /**
  101591. * Sets material defines used by the effect associated to the sub mesh
  101592. */
  101593. set materialDefines(defines: Nullable<MaterialDefines>);
  101594. /**
  101595. * Gets associated effect
  101596. */
  101597. get effect(): Nullable<Effect>;
  101598. /**
  101599. * Sets associated effect (effect used to render this submesh)
  101600. * @param effect defines the effect to associate with
  101601. * @param defines defines the set of defines used to compile this effect
  101602. */
  101603. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  101604. /** @hidden */
  101605. _linesIndexCount: number;
  101606. private _mesh;
  101607. private _renderingMesh;
  101608. private _boundingInfo;
  101609. private _linesIndexBuffer;
  101610. /** @hidden */
  101611. _lastColliderWorldVertices: Nullable<Vector3[]>;
  101612. /** @hidden */
  101613. _trianglePlanes: Plane[];
  101614. /** @hidden */
  101615. _lastColliderTransformMatrix: Nullable<Matrix>;
  101616. /** @hidden */
  101617. _renderId: number;
  101618. /** @hidden */
  101619. _alphaIndex: number;
  101620. /** @hidden */
  101621. _distanceToCamera: number;
  101622. /** @hidden */
  101623. _id: number;
  101624. private _currentMaterial;
  101625. /**
  101626. * Add a new submesh to a mesh
  101627. * @param materialIndex defines the material index to use
  101628. * @param verticesStart defines vertex index start
  101629. * @param verticesCount defines vertices count
  101630. * @param indexStart defines index start
  101631. * @param indexCount defines indices count
  101632. * @param mesh defines the parent mesh
  101633. * @param renderingMesh defines an optional rendering mesh
  101634. * @param createBoundingBox defines if bounding box should be created for this submesh
  101635. * @returns the new submesh
  101636. */
  101637. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  101638. /**
  101639. * Creates a new submesh
  101640. * @param materialIndex defines the material index to use
  101641. * @param verticesStart defines vertex index start
  101642. * @param verticesCount defines vertices count
  101643. * @param indexStart defines index start
  101644. * @param indexCount defines indices count
  101645. * @param mesh defines the parent mesh
  101646. * @param renderingMesh defines an optional rendering mesh
  101647. * @param createBoundingBox defines if bounding box should be created for this submesh
  101648. */
  101649. constructor(
  101650. /** the material index to use */
  101651. materialIndex: number,
  101652. /** vertex index start */
  101653. verticesStart: number,
  101654. /** vertices count */
  101655. verticesCount: number,
  101656. /** index start */
  101657. indexStart: number,
  101658. /** indices count */
  101659. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  101660. /**
  101661. * Returns true if this submesh covers the entire parent mesh
  101662. * @ignorenaming
  101663. */
  101664. get IsGlobal(): boolean;
  101665. /**
  101666. * Returns the submesh BoudingInfo object
  101667. * @returns current bounding info (or mesh's one if the submesh is global)
  101668. */
  101669. getBoundingInfo(): BoundingInfo;
  101670. /**
  101671. * Sets the submesh BoundingInfo
  101672. * @param boundingInfo defines the new bounding info to use
  101673. * @returns the SubMesh
  101674. */
  101675. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  101676. /**
  101677. * Returns the mesh of the current submesh
  101678. * @return the parent mesh
  101679. */
  101680. getMesh(): AbstractMesh;
  101681. /**
  101682. * Returns the rendering mesh of the submesh
  101683. * @returns the rendering mesh (could be different from parent mesh)
  101684. */
  101685. getRenderingMesh(): Mesh;
  101686. /**
  101687. * Returns the replacement mesh of the submesh
  101688. * @returns the replacement mesh (could be different from parent mesh)
  101689. */
  101690. getReplacementMesh(): Nullable<AbstractMesh>;
  101691. /**
  101692. * Returns the effective mesh of the submesh
  101693. * @returns the effective mesh (could be different from parent mesh)
  101694. */
  101695. getEffectiveMesh(): AbstractMesh;
  101696. /**
  101697. * Returns the submesh material
  101698. * @returns null or the current material
  101699. */
  101700. getMaterial(): Nullable<Material>;
  101701. /**
  101702. * Sets a new updated BoundingInfo object to the submesh
  101703. * @param data defines an optional position array to use to determine the bounding info
  101704. * @returns the SubMesh
  101705. */
  101706. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  101707. /** @hidden */
  101708. _checkCollision(collider: Collider): boolean;
  101709. /**
  101710. * Updates the submesh BoundingInfo
  101711. * @param world defines the world matrix to use to update the bounding info
  101712. * @returns the submesh
  101713. */
  101714. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  101715. /**
  101716. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  101717. * @param frustumPlanes defines the frustum planes
  101718. * @returns true if the submesh is intersecting with the frustum
  101719. */
  101720. isInFrustum(frustumPlanes: Plane[]): boolean;
  101721. /**
  101722. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  101723. * @param frustumPlanes defines the frustum planes
  101724. * @returns true if the submesh is inside the frustum
  101725. */
  101726. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101727. /**
  101728. * Renders the submesh
  101729. * @param enableAlphaMode defines if alpha needs to be used
  101730. * @returns the submesh
  101731. */
  101732. render(enableAlphaMode: boolean): SubMesh;
  101733. /**
  101734. * @hidden
  101735. */
  101736. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  101737. /**
  101738. * Checks if the submesh intersects with a ray
  101739. * @param ray defines the ray to test
  101740. * @returns true is the passed ray intersects the submesh bounding box
  101741. */
  101742. canIntersects(ray: Ray): boolean;
  101743. /**
  101744. * Intersects current submesh with a ray
  101745. * @param ray defines the ray to test
  101746. * @param positions defines mesh's positions array
  101747. * @param indices defines mesh's indices array
  101748. * @param fastCheck defines if the first intersection will be used (and not the closest)
  101749. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101750. * @returns intersection info or null if no intersection
  101751. */
  101752. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  101753. /** @hidden */
  101754. private _intersectLines;
  101755. /** @hidden */
  101756. private _intersectUnIndexedLines;
  101757. /** @hidden */
  101758. private _intersectTriangles;
  101759. /** @hidden */
  101760. private _intersectUnIndexedTriangles;
  101761. /** @hidden */
  101762. _rebuild(): void;
  101763. /**
  101764. * Creates a new submesh from the passed mesh
  101765. * @param newMesh defines the new hosting mesh
  101766. * @param newRenderingMesh defines an optional rendering mesh
  101767. * @returns the new submesh
  101768. */
  101769. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  101770. /**
  101771. * Release associated resources
  101772. */
  101773. dispose(): void;
  101774. /**
  101775. * Gets the class name
  101776. * @returns the string "SubMesh".
  101777. */
  101778. getClassName(): string;
  101779. /**
  101780. * Creates a new submesh from indices data
  101781. * @param materialIndex the index of the main mesh material
  101782. * @param startIndex the index where to start the copy in the mesh indices array
  101783. * @param indexCount the number of indices to copy then from the startIndex
  101784. * @param mesh the main mesh to create the submesh from
  101785. * @param renderingMesh the optional rendering mesh
  101786. * @returns a new submesh
  101787. */
  101788. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  101789. }
  101790. }
  101791. declare module BABYLON {
  101792. /**
  101793. * Class used to represent data loading progression
  101794. */
  101795. export class SceneLoaderFlags {
  101796. private static _ForceFullSceneLoadingForIncremental;
  101797. private static _ShowLoadingScreen;
  101798. private static _CleanBoneMatrixWeights;
  101799. private static _loggingLevel;
  101800. /**
  101801. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101802. */
  101803. static get ForceFullSceneLoadingForIncremental(): boolean;
  101804. static set ForceFullSceneLoadingForIncremental(value: boolean);
  101805. /**
  101806. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101807. */
  101808. static get ShowLoadingScreen(): boolean;
  101809. static set ShowLoadingScreen(value: boolean);
  101810. /**
  101811. * Defines the current logging level (while loading the scene)
  101812. * @ignorenaming
  101813. */
  101814. static get loggingLevel(): number;
  101815. static set loggingLevel(value: number);
  101816. /**
  101817. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101818. */
  101819. static get CleanBoneMatrixWeights(): boolean;
  101820. static set CleanBoneMatrixWeights(value: boolean);
  101821. }
  101822. }
  101823. declare module BABYLON {
  101824. /**
  101825. * Class used to store geometry data (vertex buffers + index buffer)
  101826. */
  101827. export class Geometry implements IGetSetVerticesData {
  101828. /**
  101829. * Gets or sets the ID of the geometry
  101830. */
  101831. id: string;
  101832. /**
  101833. * Gets or sets the unique ID of the geometry
  101834. */
  101835. uniqueId: number;
  101836. /**
  101837. * Gets the delay loading state of the geometry (none by default which means not delayed)
  101838. */
  101839. delayLoadState: number;
  101840. /**
  101841. * Gets the file containing the data to load when running in delay load state
  101842. */
  101843. delayLoadingFile: Nullable<string>;
  101844. /**
  101845. * Callback called when the geometry is updated
  101846. */
  101847. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  101848. private _scene;
  101849. private _engine;
  101850. private _meshes;
  101851. private _totalVertices;
  101852. /** @hidden */
  101853. _indices: IndicesArray;
  101854. /** @hidden */
  101855. _vertexBuffers: {
  101856. [key: string]: VertexBuffer;
  101857. };
  101858. private _isDisposed;
  101859. private _extend;
  101860. private _boundingBias;
  101861. /** @hidden */
  101862. _delayInfo: Array<string>;
  101863. private _indexBuffer;
  101864. private _indexBufferIsUpdatable;
  101865. /** @hidden */
  101866. _boundingInfo: Nullable<BoundingInfo>;
  101867. /** @hidden */
  101868. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  101869. /** @hidden */
  101870. _softwareSkinningFrameId: number;
  101871. private _vertexArrayObjects;
  101872. private _updatable;
  101873. /** @hidden */
  101874. _positions: Nullable<Vector3[]>;
  101875. /**
  101876. * 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
  101877. */
  101878. get boundingBias(): Vector2;
  101879. /**
  101880. * 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
  101881. */
  101882. set boundingBias(value: Vector2);
  101883. /**
  101884. * Static function used to attach a new empty geometry to a mesh
  101885. * @param mesh defines the mesh to attach the geometry to
  101886. * @returns the new Geometry
  101887. */
  101888. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  101889. /** Get the list of meshes using this geometry */
  101890. get meshes(): Mesh[];
  101891. /**
  101892. * Creates a new geometry
  101893. * @param id defines the unique ID
  101894. * @param scene defines the hosting scene
  101895. * @param vertexData defines the VertexData used to get geometry data
  101896. * @param updatable defines if geometry must be updatable (false by default)
  101897. * @param mesh defines the mesh that will be associated with the geometry
  101898. */
  101899. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  101900. /**
  101901. * Gets the current extend of the geometry
  101902. */
  101903. get extend(): {
  101904. minimum: Vector3;
  101905. maximum: Vector3;
  101906. };
  101907. /**
  101908. * Gets the hosting scene
  101909. * @returns the hosting Scene
  101910. */
  101911. getScene(): Scene;
  101912. /**
  101913. * Gets the hosting engine
  101914. * @returns the hosting Engine
  101915. */
  101916. getEngine(): Engine;
  101917. /**
  101918. * Defines if the geometry is ready to use
  101919. * @returns true if the geometry is ready to be used
  101920. */
  101921. isReady(): boolean;
  101922. /**
  101923. * Gets a value indicating that the geometry should not be serialized
  101924. */
  101925. get doNotSerialize(): boolean;
  101926. /** @hidden */
  101927. _rebuild(): void;
  101928. /**
  101929. * Affects all geometry data in one call
  101930. * @param vertexData defines the geometry data
  101931. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  101932. */
  101933. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  101934. /**
  101935. * Set specific vertex data
  101936. * @param kind defines the data kind (Position, normal, etc...)
  101937. * @param data defines the vertex data to use
  101938. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  101939. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  101940. */
  101941. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  101942. /**
  101943. * Removes a specific vertex data
  101944. * @param kind defines the data kind (Position, normal, etc...)
  101945. */
  101946. removeVerticesData(kind: string): void;
  101947. /**
  101948. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  101949. * @param buffer defines the vertex buffer to use
  101950. * @param totalVertices defines the total number of vertices for position kind (could be null)
  101951. */
  101952. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  101953. /**
  101954. * Update a specific vertex buffer
  101955. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  101956. * It will do nothing if the buffer is not updatable
  101957. * @param kind defines the data kind (Position, normal, etc...)
  101958. * @param data defines the data to use
  101959. * @param offset defines the offset in the target buffer where to store the data
  101960. * @param useBytes set to true if the offset is in bytes
  101961. */
  101962. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  101963. /**
  101964. * Update a specific vertex buffer
  101965. * This function will create a new buffer if the current one is not updatable
  101966. * @param kind defines the data kind (Position, normal, etc...)
  101967. * @param data defines the data to use
  101968. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  101969. */
  101970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  101971. private _updateBoundingInfo;
  101972. /** @hidden */
  101973. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  101974. /**
  101975. * Gets total number of vertices
  101976. * @returns the total number of vertices
  101977. */
  101978. getTotalVertices(): number;
  101979. /**
  101980. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  101981. * @param kind defines the data kind (Position, normal, etc...)
  101982. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101983. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101984. * @returns a float array containing vertex data
  101985. */
  101986. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101987. /**
  101988. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  101989. * @param kind defines the data kind (Position, normal, etc...)
  101990. * @returns true if the vertex buffer with the specified kind is updatable
  101991. */
  101992. isVertexBufferUpdatable(kind: string): boolean;
  101993. /**
  101994. * Gets a specific vertex buffer
  101995. * @param kind defines the data kind (Position, normal, etc...)
  101996. * @returns a VertexBuffer
  101997. */
  101998. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  101999. /**
  102000. * Returns all vertex buffers
  102001. * @return an object holding all vertex buffers indexed by kind
  102002. */
  102003. getVertexBuffers(): Nullable<{
  102004. [key: string]: VertexBuffer;
  102005. }>;
  102006. /**
  102007. * Gets a boolean indicating if specific vertex buffer is present
  102008. * @param kind defines the data kind (Position, normal, etc...)
  102009. * @returns true if data is present
  102010. */
  102011. isVerticesDataPresent(kind: string): boolean;
  102012. /**
  102013. * Gets a list of all attached data kinds (Position, normal, etc...)
  102014. * @returns a list of string containing all kinds
  102015. */
  102016. getVerticesDataKinds(): string[];
  102017. /**
  102018. * Update index buffer
  102019. * @param indices defines the indices to store in the index buffer
  102020. * @param offset defines the offset in the target buffer where to store the data
  102021. * @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)
  102022. */
  102023. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102024. /**
  102025. * Creates a new index buffer
  102026. * @param indices defines the indices to store in the index buffer
  102027. * @param totalVertices defines the total number of vertices (could be null)
  102028. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102029. */
  102030. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102031. /**
  102032. * Return the total number of indices
  102033. * @returns the total number of indices
  102034. */
  102035. getTotalIndices(): number;
  102036. /**
  102037. * Gets the index buffer array
  102038. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102039. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102040. * @returns the index buffer array
  102041. */
  102042. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102043. /**
  102044. * Gets the index buffer
  102045. * @return the index buffer
  102046. */
  102047. getIndexBuffer(): Nullable<DataBuffer>;
  102048. /** @hidden */
  102049. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102050. /**
  102051. * Release the associated resources for a specific mesh
  102052. * @param mesh defines the source mesh
  102053. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102054. */
  102055. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102056. /**
  102057. * Apply current geometry to a given mesh
  102058. * @param mesh defines the mesh to apply geometry to
  102059. */
  102060. applyToMesh(mesh: Mesh): void;
  102061. private _updateExtend;
  102062. private _applyToMesh;
  102063. private notifyUpdate;
  102064. /**
  102065. * Load the geometry if it was flagged as delay loaded
  102066. * @param scene defines the hosting scene
  102067. * @param onLoaded defines a callback called when the geometry is loaded
  102068. */
  102069. load(scene: Scene, onLoaded?: () => void): void;
  102070. private _queueLoad;
  102071. /**
  102072. * Invert the geometry to move from a right handed system to a left handed one.
  102073. */
  102074. toLeftHanded(): void;
  102075. /** @hidden */
  102076. _resetPointsArrayCache(): void;
  102077. /** @hidden */
  102078. _generatePointsArray(): boolean;
  102079. /**
  102080. * Gets a value indicating if the geometry is disposed
  102081. * @returns true if the geometry was disposed
  102082. */
  102083. isDisposed(): boolean;
  102084. private _disposeVertexArrayObjects;
  102085. /**
  102086. * Free all associated resources
  102087. */
  102088. dispose(): void;
  102089. /**
  102090. * Clone the current geometry into a new geometry
  102091. * @param id defines the unique ID of the new geometry
  102092. * @returns a new geometry object
  102093. */
  102094. copy(id: string): Geometry;
  102095. /**
  102096. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102097. * @return a JSON representation of the current geometry data (without the vertices data)
  102098. */
  102099. serialize(): any;
  102100. private toNumberArray;
  102101. /**
  102102. * Serialize all vertices data into a JSON oject
  102103. * @returns a JSON representation of the current geometry data
  102104. */
  102105. serializeVerticeData(): any;
  102106. /**
  102107. * Extracts a clone of a mesh geometry
  102108. * @param mesh defines the source mesh
  102109. * @param id defines the unique ID of the new geometry object
  102110. * @returns the new geometry object
  102111. */
  102112. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102113. /**
  102114. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102115. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102116. * Be aware Math.random() could cause collisions, but:
  102117. * "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"
  102118. * @returns a string containing a new GUID
  102119. */
  102120. static RandomId(): string;
  102121. /** @hidden */
  102122. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102123. private static _CleanMatricesWeights;
  102124. /**
  102125. * Create a new geometry from persisted data (Using .babylon file format)
  102126. * @param parsedVertexData defines the persisted data
  102127. * @param scene defines the hosting scene
  102128. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102129. * @returns the new geometry object
  102130. */
  102131. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102132. }
  102133. }
  102134. declare module BABYLON {
  102135. /**
  102136. * Define an interface for all classes that will get and set the data on vertices
  102137. */
  102138. export interface IGetSetVerticesData {
  102139. /**
  102140. * Gets a boolean indicating if specific vertex data is present
  102141. * @param kind defines the vertex data kind to use
  102142. * @returns true is data kind is present
  102143. */
  102144. isVerticesDataPresent(kind: string): boolean;
  102145. /**
  102146. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102147. * @param kind defines the data kind (Position, normal, etc...)
  102148. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102149. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102150. * @returns a float array containing vertex data
  102151. */
  102152. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102153. /**
  102154. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102155. * @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.
  102156. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102157. * @returns the indices array or an empty array if the mesh has no geometry
  102158. */
  102159. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102160. /**
  102161. * Set specific vertex data
  102162. * @param kind defines the data kind (Position, normal, etc...)
  102163. * @param data defines the vertex data to use
  102164. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102165. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102166. */
  102167. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102168. /**
  102169. * Update a specific associated vertex buffer
  102170. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102171. * - VertexBuffer.PositionKind
  102172. * - VertexBuffer.UVKind
  102173. * - VertexBuffer.UV2Kind
  102174. * - VertexBuffer.UV3Kind
  102175. * - VertexBuffer.UV4Kind
  102176. * - VertexBuffer.UV5Kind
  102177. * - VertexBuffer.UV6Kind
  102178. * - VertexBuffer.ColorKind
  102179. * - VertexBuffer.MatricesIndicesKind
  102180. * - VertexBuffer.MatricesIndicesExtraKind
  102181. * - VertexBuffer.MatricesWeightsKind
  102182. * - VertexBuffer.MatricesWeightsExtraKind
  102183. * @param data defines the data source
  102184. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102185. * @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)
  102186. */
  102187. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102188. /**
  102189. * Creates a new index buffer
  102190. * @param indices defines the indices to store in the index buffer
  102191. * @param totalVertices defines the total number of vertices (could be null)
  102192. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102193. */
  102194. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102195. }
  102196. /**
  102197. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102198. */
  102199. export class VertexData {
  102200. /**
  102201. * Mesh side orientation : usually the external or front surface
  102202. */
  102203. static readonly FRONTSIDE: number;
  102204. /**
  102205. * Mesh side orientation : usually the internal or back surface
  102206. */
  102207. static readonly BACKSIDE: number;
  102208. /**
  102209. * Mesh side orientation : both internal and external or front and back surfaces
  102210. */
  102211. static readonly DOUBLESIDE: number;
  102212. /**
  102213. * Mesh side orientation : by default, `FRONTSIDE`
  102214. */
  102215. static readonly DEFAULTSIDE: number;
  102216. /**
  102217. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102218. */
  102219. positions: Nullable<FloatArray>;
  102220. /**
  102221. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102222. */
  102223. normals: Nullable<FloatArray>;
  102224. /**
  102225. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102226. */
  102227. tangents: Nullable<FloatArray>;
  102228. /**
  102229. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102230. */
  102231. uvs: Nullable<FloatArray>;
  102232. /**
  102233. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102234. */
  102235. uvs2: Nullable<FloatArray>;
  102236. /**
  102237. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102238. */
  102239. uvs3: Nullable<FloatArray>;
  102240. /**
  102241. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102242. */
  102243. uvs4: Nullable<FloatArray>;
  102244. /**
  102245. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102246. */
  102247. uvs5: Nullable<FloatArray>;
  102248. /**
  102249. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102250. */
  102251. uvs6: Nullable<FloatArray>;
  102252. /**
  102253. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102254. */
  102255. colors: Nullable<FloatArray>;
  102256. /**
  102257. * 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).
  102258. */
  102259. matricesIndices: Nullable<FloatArray>;
  102260. /**
  102261. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102262. */
  102263. matricesWeights: Nullable<FloatArray>;
  102264. /**
  102265. * An array extending the number of possible indices
  102266. */
  102267. matricesIndicesExtra: Nullable<FloatArray>;
  102268. /**
  102269. * An array extending the number of possible weights when the number of indices is extended
  102270. */
  102271. matricesWeightsExtra: Nullable<FloatArray>;
  102272. /**
  102273. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102274. */
  102275. indices: Nullable<IndicesArray>;
  102276. /**
  102277. * Uses the passed data array to set the set the values for the specified kind of data
  102278. * @param data a linear array of floating numbers
  102279. * @param kind the type of data that is being set, eg positions, colors etc
  102280. */
  102281. set(data: FloatArray, kind: string): void;
  102282. /**
  102283. * Associates the vertexData to the passed Mesh.
  102284. * Sets it as updatable or not (default `false`)
  102285. * @param mesh the mesh the vertexData is applied to
  102286. * @param updatable when used and having the value true allows new data to update the vertexData
  102287. * @returns the VertexData
  102288. */
  102289. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102290. /**
  102291. * Associates the vertexData to the passed Geometry.
  102292. * Sets it as updatable or not (default `false`)
  102293. * @param geometry the geometry the vertexData is applied to
  102294. * @param updatable when used and having the value true allows new data to update the vertexData
  102295. * @returns VertexData
  102296. */
  102297. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102298. /**
  102299. * Updates the associated mesh
  102300. * @param mesh the mesh to be updated
  102301. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102302. * @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
  102303. * @returns VertexData
  102304. */
  102305. updateMesh(mesh: Mesh): VertexData;
  102306. /**
  102307. * Updates the associated geometry
  102308. * @param geometry the geometry to be updated
  102309. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102310. * @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
  102311. * @returns VertexData.
  102312. */
  102313. updateGeometry(geometry: Geometry): VertexData;
  102314. private _applyTo;
  102315. private _update;
  102316. /**
  102317. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102318. * @param matrix the transforming matrix
  102319. * @returns the VertexData
  102320. */
  102321. transform(matrix: Matrix): VertexData;
  102322. /**
  102323. * Merges the passed VertexData into the current one
  102324. * @param other the VertexData to be merged into the current one
  102325. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102326. * @returns the modified VertexData
  102327. */
  102328. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102329. private _mergeElement;
  102330. private _validate;
  102331. /**
  102332. * Serializes the VertexData
  102333. * @returns a serialized object
  102334. */
  102335. serialize(): any;
  102336. /**
  102337. * Extracts the vertexData from a mesh
  102338. * @param mesh the mesh from which to extract the VertexData
  102339. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102340. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102341. * @returns the object VertexData associated to the passed mesh
  102342. */
  102343. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102344. /**
  102345. * Extracts the vertexData from the geometry
  102346. * @param geometry the geometry from which to extract the VertexData
  102347. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102348. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102349. * @returns the object VertexData associated to the passed mesh
  102350. */
  102351. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102352. private static _ExtractFrom;
  102353. /**
  102354. * Creates the VertexData for a Ribbon
  102355. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102356. * * pathArray array of paths, each of which an array of successive Vector3
  102357. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102358. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102359. * * 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
  102360. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102361. * * 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)
  102362. * * 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)
  102363. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102364. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102365. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102366. * @returns the VertexData of the ribbon
  102367. */
  102368. static CreateRibbon(options: {
  102369. pathArray: Vector3[][];
  102370. closeArray?: boolean;
  102371. closePath?: boolean;
  102372. offset?: number;
  102373. sideOrientation?: number;
  102374. frontUVs?: Vector4;
  102375. backUVs?: Vector4;
  102376. invertUV?: boolean;
  102377. uvs?: Vector2[];
  102378. colors?: Color4[];
  102379. }): VertexData;
  102380. /**
  102381. * Creates the VertexData for a box
  102382. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102383. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102384. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102385. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102386. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102387. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102388. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102390. * * 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)
  102391. * * 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)
  102392. * @returns the VertexData of the box
  102393. */
  102394. static CreateBox(options: {
  102395. size?: number;
  102396. width?: number;
  102397. height?: number;
  102398. depth?: number;
  102399. faceUV?: Vector4[];
  102400. faceColors?: Color4[];
  102401. sideOrientation?: number;
  102402. frontUVs?: Vector4;
  102403. backUVs?: Vector4;
  102404. }): VertexData;
  102405. /**
  102406. * Creates the VertexData for a tiled box
  102407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102408. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102409. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102410. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102412. * @returns the VertexData of the box
  102413. */
  102414. static CreateTiledBox(options: {
  102415. pattern?: number;
  102416. width?: number;
  102417. height?: number;
  102418. depth?: number;
  102419. tileSize?: number;
  102420. tileWidth?: number;
  102421. tileHeight?: number;
  102422. alignHorizontal?: number;
  102423. alignVertical?: number;
  102424. faceUV?: Vector4[];
  102425. faceColors?: Color4[];
  102426. sideOrientation?: number;
  102427. }): VertexData;
  102428. /**
  102429. * Creates the VertexData for a tiled plane
  102430. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102431. * * pattern a limited pattern arrangement depending on the number
  102432. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102433. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102434. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102436. * * 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)
  102437. * * 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)
  102438. * @returns the VertexData of the tiled plane
  102439. */
  102440. static CreateTiledPlane(options: {
  102441. pattern?: number;
  102442. tileSize?: number;
  102443. tileWidth?: number;
  102444. tileHeight?: number;
  102445. size?: number;
  102446. width?: number;
  102447. height?: number;
  102448. alignHorizontal?: number;
  102449. alignVertical?: number;
  102450. sideOrientation?: number;
  102451. frontUVs?: Vector4;
  102452. backUVs?: Vector4;
  102453. }): VertexData;
  102454. /**
  102455. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102456. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102457. * * segments sets the number of horizontal strips optional, default 32
  102458. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102459. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102460. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102461. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102462. * * 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
  102463. * * 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
  102464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102465. * * 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)
  102466. * * 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)
  102467. * @returns the VertexData of the ellipsoid
  102468. */
  102469. static CreateSphere(options: {
  102470. segments?: number;
  102471. diameter?: number;
  102472. diameterX?: number;
  102473. diameterY?: number;
  102474. diameterZ?: number;
  102475. arc?: number;
  102476. slice?: number;
  102477. sideOrientation?: number;
  102478. frontUVs?: Vector4;
  102479. backUVs?: Vector4;
  102480. }): VertexData;
  102481. /**
  102482. * Creates the VertexData for a cylinder, cone or prism
  102483. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102484. * * height sets the height (y direction) of the cylinder, optional, default 2
  102485. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102486. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102487. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102488. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102489. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102490. * * 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
  102491. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102492. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102493. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102494. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102496. * * 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)
  102497. * * 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)
  102498. * @returns the VertexData of the cylinder, cone or prism
  102499. */
  102500. static CreateCylinder(options: {
  102501. height?: number;
  102502. diameterTop?: number;
  102503. diameterBottom?: number;
  102504. diameter?: number;
  102505. tessellation?: number;
  102506. subdivisions?: number;
  102507. arc?: number;
  102508. faceColors?: Color4[];
  102509. faceUV?: Vector4[];
  102510. hasRings?: boolean;
  102511. enclose?: boolean;
  102512. sideOrientation?: number;
  102513. frontUVs?: Vector4;
  102514. backUVs?: Vector4;
  102515. }): VertexData;
  102516. /**
  102517. * Creates the VertexData for a torus
  102518. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102519. * * diameter the diameter of the torus, optional default 1
  102520. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102521. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102522. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102523. * * 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)
  102524. * * 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)
  102525. * @returns the VertexData of the torus
  102526. */
  102527. static CreateTorus(options: {
  102528. diameter?: number;
  102529. thickness?: number;
  102530. tessellation?: number;
  102531. sideOrientation?: number;
  102532. frontUVs?: Vector4;
  102533. backUVs?: Vector4;
  102534. }): VertexData;
  102535. /**
  102536. * Creates the VertexData of the LineSystem
  102537. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102538. * - lines an array of lines, each line being an array of successive Vector3
  102539. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102540. * @returns the VertexData of the LineSystem
  102541. */
  102542. static CreateLineSystem(options: {
  102543. lines: Vector3[][];
  102544. colors?: Nullable<Color4[][]>;
  102545. }): VertexData;
  102546. /**
  102547. * Create the VertexData for a DashedLines
  102548. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102549. * - points an array successive Vector3
  102550. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102551. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102552. * - dashNb the intended total number of dashes, optional, default 200
  102553. * @returns the VertexData for the DashedLines
  102554. */
  102555. static CreateDashedLines(options: {
  102556. points: Vector3[];
  102557. dashSize?: number;
  102558. gapSize?: number;
  102559. dashNb?: number;
  102560. }): VertexData;
  102561. /**
  102562. * Creates the VertexData for a Ground
  102563. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102564. * - width the width (x direction) of the ground, optional, default 1
  102565. * - height the height (z direction) of the ground, optional, default 1
  102566. * - subdivisions the number of subdivisions per side, optional, default 1
  102567. * @returns the VertexData of the Ground
  102568. */
  102569. static CreateGround(options: {
  102570. width?: number;
  102571. height?: number;
  102572. subdivisions?: number;
  102573. subdivisionsX?: number;
  102574. subdivisionsY?: number;
  102575. }): VertexData;
  102576. /**
  102577. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102578. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102579. * * xmin the ground minimum X coordinate, optional, default -1
  102580. * * zmin the ground minimum Z coordinate, optional, default -1
  102581. * * xmax the ground maximum X coordinate, optional, default 1
  102582. * * zmax the ground maximum Z coordinate, optional, default 1
  102583. * * 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}
  102584. * * 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}
  102585. * @returns the VertexData of the TiledGround
  102586. */
  102587. static CreateTiledGround(options: {
  102588. xmin: number;
  102589. zmin: number;
  102590. xmax: number;
  102591. zmax: number;
  102592. subdivisions?: {
  102593. w: number;
  102594. h: number;
  102595. };
  102596. precision?: {
  102597. w: number;
  102598. h: number;
  102599. };
  102600. }): VertexData;
  102601. /**
  102602. * Creates the VertexData of the Ground designed from a heightmap
  102603. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102604. * * width the width (x direction) of the ground
  102605. * * height the height (z direction) of the ground
  102606. * * subdivisions the number of subdivisions per side
  102607. * * minHeight the minimum altitude on the ground, optional, default 0
  102608. * * maxHeight the maximum altitude on the ground, optional default 1
  102609. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  102610. * * buffer the array holding the image color data
  102611. * * bufferWidth the width of image
  102612. * * bufferHeight the height of image
  102613. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  102614. * @returns the VertexData of the Ground designed from a heightmap
  102615. */
  102616. static CreateGroundFromHeightMap(options: {
  102617. width: number;
  102618. height: number;
  102619. subdivisions: number;
  102620. minHeight: number;
  102621. maxHeight: number;
  102622. colorFilter: Color3;
  102623. buffer: Uint8Array;
  102624. bufferWidth: number;
  102625. bufferHeight: number;
  102626. alphaFilter: number;
  102627. }): VertexData;
  102628. /**
  102629. * Creates the VertexData for a Plane
  102630. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  102631. * * size sets the width and height of the plane to the value of size, optional default 1
  102632. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  102633. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  102634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102635. * * 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)
  102636. * * 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)
  102637. * @returns the VertexData of the box
  102638. */
  102639. static CreatePlane(options: {
  102640. size?: number;
  102641. width?: number;
  102642. height?: number;
  102643. sideOrientation?: number;
  102644. frontUVs?: Vector4;
  102645. backUVs?: Vector4;
  102646. }): VertexData;
  102647. /**
  102648. * Creates the VertexData of the Disc or regular Polygon
  102649. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  102650. * * radius the radius of the disc, optional default 0.5
  102651. * * tessellation the number of polygon sides, optional, default 64
  102652. * * 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
  102653. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102654. * * 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)
  102655. * * 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)
  102656. * @returns the VertexData of the box
  102657. */
  102658. static CreateDisc(options: {
  102659. radius?: number;
  102660. tessellation?: number;
  102661. arc?: number;
  102662. sideOrientation?: number;
  102663. frontUVs?: Vector4;
  102664. backUVs?: Vector4;
  102665. }): VertexData;
  102666. /**
  102667. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  102668. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  102669. * @param polygon a mesh built from polygonTriangulation.build()
  102670. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102671. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102672. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102673. * @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)
  102674. * @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)
  102675. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  102676. * @returns the VertexData of the Polygon
  102677. */
  102678. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  102679. /**
  102680. * Creates the VertexData of the IcoSphere
  102681. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  102682. * * radius the radius of the IcoSphere, optional default 1
  102683. * * radiusX allows stretching in the x direction, optional, default radius
  102684. * * radiusY allows stretching in the y direction, optional, default radius
  102685. * * radiusZ allows stretching in the z direction, optional, default radius
  102686. * * flat when true creates a flat shaded mesh, optional, default true
  102687. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102688. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102689. * * 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)
  102690. * * 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)
  102691. * @returns the VertexData of the IcoSphere
  102692. */
  102693. static CreateIcoSphere(options: {
  102694. radius?: number;
  102695. radiusX?: number;
  102696. radiusY?: number;
  102697. radiusZ?: number;
  102698. flat?: boolean;
  102699. subdivisions?: number;
  102700. sideOrientation?: number;
  102701. frontUVs?: Vector4;
  102702. backUVs?: Vector4;
  102703. }): VertexData;
  102704. /**
  102705. * Creates the VertexData for a Polyhedron
  102706. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  102707. * * type provided types are:
  102708. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  102709. * * 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)
  102710. * * size the size of the IcoSphere, optional default 1
  102711. * * sizeX allows stretching in the x direction, optional, default size
  102712. * * sizeY allows stretching in the y direction, optional, default size
  102713. * * sizeZ allows stretching in the z direction, optional, default size
  102714. * * 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
  102715. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102716. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102717. * * flat when true creates a flat shaded mesh, optional, default true
  102718. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102720. * * 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)
  102721. * * 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)
  102722. * @returns the VertexData of the Polyhedron
  102723. */
  102724. static CreatePolyhedron(options: {
  102725. type?: number;
  102726. size?: number;
  102727. sizeX?: number;
  102728. sizeY?: number;
  102729. sizeZ?: number;
  102730. custom?: any;
  102731. faceUV?: Vector4[];
  102732. faceColors?: Color4[];
  102733. flat?: boolean;
  102734. sideOrientation?: number;
  102735. frontUVs?: Vector4;
  102736. backUVs?: Vector4;
  102737. }): VertexData;
  102738. /**
  102739. * Creates the VertexData for a TorusKnot
  102740. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  102741. * * radius the radius of the torus knot, optional, default 2
  102742. * * tube the thickness of the tube, optional, default 0.5
  102743. * * radialSegments the number of sides on each tube segments, optional, default 32
  102744. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  102745. * * p the number of windings around the z axis, optional, default 2
  102746. * * q the number of windings around the x axis, optional, default 3
  102747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102748. * * 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)
  102749. * * 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)
  102750. * @returns the VertexData of the Torus Knot
  102751. */
  102752. static CreateTorusKnot(options: {
  102753. radius?: number;
  102754. tube?: number;
  102755. radialSegments?: number;
  102756. tubularSegments?: number;
  102757. p?: number;
  102758. q?: number;
  102759. sideOrientation?: number;
  102760. frontUVs?: Vector4;
  102761. backUVs?: Vector4;
  102762. }): VertexData;
  102763. /**
  102764. * Compute normals for given positions and indices
  102765. * @param positions an array of vertex positions, [...., x, y, z, ......]
  102766. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  102767. * @param normals an array of vertex normals, [...., x, y, z, ......]
  102768. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  102769. * * facetNormals : optional array of facet normals (vector3)
  102770. * * facetPositions : optional array of facet positions (vector3)
  102771. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  102772. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  102773. * * bInfo : optional bounding info, required for facetPartitioning computation
  102774. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  102775. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  102776. * * useRightHandedSystem: optional boolean to for right handed system computation
  102777. * * depthSort : optional boolean to enable the facet depth sort computation
  102778. * * distanceTo : optional Vector3 to compute the facet depth from this location
  102779. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  102780. */
  102781. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  102782. facetNormals?: any;
  102783. facetPositions?: any;
  102784. facetPartitioning?: any;
  102785. ratio?: number;
  102786. bInfo?: any;
  102787. bbSize?: Vector3;
  102788. subDiv?: any;
  102789. useRightHandedSystem?: boolean;
  102790. depthSort?: boolean;
  102791. distanceTo?: Vector3;
  102792. depthSortedFacets?: any;
  102793. }): void;
  102794. /** @hidden */
  102795. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  102796. /**
  102797. * Applies VertexData created from the imported parameters to the geometry
  102798. * @param parsedVertexData the parsed data from an imported file
  102799. * @param geometry the geometry to apply the VertexData to
  102800. */
  102801. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  102802. }
  102803. }
  102804. declare module BABYLON {
  102805. /**
  102806. * Defines a target to use with MorphTargetManager
  102807. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102808. */
  102809. export class MorphTarget implements IAnimatable {
  102810. /** defines the name of the target */
  102811. name: string;
  102812. /**
  102813. * Gets or sets the list of animations
  102814. */
  102815. animations: Animation[];
  102816. private _scene;
  102817. private _positions;
  102818. private _normals;
  102819. private _tangents;
  102820. private _uvs;
  102821. private _influence;
  102822. private _uniqueId;
  102823. /**
  102824. * Observable raised when the influence changes
  102825. */
  102826. onInfluenceChanged: Observable<boolean>;
  102827. /** @hidden */
  102828. _onDataLayoutChanged: Observable<void>;
  102829. /**
  102830. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102831. */
  102832. get influence(): number;
  102833. set influence(influence: number);
  102834. /**
  102835. * Gets or sets the id of the morph Target
  102836. */
  102837. id: string;
  102838. private _animationPropertiesOverride;
  102839. /**
  102840. * Gets or sets the animation properties override
  102841. */
  102842. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102843. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102844. /**
  102845. * Creates a new MorphTarget
  102846. * @param name defines the name of the target
  102847. * @param influence defines the influence to use
  102848. * @param scene defines the scene the morphtarget belongs to
  102849. */
  102850. constructor(
  102851. /** defines the name of the target */
  102852. name: string, influence?: number, scene?: Nullable<Scene>);
  102853. /**
  102854. * Gets the unique ID of this manager
  102855. */
  102856. get uniqueId(): number;
  102857. /**
  102858. * Gets a boolean defining if the target contains position data
  102859. */
  102860. get hasPositions(): boolean;
  102861. /**
  102862. * Gets a boolean defining if the target contains normal data
  102863. */
  102864. get hasNormals(): boolean;
  102865. /**
  102866. * Gets a boolean defining if the target contains tangent data
  102867. */
  102868. get hasTangents(): boolean;
  102869. /**
  102870. * Gets a boolean defining if the target contains texture coordinates data
  102871. */
  102872. get hasUVs(): boolean;
  102873. /**
  102874. * Affects position data to this target
  102875. * @param data defines the position data to use
  102876. */
  102877. setPositions(data: Nullable<FloatArray>): void;
  102878. /**
  102879. * Gets the position data stored in this target
  102880. * @returns a FloatArray containing the position data (or null if not present)
  102881. */
  102882. getPositions(): Nullable<FloatArray>;
  102883. /**
  102884. * Affects normal data to this target
  102885. * @param data defines the normal data to use
  102886. */
  102887. setNormals(data: Nullable<FloatArray>): void;
  102888. /**
  102889. * Gets the normal data stored in this target
  102890. * @returns a FloatArray containing the normal data (or null if not present)
  102891. */
  102892. getNormals(): Nullable<FloatArray>;
  102893. /**
  102894. * Affects tangent data to this target
  102895. * @param data defines the tangent data to use
  102896. */
  102897. setTangents(data: Nullable<FloatArray>): void;
  102898. /**
  102899. * Gets the tangent data stored in this target
  102900. * @returns a FloatArray containing the tangent data (or null if not present)
  102901. */
  102902. getTangents(): Nullable<FloatArray>;
  102903. /**
  102904. * Affects texture coordinates data to this target
  102905. * @param data defines the texture coordinates data to use
  102906. */
  102907. setUVs(data: Nullable<FloatArray>): void;
  102908. /**
  102909. * Gets the texture coordinates data stored in this target
  102910. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  102911. */
  102912. getUVs(): Nullable<FloatArray>;
  102913. /**
  102914. * Clone the current target
  102915. * @returns a new MorphTarget
  102916. */
  102917. clone(): MorphTarget;
  102918. /**
  102919. * Serializes the current target into a Serialization object
  102920. * @returns the serialized object
  102921. */
  102922. serialize(): any;
  102923. /**
  102924. * Returns the string "MorphTarget"
  102925. * @returns "MorphTarget"
  102926. */
  102927. getClassName(): string;
  102928. /**
  102929. * Creates a new target from serialized data
  102930. * @param serializationObject defines the serialized data to use
  102931. * @returns a new MorphTarget
  102932. */
  102933. static Parse(serializationObject: any): MorphTarget;
  102934. /**
  102935. * Creates a MorphTarget from mesh data
  102936. * @param mesh defines the source mesh
  102937. * @param name defines the name to use for the new target
  102938. * @param influence defines the influence to attach to the target
  102939. * @returns a new MorphTarget
  102940. */
  102941. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  102942. }
  102943. }
  102944. declare module BABYLON {
  102945. /**
  102946. * This class is used to deform meshes using morphing between different targets
  102947. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102948. */
  102949. export class MorphTargetManager {
  102950. private _targets;
  102951. private _targetInfluenceChangedObservers;
  102952. private _targetDataLayoutChangedObservers;
  102953. private _activeTargets;
  102954. private _scene;
  102955. private _influences;
  102956. private _supportsNormals;
  102957. private _supportsTangents;
  102958. private _supportsUVs;
  102959. private _vertexCount;
  102960. private _uniqueId;
  102961. private _tempInfluences;
  102962. /**
  102963. * Gets or sets a boolean indicating if normals must be morphed
  102964. */
  102965. enableNormalMorphing: boolean;
  102966. /**
  102967. * Gets or sets a boolean indicating if tangents must be morphed
  102968. */
  102969. enableTangentMorphing: boolean;
  102970. /**
  102971. * Gets or sets a boolean indicating if UV must be morphed
  102972. */
  102973. enableUVMorphing: boolean;
  102974. /**
  102975. * Creates a new MorphTargetManager
  102976. * @param scene defines the current scene
  102977. */
  102978. constructor(scene?: Nullable<Scene>);
  102979. /**
  102980. * Gets the unique ID of this manager
  102981. */
  102982. get uniqueId(): number;
  102983. /**
  102984. * Gets the number of vertices handled by this manager
  102985. */
  102986. get vertexCount(): number;
  102987. /**
  102988. * Gets a boolean indicating if this manager supports morphing of normals
  102989. */
  102990. get supportsNormals(): boolean;
  102991. /**
  102992. * Gets a boolean indicating if this manager supports morphing of tangents
  102993. */
  102994. get supportsTangents(): boolean;
  102995. /**
  102996. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  102997. */
  102998. get supportsUVs(): boolean;
  102999. /**
  103000. * Gets the number of targets stored in this manager
  103001. */
  103002. get numTargets(): number;
  103003. /**
  103004. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103005. */
  103006. get numInfluencers(): number;
  103007. /**
  103008. * Gets the list of influences (one per target)
  103009. */
  103010. get influences(): Float32Array;
  103011. /**
  103012. * Gets the active target at specified index. An active target is a target with an influence > 0
  103013. * @param index defines the index to check
  103014. * @returns the requested target
  103015. */
  103016. getActiveTarget(index: number): MorphTarget;
  103017. /**
  103018. * Gets the target at specified index
  103019. * @param index defines the index to check
  103020. * @returns the requested target
  103021. */
  103022. getTarget(index: number): MorphTarget;
  103023. /**
  103024. * Add a new target to this manager
  103025. * @param target defines the target to add
  103026. */
  103027. addTarget(target: MorphTarget): void;
  103028. /**
  103029. * Removes a target from the manager
  103030. * @param target defines the target to remove
  103031. */
  103032. removeTarget(target: MorphTarget): void;
  103033. /**
  103034. * Clone the current manager
  103035. * @returns a new MorphTargetManager
  103036. */
  103037. clone(): MorphTargetManager;
  103038. /**
  103039. * Serializes the current manager into a Serialization object
  103040. * @returns the serialized object
  103041. */
  103042. serialize(): any;
  103043. private _syncActiveTargets;
  103044. /**
  103045. * Syncrhonize the targets with all the meshes using this morph target manager
  103046. */
  103047. synchronize(): void;
  103048. /**
  103049. * Creates a new MorphTargetManager from serialized data
  103050. * @param serializationObject defines the serialized data
  103051. * @param scene defines the hosting scene
  103052. * @returns the new MorphTargetManager
  103053. */
  103054. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103055. }
  103056. }
  103057. declare module BABYLON {
  103058. /**
  103059. * Class used to represent a specific level of detail of a mesh
  103060. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103061. */
  103062. export class MeshLODLevel {
  103063. /** Defines the distance where this level should start being displayed */
  103064. distance: number;
  103065. /** Defines the mesh to use to render this level */
  103066. mesh: Nullable<Mesh>;
  103067. /**
  103068. * Creates a new LOD level
  103069. * @param distance defines the distance where this level should star being displayed
  103070. * @param mesh defines the mesh to use to render this level
  103071. */
  103072. constructor(
  103073. /** Defines the distance where this level should start being displayed */
  103074. distance: number,
  103075. /** Defines the mesh to use to render this level */
  103076. mesh: Nullable<Mesh>);
  103077. }
  103078. }
  103079. declare module BABYLON {
  103080. /**
  103081. * Mesh representing the gorund
  103082. */
  103083. export class GroundMesh extends Mesh {
  103084. /** If octree should be generated */
  103085. generateOctree: boolean;
  103086. private _heightQuads;
  103087. /** @hidden */
  103088. _subdivisionsX: number;
  103089. /** @hidden */
  103090. _subdivisionsY: number;
  103091. /** @hidden */
  103092. _width: number;
  103093. /** @hidden */
  103094. _height: number;
  103095. /** @hidden */
  103096. _minX: number;
  103097. /** @hidden */
  103098. _maxX: number;
  103099. /** @hidden */
  103100. _minZ: number;
  103101. /** @hidden */
  103102. _maxZ: number;
  103103. constructor(name: string, scene: Scene);
  103104. /**
  103105. * "GroundMesh"
  103106. * @returns "GroundMesh"
  103107. */
  103108. getClassName(): string;
  103109. /**
  103110. * The minimum of x and y subdivisions
  103111. */
  103112. get subdivisions(): number;
  103113. /**
  103114. * X subdivisions
  103115. */
  103116. get subdivisionsX(): number;
  103117. /**
  103118. * Y subdivisions
  103119. */
  103120. get subdivisionsY(): number;
  103121. /**
  103122. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103123. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103124. * @param chunksCount the number of subdivisions for x and y
  103125. * @param octreeBlocksSize (Default: 32)
  103126. */
  103127. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103128. /**
  103129. * Returns a height (y) value in the Worl system :
  103130. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103131. * @param x x coordinate
  103132. * @param z z coordinate
  103133. * @returns the ground y position if (x, z) are outside the ground surface.
  103134. */
  103135. getHeightAtCoordinates(x: number, z: number): number;
  103136. /**
  103137. * Returns a normalized vector (Vector3) orthogonal to the ground
  103138. * at the ground coordinates (x, z) expressed in the World system.
  103139. * @param x x coordinate
  103140. * @param z z coordinate
  103141. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103142. */
  103143. getNormalAtCoordinates(x: number, z: number): Vector3;
  103144. /**
  103145. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103146. * at the ground coordinates (x, z) expressed in the World system.
  103147. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103148. * @param x x coordinate
  103149. * @param z z coordinate
  103150. * @param ref vector to store the result
  103151. * @returns the GroundMesh.
  103152. */
  103153. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103154. /**
  103155. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103156. * if the ground has been updated.
  103157. * This can be used in the render loop.
  103158. * @returns the GroundMesh.
  103159. */
  103160. updateCoordinateHeights(): GroundMesh;
  103161. private _getFacetAt;
  103162. private _initHeightQuads;
  103163. private _computeHeightQuads;
  103164. /**
  103165. * Serializes this ground mesh
  103166. * @param serializationObject object to write serialization to
  103167. */
  103168. serialize(serializationObject: any): void;
  103169. /**
  103170. * Parses a serialized ground mesh
  103171. * @param parsedMesh the serialized mesh
  103172. * @param scene the scene to create the ground mesh in
  103173. * @returns the created ground mesh
  103174. */
  103175. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103176. }
  103177. }
  103178. declare module BABYLON {
  103179. /**
  103180. * Interface for Physics-Joint data
  103181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103182. */
  103183. export interface PhysicsJointData {
  103184. /**
  103185. * The main pivot of the joint
  103186. */
  103187. mainPivot?: Vector3;
  103188. /**
  103189. * The connected pivot of the joint
  103190. */
  103191. connectedPivot?: Vector3;
  103192. /**
  103193. * The main axis of the joint
  103194. */
  103195. mainAxis?: Vector3;
  103196. /**
  103197. * The connected axis of the joint
  103198. */
  103199. connectedAxis?: Vector3;
  103200. /**
  103201. * The collision of the joint
  103202. */
  103203. collision?: boolean;
  103204. /**
  103205. * Native Oimo/Cannon/Energy data
  103206. */
  103207. nativeParams?: any;
  103208. }
  103209. /**
  103210. * This is a holder class for the physics joint created by the physics plugin
  103211. * It holds a set of functions to control the underlying joint
  103212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103213. */
  103214. export class PhysicsJoint {
  103215. /**
  103216. * The type of the physics joint
  103217. */
  103218. type: number;
  103219. /**
  103220. * The data for the physics joint
  103221. */
  103222. jointData: PhysicsJointData;
  103223. private _physicsJoint;
  103224. protected _physicsPlugin: IPhysicsEnginePlugin;
  103225. /**
  103226. * Initializes the physics joint
  103227. * @param type The type of the physics joint
  103228. * @param jointData The data for the physics joint
  103229. */
  103230. constructor(
  103231. /**
  103232. * The type of the physics joint
  103233. */
  103234. type: number,
  103235. /**
  103236. * The data for the physics joint
  103237. */
  103238. jointData: PhysicsJointData);
  103239. /**
  103240. * Gets the physics joint
  103241. */
  103242. get physicsJoint(): any;
  103243. /**
  103244. * Sets the physics joint
  103245. */
  103246. set physicsJoint(newJoint: any);
  103247. /**
  103248. * Sets the physics plugin
  103249. */
  103250. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103251. /**
  103252. * Execute a function that is physics-plugin specific.
  103253. * @param {Function} func the function that will be executed.
  103254. * It accepts two parameters: the physics world and the physics joint
  103255. */
  103256. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103257. /**
  103258. * Distance-Joint type
  103259. */
  103260. static DistanceJoint: number;
  103261. /**
  103262. * Hinge-Joint type
  103263. */
  103264. static HingeJoint: number;
  103265. /**
  103266. * Ball-and-Socket joint type
  103267. */
  103268. static BallAndSocketJoint: number;
  103269. /**
  103270. * Wheel-Joint type
  103271. */
  103272. static WheelJoint: number;
  103273. /**
  103274. * Slider-Joint type
  103275. */
  103276. static SliderJoint: number;
  103277. /**
  103278. * Prismatic-Joint type
  103279. */
  103280. static PrismaticJoint: number;
  103281. /**
  103282. * Universal-Joint type
  103283. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103284. */
  103285. static UniversalJoint: number;
  103286. /**
  103287. * Hinge-Joint 2 type
  103288. */
  103289. static Hinge2Joint: number;
  103290. /**
  103291. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103292. */
  103293. static PointToPointJoint: number;
  103294. /**
  103295. * Spring-Joint type
  103296. */
  103297. static SpringJoint: number;
  103298. /**
  103299. * Lock-Joint type
  103300. */
  103301. static LockJoint: number;
  103302. }
  103303. /**
  103304. * A class representing a physics distance joint
  103305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103306. */
  103307. export class DistanceJoint extends PhysicsJoint {
  103308. /**
  103309. *
  103310. * @param jointData The data for the Distance-Joint
  103311. */
  103312. constructor(jointData: DistanceJointData);
  103313. /**
  103314. * Update the predefined distance.
  103315. * @param maxDistance The maximum preferred distance
  103316. * @param minDistance The minimum preferred distance
  103317. */
  103318. updateDistance(maxDistance: number, minDistance?: number): void;
  103319. }
  103320. /**
  103321. * Represents a Motor-Enabled Joint
  103322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103323. */
  103324. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103325. /**
  103326. * Initializes the Motor-Enabled Joint
  103327. * @param type The type of the joint
  103328. * @param jointData The physica joint data for the joint
  103329. */
  103330. constructor(type: number, jointData: PhysicsJointData);
  103331. /**
  103332. * Set the motor values.
  103333. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103334. * @param force the force to apply
  103335. * @param maxForce max force for this motor.
  103336. */
  103337. setMotor(force?: number, maxForce?: number): void;
  103338. /**
  103339. * Set the motor's limits.
  103340. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103341. * @param upperLimit The upper limit of the motor
  103342. * @param lowerLimit The lower limit of the motor
  103343. */
  103344. setLimit(upperLimit: number, lowerLimit?: number): void;
  103345. }
  103346. /**
  103347. * This class represents a single physics Hinge-Joint
  103348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103349. */
  103350. export class HingeJoint extends MotorEnabledJoint {
  103351. /**
  103352. * Initializes the Hinge-Joint
  103353. * @param jointData The joint data for the Hinge-Joint
  103354. */
  103355. constructor(jointData: PhysicsJointData);
  103356. /**
  103357. * Set the motor values.
  103358. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103359. * @param {number} force the force to apply
  103360. * @param {number} maxForce max force for this motor.
  103361. */
  103362. setMotor(force?: number, maxForce?: number): void;
  103363. /**
  103364. * Set the motor's limits.
  103365. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103366. * @param upperLimit The upper limit of the motor
  103367. * @param lowerLimit The lower limit of the motor
  103368. */
  103369. setLimit(upperLimit: number, lowerLimit?: number): void;
  103370. }
  103371. /**
  103372. * This class represents a dual hinge physics joint (same as wheel joint)
  103373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103374. */
  103375. export class Hinge2Joint extends MotorEnabledJoint {
  103376. /**
  103377. * Initializes the Hinge2-Joint
  103378. * @param jointData The joint data for the Hinge2-Joint
  103379. */
  103380. constructor(jointData: PhysicsJointData);
  103381. /**
  103382. * Set the motor values.
  103383. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103384. * @param {number} targetSpeed the speed the motor is to reach
  103385. * @param {number} maxForce max force for this motor.
  103386. * @param {motorIndex} the motor's index, 0 or 1.
  103387. */
  103388. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103389. /**
  103390. * Set the motor limits.
  103391. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103392. * @param {number} upperLimit the upper limit
  103393. * @param {number} lowerLimit lower limit
  103394. * @param {motorIndex} the motor's index, 0 or 1.
  103395. */
  103396. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103397. }
  103398. /**
  103399. * Interface for a motor enabled joint
  103400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103401. */
  103402. export interface IMotorEnabledJoint {
  103403. /**
  103404. * Physics joint
  103405. */
  103406. physicsJoint: any;
  103407. /**
  103408. * Sets the motor of the motor-enabled joint
  103409. * @param force The force of the motor
  103410. * @param maxForce The maximum force of the motor
  103411. * @param motorIndex The index of the motor
  103412. */
  103413. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103414. /**
  103415. * Sets the limit of the motor
  103416. * @param upperLimit The upper limit of the motor
  103417. * @param lowerLimit The lower limit of the motor
  103418. * @param motorIndex The index of the motor
  103419. */
  103420. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103421. }
  103422. /**
  103423. * Joint data for a Distance-Joint
  103424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103425. */
  103426. export interface DistanceJointData extends PhysicsJointData {
  103427. /**
  103428. * Max distance the 2 joint objects can be apart
  103429. */
  103430. maxDistance: number;
  103431. }
  103432. /**
  103433. * Joint data from a spring joint
  103434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103435. */
  103436. export interface SpringJointData extends PhysicsJointData {
  103437. /**
  103438. * Length of the spring
  103439. */
  103440. length: number;
  103441. /**
  103442. * Stiffness of the spring
  103443. */
  103444. stiffness: number;
  103445. /**
  103446. * Damping of the spring
  103447. */
  103448. damping: number;
  103449. /** this callback will be called when applying the force to the impostors. */
  103450. forceApplicationCallback: () => void;
  103451. }
  103452. }
  103453. declare module BABYLON {
  103454. /**
  103455. * Holds the data for the raycast result
  103456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103457. */
  103458. export class PhysicsRaycastResult {
  103459. private _hasHit;
  103460. private _hitDistance;
  103461. private _hitNormalWorld;
  103462. private _hitPointWorld;
  103463. private _rayFromWorld;
  103464. private _rayToWorld;
  103465. /**
  103466. * Gets if there was a hit
  103467. */
  103468. get hasHit(): boolean;
  103469. /**
  103470. * Gets the distance from the hit
  103471. */
  103472. get hitDistance(): number;
  103473. /**
  103474. * Gets the hit normal/direction in the world
  103475. */
  103476. get hitNormalWorld(): Vector3;
  103477. /**
  103478. * Gets the hit point in the world
  103479. */
  103480. get hitPointWorld(): Vector3;
  103481. /**
  103482. * Gets the ray "start point" of the ray in the world
  103483. */
  103484. get rayFromWorld(): Vector3;
  103485. /**
  103486. * Gets the ray "end point" of the ray in the world
  103487. */
  103488. get rayToWorld(): Vector3;
  103489. /**
  103490. * Sets the hit data (normal & point in world space)
  103491. * @param hitNormalWorld defines the normal in world space
  103492. * @param hitPointWorld defines the point in world space
  103493. */
  103494. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103495. /**
  103496. * Sets the distance from the start point to the hit point
  103497. * @param distance
  103498. */
  103499. setHitDistance(distance: number): void;
  103500. /**
  103501. * Calculates the distance manually
  103502. */
  103503. calculateHitDistance(): void;
  103504. /**
  103505. * Resets all the values to default
  103506. * @param from The from point on world space
  103507. * @param to The to point on world space
  103508. */
  103509. reset(from?: Vector3, to?: Vector3): void;
  103510. }
  103511. /**
  103512. * Interface for the size containing width and height
  103513. */
  103514. interface IXYZ {
  103515. /**
  103516. * X
  103517. */
  103518. x: number;
  103519. /**
  103520. * Y
  103521. */
  103522. y: number;
  103523. /**
  103524. * Z
  103525. */
  103526. z: number;
  103527. }
  103528. }
  103529. declare module BABYLON {
  103530. /**
  103531. * Interface used to describe a physics joint
  103532. */
  103533. export interface PhysicsImpostorJoint {
  103534. /** Defines the main impostor to which the joint is linked */
  103535. mainImpostor: PhysicsImpostor;
  103536. /** Defines the impostor that is connected to the main impostor using this joint */
  103537. connectedImpostor: PhysicsImpostor;
  103538. /** Defines the joint itself */
  103539. joint: PhysicsJoint;
  103540. }
  103541. /** @hidden */
  103542. export interface IPhysicsEnginePlugin {
  103543. world: any;
  103544. name: string;
  103545. setGravity(gravity: Vector3): void;
  103546. setTimeStep(timeStep: number): void;
  103547. getTimeStep(): number;
  103548. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103549. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103550. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103551. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103552. removePhysicsBody(impostor: PhysicsImpostor): void;
  103553. generateJoint(joint: PhysicsImpostorJoint): void;
  103554. removeJoint(joint: PhysicsImpostorJoint): void;
  103555. isSupported(): boolean;
  103556. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103557. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103558. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103559. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103560. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103561. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103562. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103563. getBodyMass(impostor: PhysicsImpostor): number;
  103564. getBodyFriction(impostor: PhysicsImpostor): number;
  103565. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103566. getBodyRestitution(impostor: PhysicsImpostor): number;
  103567. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103568. getBodyPressure?(impostor: PhysicsImpostor): number;
  103569. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  103570. getBodyStiffness?(impostor: PhysicsImpostor): number;
  103571. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  103572. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  103573. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  103574. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  103575. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  103576. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103577. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103578. sleepBody(impostor: PhysicsImpostor): void;
  103579. wakeUpBody(impostor: PhysicsImpostor): void;
  103580. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103581. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103582. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  103583. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103584. getRadius(impostor: PhysicsImpostor): number;
  103585. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103586. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103587. dispose(): void;
  103588. }
  103589. /**
  103590. * Interface used to define a physics engine
  103591. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103592. */
  103593. export interface IPhysicsEngine {
  103594. /**
  103595. * Gets the gravity vector used by the simulation
  103596. */
  103597. gravity: Vector3;
  103598. /**
  103599. * Sets the gravity vector used by the simulation
  103600. * @param gravity defines the gravity vector to use
  103601. */
  103602. setGravity(gravity: Vector3): void;
  103603. /**
  103604. * Set the time step of the physics engine.
  103605. * Default is 1/60.
  103606. * To slow it down, enter 1/600 for example.
  103607. * To speed it up, 1/30
  103608. * @param newTimeStep the new timestep to apply to this world.
  103609. */
  103610. setTimeStep(newTimeStep: number): void;
  103611. /**
  103612. * Get the time step of the physics engine.
  103613. * @returns the current time step
  103614. */
  103615. getTimeStep(): number;
  103616. /**
  103617. * Set the sub time step of the physics engine.
  103618. * Default is 0 meaning there is no sub steps
  103619. * To increase physics resolution precision, set a small value (like 1 ms)
  103620. * @param subTimeStep defines the new sub timestep used for physics resolution.
  103621. */
  103622. setSubTimeStep(subTimeStep: number): void;
  103623. /**
  103624. * Get the sub time step of the physics engine.
  103625. * @returns the current sub time step
  103626. */
  103627. getSubTimeStep(): number;
  103628. /**
  103629. * Release all resources
  103630. */
  103631. dispose(): void;
  103632. /**
  103633. * Gets the name of the current physics plugin
  103634. * @returns the name of the plugin
  103635. */
  103636. getPhysicsPluginName(): string;
  103637. /**
  103638. * Adding a new impostor for the impostor tracking.
  103639. * This will be done by the impostor itself.
  103640. * @param impostor the impostor to add
  103641. */
  103642. addImpostor(impostor: PhysicsImpostor): void;
  103643. /**
  103644. * Remove an impostor from the engine.
  103645. * This impostor and its mesh will not longer be updated by the physics engine.
  103646. * @param impostor the impostor to remove
  103647. */
  103648. removeImpostor(impostor: PhysicsImpostor): void;
  103649. /**
  103650. * Add a joint to the physics engine
  103651. * @param mainImpostor defines the main impostor to which the joint is added.
  103652. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103653. * @param joint defines the joint that will connect both impostors.
  103654. */
  103655. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103656. /**
  103657. * Removes a joint from the simulation
  103658. * @param mainImpostor defines the impostor used with the joint
  103659. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103660. * @param joint defines the joint to remove
  103661. */
  103662. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103663. /**
  103664. * Gets the current plugin used to run the simulation
  103665. * @returns current plugin
  103666. */
  103667. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103668. /**
  103669. * Gets the list of physic impostors
  103670. * @returns an array of PhysicsImpostor
  103671. */
  103672. getImpostors(): Array<PhysicsImpostor>;
  103673. /**
  103674. * Gets the impostor for a physics enabled object
  103675. * @param object defines the object impersonated by the impostor
  103676. * @returns the PhysicsImpostor or null if not found
  103677. */
  103678. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103679. /**
  103680. * Gets the impostor for a physics body object
  103681. * @param body defines physics body used by the impostor
  103682. * @returns the PhysicsImpostor or null if not found
  103683. */
  103684. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103685. /**
  103686. * Does a raycast in the physics world
  103687. * @param from when should the ray start?
  103688. * @param to when should the ray end?
  103689. * @returns PhysicsRaycastResult
  103690. */
  103691. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103692. /**
  103693. * Called by the scene. No need to call it.
  103694. * @param delta defines the timespam between frames
  103695. */
  103696. _step(delta: number): void;
  103697. }
  103698. }
  103699. declare module BABYLON {
  103700. /**
  103701. * The interface for the physics imposter parameters
  103702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103703. */
  103704. export interface PhysicsImpostorParameters {
  103705. /**
  103706. * The mass of the physics imposter
  103707. */
  103708. mass: number;
  103709. /**
  103710. * The friction of the physics imposter
  103711. */
  103712. friction?: number;
  103713. /**
  103714. * The coefficient of restitution of the physics imposter
  103715. */
  103716. restitution?: number;
  103717. /**
  103718. * The native options of the physics imposter
  103719. */
  103720. nativeOptions?: any;
  103721. /**
  103722. * Specifies if the parent should be ignored
  103723. */
  103724. ignoreParent?: boolean;
  103725. /**
  103726. * Specifies if bi-directional transformations should be disabled
  103727. */
  103728. disableBidirectionalTransformation?: boolean;
  103729. /**
  103730. * The pressure inside the physics imposter, soft object only
  103731. */
  103732. pressure?: number;
  103733. /**
  103734. * The stiffness the physics imposter, soft object only
  103735. */
  103736. stiffness?: number;
  103737. /**
  103738. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  103739. */
  103740. velocityIterations?: number;
  103741. /**
  103742. * The number of iterations used in maintaining consistent vertex positions, soft object only
  103743. */
  103744. positionIterations?: number;
  103745. /**
  103746. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  103747. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  103748. * Add to fix multiple points
  103749. */
  103750. fixedPoints?: number;
  103751. /**
  103752. * The collision margin around a soft object
  103753. */
  103754. margin?: number;
  103755. /**
  103756. * The collision margin around a soft object
  103757. */
  103758. damping?: number;
  103759. /**
  103760. * The path for a rope based on an extrusion
  103761. */
  103762. path?: any;
  103763. /**
  103764. * The shape of an extrusion used for a rope based on an extrusion
  103765. */
  103766. shape?: any;
  103767. }
  103768. /**
  103769. * Interface for a physics-enabled object
  103770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103771. */
  103772. export interface IPhysicsEnabledObject {
  103773. /**
  103774. * The position of the physics-enabled object
  103775. */
  103776. position: Vector3;
  103777. /**
  103778. * The rotation of the physics-enabled object
  103779. */
  103780. rotationQuaternion: Nullable<Quaternion>;
  103781. /**
  103782. * The scale of the physics-enabled object
  103783. */
  103784. scaling: Vector3;
  103785. /**
  103786. * The rotation of the physics-enabled object
  103787. */
  103788. rotation?: Vector3;
  103789. /**
  103790. * The parent of the physics-enabled object
  103791. */
  103792. parent?: any;
  103793. /**
  103794. * The bounding info of the physics-enabled object
  103795. * @returns The bounding info of the physics-enabled object
  103796. */
  103797. getBoundingInfo(): BoundingInfo;
  103798. /**
  103799. * Computes the world matrix
  103800. * @param force Specifies if the world matrix should be computed by force
  103801. * @returns A world matrix
  103802. */
  103803. computeWorldMatrix(force: boolean): Matrix;
  103804. /**
  103805. * Gets the world matrix
  103806. * @returns A world matrix
  103807. */
  103808. getWorldMatrix?(): Matrix;
  103809. /**
  103810. * Gets the child meshes
  103811. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  103812. * @returns An array of abstract meshes
  103813. */
  103814. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  103815. /**
  103816. * Gets the vertex data
  103817. * @param kind The type of vertex data
  103818. * @returns A nullable array of numbers, or a float32 array
  103819. */
  103820. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  103821. /**
  103822. * Gets the indices from the mesh
  103823. * @returns A nullable array of index arrays
  103824. */
  103825. getIndices?(): Nullable<IndicesArray>;
  103826. /**
  103827. * Gets the scene from the mesh
  103828. * @returns the indices array or null
  103829. */
  103830. getScene?(): Scene;
  103831. /**
  103832. * Gets the absolute position from the mesh
  103833. * @returns the absolute position
  103834. */
  103835. getAbsolutePosition(): Vector3;
  103836. /**
  103837. * Gets the absolute pivot point from the mesh
  103838. * @returns the absolute pivot point
  103839. */
  103840. getAbsolutePivotPoint(): Vector3;
  103841. /**
  103842. * Rotates the mesh
  103843. * @param axis The axis of rotation
  103844. * @param amount The amount of rotation
  103845. * @param space The space of the rotation
  103846. * @returns The rotation transform node
  103847. */
  103848. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  103849. /**
  103850. * Translates the mesh
  103851. * @param axis The axis of translation
  103852. * @param distance The distance of translation
  103853. * @param space The space of the translation
  103854. * @returns The transform node
  103855. */
  103856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  103857. /**
  103858. * Sets the absolute position of the mesh
  103859. * @param absolutePosition The absolute position of the mesh
  103860. * @returns The transform node
  103861. */
  103862. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  103863. /**
  103864. * Gets the class name of the mesh
  103865. * @returns The class name
  103866. */
  103867. getClassName(): string;
  103868. }
  103869. /**
  103870. * Represents a physics imposter
  103871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103872. */
  103873. export class PhysicsImpostor {
  103874. /**
  103875. * The physics-enabled object used as the physics imposter
  103876. */
  103877. object: IPhysicsEnabledObject;
  103878. /**
  103879. * The type of the physics imposter
  103880. */
  103881. type: number;
  103882. private _options;
  103883. private _scene?;
  103884. /**
  103885. * The default object size of the imposter
  103886. */
  103887. static DEFAULT_OBJECT_SIZE: Vector3;
  103888. /**
  103889. * The identity quaternion of the imposter
  103890. */
  103891. static IDENTITY_QUATERNION: Quaternion;
  103892. /** @hidden */
  103893. _pluginData: any;
  103894. private _physicsEngine;
  103895. private _physicsBody;
  103896. private _bodyUpdateRequired;
  103897. private _onBeforePhysicsStepCallbacks;
  103898. private _onAfterPhysicsStepCallbacks;
  103899. /** @hidden */
  103900. _onPhysicsCollideCallbacks: Array<{
  103901. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  103902. otherImpostors: Array<PhysicsImpostor>;
  103903. }>;
  103904. private _deltaPosition;
  103905. private _deltaRotation;
  103906. private _deltaRotationConjugated;
  103907. /** @hidden */
  103908. _isFromLine: boolean;
  103909. private _parent;
  103910. private _isDisposed;
  103911. private static _tmpVecs;
  103912. private static _tmpQuat;
  103913. /**
  103914. * Specifies if the physics imposter is disposed
  103915. */
  103916. get isDisposed(): boolean;
  103917. /**
  103918. * Gets the mass of the physics imposter
  103919. */
  103920. get mass(): number;
  103921. set mass(value: number);
  103922. /**
  103923. * Gets the coefficient of friction
  103924. */
  103925. get friction(): number;
  103926. /**
  103927. * Sets the coefficient of friction
  103928. */
  103929. set friction(value: number);
  103930. /**
  103931. * Gets the coefficient of restitution
  103932. */
  103933. get restitution(): number;
  103934. /**
  103935. * Sets the coefficient of restitution
  103936. */
  103937. set restitution(value: number);
  103938. /**
  103939. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  103940. */
  103941. get pressure(): number;
  103942. /**
  103943. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  103944. */
  103945. set pressure(value: number);
  103946. /**
  103947. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103948. */
  103949. get stiffness(): number;
  103950. /**
  103951. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103952. */
  103953. set stiffness(value: number);
  103954. /**
  103955. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103956. */
  103957. get velocityIterations(): number;
  103958. /**
  103959. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103960. */
  103961. set velocityIterations(value: number);
  103962. /**
  103963. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103964. */
  103965. get positionIterations(): number;
  103966. /**
  103967. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103968. */
  103969. set positionIterations(value: number);
  103970. /**
  103971. * The unique id of the physics imposter
  103972. * set by the physics engine when adding this impostor to the array
  103973. */
  103974. uniqueId: number;
  103975. /**
  103976. * @hidden
  103977. */
  103978. soft: boolean;
  103979. /**
  103980. * @hidden
  103981. */
  103982. segments: number;
  103983. private _joints;
  103984. /**
  103985. * Initializes the physics imposter
  103986. * @param object The physics-enabled object used as the physics imposter
  103987. * @param type The type of the physics imposter
  103988. * @param _options The options for the physics imposter
  103989. * @param _scene The Babylon scene
  103990. */
  103991. constructor(
  103992. /**
  103993. * The physics-enabled object used as the physics imposter
  103994. */
  103995. object: IPhysicsEnabledObject,
  103996. /**
  103997. * The type of the physics imposter
  103998. */
  103999. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104000. /**
  104001. * This function will completly initialize this impostor.
  104002. * It will create a new body - but only if this mesh has no parent.
  104003. * If it has, this impostor will not be used other than to define the impostor
  104004. * of the child mesh.
  104005. * @hidden
  104006. */
  104007. _init(): void;
  104008. private _getPhysicsParent;
  104009. /**
  104010. * Should a new body be generated.
  104011. * @returns boolean specifying if body initialization is required
  104012. */
  104013. isBodyInitRequired(): boolean;
  104014. /**
  104015. * Sets the updated scaling
  104016. * @param updated Specifies if the scaling is updated
  104017. */
  104018. setScalingUpdated(): void;
  104019. /**
  104020. * Force a regeneration of this or the parent's impostor's body.
  104021. * Use under cautious - This will remove all joints already implemented.
  104022. */
  104023. forceUpdate(): void;
  104024. /**
  104025. * Gets the body that holds this impostor. Either its own, or its parent.
  104026. */
  104027. get physicsBody(): any;
  104028. /**
  104029. * Get the parent of the physics imposter
  104030. * @returns Physics imposter or null
  104031. */
  104032. get parent(): Nullable<PhysicsImpostor>;
  104033. /**
  104034. * Sets the parent of the physics imposter
  104035. */
  104036. set parent(value: Nullable<PhysicsImpostor>);
  104037. /**
  104038. * Set the physics body. Used mainly by the physics engine/plugin
  104039. */
  104040. set physicsBody(physicsBody: any);
  104041. /**
  104042. * Resets the update flags
  104043. */
  104044. resetUpdateFlags(): void;
  104045. /**
  104046. * Gets the object extend size
  104047. * @returns the object extend size
  104048. */
  104049. getObjectExtendSize(): Vector3;
  104050. /**
  104051. * Gets the object center
  104052. * @returns The object center
  104053. */
  104054. getObjectCenter(): Vector3;
  104055. /**
  104056. * Get a specific parameter from the options parameters
  104057. * @param paramName The object parameter name
  104058. * @returns The object parameter
  104059. */
  104060. getParam(paramName: string): any;
  104061. /**
  104062. * Sets a specific parameter in the options given to the physics plugin
  104063. * @param paramName The parameter name
  104064. * @param value The value of the parameter
  104065. */
  104066. setParam(paramName: string, value: number): void;
  104067. /**
  104068. * Specifically change the body's mass option. Won't recreate the physics body object
  104069. * @param mass The mass of the physics imposter
  104070. */
  104071. setMass(mass: number): void;
  104072. /**
  104073. * Gets the linear velocity
  104074. * @returns linear velocity or null
  104075. */
  104076. getLinearVelocity(): Nullable<Vector3>;
  104077. /**
  104078. * Sets the linear velocity
  104079. * @param velocity linear velocity or null
  104080. */
  104081. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104082. /**
  104083. * Gets the angular velocity
  104084. * @returns angular velocity or null
  104085. */
  104086. getAngularVelocity(): Nullable<Vector3>;
  104087. /**
  104088. * Sets the angular velocity
  104089. * @param velocity The velocity or null
  104090. */
  104091. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104092. /**
  104093. * Execute a function with the physics plugin native code
  104094. * Provide a function the will have two variables - the world object and the physics body object
  104095. * @param func The function to execute with the physics plugin native code
  104096. */
  104097. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104098. /**
  104099. * Register a function that will be executed before the physics world is stepping forward
  104100. * @param func The function to execute before the physics world is stepped forward
  104101. */
  104102. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104103. /**
  104104. * Unregister a function that will be executed before the physics world is stepping forward
  104105. * @param func The function to execute before the physics world is stepped forward
  104106. */
  104107. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104108. /**
  104109. * Register a function that will be executed after the physics step
  104110. * @param func The function to execute after physics step
  104111. */
  104112. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104113. /**
  104114. * Unregisters a function that will be executed after the physics step
  104115. * @param func The function to execute after physics step
  104116. */
  104117. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104118. /**
  104119. * register a function that will be executed when this impostor collides against a different body
  104120. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104121. * @param func Callback that is executed on collision
  104122. */
  104123. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104124. /**
  104125. * Unregisters the physics imposter on contact
  104126. * @param collideAgainst The physics object to collide against
  104127. * @param func Callback to execute on collision
  104128. */
  104129. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104130. private _tmpQuat;
  104131. private _tmpQuat2;
  104132. /**
  104133. * Get the parent rotation
  104134. * @returns The parent rotation
  104135. */
  104136. getParentsRotation(): Quaternion;
  104137. /**
  104138. * this function is executed by the physics engine.
  104139. */
  104140. beforeStep: () => void;
  104141. /**
  104142. * this function is executed by the physics engine
  104143. */
  104144. afterStep: () => void;
  104145. /**
  104146. * Legacy collision detection event support
  104147. */
  104148. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104149. /**
  104150. * event and body object due to cannon's event-based architecture.
  104151. */
  104152. onCollide: (e: {
  104153. body: any;
  104154. }) => void;
  104155. /**
  104156. * Apply a force
  104157. * @param force The force to apply
  104158. * @param contactPoint The contact point for the force
  104159. * @returns The physics imposter
  104160. */
  104161. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104162. /**
  104163. * Apply an impulse
  104164. * @param force The impulse force
  104165. * @param contactPoint The contact point for the impulse force
  104166. * @returns The physics imposter
  104167. */
  104168. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104169. /**
  104170. * A help function to create a joint
  104171. * @param otherImpostor A physics imposter used to create a joint
  104172. * @param jointType The type of joint
  104173. * @param jointData The data for the joint
  104174. * @returns The physics imposter
  104175. */
  104176. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104177. /**
  104178. * Add a joint to this impostor with a different impostor
  104179. * @param otherImpostor A physics imposter used to add a joint
  104180. * @param joint The joint to add
  104181. * @returns The physics imposter
  104182. */
  104183. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104184. /**
  104185. * Add an anchor to a cloth impostor
  104186. * @param otherImpostor rigid impostor to anchor to
  104187. * @param width ratio across width from 0 to 1
  104188. * @param height ratio up height from 0 to 1
  104189. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104190. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104191. * @returns impostor the soft imposter
  104192. */
  104193. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104194. /**
  104195. * Add a hook to a rope impostor
  104196. * @param otherImpostor rigid impostor to anchor to
  104197. * @param length ratio across rope from 0 to 1
  104198. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104199. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104200. * @returns impostor the rope imposter
  104201. */
  104202. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104203. /**
  104204. * Will keep this body still, in a sleep mode.
  104205. * @returns the physics imposter
  104206. */
  104207. sleep(): PhysicsImpostor;
  104208. /**
  104209. * Wake the body up.
  104210. * @returns The physics imposter
  104211. */
  104212. wakeUp(): PhysicsImpostor;
  104213. /**
  104214. * Clones the physics imposter
  104215. * @param newObject The physics imposter clones to this physics-enabled object
  104216. * @returns A nullable physics imposter
  104217. */
  104218. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104219. /**
  104220. * Disposes the physics imposter
  104221. */
  104222. dispose(): void;
  104223. /**
  104224. * Sets the delta position
  104225. * @param position The delta position amount
  104226. */
  104227. setDeltaPosition(position: Vector3): void;
  104228. /**
  104229. * Sets the delta rotation
  104230. * @param rotation The delta rotation amount
  104231. */
  104232. setDeltaRotation(rotation: Quaternion): void;
  104233. /**
  104234. * Gets the box size of the physics imposter and stores the result in the input parameter
  104235. * @param result Stores the box size
  104236. * @returns The physics imposter
  104237. */
  104238. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104239. /**
  104240. * Gets the radius of the physics imposter
  104241. * @returns Radius of the physics imposter
  104242. */
  104243. getRadius(): number;
  104244. /**
  104245. * Sync a bone with this impostor
  104246. * @param bone The bone to sync to the impostor.
  104247. * @param boneMesh The mesh that the bone is influencing.
  104248. * @param jointPivot The pivot of the joint / bone in local space.
  104249. * @param distToJoint Optional distance from the impostor to the joint.
  104250. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104251. */
  104252. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104253. /**
  104254. * Sync impostor to a bone
  104255. * @param bone The bone that the impostor will be synced to.
  104256. * @param boneMesh The mesh that the bone is influencing.
  104257. * @param jointPivot The pivot of the joint / bone in local space.
  104258. * @param distToJoint Optional distance from the impostor to the joint.
  104259. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104260. * @param boneAxis Optional vector3 axis the bone is aligned with
  104261. */
  104262. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104263. /**
  104264. * No-Imposter type
  104265. */
  104266. static NoImpostor: number;
  104267. /**
  104268. * Sphere-Imposter type
  104269. */
  104270. static SphereImpostor: number;
  104271. /**
  104272. * Box-Imposter type
  104273. */
  104274. static BoxImpostor: number;
  104275. /**
  104276. * Plane-Imposter type
  104277. */
  104278. static PlaneImpostor: number;
  104279. /**
  104280. * Mesh-imposter type
  104281. */
  104282. static MeshImpostor: number;
  104283. /**
  104284. * Capsule-Impostor type (Ammo.js plugin only)
  104285. */
  104286. static CapsuleImpostor: number;
  104287. /**
  104288. * Cylinder-Imposter type
  104289. */
  104290. static CylinderImpostor: number;
  104291. /**
  104292. * Particle-Imposter type
  104293. */
  104294. static ParticleImpostor: number;
  104295. /**
  104296. * Heightmap-Imposter type
  104297. */
  104298. static HeightmapImpostor: number;
  104299. /**
  104300. * ConvexHull-Impostor type (Ammo.js plugin only)
  104301. */
  104302. static ConvexHullImpostor: number;
  104303. /**
  104304. * Custom-Imposter type (Ammo.js plugin only)
  104305. */
  104306. static CustomImpostor: number;
  104307. /**
  104308. * Rope-Imposter type
  104309. */
  104310. static RopeImpostor: number;
  104311. /**
  104312. * Cloth-Imposter type
  104313. */
  104314. static ClothImpostor: number;
  104315. /**
  104316. * Softbody-Imposter type
  104317. */
  104318. static SoftbodyImpostor: number;
  104319. }
  104320. }
  104321. declare module BABYLON {
  104322. /**
  104323. * @hidden
  104324. **/
  104325. export class _CreationDataStorage {
  104326. closePath?: boolean;
  104327. closeArray?: boolean;
  104328. idx: number[];
  104329. dashSize: number;
  104330. gapSize: number;
  104331. path3D: Path3D;
  104332. pathArray: Vector3[][];
  104333. arc: number;
  104334. radius: number;
  104335. cap: number;
  104336. tessellation: number;
  104337. }
  104338. /**
  104339. * @hidden
  104340. **/
  104341. class _InstanceDataStorage {
  104342. visibleInstances: any;
  104343. batchCache: _InstancesBatch;
  104344. instancesBufferSize: number;
  104345. instancesBuffer: Nullable<Buffer>;
  104346. instancesData: Float32Array;
  104347. overridenInstanceCount: number;
  104348. isFrozen: boolean;
  104349. previousBatch: Nullable<_InstancesBatch>;
  104350. hardwareInstancedRendering: boolean;
  104351. sideOrientation: number;
  104352. manualUpdate: boolean;
  104353. }
  104354. /**
  104355. * @hidden
  104356. **/
  104357. export class _InstancesBatch {
  104358. mustReturn: boolean;
  104359. visibleInstances: Nullable<InstancedMesh[]>[];
  104360. renderSelf: boolean[];
  104361. hardwareInstancedRendering: boolean[];
  104362. }
  104363. /**
  104364. * @hidden
  104365. **/
  104366. class _ThinInstanceDataStorage {
  104367. instancesCount: number;
  104368. matrixBuffer: Nullable<Buffer>;
  104369. matrixBufferSize: number;
  104370. matrixData: Nullable<Float32Array>;
  104371. boundingVectors: Array<Vector3>;
  104372. }
  104373. /**
  104374. * Class used to represent renderable models
  104375. */
  104376. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104377. /**
  104378. * Mesh side orientation : usually the external or front surface
  104379. */
  104380. static readonly FRONTSIDE: number;
  104381. /**
  104382. * Mesh side orientation : usually the internal or back surface
  104383. */
  104384. static readonly BACKSIDE: number;
  104385. /**
  104386. * Mesh side orientation : both internal and external or front and back surfaces
  104387. */
  104388. static readonly DOUBLESIDE: number;
  104389. /**
  104390. * Mesh side orientation : by default, `FRONTSIDE`
  104391. */
  104392. static readonly DEFAULTSIDE: number;
  104393. /**
  104394. * Mesh cap setting : no cap
  104395. */
  104396. static readonly NO_CAP: number;
  104397. /**
  104398. * Mesh cap setting : one cap at the beginning of the mesh
  104399. */
  104400. static readonly CAP_START: number;
  104401. /**
  104402. * Mesh cap setting : one cap at the end of the mesh
  104403. */
  104404. static readonly CAP_END: number;
  104405. /**
  104406. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104407. */
  104408. static readonly CAP_ALL: number;
  104409. /**
  104410. * Mesh pattern setting : no flip or rotate
  104411. */
  104412. static readonly NO_FLIP: number;
  104413. /**
  104414. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104415. */
  104416. static readonly FLIP_TILE: number;
  104417. /**
  104418. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104419. */
  104420. static readonly ROTATE_TILE: number;
  104421. /**
  104422. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104423. */
  104424. static readonly FLIP_ROW: number;
  104425. /**
  104426. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104427. */
  104428. static readonly ROTATE_ROW: number;
  104429. /**
  104430. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104431. */
  104432. static readonly FLIP_N_ROTATE_TILE: number;
  104433. /**
  104434. * Mesh pattern setting : rotate pattern and rotate
  104435. */
  104436. static readonly FLIP_N_ROTATE_ROW: number;
  104437. /**
  104438. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104439. */
  104440. static readonly CENTER: number;
  104441. /**
  104442. * Mesh tile positioning : part tiles on left
  104443. */
  104444. static readonly LEFT: number;
  104445. /**
  104446. * Mesh tile positioning : part tiles on right
  104447. */
  104448. static readonly RIGHT: number;
  104449. /**
  104450. * Mesh tile positioning : part tiles on top
  104451. */
  104452. static readonly TOP: number;
  104453. /**
  104454. * Mesh tile positioning : part tiles on bottom
  104455. */
  104456. static readonly BOTTOM: number;
  104457. /**
  104458. * Gets the default side orientation.
  104459. * @param orientation the orientation to value to attempt to get
  104460. * @returns the default orientation
  104461. * @hidden
  104462. */
  104463. static _GetDefaultSideOrientation(orientation?: number): number;
  104464. private _internalMeshDataInfo;
  104465. /**
  104466. * An event triggered before rendering the mesh
  104467. */
  104468. get onBeforeRenderObservable(): Observable<Mesh>;
  104469. /**
  104470. * An event triggered before binding the mesh
  104471. */
  104472. get onBeforeBindObservable(): Observable<Mesh>;
  104473. /**
  104474. * An event triggered after rendering the mesh
  104475. */
  104476. get onAfterRenderObservable(): Observable<Mesh>;
  104477. /**
  104478. * An event triggered before drawing the mesh
  104479. */
  104480. get onBeforeDrawObservable(): Observable<Mesh>;
  104481. private _onBeforeDrawObserver;
  104482. /**
  104483. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104484. */
  104485. set onBeforeDraw(callback: () => void);
  104486. get hasInstances(): boolean;
  104487. get hasThinInstances(): boolean;
  104488. /**
  104489. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104490. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104491. */
  104492. delayLoadState: number;
  104493. /**
  104494. * Gets the list of instances created from this mesh
  104495. * it is not supposed to be modified manually.
  104496. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104497. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104498. */
  104499. instances: InstancedMesh[];
  104500. /**
  104501. * Gets the file containing delay loading data for this mesh
  104502. */
  104503. delayLoadingFile: string;
  104504. /** @hidden */
  104505. _binaryInfo: any;
  104506. /**
  104507. * User defined function used to change how LOD level selection is done
  104508. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104509. */
  104510. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104511. /**
  104512. * Gets or sets the morph target manager
  104513. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104514. */
  104515. get morphTargetManager(): Nullable<MorphTargetManager>;
  104516. set morphTargetManager(value: Nullable<MorphTargetManager>);
  104517. /** @hidden */
  104518. _creationDataStorage: Nullable<_CreationDataStorage>;
  104519. /** @hidden */
  104520. _geometry: Nullable<Geometry>;
  104521. /** @hidden */
  104522. _delayInfo: Array<string>;
  104523. /** @hidden */
  104524. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  104525. /** @hidden */
  104526. _instanceDataStorage: _InstanceDataStorage;
  104527. /** @hidden */
  104528. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  104529. private _effectiveMaterial;
  104530. /** @hidden */
  104531. _shouldGenerateFlatShading: boolean;
  104532. /** @hidden */
  104533. _originalBuilderSideOrientation: number;
  104534. /**
  104535. * Use this property to change the original side orientation defined at construction time
  104536. */
  104537. overrideMaterialSideOrientation: Nullable<number>;
  104538. /**
  104539. * Gets the source mesh (the one used to clone this one from)
  104540. */
  104541. get source(): Nullable<Mesh>;
  104542. /**
  104543. * Gets or sets a boolean indicating that this mesh does not use index buffer
  104544. */
  104545. get isUnIndexed(): boolean;
  104546. set isUnIndexed(value: boolean);
  104547. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  104548. get worldMatrixInstancedBuffer(): Float32Array;
  104549. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  104550. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  104551. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  104552. /**
  104553. * @constructor
  104554. * @param name The value used by scene.getMeshByName() to do a lookup.
  104555. * @param scene The scene to add this mesh to.
  104556. * @param parent The parent of this mesh, if it has one
  104557. * @param source An optional Mesh from which geometry is shared, cloned.
  104558. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  104559. * When false, achieved by calling a clone(), also passing False.
  104560. * This will make creation of children, recursive.
  104561. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  104562. */
  104563. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  104564. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  104565. doNotInstantiate: boolean;
  104566. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  104567. /**
  104568. * Gets the class name
  104569. * @returns the string "Mesh".
  104570. */
  104571. getClassName(): string;
  104572. /** @hidden */
  104573. get _isMesh(): boolean;
  104574. /**
  104575. * Returns a description of this mesh
  104576. * @param fullDetails define if full details about this mesh must be used
  104577. * @returns a descriptive string representing this mesh
  104578. */
  104579. toString(fullDetails?: boolean): string;
  104580. /** @hidden */
  104581. _unBindEffect(): void;
  104582. /**
  104583. * Gets a boolean indicating if this mesh has LOD
  104584. */
  104585. get hasLODLevels(): boolean;
  104586. /**
  104587. * Gets the list of MeshLODLevel associated with the current mesh
  104588. * @returns an array of MeshLODLevel
  104589. */
  104590. getLODLevels(): MeshLODLevel[];
  104591. private _sortLODLevels;
  104592. /**
  104593. * Add a mesh as LOD level triggered at the given distance.
  104594. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104595. * @param distance The distance from the center of the object to show this level
  104596. * @param mesh The mesh to be added as LOD level (can be null)
  104597. * @return This mesh (for chaining)
  104598. */
  104599. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  104600. /**
  104601. * Returns the LOD level mesh at the passed distance or null if not found.
  104602. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104603. * @param distance The distance from the center of the object to show this level
  104604. * @returns a Mesh or `null`
  104605. */
  104606. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  104607. /**
  104608. * Remove a mesh from the LOD array
  104609. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104610. * @param mesh defines the mesh to be removed
  104611. * @return This mesh (for chaining)
  104612. */
  104613. removeLODLevel(mesh: Mesh): Mesh;
  104614. /**
  104615. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  104616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104617. * @param camera defines the camera to use to compute distance
  104618. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  104619. * @return This mesh (for chaining)
  104620. */
  104621. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  104622. /**
  104623. * Gets the mesh internal Geometry object
  104624. */
  104625. get geometry(): Nullable<Geometry>;
  104626. /**
  104627. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  104628. * @returns the total number of vertices
  104629. */
  104630. getTotalVertices(): number;
  104631. /**
  104632. * Returns the content of an associated vertex buffer
  104633. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104634. * - VertexBuffer.PositionKind
  104635. * - VertexBuffer.UVKind
  104636. * - VertexBuffer.UV2Kind
  104637. * - VertexBuffer.UV3Kind
  104638. * - VertexBuffer.UV4Kind
  104639. * - VertexBuffer.UV5Kind
  104640. * - VertexBuffer.UV6Kind
  104641. * - VertexBuffer.ColorKind
  104642. * - VertexBuffer.MatricesIndicesKind
  104643. * - VertexBuffer.MatricesIndicesExtraKind
  104644. * - VertexBuffer.MatricesWeightsKind
  104645. * - VertexBuffer.MatricesWeightsExtraKind
  104646. * @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
  104647. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  104648. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  104649. */
  104650. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104651. /**
  104652. * Returns the mesh VertexBuffer object from the requested `kind`
  104653. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104654. * - VertexBuffer.PositionKind
  104655. * - VertexBuffer.NormalKind
  104656. * - VertexBuffer.UVKind
  104657. * - VertexBuffer.UV2Kind
  104658. * - VertexBuffer.UV3Kind
  104659. * - VertexBuffer.UV4Kind
  104660. * - VertexBuffer.UV5Kind
  104661. * - VertexBuffer.UV6Kind
  104662. * - VertexBuffer.ColorKind
  104663. * - VertexBuffer.MatricesIndicesKind
  104664. * - VertexBuffer.MatricesIndicesExtraKind
  104665. * - VertexBuffer.MatricesWeightsKind
  104666. * - VertexBuffer.MatricesWeightsExtraKind
  104667. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  104668. */
  104669. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104670. /**
  104671. * Tests if a specific vertex buffer is associated with this mesh
  104672. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104673. * - VertexBuffer.PositionKind
  104674. * - VertexBuffer.NormalKind
  104675. * - VertexBuffer.UVKind
  104676. * - VertexBuffer.UV2Kind
  104677. * - VertexBuffer.UV3Kind
  104678. * - VertexBuffer.UV4Kind
  104679. * - VertexBuffer.UV5Kind
  104680. * - VertexBuffer.UV6Kind
  104681. * - VertexBuffer.ColorKind
  104682. * - VertexBuffer.MatricesIndicesKind
  104683. * - VertexBuffer.MatricesIndicesExtraKind
  104684. * - VertexBuffer.MatricesWeightsKind
  104685. * - VertexBuffer.MatricesWeightsExtraKind
  104686. * @returns a boolean
  104687. */
  104688. isVerticesDataPresent(kind: string): boolean;
  104689. /**
  104690. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  104691. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104692. * - VertexBuffer.PositionKind
  104693. * - VertexBuffer.UVKind
  104694. * - VertexBuffer.UV2Kind
  104695. * - VertexBuffer.UV3Kind
  104696. * - VertexBuffer.UV4Kind
  104697. * - VertexBuffer.UV5Kind
  104698. * - VertexBuffer.UV6Kind
  104699. * - VertexBuffer.ColorKind
  104700. * - VertexBuffer.MatricesIndicesKind
  104701. * - VertexBuffer.MatricesIndicesExtraKind
  104702. * - VertexBuffer.MatricesWeightsKind
  104703. * - VertexBuffer.MatricesWeightsExtraKind
  104704. * @returns a boolean
  104705. */
  104706. isVertexBufferUpdatable(kind: string): boolean;
  104707. /**
  104708. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  104709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104710. * - VertexBuffer.PositionKind
  104711. * - VertexBuffer.NormalKind
  104712. * - VertexBuffer.UVKind
  104713. * - VertexBuffer.UV2Kind
  104714. * - VertexBuffer.UV3Kind
  104715. * - VertexBuffer.UV4Kind
  104716. * - VertexBuffer.UV5Kind
  104717. * - VertexBuffer.UV6Kind
  104718. * - VertexBuffer.ColorKind
  104719. * - VertexBuffer.MatricesIndicesKind
  104720. * - VertexBuffer.MatricesIndicesExtraKind
  104721. * - VertexBuffer.MatricesWeightsKind
  104722. * - VertexBuffer.MatricesWeightsExtraKind
  104723. * @returns an array of strings
  104724. */
  104725. getVerticesDataKinds(): string[];
  104726. /**
  104727. * Returns a positive integer : the total number of indices in this mesh geometry.
  104728. * @returns the numner of indices or zero if the mesh has no geometry.
  104729. */
  104730. getTotalIndices(): number;
  104731. /**
  104732. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104733. * @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.
  104734. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104735. * @returns the indices array or an empty array if the mesh has no geometry
  104736. */
  104737. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104738. get isBlocked(): boolean;
  104739. /**
  104740. * Determine if the current mesh is ready to be rendered
  104741. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104742. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  104743. * @returns true if all associated assets are ready (material, textures, shaders)
  104744. */
  104745. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  104746. /**
  104747. * 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.
  104748. */
  104749. get areNormalsFrozen(): boolean;
  104750. /**
  104751. * 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.
  104752. * @returns the current mesh
  104753. */
  104754. freezeNormals(): Mesh;
  104755. /**
  104756. * 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
  104757. * @returns the current mesh
  104758. */
  104759. unfreezeNormals(): Mesh;
  104760. /**
  104761. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  104762. */
  104763. set overridenInstanceCount(count: number);
  104764. /** @hidden */
  104765. _preActivate(): Mesh;
  104766. /** @hidden */
  104767. _preActivateForIntermediateRendering(renderId: number): Mesh;
  104768. /** @hidden */
  104769. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  104770. protected _afterComputeWorldMatrix(): void;
  104771. /**
  104772. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104773. * This means the mesh underlying bounding box and sphere are recomputed.
  104774. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104775. * @returns the current mesh
  104776. */
  104777. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  104778. /** @hidden */
  104779. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  104780. /**
  104781. * This function will subdivide the mesh into multiple submeshes
  104782. * @param count defines the expected number of submeshes
  104783. */
  104784. subdivide(count: number): void;
  104785. /**
  104786. * Copy a FloatArray into a specific associated vertex buffer
  104787. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104788. * - VertexBuffer.PositionKind
  104789. * - VertexBuffer.UVKind
  104790. * - VertexBuffer.UV2Kind
  104791. * - VertexBuffer.UV3Kind
  104792. * - VertexBuffer.UV4Kind
  104793. * - VertexBuffer.UV5Kind
  104794. * - VertexBuffer.UV6Kind
  104795. * - VertexBuffer.ColorKind
  104796. * - VertexBuffer.MatricesIndicesKind
  104797. * - VertexBuffer.MatricesIndicesExtraKind
  104798. * - VertexBuffer.MatricesWeightsKind
  104799. * - VertexBuffer.MatricesWeightsExtraKind
  104800. * @param data defines the data source
  104801. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104802. * @param stride defines the data stride size (can be null)
  104803. * @returns the current mesh
  104804. */
  104805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104806. /**
  104807. * Delete a vertex buffer associated with this mesh
  104808. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  104809. * - VertexBuffer.PositionKind
  104810. * - VertexBuffer.UVKind
  104811. * - VertexBuffer.UV2Kind
  104812. * - VertexBuffer.UV3Kind
  104813. * - VertexBuffer.UV4Kind
  104814. * - VertexBuffer.UV5Kind
  104815. * - VertexBuffer.UV6Kind
  104816. * - VertexBuffer.ColorKind
  104817. * - VertexBuffer.MatricesIndicesKind
  104818. * - VertexBuffer.MatricesIndicesExtraKind
  104819. * - VertexBuffer.MatricesWeightsKind
  104820. * - VertexBuffer.MatricesWeightsExtraKind
  104821. */
  104822. removeVerticesData(kind: string): void;
  104823. /**
  104824. * Flags an associated vertex buffer as updatable
  104825. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  104826. * - VertexBuffer.PositionKind
  104827. * - VertexBuffer.UVKind
  104828. * - VertexBuffer.UV2Kind
  104829. * - VertexBuffer.UV3Kind
  104830. * - VertexBuffer.UV4Kind
  104831. * - VertexBuffer.UV5Kind
  104832. * - VertexBuffer.UV6Kind
  104833. * - VertexBuffer.ColorKind
  104834. * - VertexBuffer.MatricesIndicesKind
  104835. * - VertexBuffer.MatricesIndicesExtraKind
  104836. * - VertexBuffer.MatricesWeightsKind
  104837. * - VertexBuffer.MatricesWeightsExtraKind
  104838. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104839. */
  104840. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  104841. /**
  104842. * Sets the mesh global Vertex Buffer
  104843. * @param buffer defines the buffer to use
  104844. * @returns the current mesh
  104845. */
  104846. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  104847. /**
  104848. * Update a specific associated vertex buffer
  104849. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104850. * - VertexBuffer.PositionKind
  104851. * - VertexBuffer.UVKind
  104852. * - VertexBuffer.UV2Kind
  104853. * - VertexBuffer.UV3Kind
  104854. * - VertexBuffer.UV4Kind
  104855. * - VertexBuffer.UV5Kind
  104856. * - VertexBuffer.UV6Kind
  104857. * - VertexBuffer.ColorKind
  104858. * - VertexBuffer.MatricesIndicesKind
  104859. * - VertexBuffer.MatricesIndicesExtraKind
  104860. * - VertexBuffer.MatricesWeightsKind
  104861. * - VertexBuffer.MatricesWeightsExtraKind
  104862. * @param data defines the data source
  104863. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104864. * @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)
  104865. * @returns the current mesh
  104866. */
  104867. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104868. /**
  104869. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  104870. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  104871. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  104872. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  104873. * @returns the current mesh
  104874. */
  104875. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  104876. /**
  104877. * Creates a un-shared specific occurence of the geometry for the mesh.
  104878. * @returns the current mesh
  104879. */
  104880. makeGeometryUnique(): Mesh;
  104881. /**
  104882. * Set the index buffer of this mesh
  104883. * @param indices defines the source data
  104884. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  104885. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  104886. * @returns the current mesh
  104887. */
  104888. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  104889. /**
  104890. * Update the current index buffer
  104891. * @param indices defines the source data
  104892. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104893. * @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)
  104894. * @returns the current mesh
  104895. */
  104896. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104897. /**
  104898. * Invert the geometry to move from a right handed system to a left handed one.
  104899. * @returns the current mesh
  104900. */
  104901. toLeftHanded(): Mesh;
  104902. /** @hidden */
  104903. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  104904. /** @hidden */
  104905. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  104906. /**
  104907. * Registers for this mesh a javascript function called just before the rendering process
  104908. * @param func defines the function to call before rendering this mesh
  104909. * @returns the current mesh
  104910. */
  104911. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104912. /**
  104913. * Disposes a previously registered javascript function called before the rendering
  104914. * @param func defines the function to remove
  104915. * @returns the current mesh
  104916. */
  104917. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104918. /**
  104919. * Registers for this mesh a javascript function called just after the rendering is complete
  104920. * @param func defines the function to call after rendering this mesh
  104921. * @returns the current mesh
  104922. */
  104923. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104924. /**
  104925. * Disposes a previously registered javascript function called after the rendering.
  104926. * @param func defines the function to remove
  104927. * @returns the current mesh
  104928. */
  104929. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104930. /** @hidden */
  104931. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  104932. /** @hidden */
  104933. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  104934. /** @hidden */
  104935. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  104936. /** @hidden */
  104937. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  104938. /** @hidden */
  104939. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  104940. /** @hidden */
  104941. _rebuild(): void;
  104942. /** @hidden */
  104943. _freeze(): void;
  104944. /** @hidden */
  104945. _unFreeze(): void;
  104946. /**
  104947. * 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
  104948. * @param subMesh defines the subMesh to render
  104949. * @param enableAlphaMode defines if alpha mode can be changed
  104950. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  104951. * @returns the current mesh
  104952. */
  104953. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  104954. private _onBeforeDraw;
  104955. /**
  104956. * Renormalize the mesh and patch it up if there are no weights
  104957. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  104958. * However in the case of zero weights then we set just a single influence to 1.
  104959. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  104960. */
  104961. cleanMatrixWeights(): void;
  104962. private normalizeSkinFourWeights;
  104963. private normalizeSkinWeightsAndExtra;
  104964. /**
  104965. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  104966. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  104967. * the user know there was an issue with importing the mesh
  104968. * @returns a validation object with skinned, valid and report string
  104969. */
  104970. validateSkinning(): {
  104971. skinned: boolean;
  104972. valid: boolean;
  104973. report: string;
  104974. };
  104975. /** @hidden */
  104976. _checkDelayState(): Mesh;
  104977. private _queueLoad;
  104978. /**
  104979. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104980. * A mesh is in the frustum if its bounding box intersects the frustum
  104981. * @param frustumPlanes defines the frustum to test
  104982. * @returns true if the mesh is in the frustum planes
  104983. */
  104984. isInFrustum(frustumPlanes: Plane[]): boolean;
  104985. /**
  104986. * Sets the mesh material by the material or multiMaterial `id` property
  104987. * @param id is a string identifying the material or the multiMaterial
  104988. * @returns the current mesh
  104989. */
  104990. setMaterialByID(id: string): Mesh;
  104991. /**
  104992. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  104993. * @returns an array of IAnimatable
  104994. */
  104995. getAnimatables(): IAnimatable[];
  104996. /**
  104997. * Modifies the mesh geometry according to the passed transformation matrix.
  104998. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  104999. * The mesh normals are modified using the same transformation.
  105000. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105001. * @param transform defines the transform matrix to use
  105002. * @see http://doc.babylonjs.com/resources/baking_transformations
  105003. * @returns the current mesh
  105004. */
  105005. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105006. /**
  105007. * Modifies the mesh geometry according to its own current World Matrix.
  105008. * The mesh World Matrix is then reset.
  105009. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105010. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105011. * @see http://doc.babylonjs.com/resources/baking_transformations
  105012. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105013. * @returns the current mesh
  105014. */
  105015. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105016. /** @hidden */
  105017. get _positions(): Nullable<Vector3[]>;
  105018. /** @hidden */
  105019. _resetPointsArrayCache(): Mesh;
  105020. /** @hidden */
  105021. _generatePointsArray(): boolean;
  105022. /**
  105023. * Returns a new Mesh object generated from the current mesh properties.
  105024. * This method must not get confused with createInstance()
  105025. * @param name is a string, the name given to the new mesh
  105026. * @param newParent can be any Node object (default `null`)
  105027. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105028. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105029. * @returns a new mesh
  105030. */
  105031. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105032. /**
  105033. * Releases resources associated with this mesh.
  105034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105036. */
  105037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105038. /** @hidden */
  105039. _disposeInstanceSpecificData(): void;
  105040. /** @hidden */
  105041. _disposeThinInstanceSpecificData(): void;
  105042. /**
  105043. * Modifies the mesh geometry according to a displacement map.
  105044. * 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.
  105045. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105046. * @param url is a string, the URL from the image file is to be downloaded.
  105047. * @param minHeight is the lower limit of the displacement.
  105048. * @param maxHeight is the upper limit of the displacement.
  105049. * @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.
  105050. * @param uvOffset is an optional vector2 used to offset UV.
  105051. * @param uvScale is an optional vector2 used to scale UV.
  105052. * @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.
  105053. * @returns the Mesh.
  105054. */
  105055. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105056. /**
  105057. * Modifies the mesh geometry according to a displacementMap buffer.
  105058. * 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.
  105059. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105060. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105061. * @param heightMapWidth is the width of the buffer image.
  105062. * @param heightMapHeight is the height of the buffer image.
  105063. * @param minHeight is the lower limit of the displacement.
  105064. * @param maxHeight is the upper limit of the displacement.
  105065. * @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.
  105066. * @param uvOffset is an optional vector2 used to offset UV.
  105067. * @param uvScale is an optional vector2 used to scale UV.
  105068. * @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.
  105069. * @returns the Mesh.
  105070. */
  105071. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105072. /**
  105073. * Modify the mesh to get a flat shading rendering.
  105074. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105075. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105076. * @returns current mesh
  105077. */
  105078. convertToFlatShadedMesh(): Mesh;
  105079. /**
  105080. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105081. * In other words, more vertices, no more indices and a single bigger VBO.
  105082. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105083. * @returns current mesh
  105084. */
  105085. convertToUnIndexedMesh(): Mesh;
  105086. /**
  105087. * Inverses facet orientations.
  105088. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105089. * @param flipNormals will also inverts the normals
  105090. * @returns current mesh
  105091. */
  105092. flipFaces(flipNormals?: boolean): Mesh;
  105093. /**
  105094. * Increase the number of facets and hence vertices in a mesh
  105095. * Vertex normals are interpolated from existing vertex normals
  105096. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105097. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105098. */
  105099. increaseVertices(numberPerEdge: number): void;
  105100. /**
  105101. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105102. * This will undo any application of covertToFlatShadedMesh
  105103. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105104. */
  105105. forceSharedVertices(): void;
  105106. /** @hidden */
  105107. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105108. /** @hidden */
  105109. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105110. /**
  105111. * Creates a new InstancedMesh object from the mesh model.
  105112. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105113. * @param name defines the name of the new instance
  105114. * @returns a new InstancedMesh
  105115. */
  105116. createInstance(name: string): InstancedMesh;
  105117. /**
  105118. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105119. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105120. * @returns the current mesh
  105121. */
  105122. synchronizeInstances(): Mesh;
  105123. /**
  105124. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105125. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105126. * This should be used together with the simplification to avoid disappearing triangles.
  105127. * @param successCallback an optional success callback to be called after the optimization finished.
  105128. * @returns the current mesh
  105129. */
  105130. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105131. /**
  105132. * Serialize current mesh
  105133. * @param serializationObject defines the object which will receive the serialization data
  105134. */
  105135. serialize(serializationObject: any): void;
  105136. /** @hidden */
  105137. _syncGeometryWithMorphTargetManager(): void;
  105138. /** @hidden */
  105139. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105140. /**
  105141. * Returns a new Mesh object parsed from the source provided.
  105142. * @param parsedMesh is the source
  105143. * @param scene defines the hosting scene
  105144. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105145. * @returns a new Mesh
  105146. */
  105147. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105148. /**
  105149. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105150. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105151. * @param name defines the name of the mesh to create
  105152. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105153. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105154. * @param closePath creates a seam between the first and the last points of each path of the path array
  105155. * @param offset is taken in account only if the `pathArray` is containing a single path
  105156. * @param scene defines the hosting scene
  105157. * @param updatable defines if the mesh must be flagged as updatable
  105158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105159. * @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)
  105160. * @returns a new Mesh
  105161. */
  105162. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105163. /**
  105164. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105165. * @param name defines the name of the mesh to create
  105166. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105167. * @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
  105168. * @param scene defines the hosting scene
  105169. * @param updatable defines if the mesh must be flagged as updatable
  105170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105171. * @returns a new Mesh
  105172. */
  105173. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105174. /**
  105175. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105176. * @param name defines the name of the mesh to create
  105177. * @param size sets the size (float) of each box side (default 1)
  105178. * @param scene defines the hosting scene
  105179. * @param updatable defines if the mesh must be flagged as updatable
  105180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105181. * @returns a new Mesh
  105182. */
  105183. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105184. /**
  105185. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105186. * @param name defines the name of the mesh to create
  105187. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105188. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105189. * @param scene defines the hosting scene
  105190. * @param updatable defines if the mesh must be flagged as updatable
  105191. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105192. * @returns a new Mesh
  105193. */
  105194. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105195. /**
  105196. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105197. * @param name defines the name of the mesh to create
  105198. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105199. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105200. * @param scene defines the hosting scene
  105201. * @returns a new Mesh
  105202. */
  105203. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105204. /**
  105205. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105206. * @param name defines the name of the mesh to create
  105207. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105208. * @param diameterTop set the top cap diameter (floats, default 1)
  105209. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105210. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105211. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105212. * @param scene defines the hosting scene
  105213. * @param updatable defines if the mesh must be flagged as updatable
  105214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105215. * @returns a new Mesh
  105216. */
  105217. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105218. /**
  105219. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105220. * @param name defines the name of the mesh to create
  105221. * @param diameter sets the diameter size (float) of the torus (default 1)
  105222. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105223. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105224. * @param scene defines the hosting scene
  105225. * @param updatable defines if the mesh must be flagged as updatable
  105226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105227. * @returns a new Mesh
  105228. */
  105229. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105230. /**
  105231. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105232. * @param name defines the name of the mesh to create
  105233. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105234. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105235. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105236. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105237. * @param p the number of windings on X axis (positive integers, default 2)
  105238. * @param q the number of windings on Y axis (positive integers, default 3)
  105239. * @param scene defines the hosting scene
  105240. * @param updatable defines if the mesh must be flagged as updatable
  105241. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105242. * @returns a new Mesh
  105243. */
  105244. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105245. /**
  105246. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105247. * @param name defines the name of the mesh to create
  105248. * @param points is an array successive Vector3
  105249. * @param scene defines the hosting scene
  105250. * @param updatable defines if the mesh must be flagged as updatable
  105251. * @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).
  105252. * @returns a new Mesh
  105253. */
  105254. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105255. /**
  105256. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105257. * @param name defines the name of the mesh to create
  105258. * @param points is an array successive Vector3
  105259. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105260. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105261. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105262. * @param scene defines the hosting scene
  105263. * @param updatable defines if the mesh must be flagged as updatable
  105264. * @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)
  105265. * @returns a new Mesh
  105266. */
  105267. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105268. /**
  105269. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105270. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105271. * 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.
  105272. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105273. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105274. * Remember you can only change the shape positions, not their number when updating a polygon.
  105275. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105276. * @param name defines the name of the mesh to create
  105277. * @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
  105278. * @param scene defines the hosting scene
  105279. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105280. * @param updatable defines if the mesh must be flagged as updatable
  105281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105282. * @param earcutInjection can be used to inject your own earcut reference
  105283. * @returns a new Mesh
  105284. */
  105285. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105286. /**
  105287. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105288. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105289. * @param name defines the name of the mesh to create
  105290. * @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
  105291. * @param depth defines the height of extrusion
  105292. * @param scene defines the hosting scene
  105293. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105294. * @param updatable defines if the mesh must be flagged as updatable
  105295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105296. * @param earcutInjection can be used to inject your own earcut reference
  105297. * @returns a new Mesh
  105298. */
  105299. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105300. /**
  105301. * Creates an extruded shape mesh.
  105302. * 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
  105303. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105305. * @param name defines the name of the mesh to create
  105306. * @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
  105307. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105308. * @param scale is the value to scale the shape
  105309. * @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
  105310. * @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
  105311. * @param scene defines the hosting scene
  105312. * @param updatable defines if the mesh must be flagged as updatable
  105313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105314. * @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)
  105315. * @returns a new Mesh
  105316. */
  105317. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105318. /**
  105319. * Creates an custom extruded shape mesh.
  105320. * The custom extrusion is a parametric shape.
  105321. * It has no predefined shape. Its final shape will depend on the input parameters.
  105322. * Please consider using the same method from the MeshBuilder class instead
  105323. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105324. * @param name defines the name of the mesh to create
  105325. * @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
  105326. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105327. * @param scaleFunction is a custom Javascript function called on each path point
  105328. * @param rotationFunction is a custom Javascript function called on each path point
  105329. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105330. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105331. * @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
  105332. * @param scene defines the hosting scene
  105333. * @param updatable defines if the mesh must be flagged as updatable
  105334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105335. * @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)
  105336. * @returns a new Mesh
  105337. */
  105338. 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;
  105339. /**
  105340. * Creates lathe mesh.
  105341. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105342. * Please consider using the same method from the MeshBuilder class instead
  105343. * @param name defines the name of the mesh to create
  105344. * @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
  105345. * @param radius is the radius value of the lathe
  105346. * @param tessellation is the side number of the lathe.
  105347. * @param scene defines the hosting scene
  105348. * @param updatable defines if the mesh must be flagged as updatable
  105349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105350. * @returns a new Mesh
  105351. */
  105352. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105353. /**
  105354. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105355. * @param name defines the name of the mesh to create
  105356. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105357. * @param scene defines the hosting scene
  105358. * @param updatable defines if the mesh must be flagged as updatable
  105359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105360. * @returns a new Mesh
  105361. */
  105362. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105363. /**
  105364. * Creates a ground mesh.
  105365. * Please consider using the same method from the MeshBuilder class instead
  105366. * @param name defines the name of the mesh to create
  105367. * @param width set the width of the ground
  105368. * @param height set the height of the ground
  105369. * @param subdivisions sets the number of subdivisions per side
  105370. * @param scene defines the hosting scene
  105371. * @param updatable defines if the mesh must be flagged as updatable
  105372. * @returns a new Mesh
  105373. */
  105374. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105375. /**
  105376. * Creates a tiled ground mesh.
  105377. * Please consider using the same method from the MeshBuilder class instead
  105378. * @param name defines the name of the mesh to create
  105379. * @param xmin set the ground minimum X coordinate
  105380. * @param zmin set the ground minimum Y coordinate
  105381. * @param xmax set the ground maximum X coordinate
  105382. * @param zmax set the ground maximum Z coordinate
  105383. * @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
  105384. * @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
  105385. * @param scene defines the hosting scene
  105386. * @param updatable defines if the mesh must be flagged as updatable
  105387. * @returns a new Mesh
  105388. */
  105389. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105390. w: number;
  105391. h: number;
  105392. }, precision: {
  105393. w: number;
  105394. h: number;
  105395. }, scene: Scene, updatable?: boolean): Mesh;
  105396. /**
  105397. * Creates a ground mesh from a height map.
  105398. * Please consider using the same method from the MeshBuilder class instead
  105399. * @see http://doc.babylonjs.com/babylon101/height_map
  105400. * @param name defines the name of the mesh to create
  105401. * @param url sets the URL of the height map image resource
  105402. * @param width set the ground width size
  105403. * @param height set the ground height size
  105404. * @param subdivisions sets the number of subdivision per side
  105405. * @param minHeight is the minimum altitude on the ground
  105406. * @param maxHeight is the maximum altitude on the ground
  105407. * @param scene defines the hosting scene
  105408. * @param updatable defines if the mesh must be flagged as updatable
  105409. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105410. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105411. * @returns a new Mesh
  105412. */
  105413. 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;
  105414. /**
  105415. * Creates a tube mesh.
  105416. * The tube is a parametric shape.
  105417. * It has no predefined shape. Its final shape will depend on the input parameters.
  105418. * Please consider using the same method from the MeshBuilder class instead
  105419. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105420. * @param name defines the name of the mesh to create
  105421. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105422. * @param radius sets the tube radius size
  105423. * @param tessellation is the number of sides on the tubular surface
  105424. * @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
  105425. * @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
  105426. * @param scene defines the hosting scene
  105427. * @param updatable defines if the mesh must be flagged as updatable
  105428. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105429. * @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)
  105430. * @returns a new Mesh
  105431. */
  105432. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105433. (i: number, distance: number): number;
  105434. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105435. /**
  105436. * Creates a polyhedron mesh.
  105437. * Please consider using the same method from the MeshBuilder class instead.
  105438. * * 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
  105439. * * The parameter `size` (positive float, default 1) sets the polygon size
  105440. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105441. * * 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`
  105442. * * 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
  105443. * * 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)`)
  105444. * * 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
  105445. * * 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
  105446. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105447. * * If you create a double-sided mesh, you can choose what parts of 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
  105448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105449. * @param name defines the name of the mesh to create
  105450. * @param options defines the options used to create the mesh
  105451. * @param scene defines the hosting scene
  105452. * @returns a new Mesh
  105453. */
  105454. static CreatePolyhedron(name: string, options: {
  105455. type?: number;
  105456. size?: number;
  105457. sizeX?: number;
  105458. sizeY?: number;
  105459. sizeZ?: number;
  105460. custom?: any;
  105461. faceUV?: Vector4[];
  105462. faceColors?: Color4[];
  105463. updatable?: boolean;
  105464. sideOrientation?: number;
  105465. }, scene: Scene): Mesh;
  105466. /**
  105467. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105468. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105469. * * 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`)
  105470. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105471. * * 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
  105472. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105473. * * If you create a double-sided mesh, you can choose what parts of 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
  105474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105475. * @param name defines the name of the mesh
  105476. * @param options defines the options used to create the mesh
  105477. * @param scene defines the hosting scene
  105478. * @returns a new Mesh
  105479. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105480. */
  105481. static CreateIcoSphere(name: string, options: {
  105482. radius?: number;
  105483. flat?: boolean;
  105484. subdivisions?: number;
  105485. sideOrientation?: number;
  105486. updatable?: boolean;
  105487. }, scene: Scene): Mesh;
  105488. /**
  105489. * Creates a decal mesh.
  105490. * Please consider using the same method from the MeshBuilder class instead.
  105491. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105492. * @param name defines the name of the mesh
  105493. * @param sourceMesh defines the mesh receiving the decal
  105494. * @param position sets the position of the decal in world coordinates
  105495. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105496. * @param size sets the decal scaling
  105497. * @param angle sets the angle to rotate the decal
  105498. * @returns a new Mesh
  105499. */
  105500. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105501. /**
  105502. * Prepare internal position array for software CPU skinning
  105503. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105504. */
  105505. setPositionsForCPUSkinning(): Float32Array;
  105506. /**
  105507. * Prepare internal normal array for software CPU skinning
  105508. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105509. */
  105510. setNormalsForCPUSkinning(): Float32Array;
  105511. /**
  105512. * Updates the vertex buffer by applying transformation from the bones
  105513. * @param skeleton defines the skeleton to apply to current mesh
  105514. * @returns the current mesh
  105515. */
  105516. applySkeleton(skeleton: Skeleton): Mesh;
  105517. /**
  105518. * 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
  105519. * @param meshes defines the list of meshes to scan
  105520. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  105521. */
  105522. static MinMax(meshes: AbstractMesh[]): {
  105523. min: Vector3;
  105524. max: Vector3;
  105525. };
  105526. /**
  105527. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  105528. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  105529. * @returns a vector3
  105530. */
  105531. static Center(meshesOrMinMaxVector: {
  105532. min: Vector3;
  105533. max: Vector3;
  105534. } | AbstractMesh[]): Vector3;
  105535. /**
  105536. * Merge the array of meshes into a single mesh for performance reasons.
  105537. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  105538. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  105539. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  105540. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  105541. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  105542. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  105543. * @returns a new mesh
  105544. */
  105545. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  105546. /** @hidden */
  105547. addInstance(instance: InstancedMesh): void;
  105548. /** @hidden */
  105549. removeInstance(instance: InstancedMesh): void;
  105550. }
  105551. }
  105552. declare module BABYLON {
  105553. /**
  105554. * This is the base class of all the camera used in the application.
  105555. * @see http://doc.babylonjs.com/features/cameras
  105556. */
  105557. export class Camera extends Node {
  105558. /** @hidden */
  105559. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  105560. /**
  105561. * This is the default projection mode used by the cameras.
  105562. * It helps recreating a feeling of perspective and better appreciate depth.
  105563. * This is the best way to simulate real life cameras.
  105564. */
  105565. static readonly PERSPECTIVE_CAMERA: number;
  105566. /**
  105567. * This helps creating camera with an orthographic mode.
  105568. * 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.
  105569. */
  105570. static readonly ORTHOGRAPHIC_CAMERA: number;
  105571. /**
  105572. * This is the default FOV mode for perspective cameras.
  105573. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  105574. */
  105575. static readonly FOVMODE_VERTICAL_FIXED: number;
  105576. /**
  105577. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  105578. */
  105579. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  105580. /**
  105581. * This specifies ther is no need for a camera rig.
  105582. * Basically only one eye is rendered corresponding to the camera.
  105583. */
  105584. static readonly RIG_MODE_NONE: number;
  105585. /**
  105586. * Simulates a camera Rig with one blue eye and one red eye.
  105587. * This can be use with 3d blue and red glasses.
  105588. */
  105589. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  105590. /**
  105591. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  105592. */
  105593. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  105594. /**
  105595. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  105596. */
  105597. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  105598. /**
  105599. * Defines that both eyes of the camera will be rendered over under each other.
  105600. */
  105601. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  105602. /**
  105603. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  105604. */
  105605. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  105606. /**
  105607. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  105608. */
  105609. static readonly RIG_MODE_VR: number;
  105610. /**
  105611. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  105612. */
  105613. static readonly RIG_MODE_WEBVR: number;
  105614. /**
  105615. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  105616. */
  105617. static readonly RIG_MODE_CUSTOM: number;
  105618. /**
  105619. * Defines if by default attaching controls should prevent the default javascript event to continue.
  105620. */
  105621. static ForceAttachControlToAlwaysPreventDefault: boolean;
  105622. /**
  105623. * Define the input manager associated with the camera.
  105624. */
  105625. inputs: CameraInputsManager<Camera>;
  105626. /** @hidden */
  105627. _position: Vector3;
  105628. /**
  105629. * Define the current local position of the camera in the scene
  105630. */
  105631. get position(): Vector3;
  105632. set position(newPosition: Vector3);
  105633. /**
  105634. * The vector the camera should consider as up.
  105635. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  105636. */
  105637. upVector: Vector3;
  105638. /**
  105639. * Define the current limit on the left side for an orthographic camera
  105640. * In scene unit
  105641. */
  105642. orthoLeft: Nullable<number>;
  105643. /**
  105644. * Define the current limit on the right side for an orthographic camera
  105645. * In scene unit
  105646. */
  105647. orthoRight: Nullable<number>;
  105648. /**
  105649. * Define the current limit on the bottom side for an orthographic camera
  105650. * In scene unit
  105651. */
  105652. orthoBottom: Nullable<number>;
  105653. /**
  105654. * Define the current limit on the top side for an orthographic camera
  105655. * In scene unit
  105656. */
  105657. orthoTop: Nullable<number>;
  105658. /**
  105659. * Field Of View is set in Radians. (default is 0.8)
  105660. */
  105661. fov: number;
  105662. /**
  105663. * Define the minimum distance the camera can see from.
  105664. * This is important to note that the depth buffer are not infinite and the closer it starts
  105665. * the more your scene might encounter depth fighting issue.
  105666. */
  105667. minZ: number;
  105668. /**
  105669. * Define the maximum distance the camera can see to.
  105670. * This is important to note that the depth buffer are not infinite and the further it end
  105671. * the more your scene might encounter depth fighting issue.
  105672. */
  105673. maxZ: number;
  105674. /**
  105675. * Define the default inertia of the camera.
  105676. * This helps giving a smooth feeling to the camera movement.
  105677. */
  105678. inertia: number;
  105679. /**
  105680. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  105681. */
  105682. mode: number;
  105683. /**
  105684. * Define whether the camera is intermediate.
  105685. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  105686. */
  105687. isIntermediate: boolean;
  105688. /**
  105689. * Define the viewport of the camera.
  105690. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  105691. */
  105692. viewport: Viewport;
  105693. /**
  105694. * Restricts the camera to viewing objects with the same layerMask.
  105695. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  105696. */
  105697. layerMask: number;
  105698. /**
  105699. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  105700. */
  105701. fovMode: number;
  105702. /**
  105703. * Rig mode of the camera.
  105704. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  105705. * This is normally controlled byt the camera themselves as internal use.
  105706. */
  105707. cameraRigMode: number;
  105708. /**
  105709. * Defines the distance between both "eyes" in case of a RIG
  105710. */
  105711. interaxialDistance: number;
  105712. /**
  105713. * Defines if stereoscopic rendering is done side by side or over under.
  105714. */
  105715. isStereoscopicSideBySide: boolean;
  105716. /**
  105717. * 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
  105718. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  105719. * else in the scene. (Eg. security camera)
  105720. *
  105721. * 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)
  105722. */
  105723. customRenderTargets: RenderTargetTexture[];
  105724. /**
  105725. * When set, the camera will render to this render target instead of the default canvas
  105726. *
  105727. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  105728. */
  105729. outputRenderTarget: Nullable<RenderTargetTexture>;
  105730. /**
  105731. * Observable triggered when the camera view matrix has changed.
  105732. */
  105733. onViewMatrixChangedObservable: Observable<Camera>;
  105734. /**
  105735. * Observable triggered when the camera Projection matrix has changed.
  105736. */
  105737. onProjectionMatrixChangedObservable: Observable<Camera>;
  105738. /**
  105739. * Observable triggered when the inputs have been processed.
  105740. */
  105741. onAfterCheckInputsObservable: Observable<Camera>;
  105742. /**
  105743. * Observable triggered when reset has been called and applied to the camera.
  105744. */
  105745. onRestoreStateObservable: Observable<Camera>;
  105746. /**
  105747. * Is this camera a part of a rig system?
  105748. */
  105749. isRigCamera: boolean;
  105750. /**
  105751. * If isRigCamera set to true this will be set with the parent camera.
  105752. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  105753. */
  105754. rigParent?: Camera;
  105755. /** @hidden */
  105756. _cameraRigParams: any;
  105757. /** @hidden */
  105758. _rigCameras: Camera[];
  105759. /** @hidden */
  105760. _rigPostProcess: Nullable<PostProcess>;
  105761. protected _webvrViewMatrix: Matrix;
  105762. /** @hidden */
  105763. _skipRendering: boolean;
  105764. /** @hidden */
  105765. _projectionMatrix: Matrix;
  105766. /** @hidden */
  105767. _postProcesses: Nullable<PostProcess>[];
  105768. /** @hidden */
  105769. _activeMeshes: SmartArray<AbstractMesh>;
  105770. protected _globalPosition: Vector3;
  105771. /** @hidden */
  105772. _computedViewMatrix: Matrix;
  105773. private _doNotComputeProjectionMatrix;
  105774. private _transformMatrix;
  105775. private _frustumPlanes;
  105776. private _refreshFrustumPlanes;
  105777. private _storedFov;
  105778. private _stateStored;
  105779. /**
  105780. * Instantiates a new camera object.
  105781. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  105782. * @see http://doc.babylonjs.com/features/cameras
  105783. * @param name Defines the name of the camera in the scene
  105784. * @param position Defines the position of the camera
  105785. * @param scene Defines the scene the camera belongs too
  105786. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  105787. */
  105788. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105789. /**
  105790. * Store current camera state (fov, position, etc..)
  105791. * @returns the camera
  105792. */
  105793. storeState(): Camera;
  105794. /**
  105795. * Restores the camera state values if it has been stored. You must call storeState() first
  105796. */
  105797. protected _restoreStateValues(): boolean;
  105798. /**
  105799. * Restored camera state. You must call storeState() first.
  105800. * @returns true if restored and false otherwise
  105801. */
  105802. restoreState(): boolean;
  105803. /**
  105804. * Gets the class name of the camera.
  105805. * @returns the class name
  105806. */
  105807. getClassName(): string;
  105808. /** @hidden */
  105809. readonly _isCamera: boolean;
  105810. /**
  105811. * Gets a string representation of the camera useful for debug purpose.
  105812. * @param fullDetails Defines that a more verboe level of logging is required
  105813. * @returns the string representation
  105814. */
  105815. toString(fullDetails?: boolean): string;
  105816. /**
  105817. * Gets the current world space position of the camera.
  105818. */
  105819. get globalPosition(): Vector3;
  105820. /**
  105821. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  105822. * @returns the active meshe list
  105823. */
  105824. getActiveMeshes(): SmartArray<AbstractMesh>;
  105825. /**
  105826. * Check whether a mesh is part of the current active mesh list of the camera
  105827. * @param mesh Defines the mesh to check
  105828. * @returns true if active, false otherwise
  105829. */
  105830. isActiveMesh(mesh: Mesh): boolean;
  105831. /**
  105832. * Is this camera ready to be used/rendered
  105833. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  105834. * @return true if the camera is ready
  105835. */
  105836. isReady(completeCheck?: boolean): boolean;
  105837. /** @hidden */
  105838. _initCache(): void;
  105839. /** @hidden */
  105840. _updateCache(ignoreParentClass?: boolean): void;
  105841. /** @hidden */
  105842. _isSynchronized(): boolean;
  105843. /** @hidden */
  105844. _isSynchronizedViewMatrix(): boolean;
  105845. /** @hidden */
  105846. _isSynchronizedProjectionMatrix(): boolean;
  105847. /**
  105848. * Attach the input controls to a specific dom element to get the input from.
  105849. * @param element Defines the element the controls should be listened from
  105850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105851. */
  105852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105853. /**
  105854. * Detach the current controls from the specified dom element.
  105855. * @param element Defines the element to stop listening the inputs from
  105856. */
  105857. detachControl(element: HTMLElement): void;
  105858. /**
  105859. * Update the camera state according to the different inputs gathered during the frame.
  105860. */
  105861. update(): void;
  105862. /** @hidden */
  105863. _checkInputs(): void;
  105864. /** @hidden */
  105865. get rigCameras(): Camera[];
  105866. /**
  105867. * Gets the post process used by the rig cameras
  105868. */
  105869. get rigPostProcess(): Nullable<PostProcess>;
  105870. /**
  105871. * Internal, gets the first post proces.
  105872. * @returns the first post process to be run on this camera.
  105873. */
  105874. _getFirstPostProcess(): Nullable<PostProcess>;
  105875. private _cascadePostProcessesToRigCams;
  105876. /**
  105877. * Attach a post process to the camera.
  105878. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105879. * @param postProcess The post process to attach to the camera
  105880. * @param insertAt The position of the post process in case several of them are in use in the scene
  105881. * @returns the position the post process has been inserted at
  105882. */
  105883. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  105884. /**
  105885. * Detach a post process to the camera.
  105886. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105887. * @param postProcess The post process to detach from the camera
  105888. */
  105889. detachPostProcess(postProcess: PostProcess): void;
  105890. /**
  105891. * Gets the current world matrix of the camera
  105892. */
  105893. getWorldMatrix(): Matrix;
  105894. /** @hidden */
  105895. _getViewMatrix(): Matrix;
  105896. /**
  105897. * Gets the current view matrix of the camera.
  105898. * @param force forces the camera to recompute the matrix without looking at the cached state
  105899. * @returns the view matrix
  105900. */
  105901. getViewMatrix(force?: boolean): Matrix;
  105902. /**
  105903. * Freeze the projection matrix.
  105904. * It will prevent the cache check of the camera projection compute and can speed up perf
  105905. * if no parameter of the camera are meant to change
  105906. * @param projection Defines manually a projection if necessary
  105907. */
  105908. freezeProjectionMatrix(projection?: Matrix): void;
  105909. /**
  105910. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  105911. */
  105912. unfreezeProjectionMatrix(): void;
  105913. /**
  105914. * Gets the current projection matrix of the camera.
  105915. * @param force forces the camera to recompute the matrix without looking at the cached state
  105916. * @returns the projection matrix
  105917. */
  105918. getProjectionMatrix(force?: boolean): Matrix;
  105919. /**
  105920. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  105921. * @returns a Matrix
  105922. */
  105923. getTransformationMatrix(): Matrix;
  105924. private _updateFrustumPlanes;
  105925. /**
  105926. * Checks if a cullable object (mesh...) is in the camera frustum
  105927. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  105928. * @param target The object to check
  105929. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  105930. * @returns true if the object is in frustum otherwise false
  105931. */
  105932. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  105933. /**
  105934. * Checks if a cullable object (mesh...) is in the camera frustum
  105935. * Unlike isInFrustum this cheks the full bounding box
  105936. * @param target The object to check
  105937. * @returns true if the object is in frustum otherwise false
  105938. */
  105939. isCompletelyInFrustum(target: ICullable): boolean;
  105940. /**
  105941. * Gets a ray in the forward direction from the camera.
  105942. * @param length Defines the length of the ray to create
  105943. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  105944. * @param origin Defines the start point of the ray which defaults to the camera position
  105945. * @returns the forward ray
  105946. */
  105947. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  105948. /**
  105949. * Releases resources associated with this node.
  105950. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105951. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105952. */
  105953. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105954. /** @hidden */
  105955. _isLeftCamera: boolean;
  105956. /**
  105957. * Gets the left camera of a rig setup in case of Rigged Camera
  105958. */
  105959. get isLeftCamera(): boolean;
  105960. /** @hidden */
  105961. _isRightCamera: boolean;
  105962. /**
  105963. * Gets the right camera of a rig setup in case of Rigged Camera
  105964. */
  105965. get isRightCamera(): boolean;
  105966. /**
  105967. * Gets the left camera of a rig setup in case of Rigged Camera
  105968. */
  105969. get leftCamera(): Nullable<FreeCamera>;
  105970. /**
  105971. * Gets the right camera of a rig setup in case of Rigged Camera
  105972. */
  105973. get rightCamera(): Nullable<FreeCamera>;
  105974. /**
  105975. * Gets the left camera target of a rig setup in case of Rigged Camera
  105976. * @returns the target position
  105977. */
  105978. getLeftTarget(): Nullable<Vector3>;
  105979. /**
  105980. * Gets the right camera target of a rig setup in case of Rigged Camera
  105981. * @returns the target position
  105982. */
  105983. getRightTarget(): Nullable<Vector3>;
  105984. /**
  105985. * @hidden
  105986. */
  105987. setCameraRigMode(mode: number, rigParams: any): void;
  105988. /** @hidden */
  105989. static _setStereoscopicRigMode(camera: Camera): void;
  105990. /** @hidden */
  105991. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  105992. /** @hidden */
  105993. static _setVRRigMode(camera: Camera, rigParams: any): void;
  105994. /** @hidden */
  105995. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  105996. /** @hidden */
  105997. _getVRProjectionMatrix(): Matrix;
  105998. protected _updateCameraRotationMatrix(): void;
  105999. protected _updateWebVRCameraRotationMatrix(): void;
  106000. /**
  106001. * This function MUST be overwritten by the different WebVR cameras available.
  106002. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106003. * @hidden
  106004. */
  106005. _getWebVRProjectionMatrix(): Matrix;
  106006. /**
  106007. * This function MUST be overwritten by the different WebVR cameras available.
  106008. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106009. * @hidden
  106010. */
  106011. _getWebVRViewMatrix(): Matrix;
  106012. /** @hidden */
  106013. setCameraRigParameter(name: string, value: any): void;
  106014. /**
  106015. * needs to be overridden by children so sub has required properties to be copied
  106016. * @hidden
  106017. */
  106018. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106019. /**
  106020. * May need to be overridden by children
  106021. * @hidden
  106022. */
  106023. _updateRigCameras(): void;
  106024. /** @hidden */
  106025. _setupInputs(): void;
  106026. /**
  106027. * Serialiaze the camera setup to a json represention
  106028. * @returns the JSON representation
  106029. */
  106030. serialize(): any;
  106031. /**
  106032. * Clones the current camera.
  106033. * @param name The cloned camera name
  106034. * @returns the cloned camera
  106035. */
  106036. clone(name: string): Camera;
  106037. /**
  106038. * Gets the direction of the camera relative to a given local axis.
  106039. * @param localAxis Defines the reference axis to provide a relative direction.
  106040. * @return the direction
  106041. */
  106042. getDirection(localAxis: Vector3): Vector3;
  106043. /**
  106044. * Returns the current camera absolute rotation
  106045. */
  106046. get absoluteRotation(): Quaternion;
  106047. /**
  106048. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106049. * @param localAxis Defines the reference axis to provide a relative direction.
  106050. * @param result Defines the vector to store the result in
  106051. */
  106052. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106053. /**
  106054. * Gets a camera constructor for a given camera type
  106055. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106056. * @param name The name of the camera the result will be able to instantiate
  106057. * @param scene The scene the result will construct the camera in
  106058. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106059. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106060. * @returns a factory method to construc the camera
  106061. */
  106062. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106063. /**
  106064. * Compute the world matrix of the camera.
  106065. * @returns the camera world matrix
  106066. */
  106067. computeWorldMatrix(): Matrix;
  106068. /**
  106069. * Parse a JSON and creates the camera from the parsed information
  106070. * @param parsedCamera The JSON to parse
  106071. * @param scene The scene to instantiate the camera in
  106072. * @returns the newly constructed camera
  106073. */
  106074. static Parse(parsedCamera: any, scene: Scene): Camera;
  106075. }
  106076. }
  106077. declare module BABYLON {
  106078. /**
  106079. * Class containing static functions to help procedurally build meshes
  106080. */
  106081. export class DiscBuilder {
  106082. /**
  106083. * Creates a plane polygonal mesh. By default, this is a disc
  106084. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106085. * * 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
  106086. * * 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
  106087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106090. * @param name defines the name of the mesh
  106091. * @param options defines the options used to create the mesh
  106092. * @param scene defines the hosting scene
  106093. * @returns the plane polygonal mesh
  106094. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106095. */
  106096. static CreateDisc(name: string, options: {
  106097. radius?: number;
  106098. tessellation?: number;
  106099. arc?: number;
  106100. updatable?: boolean;
  106101. sideOrientation?: number;
  106102. frontUVs?: Vector4;
  106103. backUVs?: Vector4;
  106104. }, scene?: Nullable<Scene>): Mesh;
  106105. }
  106106. }
  106107. declare module BABYLON {
  106108. /**
  106109. * Options to be used when creating a FresnelParameters.
  106110. */
  106111. export type IFresnelParametersCreationOptions = {
  106112. /**
  106113. * Define the color used on edges (grazing angle)
  106114. */
  106115. leftColor?: Color3;
  106116. /**
  106117. * Define the color used on center
  106118. */
  106119. rightColor?: Color3;
  106120. /**
  106121. * Define bias applied to computed fresnel term
  106122. */
  106123. bias?: number;
  106124. /**
  106125. * Defined the power exponent applied to fresnel term
  106126. */
  106127. power?: number;
  106128. /**
  106129. * Define if the fresnel effect is enable or not.
  106130. */
  106131. isEnabled?: boolean;
  106132. };
  106133. /**
  106134. * Serialized format for FresnelParameters.
  106135. */
  106136. export type IFresnelParametersSerialized = {
  106137. /**
  106138. * Define the color used on edges (grazing angle) [as an array]
  106139. */
  106140. leftColor: number[];
  106141. /**
  106142. * Define the color used on center [as an array]
  106143. */
  106144. rightColor: number[];
  106145. /**
  106146. * Define bias applied to computed fresnel term
  106147. */
  106148. bias: number;
  106149. /**
  106150. * Defined the power exponent applied to fresnel term
  106151. */
  106152. power?: number;
  106153. /**
  106154. * Define if the fresnel effect is enable or not.
  106155. */
  106156. isEnabled: boolean;
  106157. };
  106158. /**
  106159. * This represents all the required information to add a fresnel effect on a material:
  106160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106161. */
  106162. export class FresnelParameters {
  106163. private _isEnabled;
  106164. /**
  106165. * Define if the fresnel effect is enable or not.
  106166. */
  106167. get isEnabled(): boolean;
  106168. set isEnabled(value: boolean);
  106169. /**
  106170. * Define the color used on edges (grazing angle)
  106171. */
  106172. leftColor: Color3;
  106173. /**
  106174. * Define the color used on center
  106175. */
  106176. rightColor: Color3;
  106177. /**
  106178. * Define bias applied to computed fresnel term
  106179. */
  106180. bias: number;
  106181. /**
  106182. * Defined the power exponent applied to fresnel term
  106183. */
  106184. power: number;
  106185. /**
  106186. * Creates a new FresnelParameters object.
  106187. *
  106188. * @param options provide your own settings to optionally to override defaults
  106189. */
  106190. constructor(options?: IFresnelParametersCreationOptions);
  106191. /**
  106192. * Clones the current fresnel and its valuues
  106193. * @returns a clone fresnel configuration
  106194. */
  106195. clone(): FresnelParameters;
  106196. /**
  106197. * Determines equality between FresnelParameters objects
  106198. * @param otherFresnelParameters defines the second operand
  106199. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106200. */
  106201. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106202. /**
  106203. * Serializes the current fresnel parameters to a JSON representation.
  106204. * @return the JSON serialization
  106205. */
  106206. serialize(): IFresnelParametersSerialized;
  106207. /**
  106208. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106209. * @param parsedFresnelParameters Define the JSON representation
  106210. * @returns the parsed parameters
  106211. */
  106212. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106213. }
  106214. }
  106215. declare module BABYLON {
  106216. /**
  106217. * This groups all the flags used to control the materials channel.
  106218. */
  106219. export class MaterialFlags {
  106220. private static _DiffuseTextureEnabled;
  106221. /**
  106222. * Are diffuse textures enabled in the application.
  106223. */
  106224. static get DiffuseTextureEnabled(): boolean;
  106225. static set DiffuseTextureEnabled(value: boolean);
  106226. private static _AmbientTextureEnabled;
  106227. /**
  106228. * Are ambient textures enabled in the application.
  106229. */
  106230. static get AmbientTextureEnabled(): boolean;
  106231. static set AmbientTextureEnabled(value: boolean);
  106232. private static _OpacityTextureEnabled;
  106233. /**
  106234. * Are opacity textures enabled in the application.
  106235. */
  106236. static get OpacityTextureEnabled(): boolean;
  106237. static set OpacityTextureEnabled(value: boolean);
  106238. private static _ReflectionTextureEnabled;
  106239. /**
  106240. * Are reflection textures enabled in the application.
  106241. */
  106242. static get ReflectionTextureEnabled(): boolean;
  106243. static set ReflectionTextureEnabled(value: boolean);
  106244. private static _EmissiveTextureEnabled;
  106245. /**
  106246. * Are emissive textures enabled in the application.
  106247. */
  106248. static get EmissiveTextureEnabled(): boolean;
  106249. static set EmissiveTextureEnabled(value: boolean);
  106250. private static _SpecularTextureEnabled;
  106251. /**
  106252. * Are specular textures enabled in the application.
  106253. */
  106254. static get SpecularTextureEnabled(): boolean;
  106255. static set SpecularTextureEnabled(value: boolean);
  106256. private static _BumpTextureEnabled;
  106257. /**
  106258. * Are bump textures enabled in the application.
  106259. */
  106260. static get BumpTextureEnabled(): boolean;
  106261. static set BumpTextureEnabled(value: boolean);
  106262. private static _LightmapTextureEnabled;
  106263. /**
  106264. * Are lightmap textures enabled in the application.
  106265. */
  106266. static get LightmapTextureEnabled(): boolean;
  106267. static set LightmapTextureEnabled(value: boolean);
  106268. private static _RefractionTextureEnabled;
  106269. /**
  106270. * Are refraction textures enabled in the application.
  106271. */
  106272. static get RefractionTextureEnabled(): boolean;
  106273. static set RefractionTextureEnabled(value: boolean);
  106274. private static _ColorGradingTextureEnabled;
  106275. /**
  106276. * Are color grading textures enabled in the application.
  106277. */
  106278. static get ColorGradingTextureEnabled(): boolean;
  106279. static set ColorGradingTextureEnabled(value: boolean);
  106280. private static _FresnelEnabled;
  106281. /**
  106282. * Are fresnels enabled in the application.
  106283. */
  106284. static get FresnelEnabled(): boolean;
  106285. static set FresnelEnabled(value: boolean);
  106286. private static _ClearCoatTextureEnabled;
  106287. /**
  106288. * Are clear coat textures enabled in the application.
  106289. */
  106290. static get ClearCoatTextureEnabled(): boolean;
  106291. static set ClearCoatTextureEnabled(value: boolean);
  106292. private static _ClearCoatBumpTextureEnabled;
  106293. /**
  106294. * Are clear coat bump textures enabled in the application.
  106295. */
  106296. static get ClearCoatBumpTextureEnabled(): boolean;
  106297. static set ClearCoatBumpTextureEnabled(value: boolean);
  106298. private static _ClearCoatTintTextureEnabled;
  106299. /**
  106300. * Are clear coat tint textures enabled in the application.
  106301. */
  106302. static get ClearCoatTintTextureEnabled(): boolean;
  106303. static set ClearCoatTintTextureEnabled(value: boolean);
  106304. private static _SheenTextureEnabled;
  106305. /**
  106306. * Are sheen textures enabled in the application.
  106307. */
  106308. static get SheenTextureEnabled(): boolean;
  106309. static set SheenTextureEnabled(value: boolean);
  106310. private static _AnisotropicTextureEnabled;
  106311. /**
  106312. * Are anisotropic textures enabled in the application.
  106313. */
  106314. static get AnisotropicTextureEnabled(): boolean;
  106315. static set AnisotropicTextureEnabled(value: boolean);
  106316. private static _ThicknessTextureEnabled;
  106317. /**
  106318. * Are thickness textures enabled in the application.
  106319. */
  106320. static get ThicknessTextureEnabled(): boolean;
  106321. static set ThicknessTextureEnabled(value: boolean);
  106322. }
  106323. }
  106324. declare module BABYLON {
  106325. /** @hidden */
  106326. export var defaultFragmentDeclaration: {
  106327. name: string;
  106328. shader: string;
  106329. };
  106330. }
  106331. declare module BABYLON {
  106332. /** @hidden */
  106333. export var defaultUboDeclaration: {
  106334. name: string;
  106335. shader: string;
  106336. };
  106337. }
  106338. declare module BABYLON {
  106339. /** @hidden */
  106340. export var lightFragmentDeclaration: {
  106341. name: string;
  106342. shader: string;
  106343. };
  106344. }
  106345. declare module BABYLON {
  106346. /** @hidden */
  106347. export var lightUboDeclaration: {
  106348. name: string;
  106349. shader: string;
  106350. };
  106351. }
  106352. declare module BABYLON {
  106353. /** @hidden */
  106354. export var lightsFragmentFunctions: {
  106355. name: string;
  106356. shader: string;
  106357. };
  106358. }
  106359. declare module BABYLON {
  106360. /** @hidden */
  106361. export var shadowsFragmentFunctions: {
  106362. name: string;
  106363. shader: string;
  106364. };
  106365. }
  106366. declare module BABYLON {
  106367. /** @hidden */
  106368. export var fresnelFunction: {
  106369. name: string;
  106370. shader: string;
  106371. };
  106372. }
  106373. declare module BABYLON {
  106374. /** @hidden */
  106375. export var bumpFragmentMainFunctions: {
  106376. name: string;
  106377. shader: string;
  106378. };
  106379. }
  106380. declare module BABYLON {
  106381. /** @hidden */
  106382. export var bumpFragmentFunctions: {
  106383. name: string;
  106384. shader: string;
  106385. };
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var logDepthDeclaration: {
  106390. name: string;
  106391. shader: string;
  106392. };
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var bumpFragment: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. /** @hidden */
  106403. export var depthPrePass: {
  106404. name: string;
  106405. shader: string;
  106406. };
  106407. }
  106408. declare module BABYLON {
  106409. /** @hidden */
  106410. export var lightFragment: {
  106411. name: string;
  106412. shader: string;
  106413. };
  106414. }
  106415. declare module BABYLON {
  106416. /** @hidden */
  106417. export var logDepthFragment: {
  106418. name: string;
  106419. shader: string;
  106420. };
  106421. }
  106422. declare module BABYLON {
  106423. /** @hidden */
  106424. export var defaultPixelShader: {
  106425. name: string;
  106426. shader: string;
  106427. };
  106428. }
  106429. declare module BABYLON {
  106430. /** @hidden */
  106431. export var defaultVertexDeclaration: {
  106432. name: string;
  106433. shader: string;
  106434. };
  106435. }
  106436. declare module BABYLON {
  106437. /** @hidden */
  106438. export var bumpVertexDeclaration: {
  106439. name: string;
  106440. shader: string;
  106441. };
  106442. }
  106443. declare module BABYLON {
  106444. /** @hidden */
  106445. export var bumpVertex: {
  106446. name: string;
  106447. shader: string;
  106448. };
  106449. }
  106450. declare module BABYLON {
  106451. /** @hidden */
  106452. export var fogVertex: {
  106453. name: string;
  106454. shader: string;
  106455. };
  106456. }
  106457. declare module BABYLON {
  106458. /** @hidden */
  106459. export var shadowsVertex: {
  106460. name: string;
  106461. shader: string;
  106462. };
  106463. }
  106464. declare module BABYLON {
  106465. /** @hidden */
  106466. export var pointCloudVertex: {
  106467. name: string;
  106468. shader: string;
  106469. };
  106470. }
  106471. declare module BABYLON {
  106472. /** @hidden */
  106473. export var logDepthVertex: {
  106474. name: string;
  106475. shader: string;
  106476. };
  106477. }
  106478. declare module BABYLON {
  106479. /** @hidden */
  106480. export var defaultVertexShader: {
  106481. name: string;
  106482. shader: string;
  106483. };
  106484. }
  106485. declare module BABYLON {
  106486. /** @hidden */
  106487. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106488. MAINUV1: boolean;
  106489. MAINUV2: boolean;
  106490. DIFFUSE: boolean;
  106491. DIFFUSEDIRECTUV: number;
  106492. AMBIENT: boolean;
  106493. AMBIENTDIRECTUV: number;
  106494. OPACITY: boolean;
  106495. OPACITYDIRECTUV: number;
  106496. OPACITYRGB: boolean;
  106497. REFLECTION: boolean;
  106498. EMISSIVE: boolean;
  106499. EMISSIVEDIRECTUV: number;
  106500. SPECULAR: boolean;
  106501. SPECULARDIRECTUV: number;
  106502. BUMP: boolean;
  106503. BUMPDIRECTUV: number;
  106504. PARALLAX: boolean;
  106505. PARALLAXOCCLUSION: boolean;
  106506. SPECULAROVERALPHA: boolean;
  106507. CLIPPLANE: boolean;
  106508. CLIPPLANE2: boolean;
  106509. CLIPPLANE3: boolean;
  106510. CLIPPLANE4: boolean;
  106511. CLIPPLANE5: boolean;
  106512. CLIPPLANE6: boolean;
  106513. ALPHATEST: boolean;
  106514. DEPTHPREPASS: boolean;
  106515. ALPHAFROMDIFFUSE: boolean;
  106516. POINTSIZE: boolean;
  106517. FOG: boolean;
  106518. SPECULARTERM: boolean;
  106519. DIFFUSEFRESNEL: boolean;
  106520. OPACITYFRESNEL: boolean;
  106521. REFLECTIONFRESNEL: boolean;
  106522. REFRACTIONFRESNEL: boolean;
  106523. EMISSIVEFRESNEL: boolean;
  106524. FRESNEL: boolean;
  106525. NORMAL: boolean;
  106526. UV1: boolean;
  106527. UV2: boolean;
  106528. VERTEXCOLOR: boolean;
  106529. VERTEXALPHA: boolean;
  106530. NUM_BONE_INFLUENCERS: number;
  106531. BonesPerMesh: number;
  106532. BONETEXTURE: boolean;
  106533. INSTANCES: boolean;
  106534. THIN_INSTANCES: boolean;
  106535. GLOSSINESS: boolean;
  106536. ROUGHNESS: boolean;
  106537. EMISSIVEASILLUMINATION: boolean;
  106538. LINKEMISSIVEWITHDIFFUSE: boolean;
  106539. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106540. LIGHTMAP: boolean;
  106541. LIGHTMAPDIRECTUV: number;
  106542. OBJECTSPACE_NORMALMAP: boolean;
  106543. USELIGHTMAPASSHADOWMAP: boolean;
  106544. REFLECTIONMAP_3D: boolean;
  106545. REFLECTIONMAP_SPHERICAL: boolean;
  106546. REFLECTIONMAP_PLANAR: boolean;
  106547. REFLECTIONMAP_CUBIC: boolean;
  106548. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106549. REFLECTIONMAP_PROJECTION: boolean;
  106550. REFLECTIONMAP_SKYBOX: boolean;
  106551. REFLECTIONMAP_EXPLICIT: boolean;
  106552. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106553. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106554. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106555. INVERTCUBICMAP: boolean;
  106556. LOGARITHMICDEPTH: boolean;
  106557. REFRACTION: boolean;
  106558. REFRACTIONMAP_3D: boolean;
  106559. REFLECTIONOVERALPHA: boolean;
  106560. TWOSIDEDLIGHTING: boolean;
  106561. SHADOWFLOAT: boolean;
  106562. MORPHTARGETS: boolean;
  106563. MORPHTARGETS_NORMAL: boolean;
  106564. MORPHTARGETS_TANGENT: boolean;
  106565. MORPHTARGETS_UV: boolean;
  106566. NUM_MORPH_INFLUENCERS: number;
  106567. NONUNIFORMSCALING: boolean;
  106568. PREMULTIPLYALPHA: boolean;
  106569. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  106570. ALPHABLEND: boolean;
  106571. RGBDLIGHTMAP: boolean;
  106572. RGBDREFLECTION: boolean;
  106573. RGBDREFRACTION: boolean;
  106574. IMAGEPROCESSING: boolean;
  106575. VIGNETTE: boolean;
  106576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106577. VIGNETTEBLENDMODEOPAQUE: boolean;
  106578. TONEMAPPING: boolean;
  106579. TONEMAPPING_ACES: boolean;
  106580. CONTRAST: boolean;
  106581. COLORCURVES: boolean;
  106582. COLORGRADING: boolean;
  106583. COLORGRADING3D: boolean;
  106584. SAMPLER3DGREENDEPTH: boolean;
  106585. SAMPLER3DBGRMAP: boolean;
  106586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106587. MULTIVIEW: boolean;
  106588. /**
  106589. * If the reflection texture on this material is in linear color space
  106590. * @hidden
  106591. */
  106592. IS_REFLECTION_LINEAR: boolean;
  106593. /**
  106594. * If the refraction texture on this material is in linear color space
  106595. * @hidden
  106596. */
  106597. IS_REFRACTION_LINEAR: boolean;
  106598. EXPOSURE: boolean;
  106599. constructor();
  106600. setReflectionMode(modeToEnable: string): void;
  106601. }
  106602. /**
  106603. * This is the default material used in Babylon. It is the best trade off between quality
  106604. * and performances.
  106605. * @see http://doc.babylonjs.com/babylon101/materials
  106606. */
  106607. export class StandardMaterial extends PushMaterial {
  106608. private _diffuseTexture;
  106609. /**
  106610. * The basic texture of the material as viewed under a light.
  106611. */
  106612. diffuseTexture: Nullable<BaseTexture>;
  106613. private _ambientTexture;
  106614. /**
  106615. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106616. */
  106617. ambientTexture: Nullable<BaseTexture>;
  106618. private _opacityTexture;
  106619. /**
  106620. * Define the transparency of the material from a texture.
  106621. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106622. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106623. */
  106624. opacityTexture: Nullable<BaseTexture>;
  106625. private _reflectionTexture;
  106626. /**
  106627. * Define the texture used to display the reflection.
  106628. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106629. */
  106630. reflectionTexture: Nullable<BaseTexture>;
  106631. private _emissiveTexture;
  106632. /**
  106633. * Define texture of the material as if self lit.
  106634. * This will be mixed in the final result even in the absence of light.
  106635. */
  106636. emissiveTexture: Nullable<BaseTexture>;
  106637. private _specularTexture;
  106638. /**
  106639. * Define how the color and intensity of the highlight given by the light in the material.
  106640. */
  106641. specularTexture: Nullable<BaseTexture>;
  106642. private _bumpTexture;
  106643. /**
  106644. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106645. * 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.
  106646. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106647. */
  106648. bumpTexture: Nullable<BaseTexture>;
  106649. private _lightmapTexture;
  106650. /**
  106651. * Complex lighting can be computationally expensive to compute at runtime.
  106652. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106653. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106654. */
  106655. lightmapTexture: Nullable<BaseTexture>;
  106656. private _refractionTexture;
  106657. /**
  106658. * Define the texture used to display the refraction.
  106659. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106660. */
  106661. refractionTexture: Nullable<BaseTexture>;
  106662. /**
  106663. * The color of the material lit by the environmental background lighting.
  106664. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106665. */
  106666. ambientColor: Color3;
  106667. /**
  106668. * The basic color of the material as viewed under a light.
  106669. */
  106670. diffuseColor: Color3;
  106671. /**
  106672. * Define how the color and intensity of the highlight given by the light in the material.
  106673. */
  106674. specularColor: Color3;
  106675. /**
  106676. * Define the color of the material as if self lit.
  106677. * This will be mixed in the final result even in the absence of light.
  106678. */
  106679. emissiveColor: Color3;
  106680. /**
  106681. * Defines how sharp are the highlights in the material.
  106682. * The bigger the value the sharper giving a more glossy feeling to the result.
  106683. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106684. */
  106685. specularPower: number;
  106686. private _useAlphaFromDiffuseTexture;
  106687. /**
  106688. * Does the transparency come from the diffuse texture alpha channel.
  106689. */
  106690. useAlphaFromDiffuseTexture: boolean;
  106691. private _useEmissiveAsIllumination;
  106692. /**
  106693. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106694. */
  106695. useEmissiveAsIllumination: boolean;
  106696. private _linkEmissiveWithDiffuse;
  106697. /**
  106698. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106699. * the emissive level when the final color is close to one.
  106700. */
  106701. linkEmissiveWithDiffuse: boolean;
  106702. private _useSpecularOverAlpha;
  106703. /**
  106704. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106705. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106706. */
  106707. useSpecularOverAlpha: boolean;
  106708. private _useReflectionOverAlpha;
  106709. /**
  106710. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106711. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106712. */
  106713. useReflectionOverAlpha: boolean;
  106714. private _disableLighting;
  106715. /**
  106716. * Does lights from the scene impacts this material.
  106717. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106718. */
  106719. disableLighting: boolean;
  106720. private _useObjectSpaceNormalMap;
  106721. /**
  106722. * Allows using an object space normal map (instead of tangent space).
  106723. */
  106724. useObjectSpaceNormalMap: boolean;
  106725. private _useParallax;
  106726. /**
  106727. * Is parallax enabled or not.
  106728. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106729. */
  106730. useParallax: boolean;
  106731. private _useParallaxOcclusion;
  106732. /**
  106733. * Is parallax occlusion enabled or not.
  106734. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106735. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106736. */
  106737. useParallaxOcclusion: boolean;
  106738. /**
  106739. * 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.
  106740. */
  106741. parallaxScaleBias: number;
  106742. private _roughness;
  106743. /**
  106744. * Helps to define how blurry the reflections should appears in the material.
  106745. */
  106746. roughness: number;
  106747. /**
  106748. * In case of refraction, define the value of the index of refraction.
  106749. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106750. */
  106751. indexOfRefraction: number;
  106752. /**
  106753. * Invert the refraction texture alongside the y axis.
  106754. * It can be useful with procedural textures or probe for instance.
  106755. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106756. */
  106757. invertRefractionY: boolean;
  106758. /**
  106759. * Defines the alpha limits in alpha test mode.
  106760. */
  106761. alphaCutOff: number;
  106762. private _useLightmapAsShadowmap;
  106763. /**
  106764. * In case of light mapping, define whether the map contains light or shadow informations.
  106765. */
  106766. useLightmapAsShadowmap: boolean;
  106767. private _diffuseFresnelParameters;
  106768. /**
  106769. * Define the diffuse fresnel parameters of the material.
  106770. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106771. */
  106772. diffuseFresnelParameters: FresnelParameters;
  106773. private _opacityFresnelParameters;
  106774. /**
  106775. * Define the opacity fresnel parameters of the material.
  106776. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106777. */
  106778. opacityFresnelParameters: FresnelParameters;
  106779. private _reflectionFresnelParameters;
  106780. /**
  106781. * Define the reflection fresnel parameters of the material.
  106782. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106783. */
  106784. reflectionFresnelParameters: FresnelParameters;
  106785. private _refractionFresnelParameters;
  106786. /**
  106787. * Define the refraction fresnel parameters of the material.
  106788. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106789. */
  106790. refractionFresnelParameters: FresnelParameters;
  106791. private _emissiveFresnelParameters;
  106792. /**
  106793. * Define the emissive fresnel parameters of the material.
  106794. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106795. */
  106796. emissiveFresnelParameters: FresnelParameters;
  106797. private _useReflectionFresnelFromSpecular;
  106798. /**
  106799. * If true automatically deducts the fresnels values from the material specularity.
  106800. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106801. */
  106802. useReflectionFresnelFromSpecular: boolean;
  106803. private _useGlossinessFromSpecularMapAlpha;
  106804. /**
  106805. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106806. */
  106807. useGlossinessFromSpecularMapAlpha: boolean;
  106808. private _maxSimultaneousLights;
  106809. /**
  106810. * Defines the maximum number of lights that can be used in the material
  106811. */
  106812. maxSimultaneousLights: number;
  106813. private _invertNormalMapX;
  106814. /**
  106815. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106816. */
  106817. invertNormalMapX: boolean;
  106818. private _invertNormalMapY;
  106819. /**
  106820. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106821. */
  106822. invertNormalMapY: boolean;
  106823. private _twoSidedLighting;
  106824. /**
  106825. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106826. */
  106827. twoSidedLighting: boolean;
  106828. /**
  106829. * Default configuration related to image processing available in the standard Material.
  106830. */
  106831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106832. /**
  106833. * Gets the image processing configuration used either in this material.
  106834. */
  106835. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106836. /**
  106837. * Sets the Default image processing configuration used either in the this material.
  106838. *
  106839. * If sets to null, the scene one is in use.
  106840. */
  106841. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  106842. /**
  106843. * Keep track of the image processing observer to allow dispose and replace.
  106844. */
  106845. private _imageProcessingObserver;
  106846. /**
  106847. * Attaches a new image processing configuration to the Standard Material.
  106848. * @param configuration
  106849. */
  106850. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106851. /**
  106852. * Gets wether the color curves effect is enabled.
  106853. */
  106854. get cameraColorCurvesEnabled(): boolean;
  106855. /**
  106856. * Sets wether the color curves effect is enabled.
  106857. */
  106858. set cameraColorCurvesEnabled(value: boolean);
  106859. /**
  106860. * Gets wether the color grading effect is enabled.
  106861. */
  106862. get cameraColorGradingEnabled(): boolean;
  106863. /**
  106864. * Gets wether the color grading effect is enabled.
  106865. */
  106866. set cameraColorGradingEnabled(value: boolean);
  106867. /**
  106868. * Gets wether tonemapping is enabled or not.
  106869. */
  106870. get cameraToneMappingEnabled(): boolean;
  106871. /**
  106872. * Sets wether tonemapping is enabled or not
  106873. */
  106874. set cameraToneMappingEnabled(value: boolean);
  106875. /**
  106876. * The camera exposure used on this material.
  106877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106878. * This corresponds to a photographic exposure.
  106879. */
  106880. get cameraExposure(): number;
  106881. /**
  106882. * The camera exposure used on this material.
  106883. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106884. * This corresponds to a photographic exposure.
  106885. */
  106886. set cameraExposure(value: number);
  106887. /**
  106888. * Gets The camera contrast used on this material.
  106889. */
  106890. get cameraContrast(): number;
  106891. /**
  106892. * Sets The camera contrast used on this material.
  106893. */
  106894. set cameraContrast(value: number);
  106895. /**
  106896. * Gets the Color Grading 2D Lookup Texture.
  106897. */
  106898. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  106899. /**
  106900. * Sets the Color Grading 2D Lookup Texture.
  106901. */
  106902. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  106903. /**
  106904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106906. * 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;
  106907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106908. */
  106909. get cameraColorCurves(): Nullable<ColorCurves>;
  106910. /**
  106911. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106912. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106913. * 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;
  106914. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106915. */
  106916. set cameraColorCurves(value: Nullable<ColorCurves>);
  106917. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106918. protected _worldViewProjectionMatrix: Matrix;
  106919. protected _globalAmbientColor: Color3;
  106920. protected _useLogarithmicDepth: boolean;
  106921. protected _rebuildInParallel: boolean;
  106922. /**
  106923. * Instantiates a new standard material.
  106924. * This is the default material used in Babylon. It is the best trade off between quality
  106925. * and performances.
  106926. * @see http://doc.babylonjs.com/babylon101/materials
  106927. * @param name Define the name of the material in the scene
  106928. * @param scene Define the scene the material belong to
  106929. */
  106930. constructor(name: string, scene: Scene);
  106931. /**
  106932. * Gets a boolean indicating that current material needs to register RTT
  106933. */
  106934. get hasRenderTargetTextures(): boolean;
  106935. /**
  106936. * Gets the current class name of the material e.g. "StandardMaterial"
  106937. * Mainly use in serialization.
  106938. * @returns the class name
  106939. */
  106940. getClassName(): string;
  106941. /**
  106942. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106943. * You can try switching to logarithmic depth.
  106944. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106945. */
  106946. get useLogarithmicDepth(): boolean;
  106947. set useLogarithmicDepth(value: boolean);
  106948. /**
  106949. * Specifies if the material will require alpha blending
  106950. * @returns a boolean specifying if alpha blending is needed
  106951. */
  106952. needAlphaBlending(): boolean;
  106953. /**
  106954. * Specifies if this material should be rendered in alpha test mode
  106955. * @returns a boolean specifying if an alpha test is needed.
  106956. */
  106957. needAlphaTesting(): boolean;
  106958. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106959. /**
  106960. * Get the texture used for alpha test purpose.
  106961. * @returns the diffuse texture in case of the standard material.
  106962. */
  106963. getAlphaTestTexture(): Nullable<BaseTexture>;
  106964. /**
  106965. * Get if the submesh is ready to be used and all its information available.
  106966. * Child classes can use it to update shaders
  106967. * @param mesh defines the mesh to check
  106968. * @param subMesh defines which submesh to check
  106969. * @param useInstances specifies that instances should be used
  106970. * @returns a boolean indicating that the submesh is ready or not
  106971. */
  106972. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106973. /**
  106974. * Builds the material UBO layouts.
  106975. * Used internally during the effect preparation.
  106976. */
  106977. buildUniformLayout(): void;
  106978. /**
  106979. * Unbinds the material from the mesh
  106980. */
  106981. unbind(): void;
  106982. /**
  106983. * Binds the submesh to this material by preparing the effect and shader to draw
  106984. * @param world defines the world transformation matrix
  106985. * @param mesh defines the mesh containing the submesh
  106986. * @param subMesh defines the submesh to bind the material to
  106987. */
  106988. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106989. /**
  106990. * Get the list of animatables in the material.
  106991. * @returns the list of animatables object used in the material
  106992. */
  106993. getAnimatables(): IAnimatable[];
  106994. /**
  106995. * Gets the active textures from the material
  106996. * @returns an array of textures
  106997. */
  106998. getActiveTextures(): BaseTexture[];
  106999. /**
  107000. * Specifies if the material uses a texture
  107001. * @param texture defines the texture to check against the material
  107002. * @returns a boolean specifying if the material uses the texture
  107003. */
  107004. hasTexture(texture: BaseTexture): boolean;
  107005. /**
  107006. * Disposes the material
  107007. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107008. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107009. */
  107010. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107011. /**
  107012. * Makes a duplicate of the material, and gives it a new name
  107013. * @param name defines the new name for the duplicated material
  107014. * @returns the cloned material
  107015. */
  107016. clone(name: string): StandardMaterial;
  107017. /**
  107018. * Serializes this material in a JSON representation
  107019. * @returns the serialized material object
  107020. */
  107021. serialize(): any;
  107022. /**
  107023. * Creates a standard material from parsed material data
  107024. * @param source defines the JSON representation of the material
  107025. * @param scene defines the hosting scene
  107026. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107027. * @returns a new standard material
  107028. */
  107029. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107030. /**
  107031. * Are diffuse textures enabled in the application.
  107032. */
  107033. static get DiffuseTextureEnabled(): boolean;
  107034. static set DiffuseTextureEnabled(value: boolean);
  107035. /**
  107036. * Are ambient textures enabled in the application.
  107037. */
  107038. static get AmbientTextureEnabled(): boolean;
  107039. static set AmbientTextureEnabled(value: boolean);
  107040. /**
  107041. * Are opacity textures enabled in the application.
  107042. */
  107043. static get OpacityTextureEnabled(): boolean;
  107044. static set OpacityTextureEnabled(value: boolean);
  107045. /**
  107046. * Are reflection textures enabled in the application.
  107047. */
  107048. static get ReflectionTextureEnabled(): boolean;
  107049. static set ReflectionTextureEnabled(value: boolean);
  107050. /**
  107051. * Are emissive textures enabled in the application.
  107052. */
  107053. static get EmissiveTextureEnabled(): boolean;
  107054. static set EmissiveTextureEnabled(value: boolean);
  107055. /**
  107056. * Are specular textures enabled in the application.
  107057. */
  107058. static get SpecularTextureEnabled(): boolean;
  107059. static set SpecularTextureEnabled(value: boolean);
  107060. /**
  107061. * Are bump textures enabled in the application.
  107062. */
  107063. static get BumpTextureEnabled(): boolean;
  107064. static set BumpTextureEnabled(value: boolean);
  107065. /**
  107066. * Are lightmap textures enabled in the application.
  107067. */
  107068. static get LightmapTextureEnabled(): boolean;
  107069. static set LightmapTextureEnabled(value: boolean);
  107070. /**
  107071. * Are refraction textures enabled in the application.
  107072. */
  107073. static get RefractionTextureEnabled(): boolean;
  107074. static set RefractionTextureEnabled(value: boolean);
  107075. /**
  107076. * Are color grading textures enabled in the application.
  107077. */
  107078. static get ColorGradingTextureEnabled(): boolean;
  107079. static set ColorGradingTextureEnabled(value: boolean);
  107080. /**
  107081. * Are fresnels enabled in the application.
  107082. */
  107083. static get FresnelEnabled(): boolean;
  107084. static set FresnelEnabled(value: boolean);
  107085. }
  107086. }
  107087. declare module BABYLON {
  107088. /**
  107089. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107090. *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.
  107091. * The SPS is also a particle system. It provides some methods to manage the particles.
  107092. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107093. *
  107094. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107095. */
  107096. export class SolidParticleSystem implements IDisposable {
  107097. /**
  107098. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107099. * Example : var p = SPS.particles[i];
  107100. */
  107101. particles: SolidParticle[];
  107102. /**
  107103. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107104. */
  107105. nbParticles: number;
  107106. /**
  107107. * If the particles must ever face the camera (default false). Useful for planar particles.
  107108. */
  107109. billboard: boolean;
  107110. /**
  107111. * Recompute normals when adding a shape
  107112. */
  107113. recomputeNormals: boolean;
  107114. /**
  107115. * This a counter ofr your own usage. It's not set by any SPS functions.
  107116. */
  107117. counter: number;
  107118. /**
  107119. * The SPS name. This name is also given to the underlying mesh.
  107120. */
  107121. name: string;
  107122. /**
  107123. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107124. */
  107125. mesh: Mesh;
  107126. /**
  107127. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107128. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107129. */
  107130. vars: any;
  107131. /**
  107132. * This array is populated when the SPS is set as 'pickable'.
  107133. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107134. * Each element of this array is an object `{idx: int, faceId: int}`.
  107135. * `idx` is the picked particle index in the `SPS.particles` array
  107136. * `faceId` is the picked face index counted within this particle.
  107137. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107138. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107139. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107140. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107141. */
  107142. pickedParticles: {
  107143. idx: number;
  107144. faceId: number;
  107145. }[];
  107146. /**
  107147. * This array is populated when the SPS is set as 'pickable'
  107148. * Each key of this array is a submesh index.
  107149. * Each element of this array is a second array defined like this :
  107150. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107151. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107152. * `idx` is the picked particle index in the `SPS.particles` array
  107153. * `faceId` is the picked face index counted within this particle.
  107154. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107155. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107156. */
  107157. pickedBySubMesh: {
  107158. idx: number;
  107159. faceId: number;
  107160. }[][];
  107161. /**
  107162. * This array is populated when `enableDepthSort` is set to true.
  107163. * Each element of this array is an instance of the class DepthSortedParticle.
  107164. */
  107165. depthSortedParticles: DepthSortedParticle[];
  107166. /**
  107167. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107168. * @hidden
  107169. */
  107170. _bSphereOnly: boolean;
  107171. /**
  107172. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107173. * @hidden
  107174. */
  107175. _bSphereRadiusFactor: number;
  107176. private _scene;
  107177. private _positions;
  107178. private _indices;
  107179. private _normals;
  107180. private _colors;
  107181. private _uvs;
  107182. private _indices32;
  107183. private _positions32;
  107184. private _normals32;
  107185. private _fixedNormal32;
  107186. private _colors32;
  107187. private _uvs32;
  107188. private _index;
  107189. private _updatable;
  107190. private _pickable;
  107191. private _isVisibilityBoxLocked;
  107192. private _alwaysVisible;
  107193. private _depthSort;
  107194. private _expandable;
  107195. private _shapeCounter;
  107196. private _copy;
  107197. private _color;
  107198. private _computeParticleColor;
  107199. private _computeParticleTexture;
  107200. private _computeParticleRotation;
  107201. private _computeParticleVertex;
  107202. private _computeBoundingBox;
  107203. private _depthSortParticles;
  107204. private _camera;
  107205. private _mustUnrotateFixedNormals;
  107206. private _particlesIntersect;
  107207. private _needs32Bits;
  107208. private _isNotBuilt;
  107209. private _lastParticleId;
  107210. private _idxOfId;
  107211. private _multimaterialEnabled;
  107212. private _useModelMaterial;
  107213. private _indicesByMaterial;
  107214. private _materialIndexes;
  107215. private _depthSortFunction;
  107216. private _materialSortFunction;
  107217. private _materials;
  107218. private _multimaterial;
  107219. private _materialIndexesById;
  107220. private _defaultMaterial;
  107221. private _autoUpdateSubMeshes;
  107222. private _tmpVertex;
  107223. /**
  107224. * Creates a SPS (Solid Particle System) object.
  107225. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107226. * @param scene (Scene) is the scene in which the SPS is added.
  107227. * @param options defines the options of the sps e.g.
  107228. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107229. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107230. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107231. * * 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.
  107232. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107233. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107234. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107235. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107236. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107237. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107238. */
  107239. constructor(name: string, scene: Scene, options?: {
  107240. updatable?: boolean;
  107241. isPickable?: boolean;
  107242. enableDepthSort?: boolean;
  107243. particleIntersection?: boolean;
  107244. boundingSphereOnly?: boolean;
  107245. bSphereRadiusFactor?: number;
  107246. expandable?: boolean;
  107247. useModelMaterial?: boolean;
  107248. enableMultiMaterial?: boolean;
  107249. });
  107250. /**
  107251. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107252. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107253. * @returns the created mesh
  107254. */
  107255. buildMesh(): Mesh;
  107256. /**
  107257. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107258. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107259. * Thus the particles generated from `digest()` have their property `position` set yet.
  107260. * @param mesh ( Mesh ) is the mesh to be digested
  107261. * @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
  107262. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107263. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107264. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107265. * @returns the current SPS
  107266. */
  107267. digest(mesh: Mesh, options?: {
  107268. facetNb?: number;
  107269. number?: number;
  107270. delta?: number;
  107271. storage?: [];
  107272. }): SolidParticleSystem;
  107273. /**
  107274. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107275. * @hidden
  107276. */
  107277. private _unrotateFixedNormals;
  107278. /**
  107279. * Resets the temporary working copy particle
  107280. * @hidden
  107281. */
  107282. private _resetCopy;
  107283. /**
  107284. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  107285. * @param p the current index in the positions array to be updated
  107286. * @param ind the current index in the indices array
  107287. * @param shape a Vector3 array, the shape geometry
  107288. * @param positions the positions array to be updated
  107289. * @param meshInd the shape indices array
  107290. * @param indices the indices array to be updated
  107291. * @param meshUV the shape uv array
  107292. * @param uvs the uv array to be updated
  107293. * @param meshCol the shape color array
  107294. * @param colors the color array to be updated
  107295. * @param meshNor the shape normals array
  107296. * @param normals the normals array to be updated
  107297. * @param idx the particle index
  107298. * @param idxInShape the particle index in its shape
  107299. * @param options the addShape() method passed options
  107300. * @model the particle model
  107301. * @hidden
  107302. */
  107303. private _meshBuilder;
  107304. /**
  107305. * Returns a shape Vector3 array from positions float array
  107306. * @param positions float array
  107307. * @returns a vector3 array
  107308. * @hidden
  107309. */
  107310. private _posToShape;
  107311. /**
  107312. * Returns a shapeUV array from a float uvs (array deep copy)
  107313. * @param uvs as a float array
  107314. * @returns a shapeUV array
  107315. * @hidden
  107316. */
  107317. private _uvsToShapeUV;
  107318. /**
  107319. * Adds a new particle object in the particles array
  107320. * @param idx particle index in particles array
  107321. * @param id particle id
  107322. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  107323. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  107324. * @param model particle ModelShape object
  107325. * @param shapeId model shape identifier
  107326. * @param idxInShape index of the particle in the current model
  107327. * @param bInfo model bounding info object
  107328. * @param storage target storage array, if any
  107329. * @hidden
  107330. */
  107331. private _addParticle;
  107332. /**
  107333. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107334. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  107335. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107336. * @param nb (positive integer) the number of particles to be created from this model
  107337. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107338. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107339. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107340. * @returns the number of shapes in the system
  107341. */
  107342. addShape(mesh: Mesh, nb: number, options?: {
  107343. positionFunction?: any;
  107344. vertexFunction?: any;
  107345. storage?: [];
  107346. }): number;
  107347. /**
  107348. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107349. * @hidden
  107350. */
  107351. private _rebuildParticle;
  107352. /**
  107353. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107354. * @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.
  107355. * @returns the SPS.
  107356. */
  107357. rebuildMesh(reset?: boolean): SolidParticleSystem;
  107358. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  107359. * Returns an array with the removed particles.
  107360. * 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.
  107361. * The SPS can't be empty so at least one particle needs to remain in place.
  107362. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  107363. * @param start index of the first particle to remove
  107364. * @param end index of the last particle to remove (included)
  107365. * @returns an array populated with the removed particles
  107366. */
  107367. removeParticles(start: number, end: number): SolidParticle[];
  107368. /**
  107369. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  107370. * @param solidParticleArray an array populated with Solid Particles objects
  107371. * @returns the SPS
  107372. */
  107373. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  107374. /**
  107375. * Creates a new particle and modifies the SPS mesh geometry :
  107376. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  107377. * - calls _addParticle() to populate the particle array
  107378. * factorized code from addShape() and insertParticlesFromArray()
  107379. * @param idx particle index in the particles array
  107380. * @param i particle index in its shape
  107381. * @param modelShape particle ModelShape object
  107382. * @param shape shape vertex array
  107383. * @param meshInd shape indices array
  107384. * @param meshUV shape uv array
  107385. * @param meshCol shape color array
  107386. * @param meshNor shape normals array
  107387. * @param bbInfo shape bounding info
  107388. * @param storage target particle storage
  107389. * @options addShape() passed options
  107390. * @hidden
  107391. */
  107392. private _insertNewParticle;
  107393. /**
  107394. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107395. * This method calls `updateParticle()` for each particle of the SPS.
  107396. * For an animated SPS, it is usually called within the render loop.
  107397. * 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.
  107398. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107399. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107400. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107401. * @returns the SPS.
  107402. */
  107403. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  107404. /**
  107405. * Disposes the SPS.
  107406. */
  107407. dispose(): void;
  107408. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  107409. * idx is the particle index in the SPS
  107410. * faceId is the picked face index counted within this particle.
  107411. * Returns null if the pickInfo can't identify a picked particle.
  107412. * @param pickingInfo (PickingInfo object)
  107413. * @returns {idx: number, faceId: number} or null
  107414. */
  107415. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  107416. idx: number;
  107417. faceId: number;
  107418. }>;
  107419. /**
  107420. * Returns a SolidParticle object from its identifier : particle.id
  107421. * @param id (integer) the particle Id
  107422. * @returns the searched particle or null if not found in the SPS.
  107423. */
  107424. getParticleById(id: number): Nullable<SolidParticle>;
  107425. /**
  107426. * Returns a new array populated with the particles having the passed shapeId.
  107427. * @param shapeId (integer) the shape identifier
  107428. * @returns a new solid particle array
  107429. */
  107430. getParticlesByShapeId(shapeId: number): SolidParticle[];
  107431. /**
  107432. * Populates the passed array "ref" with the particles having the passed shapeId.
  107433. * @param shapeId the shape identifier
  107434. * @returns the SPS
  107435. * @param ref
  107436. */
  107437. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  107438. /**
  107439. * Computes the required SubMeshes according the materials assigned to the particles.
  107440. * @returns the solid particle system.
  107441. * Does nothing if called before the SPS mesh is built.
  107442. */
  107443. computeSubMeshes(): SolidParticleSystem;
  107444. /**
  107445. * Sorts the solid particles by material when MultiMaterial is enabled.
  107446. * Updates the indices32 array.
  107447. * Updates the indicesByMaterial array.
  107448. * Updates the mesh indices array.
  107449. * @returns the SPS
  107450. * @hidden
  107451. */
  107452. private _sortParticlesByMaterial;
  107453. /**
  107454. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  107455. * @hidden
  107456. */
  107457. private _setMaterialIndexesById;
  107458. /**
  107459. * Returns an array with unique values of Materials from the passed array
  107460. * @param array the material array to be checked and filtered
  107461. * @hidden
  107462. */
  107463. private _filterUniqueMaterialId;
  107464. /**
  107465. * Sets a new Standard Material as _defaultMaterial if not already set.
  107466. * @hidden
  107467. */
  107468. private _setDefaultMaterial;
  107469. /**
  107470. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107471. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107472. * @returns the SPS.
  107473. */
  107474. refreshVisibleSize(): SolidParticleSystem;
  107475. /**
  107476. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107477. * @param size the size (float) of the visibility box
  107478. * note : this doesn't lock the SPS mesh bounding box.
  107479. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107480. */
  107481. setVisibilityBox(size: number): void;
  107482. /**
  107483. * Gets whether the SPS as always visible or not
  107484. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107485. */
  107486. get isAlwaysVisible(): boolean;
  107487. /**
  107488. * Sets the SPS as always visible or not
  107489. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107490. */
  107491. set isAlwaysVisible(val: boolean);
  107492. /**
  107493. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107494. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107495. */
  107496. set isVisibilityBoxLocked(val: boolean);
  107497. /**
  107498. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107499. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107500. */
  107501. get isVisibilityBoxLocked(): boolean;
  107502. /**
  107503. * Tells to `setParticles()` to compute the particle rotations or not.
  107504. * Default value : true. The SPS is faster when it's set to false.
  107505. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107506. */
  107507. set computeParticleRotation(val: boolean);
  107508. /**
  107509. * Tells to `setParticles()` to compute the particle colors or not.
  107510. * Default value : true. The SPS is faster when it's set to false.
  107511. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107512. */
  107513. set computeParticleColor(val: boolean);
  107514. set computeParticleTexture(val: boolean);
  107515. /**
  107516. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107517. * Default value : false. The SPS is faster when it's set to false.
  107518. * Note : the particle custom vertex positions aren't stored values.
  107519. */
  107520. set computeParticleVertex(val: boolean);
  107521. /**
  107522. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107523. */
  107524. set computeBoundingBox(val: boolean);
  107525. /**
  107526. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107527. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107528. * Default : `true`
  107529. */
  107530. set depthSortParticles(val: boolean);
  107531. /**
  107532. * Gets if `setParticles()` computes the particle rotations or not.
  107533. * Default value : true. The SPS is faster when it's set to false.
  107534. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107535. */
  107536. get computeParticleRotation(): boolean;
  107537. /**
  107538. * Gets if `setParticles()` computes the particle colors or not.
  107539. * Default value : true. The SPS is faster when it's set to false.
  107540. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107541. */
  107542. get computeParticleColor(): boolean;
  107543. /**
  107544. * Gets if `setParticles()` computes the particle textures or not.
  107545. * Default value : true. The SPS is faster when it's set to false.
  107546. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107547. */
  107548. get computeParticleTexture(): boolean;
  107549. /**
  107550. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107551. * Default value : false. The SPS is faster when it's set to false.
  107552. * Note : the particle custom vertex positions aren't stored values.
  107553. */
  107554. get computeParticleVertex(): boolean;
  107555. /**
  107556. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107557. */
  107558. get computeBoundingBox(): boolean;
  107559. /**
  107560. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107561. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107562. * Default : `true`
  107563. */
  107564. get depthSortParticles(): boolean;
  107565. /**
  107566. * Gets if the SPS is created as expandable at construction time.
  107567. * Default : `false`
  107568. */
  107569. get expandable(): boolean;
  107570. /**
  107571. * Gets if the SPS supports the Multi Materials
  107572. */
  107573. get multimaterialEnabled(): boolean;
  107574. /**
  107575. * Gets if the SPS uses the model materials for its own multimaterial.
  107576. */
  107577. get useModelMaterial(): boolean;
  107578. /**
  107579. * The SPS used material array.
  107580. */
  107581. get materials(): Material[];
  107582. /**
  107583. * Sets the SPS MultiMaterial from the passed materials.
  107584. * Note : the passed array is internally copied and not used then by reference.
  107585. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  107586. */
  107587. setMultiMaterial(materials: Material[]): void;
  107588. /**
  107589. * The SPS computed multimaterial object
  107590. */
  107591. get multimaterial(): MultiMaterial;
  107592. set multimaterial(mm: MultiMaterial);
  107593. /**
  107594. * If the subMeshes must be updated on the next call to setParticles()
  107595. */
  107596. get autoUpdateSubMeshes(): boolean;
  107597. set autoUpdateSubMeshes(val: boolean);
  107598. /**
  107599. * This function does nothing. It may be overwritten to set all the particle first values.
  107600. * The SPS doesn't call this function, you may have to call it by your own.
  107601. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107602. */
  107603. initParticles(): void;
  107604. /**
  107605. * This function does nothing. It may be overwritten to recycle a particle.
  107606. * The SPS doesn't call this function, you may have to call it by your own.
  107607. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107608. * @param particle The particle to recycle
  107609. * @returns the recycled particle
  107610. */
  107611. recycleParticle(particle: SolidParticle): SolidParticle;
  107612. /**
  107613. * Updates a particle : this function should be overwritten by the user.
  107614. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107615. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107616. * @example : just set a particle position or velocity and recycle conditions
  107617. * @param particle The particle to update
  107618. * @returns the updated particle
  107619. */
  107620. updateParticle(particle: SolidParticle): SolidParticle;
  107621. /**
  107622. * Updates a vertex of a particle : it can be overwritten by the user.
  107623. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107624. * @param particle the current particle
  107625. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  107626. * @param pt the index of the current vertex in the particle shape
  107627. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  107628. * @example : just set a vertex particle position or color
  107629. * @returns the sps
  107630. */
  107631. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  107632. /**
  107633. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107634. * This does nothing and may be overwritten by the user.
  107635. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107636. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107637. * @param update the boolean update value actually passed to setParticles()
  107638. */
  107639. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107640. /**
  107641. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107642. * This will be passed three parameters.
  107643. * This does nothing and may be overwritten by the user.
  107644. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107645. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107646. * @param update the boolean update value actually passed to setParticles()
  107647. */
  107648. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107649. }
  107650. }
  107651. declare module BABYLON {
  107652. /**
  107653. * Represents one particle of a solid particle system.
  107654. */
  107655. export class SolidParticle {
  107656. /**
  107657. * particle global index
  107658. */
  107659. idx: number;
  107660. /**
  107661. * particle identifier
  107662. */
  107663. id: number;
  107664. /**
  107665. * The color of the particle
  107666. */
  107667. color: Nullable<Color4>;
  107668. /**
  107669. * The world space position of the particle.
  107670. */
  107671. position: Vector3;
  107672. /**
  107673. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107674. */
  107675. rotation: Vector3;
  107676. /**
  107677. * The world space rotation quaternion of the particle.
  107678. */
  107679. rotationQuaternion: Nullable<Quaternion>;
  107680. /**
  107681. * The scaling of the particle.
  107682. */
  107683. scaling: Vector3;
  107684. /**
  107685. * The uvs of the particle.
  107686. */
  107687. uvs: Vector4;
  107688. /**
  107689. * The current speed of the particle.
  107690. */
  107691. velocity: Vector3;
  107692. /**
  107693. * The pivot point in the particle local space.
  107694. */
  107695. pivot: Vector3;
  107696. /**
  107697. * Must the particle be translated from its pivot point in its local space ?
  107698. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107699. * Default : false
  107700. */
  107701. translateFromPivot: boolean;
  107702. /**
  107703. * Is the particle active or not ?
  107704. */
  107705. alive: boolean;
  107706. /**
  107707. * Is the particle visible or not ?
  107708. */
  107709. isVisible: boolean;
  107710. /**
  107711. * Index of this particle in the global "positions" array (Internal use)
  107712. * @hidden
  107713. */
  107714. _pos: number;
  107715. /**
  107716. * @hidden Index of this particle in the global "indices" array (Internal use)
  107717. */
  107718. _ind: number;
  107719. /**
  107720. * @hidden ModelShape of this particle (Internal use)
  107721. */
  107722. _model: ModelShape;
  107723. /**
  107724. * ModelShape id of this particle
  107725. */
  107726. shapeId: number;
  107727. /**
  107728. * Index of the particle in its shape id
  107729. */
  107730. idxInShape: number;
  107731. /**
  107732. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  107733. */
  107734. _modelBoundingInfo: BoundingInfo;
  107735. /**
  107736. * @hidden Particle BoundingInfo object (Internal use)
  107737. */
  107738. _boundingInfo: BoundingInfo;
  107739. /**
  107740. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  107741. */
  107742. _sps: SolidParticleSystem;
  107743. /**
  107744. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107745. */
  107746. _stillInvisible: boolean;
  107747. /**
  107748. * @hidden Last computed particle rotation matrix
  107749. */
  107750. _rotationMatrix: number[];
  107751. /**
  107752. * Parent particle Id, if any.
  107753. * Default null.
  107754. */
  107755. parentId: Nullable<number>;
  107756. /**
  107757. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  107758. */
  107759. materialIndex: Nullable<number>;
  107760. /**
  107761. * Custom object or properties.
  107762. */
  107763. props: Nullable<any>;
  107764. /**
  107765. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107766. * The possible values are :
  107767. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107768. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107769. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107770. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107771. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107772. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107773. * */
  107774. cullingStrategy: number;
  107775. /**
  107776. * @hidden Internal global position in the SPS.
  107777. */
  107778. _globalPosition: Vector3;
  107779. /**
  107780. * Creates a Solid Particle object.
  107781. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107782. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  107783. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  107784. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107785. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107786. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107787. * @param shapeId (integer) is the model shape identifier in the SPS.
  107788. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107789. * @param sps defines the sps it is associated to
  107790. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107791. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  107792. */
  107793. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  107794. /**
  107795. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  107796. * @param target the particle target
  107797. * @returns the current particle
  107798. */
  107799. copyToRef(target: SolidParticle): SolidParticle;
  107800. /**
  107801. * Legacy support, changed scale to scaling
  107802. */
  107803. get scale(): Vector3;
  107804. /**
  107805. * Legacy support, changed scale to scaling
  107806. */
  107807. set scale(scale: Vector3);
  107808. /**
  107809. * Legacy support, changed quaternion to rotationQuaternion
  107810. */
  107811. get quaternion(): Nullable<Quaternion>;
  107812. /**
  107813. * Legacy support, changed quaternion to rotationQuaternion
  107814. */
  107815. set quaternion(q: Nullable<Quaternion>);
  107816. /**
  107817. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107818. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107819. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107820. * @returns true if it intersects
  107821. */
  107822. intersectsMesh(target: Mesh | SolidParticle): boolean;
  107823. /**
  107824. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107825. * A particle is in the frustum if its bounding box intersects the frustum
  107826. * @param frustumPlanes defines the frustum to test
  107827. * @returns true if the particle is in the frustum planes
  107828. */
  107829. isInFrustum(frustumPlanes: Plane[]): boolean;
  107830. /**
  107831. * get the rotation matrix of the particle
  107832. * @hidden
  107833. */
  107834. getRotationMatrix(m: Matrix): void;
  107835. }
  107836. /**
  107837. * Represents the shape of the model used by one particle of a solid particle system.
  107838. * SPS internal tool, don't use it manually.
  107839. */
  107840. export class ModelShape {
  107841. /**
  107842. * The shape id
  107843. * @hidden
  107844. */
  107845. shapeID: number;
  107846. /**
  107847. * flat array of model positions (internal use)
  107848. * @hidden
  107849. */
  107850. _shape: Vector3[];
  107851. /**
  107852. * flat array of model UVs (internal use)
  107853. * @hidden
  107854. */
  107855. _shapeUV: number[];
  107856. /**
  107857. * color array of the model
  107858. * @hidden
  107859. */
  107860. _shapeColors: number[];
  107861. /**
  107862. * indices array of the model
  107863. * @hidden
  107864. */
  107865. _indices: number[];
  107866. /**
  107867. * normals array of the model
  107868. * @hidden
  107869. */
  107870. _normals: number[];
  107871. /**
  107872. * length of the shape in the model indices array (internal use)
  107873. * @hidden
  107874. */
  107875. _indicesLength: number;
  107876. /**
  107877. * Custom position function (internal use)
  107878. * @hidden
  107879. */
  107880. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  107881. /**
  107882. * Custom vertex function (internal use)
  107883. * @hidden
  107884. */
  107885. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  107886. /**
  107887. * Model material (internal use)
  107888. * @hidden
  107889. */
  107890. _material: Nullable<Material>;
  107891. /**
  107892. * 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.
  107893. * SPS internal tool, don't use it manually.
  107894. * @hidden
  107895. */
  107896. 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>);
  107897. }
  107898. /**
  107899. * Represents a Depth Sorted Particle in the solid particle system.
  107900. * @hidden
  107901. */
  107902. export class DepthSortedParticle {
  107903. /**
  107904. * Particle index
  107905. */
  107906. idx: number;
  107907. /**
  107908. * Index of the particle in the "indices" array
  107909. */
  107910. ind: number;
  107911. /**
  107912. * Length of the particle shape in the "indices" array
  107913. */
  107914. indicesLength: number;
  107915. /**
  107916. * Squared distance from the particle to the camera
  107917. */
  107918. sqDistance: number;
  107919. /**
  107920. * Material index when used with MultiMaterials
  107921. */
  107922. materialIndex: number;
  107923. /**
  107924. * Creates a new sorted particle
  107925. * @param materialIndex
  107926. */
  107927. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  107928. }
  107929. /**
  107930. * Represents a solid particle vertex
  107931. */
  107932. export class SolidParticleVertex {
  107933. /**
  107934. * Vertex position
  107935. */
  107936. position: Vector3;
  107937. /**
  107938. * Vertex color
  107939. */
  107940. color: Color4;
  107941. /**
  107942. * Vertex UV
  107943. */
  107944. uv: Vector2;
  107945. /**
  107946. * Creates a new solid particle vertex
  107947. */
  107948. constructor();
  107949. /** Vertex x coordinate */
  107950. get x(): number;
  107951. set x(val: number);
  107952. /** Vertex y coordinate */
  107953. get y(): number;
  107954. set y(val: number);
  107955. /** Vertex z coordinate */
  107956. get z(): number;
  107957. set z(val: number);
  107958. }
  107959. }
  107960. declare module BABYLON {
  107961. /**
  107962. * @hidden
  107963. */
  107964. export class _MeshCollisionData {
  107965. _checkCollisions: boolean;
  107966. _collisionMask: number;
  107967. _collisionGroup: number;
  107968. _surroundingMeshes: Nullable<AbstractMesh[]>;
  107969. _collider: Nullable<Collider>;
  107970. _oldPositionForCollisions: Vector3;
  107971. _diffPositionForCollisions: Vector3;
  107972. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  107973. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  107974. }
  107975. }
  107976. declare module BABYLON {
  107977. /** @hidden */
  107978. class _FacetDataStorage {
  107979. facetPositions: Vector3[];
  107980. facetNormals: Vector3[];
  107981. facetPartitioning: number[][];
  107982. facetNb: number;
  107983. partitioningSubdivisions: number;
  107984. partitioningBBoxRatio: number;
  107985. facetDataEnabled: boolean;
  107986. facetParameters: any;
  107987. bbSize: Vector3;
  107988. subDiv: {
  107989. max: number;
  107990. X: number;
  107991. Y: number;
  107992. Z: number;
  107993. };
  107994. facetDepthSort: boolean;
  107995. facetDepthSortEnabled: boolean;
  107996. depthSortedIndices: IndicesArray;
  107997. depthSortedFacets: {
  107998. ind: number;
  107999. sqDistance: number;
  108000. }[];
  108001. facetDepthSortFunction: (f1: {
  108002. ind: number;
  108003. sqDistance: number;
  108004. }, f2: {
  108005. ind: number;
  108006. sqDistance: number;
  108007. }) => number;
  108008. facetDepthSortFrom: Vector3;
  108009. facetDepthSortOrigin: Vector3;
  108010. invertedMatrix: Matrix;
  108011. }
  108012. /**
  108013. * @hidden
  108014. **/
  108015. class _InternalAbstractMeshDataInfo {
  108016. _hasVertexAlpha: boolean;
  108017. _useVertexColors: boolean;
  108018. _numBoneInfluencers: number;
  108019. _applyFog: boolean;
  108020. _receiveShadows: boolean;
  108021. _facetData: _FacetDataStorage;
  108022. _visibility: number;
  108023. _skeleton: Nullable<Skeleton>;
  108024. _layerMask: number;
  108025. _computeBonesUsingShaders: boolean;
  108026. _isActive: boolean;
  108027. _onlyForInstances: boolean;
  108028. _isActiveIntermediate: boolean;
  108029. _onlyForInstancesIntermediate: boolean;
  108030. _actAsRegularMesh: boolean;
  108031. }
  108032. /**
  108033. * Class used to store all common mesh properties
  108034. */
  108035. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108036. /** No occlusion */
  108037. static OCCLUSION_TYPE_NONE: number;
  108038. /** Occlusion set to optimisitic */
  108039. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108040. /** Occlusion set to strict */
  108041. static OCCLUSION_TYPE_STRICT: number;
  108042. /** Use an accurante occlusion algorithm */
  108043. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108044. /** Use a conservative occlusion algorithm */
  108045. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108046. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108047. * Test order :
  108048. * Is the bounding sphere outside the frustum ?
  108049. * If not, are the bounding box vertices outside the frustum ?
  108050. * It not, then the cullable object is in the frustum.
  108051. */
  108052. static readonly CULLINGSTRATEGY_STANDARD: number;
  108053. /** Culling strategy : Bounding Sphere Only.
  108054. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108055. * It's also less accurate than the standard because some not visible objects can still be selected.
  108056. * Test : is the bounding sphere outside the frustum ?
  108057. * If not, then the cullable object is in the frustum.
  108058. */
  108059. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108060. /** Culling strategy : Optimistic Inclusion.
  108061. * This in an inclusion test first, then the standard exclusion test.
  108062. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108063. * 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.
  108064. * Anyway, it's as accurate as the standard strategy.
  108065. * Test :
  108066. * Is the cullable object bounding sphere center in the frustum ?
  108067. * If not, apply the default culling strategy.
  108068. */
  108069. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108070. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108071. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108072. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108073. * 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.
  108074. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108075. * Test :
  108076. * Is the cullable object bounding sphere center in the frustum ?
  108077. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108078. */
  108079. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108080. /**
  108081. * No billboard
  108082. */
  108083. static get BILLBOARDMODE_NONE(): number;
  108084. /** Billboard on X axis */
  108085. static get BILLBOARDMODE_X(): number;
  108086. /** Billboard on Y axis */
  108087. static get BILLBOARDMODE_Y(): number;
  108088. /** Billboard on Z axis */
  108089. static get BILLBOARDMODE_Z(): number;
  108090. /** Billboard on all axes */
  108091. static get BILLBOARDMODE_ALL(): number;
  108092. /** Billboard on using position instead of orientation */
  108093. static get BILLBOARDMODE_USE_POSITION(): number;
  108094. /** @hidden */
  108095. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108096. /**
  108097. * The culling strategy to use to check whether the mesh must be rendered or not.
  108098. * This value can be changed at any time and will be used on the next render mesh selection.
  108099. * The possible values are :
  108100. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108101. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108102. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108103. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108104. * Please read each static variable documentation to get details about the culling process.
  108105. * */
  108106. cullingStrategy: number;
  108107. /**
  108108. * Gets the number of facets in the mesh
  108109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108110. */
  108111. get facetNb(): number;
  108112. /**
  108113. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108115. */
  108116. get partitioningSubdivisions(): number;
  108117. set partitioningSubdivisions(nb: number);
  108118. /**
  108119. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108120. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108122. */
  108123. get partitioningBBoxRatio(): number;
  108124. set partitioningBBoxRatio(ratio: number);
  108125. /**
  108126. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108127. * Works only for updatable meshes.
  108128. * Doesn't work with multi-materials
  108129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108130. */
  108131. get mustDepthSortFacets(): boolean;
  108132. set mustDepthSortFacets(sort: boolean);
  108133. /**
  108134. * The location (Vector3) where the facet depth sort must be computed from.
  108135. * By default, the active camera position.
  108136. * Used only when facet depth sort is enabled
  108137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108138. */
  108139. get facetDepthSortFrom(): Vector3;
  108140. set facetDepthSortFrom(location: Vector3);
  108141. /**
  108142. * gets a boolean indicating if facetData is enabled
  108143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108144. */
  108145. get isFacetDataEnabled(): boolean;
  108146. /** @hidden */
  108147. _updateNonUniformScalingState(value: boolean): boolean;
  108148. /**
  108149. * An event triggered when this mesh collides with another one
  108150. */
  108151. onCollideObservable: Observable<AbstractMesh>;
  108152. /** Set a function to call when this mesh collides with another one */
  108153. set onCollide(callback: () => void);
  108154. /**
  108155. * An event triggered when the collision's position changes
  108156. */
  108157. onCollisionPositionChangeObservable: Observable<Vector3>;
  108158. /** Set a function to call when the collision's position changes */
  108159. set onCollisionPositionChange(callback: () => void);
  108160. /**
  108161. * An event triggered when material is changed
  108162. */
  108163. onMaterialChangedObservable: Observable<AbstractMesh>;
  108164. /**
  108165. * Gets or sets the orientation for POV movement & rotation
  108166. */
  108167. definedFacingForward: boolean;
  108168. /** @hidden */
  108169. _occlusionQuery: Nullable<WebGLQuery>;
  108170. /** @hidden */
  108171. _renderingGroup: Nullable<RenderingGroup>;
  108172. /**
  108173. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108174. */
  108175. get visibility(): number;
  108176. /**
  108177. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108178. */
  108179. set visibility(value: number);
  108180. /** Gets or sets the alpha index used to sort transparent meshes
  108181. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108182. */
  108183. alphaIndex: number;
  108184. /**
  108185. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108186. */
  108187. isVisible: boolean;
  108188. /**
  108189. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108190. */
  108191. isPickable: boolean;
  108192. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108193. showSubMeshesBoundingBox: boolean;
  108194. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108195. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108196. */
  108197. isBlocker: boolean;
  108198. /**
  108199. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108200. */
  108201. enablePointerMoveEvents: boolean;
  108202. /**
  108203. * Specifies the rendering group id for this mesh (0 by default)
  108204. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108205. */
  108206. renderingGroupId: number;
  108207. private _material;
  108208. /** Gets or sets current material */
  108209. get material(): Nullable<Material>;
  108210. set material(value: Nullable<Material>);
  108211. /**
  108212. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108213. * @see http://doc.babylonjs.com/babylon101/shadows
  108214. */
  108215. get receiveShadows(): boolean;
  108216. set receiveShadows(value: boolean);
  108217. /** Defines color to use when rendering outline */
  108218. outlineColor: Color3;
  108219. /** Define width to use when rendering outline */
  108220. outlineWidth: number;
  108221. /** Defines color to use when rendering overlay */
  108222. overlayColor: Color3;
  108223. /** Defines alpha to use when rendering overlay */
  108224. overlayAlpha: number;
  108225. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108226. get hasVertexAlpha(): boolean;
  108227. set hasVertexAlpha(value: boolean);
  108228. /** 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) */
  108229. get useVertexColors(): boolean;
  108230. set useVertexColors(value: boolean);
  108231. /**
  108232. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108233. */
  108234. get computeBonesUsingShaders(): boolean;
  108235. set computeBonesUsingShaders(value: boolean);
  108236. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108237. get numBoneInfluencers(): number;
  108238. set numBoneInfluencers(value: number);
  108239. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108240. get applyFog(): boolean;
  108241. set applyFog(value: boolean);
  108242. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108243. useOctreeForRenderingSelection: boolean;
  108244. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108245. useOctreeForPicking: boolean;
  108246. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108247. useOctreeForCollisions: boolean;
  108248. /**
  108249. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108250. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108251. */
  108252. get layerMask(): number;
  108253. set layerMask(value: number);
  108254. /**
  108255. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  108256. */
  108257. alwaysSelectAsActiveMesh: boolean;
  108258. /**
  108259. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  108260. */
  108261. doNotSyncBoundingInfo: boolean;
  108262. /**
  108263. * Gets or sets the current action manager
  108264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108265. */
  108266. actionManager: Nullable<AbstractActionManager>;
  108267. private _meshCollisionData;
  108268. /**
  108269. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  108270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108271. */
  108272. ellipsoid: Vector3;
  108273. /**
  108274. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  108275. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108276. */
  108277. ellipsoidOffset: Vector3;
  108278. /**
  108279. * Gets or sets a collision mask used to mask collisions (default is -1).
  108280. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108281. */
  108282. get collisionMask(): number;
  108283. set collisionMask(mask: number);
  108284. /**
  108285. * Gets or sets the current collision group mask (-1 by default).
  108286. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108287. */
  108288. get collisionGroup(): number;
  108289. set collisionGroup(mask: number);
  108290. /**
  108291. * Gets or sets current surrounding meshes (null by default).
  108292. *
  108293. * By default collision detection is tested against every mesh in the scene.
  108294. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  108295. * meshes will be tested for the collision.
  108296. *
  108297. * Note: if set to an empty array no collision will happen when this mesh is moved.
  108298. */
  108299. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  108300. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  108301. /**
  108302. * Defines edge width used when edgesRenderer is enabled
  108303. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108304. */
  108305. edgesWidth: number;
  108306. /**
  108307. * Defines edge color used when edgesRenderer is enabled
  108308. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108309. */
  108310. edgesColor: Color4;
  108311. /** @hidden */
  108312. _edgesRenderer: Nullable<IEdgesRenderer>;
  108313. /** @hidden */
  108314. _masterMesh: Nullable<AbstractMesh>;
  108315. /** @hidden */
  108316. _boundingInfo: Nullable<BoundingInfo>;
  108317. /** @hidden */
  108318. _renderId: number;
  108319. /**
  108320. * Gets or sets the list of subMeshes
  108321. * @see http://doc.babylonjs.com/how_to/multi_materials
  108322. */
  108323. subMeshes: SubMesh[];
  108324. /** @hidden */
  108325. _intersectionsInProgress: AbstractMesh[];
  108326. /** @hidden */
  108327. _unIndexed: boolean;
  108328. /** @hidden */
  108329. _lightSources: Light[];
  108330. /** Gets the list of lights affecting that mesh */
  108331. get lightSources(): Light[];
  108332. /** @hidden */
  108333. get _positions(): Nullable<Vector3[]>;
  108334. /** @hidden */
  108335. _waitingData: {
  108336. lods: Nullable<any>;
  108337. actions: Nullable<any>;
  108338. freezeWorldMatrix: Nullable<boolean>;
  108339. };
  108340. /** @hidden */
  108341. _bonesTransformMatrices: Nullable<Float32Array>;
  108342. /** @hidden */
  108343. _transformMatrixTexture: Nullable<RawTexture>;
  108344. /**
  108345. * Gets or sets a skeleton to apply skining transformations
  108346. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108347. */
  108348. set skeleton(value: Nullable<Skeleton>);
  108349. get skeleton(): Nullable<Skeleton>;
  108350. /**
  108351. * An event triggered when the mesh is rebuilt.
  108352. */
  108353. onRebuildObservable: Observable<AbstractMesh>;
  108354. /**
  108355. * Creates a new AbstractMesh
  108356. * @param name defines the name of the mesh
  108357. * @param scene defines the hosting scene
  108358. */
  108359. constructor(name: string, scene?: Nullable<Scene>);
  108360. /**
  108361. * Returns the string "AbstractMesh"
  108362. * @returns "AbstractMesh"
  108363. */
  108364. getClassName(): string;
  108365. /**
  108366. * Gets a string representation of the current mesh
  108367. * @param fullDetails defines a boolean indicating if full details must be included
  108368. * @returns a string representation of the current mesh
  108369. */
  108370. toString(fullDetails?: boolean): string;
  108371. /**
  108372. * @hidden
  108373. */
  108374. protected _getEffectiveParent(): Nullable<Node>;
  108375. /** @hidden */
  108376. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108377. /** @hidden */
  108378. _rebuild(): void;
  108379. /** @hidden */
  108380. _resyncLightSources(): void;
  108381. /** @hidden */
  108382. _resyncLightSource(light: Light): void;
  108383. /** @hidden */
  108384. _unBindEffect(): void;
  108385. /** @hidden */
  108386. _removeLightSource(light: Light, dispose: boolean): void;
  108387. private _markSubMeshesAsDirty;
  108388. /** @hidden */
  108389. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  108390. /** @hidden */
  108391. _markSubMeshesAsAttributesDirty(): void;
  108392. /** @hidden */
  108393. _markSubMeshesAsMiscDirty(): void;
  108394. /**
  108395. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  108396. */
  108397. get scaling(): Vector3;
  108398. set scaling(newScaling: Vector3);
  108399. /**
  108400. * Returns true if the mesh is blocked. Implemented by child classes
  108401. */
  108402. get isBlocked(): boolean;
  108403. /**
  108404. * Returns the mesh itself by default. Implemented by child classes
  108405. * @param camera defines the camera to use to pick the right LOD level
  108406. * @returns the currentAbstractMesh
  108407. */
  108408. getLOD(camera: Camera): Nullable<AbstractMesh>;
  108409. /**
  108410. * Returns 0 by default. Implemented by child classes
  108411. * @returns an integer
  108412. */
  108413. getTotalVertices(): number;
  108414. /**
  108415. * Returns a positive integer : the total number of indices in this mesh geometry.
  108416. * @returns the numner of indices or zero if the mesh has no geometry.
  108417. */
  108418. getTotalIndices(): number;
  108419. /**
  108420. * Returns null by default. Implemented by child classes
  108421. * @returns null
  108422. */
  108423. getIndices(): Nullable<IndicesArray>;
  108424. /**
  108425. * Returns the array of the requested vertex data kind. Implemented by child classes
  108426. * @param kind defines the vertex data kind to use
  108427. * @returns null
  108428. */
  108429. getVerticesData(kind: string): Nullable<FloatArray>;
  108430. /**
  108431. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108432. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108433. * Note that a new underlying VertexBuffer object is created each call.
  108434. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108435. * @param kind defines vertex data kind:
  108436. * * VertexBuffer.PositionKind
  108437. * * VertexBuffer.UVKind
  108438. * * VertexBuffer.UV2Kind
  108439. * * VertexBuffer.UV3Kind
  108440. * * VertexBuffer.UV4Kind
  108441. * * VertexBuffer.UV5Kind
  108442. * * VertexBuffer.UV6Kind
  108443. * * VertexBuffer.ColorKind
  108444. * * VertexBuffer.MatricesIndicesKind
  108445. * * VertexBuffer.MatricesIndicesExtraKind
  108446. * * VertexBuffer.MatricesWeightsKind
  108447. * * VertexBuffer.MatricesWeightsExtraKind
  108448. * @param data defines the data source
  108449. * @param updatable defines if the data must be flagged as updatable (or static)
  108450. * @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
  108451. * @returns the current mesh
  108452. */
  108453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108454. /**
  108455. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108456. * If the mesh has no geometry, it is simply returned as it is.
  108457. * @param kind defines vertex data kind:
  108458. * * VertexBuffer.PositionKind
  108459. * * VertexBuffer.UVKind
  108460. * * VertexBuffer.UV2Kind
  108461. * * VertexBuffer.UV3Kind
  108462. * * VertexBuffer.UV4Kind
  108463. * * VertexBuffer.UV5Kind
  108464. * * VertexBuffer.UV6Kind
  108465. * * VertexBuffer.ColorKind
  108466. * * VertexBuffer.MatricesIndicesKind
  108467. * * VertexBuffer.MatricesIndicesExtraKind
  108468. * * VertexBuffer.MatricesWeightsKind
  108469. * * VertexBuffer.MatricesWeightsExtraKind
  108470. * @param data defines the data source
  108471. * @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
  108472. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  108473. * @returns the current mesh
  108474. */
  108475. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108476. /**
  108477. * Sets the mesh indices,
  108478. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108479. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  108480. * @param totalVertices Defines the total number of vertices
  108481. * @returns the current mesh
  108482. */
  108483. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  108484. /**
  108485. * Gets a boolean indicating if specific vertex data is present
  108486. * @param kind defines the vertex data kind to use
  108487. * @returns true is data kind is present
  108488. */
  108489. isVerticesDataPresent(kind: string): boolean;
  108490. /**
  108491. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  108492. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  108493. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  108494. * @returns a BoundingInfo
  108495. */
  108496. getBoundingInfo(): BoundingInfo;
  108497. /**
  108498. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  108499. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  108500. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  108501. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  108502. * @returns the current mesh
  108503. */
  108504. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  108505. /**
  108506. * Overwrite the current bounding info
  108507. * @param boundingInfo defines the new bounding info
  108508. * @returns the current mesh
  108509. */
  108510. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  108511. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  108512. get useBones(): boolean;
  108513. /** @hidden */
  108514. _preActivate(): void;
  108515. /** @hidden */
  108516. _preActivateForIntermediateRendering(renderId: number): void;
  108517. /** @hidden */
  108518. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108519. /** @hidden */
  108520. _postActivate(): void;
  108521. /** @hidden */
  108522. _freeze(): void;
  108523. /** @hidden */
  108524. _unFreeze(): void;
  108525. /**
  108526. * Gets the current world matrix
  108527. * @returns a Matrix
  108528. */
  108529. getWorldMatrix(): Matrix;
  108530. /** @hidden */
  108531. _getWorldMatrixDeterminant(): number;
  108532. /**
  108533. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  108534. */
  108535. get isAnInstance(): boolean;
  108536. /**
  108537. * Gets a boolean indicating if this mesh has instances
  108538. */
  108539. get hasInstances(): boolean;
  108540. /**
  108541. * Gets a boolean indicating if this mesh has thin instances
  108542. */
  108543. get hasThinInstances(): boolean;
  108544. /**
  108545. * Perform relative position change from the point of view of behind the front of the mesh.
  108546. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108547. * Supports definition of mesh facing forward or backward
  108548. * @param amountRight defines the distance on the right axis
  108549. * @param amountUp defines the distance on the up axis
  108550. * @param amountForward defines the distance on the forward axis
  108551. * @returns the current mesh
  108552. */
  108553. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  108554. /**
  108555. * Calculate relative position change from the point of view of behind the front of the mesh.
  108556. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108557. * Supports definition of mesh facing forward or backward
  108558. * @param amountRight defines the distance on the right axis
  108559. * @param amountUp defines the distance on the up axis
  108560. * @param amountForward defines the distance on the forward axis
  108561. * @returns the new displacement vector
  108562. */
  108563. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  108564. /**
  108565. * Perform relative rotation change from the point of view of behind the front of the mesh.
  108566. * Supports definition of mesh facing forward or backward
  108567. * @param flipBack defines the flip
  108568. * @param twirlClockwise defines the twirl
  108569. * @param tiltRight defines the tilt
  108570. * @returns the current mesh
  108571. */
  108572. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  108573. /**
  108574. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  108575. * Supports definition of mesh facing forward or backward.
  108576. * @param flipBack defines the flip
  108577. * @param twirlClockwise defines the twirl
  108578. * @param tiltRight defines the tilt
  108579. * @returns the new rotation vector
  108580. */
  108581. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  108582. /**
  108583. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108584. * This means the mesh underlying bounding box and sphere are recomputed.
  108585. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108586. * @returns the current mesh
  108587. */
  108588. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  108589. /** @hidden */
  108590. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  108591. /** @hidden */
  108592. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  108593. /** @hidden */
  108594. _updateBoundingInfo(): AbstractMesh;
  108595. /** @hidden */
  108596. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  108597. /** @hidden */
  108598. protected _afterComputeWorldMatrix(): void;
  108599. /** @hidden */
  108600. get _effectiveMesh(): AbstractMesh;
  108601. /**
  108602. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108603. * A mesh is in the frustum if its bounding box intersects the frustum
  108604. * @param frustumPlanes defines the frustum to test
  108605. * @returns true if the mesh is in the frustum planes
  108606. */
  108607. isInFrustum(frustumPlanes: Plane[]): boolean;
  108608. /**
  108609. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  108610. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  108611. * @param frustumPlanes defines the frustum to test
  108612. * @returns true if the mesh is completely in the frustum planes
  108613. */
  108614. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  108615. /**
  108616. * True if the mesh intersects another mesh or a SolidParticle object
  108617. * @param mesh defines a target mesh or SolidParticle to test
  108618. * @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)
  108619. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  108620. * @returns true if there is an intersection
  108621. */
  108622. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  108623. /**
  108624. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  108625. * @param point defines the point to test
  108626. * @returns true if there is an intersection
  108627. */
  108628. intersectsPoint(point: Vector3): boolean;
  108629. /**
  108630. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  108631. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108632. */
  108633. get checkCollisions(): boolean;
  108634. set checkCollisions(collisionEnabled: boolean);
  108635. /**
  108636. * Gets Collider object used to compute collisions (not physics)
  108637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108638. */
  108639. get collider(): Nullable<Collider>;
  108640. /**
  108641. * Move the mesh using collision engine
  108642. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108643. * @param displacement defines the requested displacement vector
  108644. * @returns the current mesh
  108645. */
  108646. moveWithCollisions(displacement: Vector3): AbstractMesh;
  108647. private _onCollisionPositionChange;
  108648. /** @hidden */
  108649. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  108650. /** @hidden */
  108651. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  108652. /** @hidden */
  108653. _checkCollision(collider: Collider): AbstractMesh;
  108654. /** @hidden */
  108655. _generatePointsArray(): boolean;
  108656. /**
  108657. * Checks if the passed Ray intersects with the mesh
  108658. * @param ray defines the ray to use
  108659. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  108660. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108661. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  108662. * @returns the picking info
  108663. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  108664. */
  108665. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  108666. /**
  108667. * Clones the current mesh
  108668. * @param name defines the mesh name
  108669. * @param newParent defines the new mesh parent
  108670. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  108671. * @returns the new mesh
  108672. */
  108673. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  108674. /**
  108675. * Disposes all the submeshes of the current meshnp
  108676. * @returns the current mesh
  108677. */
  108678. releaseSubMeshes(): AbstractMesh;
  108679. /**
  108680. * Releases resources associated with this abstract mesh.
  108681. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108682. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108683. */
  108684. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108685. /**
  108686. * Adds the passed mesh as a child to the current mesh
  108687. * @param mesh defines the child mesh
  108688. * @returns the current mesh
  108689. */
  108690. addChild(mesh: AbstractMesh): AbstractMesh;
  108691. /**
  108692. * Removes the passed mesh from the current mesh children list
  108693. * @param mesh defines the child mesh
  108694. * @returns the current mesh
  108695. */
  108696. removeChild(mesh: AbstractMesh): AbstractMesh;
  108697. /** @hidden */
  108698. private _initFacetData;
  108699. /**
  108700. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  108701. * This method can be called within the render loop.
  108702. * 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
  108703. * @returns the current mesh
  108704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108705. */
  108706. updateFacetData(): AbstractMesh;
  108707. /**
  108708. * Returns the facetLocalNormals array.
  108709. * The normals are expressed in the mesh local spac
  108710. * @returns an array of Vector3
  108711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108712. */
  108713. getFacetLocalNormals(): Vector3[];
  108714. /**
  108715. * Returns the facetLocalPositions array.
  108716. * The facet positions are expressed in the mesh local space
  108717. * @returns an array of Vector3
  108718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108719. */
  108720. getFacetLocalPositions(): Vector3[];
  108721. /**
  108722. * Returns the facetLocalPartioning array
  108723. * @returns an array of array of numbers
  108724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108725. */
  108726. getFacetLocalPartitioning(): number[][];
  108727. /**
  108728. * Returns the i-th facet position in the world system.
  108729. * This method allocates a new Vector3 per call
  108730. * @param i defines the facet index
  108731. * @returns a new Vector3
  108732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108733. */
  108734. getFacetPosition(i: number): Vector3;
  108735. /**
  108736. * Sets the reference Vector3 with the i-th facet position in the world system
  108737. * @param i defines the facet index
  108738. * @param ref defines the target vector
  108739. * @returns the current mesh
  108740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108741. */
  108742. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  108743. /**
  108744. * Returns the i-th facet normal in the world system.
  108745. * This method allocates a new Vector3 per call
  108746. * @param i defines the facet index
  108747. * @returns a new Vector3
  108748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108749. */
  108750. getFacetNormal(i: number): Vector3;
  108751. /**
  108752. * Sets the reference Vector3 with the i-th facet normal in the world system
  108753. * @param i defines the facet index
  108754. * @param ref defines the target vector
  108755. * @returns the current mesh
  108756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108757. */
  108758. getFacetNormalToRef(i: number, ref: Vector3): this;
  108759. /**
  108760. * 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)
  108761. * @param x defines x coordinate
  108762. * @param y defines y coordinate
  108763. * @param z defines z coordinate
  108764. * @returns the array of facet indexes
  108765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108766. */
  108767. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  108768. /**
  108769. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  108770. * @param projected sets as the (x,y,z) world projection on the facet
  108771. * @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
  108772. * @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
  108773. * @param x defines x coordinate
  108774. * @param y defines y coordinate
  108775. * @param z defines z coordinate
  108776. * @returns the face index if found (or null instead)
  108777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108778. */
  108779. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108780. /**
  108781. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  108782. * @param projected sets as the (x,y,z) local projection on the facet
  108783. * @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
  108784. * @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
  108785. * @param x defines x coordinate
  108786. * @param y defines y coordinate
  108787. * @param z defines z coordinate
  108788. * @returns the face index if found (or null instead)
  108789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108790. */
  108791. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108792. /**
  108793. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  108794. * @returns the parameters
  108795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108796. */
  108797. getFacetDataParameters(): any;
  108798. /**
  108799. * Disables the feature FacetData and frees the related memory
  108800. * @returns the current mesh
  108801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108802. */
  108803. disableFacetData(): AbstractMesh;
  108804. /**
  108805. * Updates the AbstractMesh indices array
  108806. * @param indices defines the data source
  108807. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108808. * @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)
  108809. * @returns the current mesh
  108810. */
  108811. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108812. /**
  108813. * Creates new normals data for the mesh
  108814. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  108815. * @returns the current mesh
  108816. */
  108817. createNormals(updatable: boolean): AbstractMesh;
  108818. /**
  108819. * Align the mesh with a normal
  108820. * @param normal defines the normal to use
  108821. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  108822. * @returns the current mesh
  108823. */
  108824. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  108825. /** @hidden */
  108826. _checkOcclusionQuery(): boolean;
  108827. /**
  108828. * Disables the mesh edge rendering mode
  108829. * @returns the currentAbstractMesh
  108830. */
  108831. disableEdgesRendering(): AbstractMesh;
  108832. /**
  108833. * Enables the edge rendering mode on the mesh.
  108834. * This mode makes the mesh edges visible
  108835. * @param epsilon defines the maximal distance between two angles to detect a face
  108836. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  108837. * @returns the currentAbstractMesh
  108838. * @see https://www.babylonjs-playground.com/#19O9TU#0
  108839. */
  108840. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  108841. }
  108842. }
  108843. declare module BABYLON {
  108844. /**
  108845. * Interface used to define ActionEvent
  108846. */
  108847. export interface IActionEvent {
  108848. /** The mesh or sprite that triggered the action */
  108849. source: any;
  108850. /** The X mouse cursor position at the time of the event */
  108851. pointerX: number;
  108852. /** The Y mouse cursor position at the time of the event */
  108853. pointerY: number;
  108854. /** The mesh that is currently pointed at (can be null) */
  108855. meshUnderPointer: Nullable<AbstractMesh>;
  108856. /** the original (browser) event that triggered the ActionEvent */
  108857. sourceEvent?: any;
  108858. /** additional data for the event */
  108859. additionalData?: any;
  108860. }
  108861. /**
  108862. * ActionEvent is the event being sent when an action is triggered.
  108863. */
  108864. export class ActionEvent implements IActionEvent {
  108865. /** The mesh or sprite that triggered the action */
  108866. source: any;
  108867. /** The X mouse cursor position at the time of the event */
  108868. pointerX: number;
  108869. /** The Y mouse cursor position at the time of the event */
  108870. pointerY: number;
  108871. /** The mesh that is currently pointed at (can be null) */
  108872. meshUnderPointer: Nullable<AbstractMesh>;
  108873. /** the original (browser) event that triggered the ActionEvent */
  108874. sourceEvent?: any;
  108875. /** additional data for the event */
  108876. additionalData?: any;
  108877. /**
  108878. * Creates a new ActionEvent
  108879. * @param source The mesh or sprite that triggered the action
  108880. * @param pointerX The X mouse cursor position at the time of the event
  108881. * @param pointerY The Y mouse cursor position at the time of the event
  108882. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  108883. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  108884. * @param additionalData additional data for the event
  108885. */
  108886. constructor(
  108887. /** The mesh or sprite that triggered the action */
  108888. source: any,
  108889. /** The X mouse cursor position at the time of the event */
  108890. pointerX: number,
  108891. /** The Y mouse cursor position at the time of the event */
  108892. pointerY: number,
  108893. /** The mesh that is currently pointed at (can be null) */
  108894. meshUnderPointer: Nullable<AbstractMesh>,
  108895. /** the original (browser) event that triggered the ActionEvent */
  108896. sourceEvent?: any,
  108897. /** additional data for the event */
  108898. additionalData?: any);
  108899. /**
  108900. * Helper function to auto-create an ActionEvent from a source mesh.
  108901. * @param source The source mesh that triggered the event
  108902. * @param evt The original (browser) event
  108903. * @param additionalData additional data for the event
  108904. * @returns the new ActionEvent
  108905. */
  108906. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  108907. /**
  108908. * Helper function to auto-create an ActionEvent from a source sprite
  108909. * @param source The source sprite that triggered the event
  108910. * @param scene Scene associated with the sprite
  108911. * @param evt The original (browser) event
  108912. * @param additionalData additional data for the event
  108913. * @returns the new ActionEvent
  108914. */
  108915. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  108916. /**
  108917. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  108918. * @param scene the scene where the event occurred
  108919. * @param evt The original (browser) event
  108920. * @returns the new ActionEvent
  108921. */
  108922. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  108923. /**
  108924. * Helper function to auto-create an ActionEvent from a primitive
  108925. * @param prim defines the target primitive
  108926. * @param pointerPos defines the pointer position
  108927. * @param evt The original (browser) event
  108928. * @param additionalData additional data for the event
  108929. * @returns the new ActionEvent
  108930. */
  108931. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  108932. }
  108933. }
  108934. declare module BABYLON {
  108935. /**
  108936. * Abstract class used to decouple action Manager from scene and meshes.
  108937. * Do not instantiate.
  108938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108939. */
  108940. export abstract class AbstractActionManager implements IDisposable {
  108941. /** Gets the list of active triggers */
  108942. static Triggers: {
  108943. [key: string]: number;
  108944. };
  108945. /** Gets the cursor to use when hovering items */
  108946. hoverCursor: string;
  108947. /** Gets the list of actions */
  108948. actions: IAction[];
  108949. /**
  108950. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  108951. */
  108952. isRecursive: boolean;
  108953. /**
  108954. * Releases all associated resources
  108955. */
  108956. abstract dispose(): void;
  108957. /**
  108958. * Does this action manager has pointer triggers
  108959. */
  108960. abstract get hasPointerTriggers(): boolean;
  108961. /**
  108962. * Does this action manager has pick triggers
  108963. */
  108964. abstract get hasPickTriggers(): boolean;
  108965. /**
  108966. * Process a specific trigger
  108967. * @param trigger defines the trigger to process
  108968. * @param evt defines the event details to be processed
  108969. */
  108970. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  108971. /**
  108972. * Does this action manager handles actions of any of the given triggers
  108973. * @param triggers defines the triggers to be tested
  108974. * @return a boolean indicating whether one (or more) of the triggers is handled
  108975. */
  108976. abstract hasSpecificTriggers(triggers: number[]): boolean;
  108977. /**
  108978. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  108979. * speed.
  108980. * @param triggerA defines the trigger to be tested
  108981. * @param triggerB defines the trigger to be tested
  108982. * @return a boolean indicating whether one (or more) of the triggers is handled
  108983. */
  108984. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  108985. /**
  108986. * Does this action manager handles actions of a given trigger
  108987. * @param trigger defines the trigger to be tested
  108988. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  108989. * @return whether the trigger is handled
  108990. */
  108991. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  108992. /**
  108993. * Serialize this manager to a JSON object
  108994. * @param name defines the property name to store this manager
  108995. * @returns a JSON representation of this manager
  108996. */
  108997. abstract serialize(name: string): any;
  108998. /**
  108999. * Registers an action to this action manager
  109000. * @param action defines the action to be registered
  109001. * @return the action amended (prepared) after registration
  109002. */
  109003. abstract registerAction(action: IAction): Nullable<IAction>;
  109004. /**
  109005. * Unregisters an action to this action manager
  109006. * @param action defines the action to be unregistered
  109007. * @return a boolean indicating whether the action has been unregistered
  109008. */
  109009. abstract unregisterAction(action: IAction): Boolean;
  109010. /**
  109011. * Does exist one action manager with at least one trigger
  109012. **/
  109013. static get HasTriggers(): boolean;
  109014. /**
  109015. * Does exist one action manager with at least one pick trigger
  109016. **/
  109017. static get HasPickTriggers(): boolean;
  109018. /**
  109019. * Does exist one action manager that handles actions of a given trigger
  109020. * @param trigger defines the trigger to be tested
  109021. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109022. **/
  109023. static HasSpecificTrigger(trigger: number): boolean;
  109024. }
  109025. }
  109026. declare module BABYLON {
  109027. /**
  109028. * Defines how a node can be built from a string name.
  109029. */
  109030. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109031. /**
  109032. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109033. */
  109034. export class Node implements IBehaviorAware<Node> {
  109035. /** @hidden */
  109036. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109037. private static _NodeConstructors;
  109038. /**
  109039. * Add a new node constructor
  109040. * @param type defines the type name of the node to construct
  109041. * @param constructorFunc defines the constructor function
  109042. */
  109043. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109044. /**
  109045. * Returns a node constructor based on type name
  109046. * @param type defines the type name
  109047. * @param name defines the new node name
  109048. * @param scene defines the hosting scene
  109049. * @param options defines optional options to transmit to constructors
  109050. * @returns the new constructor or null
  109051. */
  109052. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109053. /**
  109054. * Gets or sets the name of the node
  109055. */
  109056. name: string;
  109057. /**
  109058. * Gets or sets the id of the node
  109059. */
  109060. id: string;
  109061. /**
  109062. * Gets or sets the unique id of the node
  109063. */
  109064. uniqueId: number;
  109065. /**
  109066. * Gets or sets a string used to store user defined state for the node
  109067. */
  109068. state: string;
  109069. /**
  109070. * Gets or sets an object used to store user defined information for the node
  109071. */
  109072. metadata: any;
  109073. /**
  109074. * For internal use only. Please do not use.
  109075. */
  109076. reservedDataStore: any;
  109077. /**
  109078. * List of inspectable custom properties (used by the Inspector)
  109079. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109080. */
  109081. inspectableCustomProperties: IInspectable[];
  109082. private _doNotSerialize;
  109083. /**
  109084. * Gets or sets a boolean used to define if the node must be serialized
  109085. */
  109086. get doNotSerialize(): boolean;
  109087. set doNotSerialize(value: boolean);
  109088. /** @hidden */
  109089. _isDisposed: boolean;
  109090. /**
  109091. * Gets a list of Animations associated with the node
  109092. */
  109093. animations: Animation[];
  109094. protected _ranges: {
  109095. [name: string]: Nullable<AnimationRange>;
  109096. };
  109097. /**
  109098. * Callback raised when the node is ready to be used
  109099. */
  109100. onReady: Nullable<(node: Node) => void>;
  109101. private _isEnabled;
  109102. private _isParentEnabled;
  109103. private _isReady;
  109104. /** @hidden */
  109105. _currentRenderId: number;
  109106. private _parentUpdateId;
  109107. /** @hidden */
  109108. _childUpdateId: number;
  109109. /** @hidden */
  109110. _waitingParentId: Nullable<string>;
  109111. /** @hidden */
  109112. _scene: Scene;
  109113. /** @hidden */
  109114. _cache: any;
  109115. private _parentNode;
  109116. private _children;
  109117. /** @hidden */
  109118. _worldMatrix: Matrix;
  109119. /** @hidden */
  109120. _worldMatrixDeterminant: number;
  109121. /** @hidden */
  109122. _worldMatrixDeterminantIsDirty: boolean;
  109123. /** @hidden */
  109124. private _sceneRootNodesIndex;
  109125. /**
  109126. * Gets a boolean indicating if the node has been disposed
  109127. * @returns true if the node was disposed
  109128. */
  109129. isDisposed(): boolean;
  109130. /**
  109131. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109132. * @see https://doc.babylonjs.com/how_to/parenting
  109133. */
  109134. set parent(parent: Nullable<Node>);
  109135. get parent(): Nullable<Node>;
  109136. /** @hidden */
  109137. _addToSceneRootNodes(): void;
  109138. /** @hidden */
  109139. _removeFromSceneRootNodes(): void;
  109140. private _animationPropertiesOverride;
  109141. /**
  109142. * Gets or sets the animation properties override
  109143. */
  109144. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109145. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109146. /**
  109147. * Gets a string idenfifying the name of the class
  109148. * @returns "Node" string
  109149. */
  109150. getClassName(): string;
  109151. /** @hidden */
  109152. readonly _isNode: boolean;
  109153. /**
  109154. * An event triggered when the mesh is disposed
  109155. */
  109156. onDisposeObservable: Observable<Node>;
  109157. private _onDisposeObserver;
  109158. /**
  109159. * Sets a callback that will be raised when the node will be disposed
  109160. */
  109161. set onDispose(callback: () => void);
  109162. /**
  109163. * Creates a new Node
  109164. * @param name the name and id to be given to this node
  109165. * @param scene the scene this node will be added to
  109166. */
  109167. constructor(name: string, scene?: Nullable<Scene>);
  109168. /**
  109169. * Gets the scene of the node
  109170. * @returns a scene
  109171. */
  109172. getScene(): Scene;
  109173. /**
  109174. * Gets the engine of the node
  109175. * @returns a Engine
  109176. */
  109177. getEngine(): Engine;
  109178. private _behaviors;
  109179. /**
  109180. * Attach a behavior to the node
  109181. * @see http://doc.babylonjs.com/features/behaviour
  109182. * @param behavior defines the behavior to attach
  109183. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109184. * @returns the current Node
  109185. */
  109186. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109187. /**
  109188. * Remove an attached behavior
  109189. * @see http://doc.babylonjs.com/features/behaviour
  109190. * @param behavior defines the behavior to attach
  109191. * @returns the current Node
  109192. */
  109193. removeBehavior(behavior: Behavior<Node>): Node;
  109194. /**
  109195. * Gets the list of attached behaviors
  109196. * @see http://doc.babylonjs.com/features/behaviour
  109197. */
  109198. get behaviors(): Behavior<Node>[];
  109199. /**
  109200. * Gets an attached behavior by name
  109201. * @param name defines the name of the behavior to look for
  109202. * @see http://doc.babylonjs.com/features/behaviour
  109203. * @returns null if behavior was not found else the requested behavior
  109204. */
  109205. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109206. /**
  109207. * Returns the latest update of the World matrix
  109208. * @returns a Matrix
  109209. */
  109210. getWorldMatrix(): Matrix;
  109211. /** @hidden */
  109212. _getWorldMatrixDeterminant(): number;
  109213. /**
  109214. * Returns directly the latest state of the mesh World matrix.
  109215. * A Matrix is returned.
  109216. */
  109217. get worldMatrixFromCache(): Matrix;
  109218. /** @hidden */
  109219. _initCache(): void;
  109220. /** @hidden */
  109221. updateCache(force?: boolean): void;
  109222. /** @hidden */
  109223. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109224. /** @hidden */
  109225. _updateCache(ignoreParentClass?: boolean): void;
  109226. /** @hidden */
  109227. _isSynchronized(): boolean;
  109228. /** @hidden */
  109229. _markSyncedWithParent(): void;
  109230. /** @hidden */
  109231. isSynchronizedWithParent(): boolean;
  109232. /** @hidden */
  109233. isSynchronized(): boolean;
  109234. /**
  109235. * Is this node ready to be used/rendered
  109236. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109237. * @return true if the node is ready
  109238. */
  109239. isReady(completeCheck?: boolean): boolean;
  109240. /**
  109241. * Is this node enabled?
  109242. * 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
  109243. * @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
  109244. * @return whether this node (and its parent) is enabled
  109245. */
  109246. isEnabled(checkAncestors?: boolean): boolean;
  109247. /** @hidden */
  109248. protected _syncParentEnabledState(): void;
  109249. /**
  109250. * Set the enabled state of this node
  109251. * @param value defines the new enabled state
  109252. */
  109253. setEnabled(value: boolean): void;
  109254. /**
  109255. * Is this node a descendant of the given node?
  109256. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  109257. * @param ancestor defines the parent node to inspect
  109258. * @returns a boolean indicating if this node is a descendant of the given node
  109259. */
  109260. isDescendantOf(ancestor: Node): boolean;
  109261. /** @hidden */
  109262. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  109263. /**
  109264. * Will return all nodes that have this node as ascendant
  109265. * @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
  109266. * @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
  109267. * @return all children nodes of all types
  109268. */
  109269. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  109270. /**
  109271. * Get all child-meshes of this node
  109272. * @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)
  109273. * @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
  109274. * @returns an array of AbstractMesh
  109275. */
  109276. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  109277. /**
  109278. * Get all direct children of this node
  109279. * @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
  109280. * @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)
  109281. * @returns an array of Node
  109282. */
  109283. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  109284. /** @hidden */
  109285. _setReady(state: boolean): void;
  109286. /**
  109287. * Get an animation by name
  109288. * @param name defines the name of the animation to look for
  109289. * @returns null if not found else the requested animation
  109290. */
  109291. getAnimationByName(name: string): Nullable<Animation>;
  109292. /**
  109293. * Creates an animation range for this node
  109294. * @param name defines the name of the range
  109295. * @param from defines the starting key
  109296. * @param to defines the end key
  109297. */
  109298. createAnimationRange(name: string, from: number, to: number): void;
  109299. /**
  109300. * Delete a specific animation range
  109301. * @param name defines the name of the range to delete
  109302. * @param deleteFrames defines if animation frames from the range must be deleted as well
  109303. */
  109304. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  109305. /**
  109306. * Get an animation range by name
  109307. * @param name defines the name of the animation range to look for
  109308. * @returns null if not found else the requested animation range
  109309. */
  109310. getAnimationRange(name: string): Nullable<AnimationRange>;
  109311. /**
  109312. * Gets the list of all animation ranges defined on this node
  109313. * @returns an array
  109314. */
  109315. getAnimationRanges(): Nullable<AnimationRange>[];
  109316. /**
  109317. * Will start the animation sequence
  109318. * @param name defines the range frames for animation sequence
  109319. * @param loop defines if the animation should loop (false by default)
  109320. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  109321. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  109322. * @returns the object created for this animation. If range does not exist, it will return null
  109323. */
  109324. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  109325. /**
  109326. * Serialize animation ranges into a JSON compatible object
  109327. * @returns serialization object
  109328. */
  109329. serializeAnimationRanges(): any;
  109330. /**
  109331. * Computes the world matrix of the node
  109332. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  109333. * @returns the world matrix
  109334. */
  109335. computeWorldMatrix(force?: boolean): Matrix;
  109336. /**
  109337. * Releases resources associated with this node.
  109338. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109339. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109340. */
  109341. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109342. /**
  109343. * Parse animation range data from a serialization object and store them into a given node
  109344. * @param node defines where to store the animation ranges
  109345. * @param parsedNode defines the serialization object to read data from
  109346. * @param scene defines the hosting scene
  109347. */
  109348. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  109349. /**
  109350. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  109351. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109352. * @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
  109353. * @returns the new bounding vectors
  109354. */
  109355. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  109356. min: Vector3;
  109357. max: Vector3;
  109358. };
  109359. }
  109360. }
  109361. declare module BABYLON {
  109362. /**
  109363. * @hidden
  109364. */
  109365. export class _IAnimationState {
  109366. key: number;
  109367. repeatCount: number;
  109368. workValue?: any;
  109369. loopMode?: number;
  109370. offsetValue?: any;
  109371. highLimitValue?: any;
  109372. }
  109373. /**
  109374. * Class used to store any kind of animation
  109375. */
  109376. export class Animation {
  109377. /**Name of the animation */
  109378. name: string;
  109379. /**Property to animate */
  109380. targetProperty: string;
  109381. /**The frames per second of the animation */
  109382. framePerSecond: number;
  109383. /**The data type of the animation */
  109384. dataType: number;
  109385. /**The loop mode of the animation */
  109386. loopMode?: number | undefined;
  109387. /**Specifies if blending should be enabled */
  109388. enableBlending?: boolean | undefined;
  109389. /**
  109390. * Use matrix interpolation instead of using direct key value when animating matrices
  109391. */
  109392. static AllowMatricesInterpolation: boolean;
  109393. /**
  109394. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  109395. */
  109396. static AllowMatrixDecomposeForInterpolation: boolean;
  109397. /**
  109398. * Stores the key frames of the animation
  109399. */
  109400. private _keys;
  109401. /**
  109402. * Stores the easing function of the animation
  109403. */
  109404. private _easingFunction;
  109405. /**
  109406. * @hidden Internal use only
  109407. */
  109408. _runtimeAnimations: RuntimeAnimation[];
  109409. /**
  109410. * The set of event that will be linked to this animation
  109411. */
  109412. private _events;
  109413. /**
  109414. * Stores an array of target property paths
  109415. */
  109416. targetPropertyPath: string[];
  109417. /**
  109418. * Stores the blending speed of the animation
  109419. */
  109420. blendingSpeed: number;
  109421. /**
  109422. * Stores the animation ranges for the animation
  109423. */
  109424. private _ranges;
  109425. /**
  109426. * @hidden Internal use
  109427. */
  109428. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  109429. /**
  109430. * Sets up an animation
  109431. * @param property The property to animate
  109432. * @param animationType The animation type to apply
  109433. * @param framePerSecond The frames per second of the animation
  109434. * @param easingFunction The easing function used in the animation
  109435. * @returns The created animation
  109436. */
  109437. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  109438. /**
  109439. * Create and start an animation on a node
  109440. * @param name defines the name of the global animation that will be run on all nodes
  109441. * @param node defines the root node where the animation will take place
  109442. * @param targetProperty defines property to animate
  109443. * @param framePerSecond defines the number of frame per second yo use
  109444. * @param totalFrame defines the number of frames in total
  109445. * @param from defines the initial value
  109446. * @param to defines the final value
  109447. * @param loopMode defines which loop mode you want to use (off by default)
  109448. * @param easingFunction defines the easing function to use (linear by default)
  109449. * @param onAnimationEnd defines the callback to call when animation end
  109450. * @returns the animatable created for this animation
  109451. */
  109452. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109453. /**
  109454. * Create and start an animation on a node and its descendants
  109455. * @param name defines the name of the global animation that will be run on all nodes
  109456. * @param node defines the root node where the animation will take place
  109457. * @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
  109458. * @param targetProperty defines property to animate
  109459. * @param framePerSecond defines the number of frame per second to use
  109460. * @param totalFrame defines the number of frames in total
  109461. * @param from defines the initial value
  109462. * @param to defines the final value
  109463. * @param loopMode defines which loop mode you want to use (off by default)
  109464. * @param easingFunction defines the easing function to use (linear by default)
  109465. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  109466. * @returns the list of animatables created for all nodes
  109467. * @example https://www.babylonjs-playground.com/#MH0VLI
  109468. */
  109469. 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[]>;
  109470. /**
  109471. * Creates a new animation, merges it with the existing animations and starts it
  109472. * @param name Name of the animation
  109473. * @param node Node which contains the scene that begins the animations
  109474. * @param targetProperty Specifies which property to animate
  109475. * @param framePerSecond The frames per second of the animation
  109476. * @param totalFrame The total number of frames
  109477. * @param from The frame at the beginning of the animation
  109478. * @param to The frame at the end of the animation
  109479. * @param loopMode Specifies the loop mode of the animation
  109480. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  109481. * @param onAnimationEnd Callback to run once the animation is complete
  109482. * @returns Nullable animation
  109483. */
  109484. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109485. /**
  109486. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109487. * @param sourceAnimation defines the Animation containing keyframes to convert
  109488. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109489. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  109490. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  109491. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  109492. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  109493. */
  109494. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  109495. /**
  109496. * Transition property of an host to the target Value
  109497. * @param property The property to transition
  109498. * @param targetValue The target Value of the property
  109499. * @param host The object where the property to animate belongs
  109500. * @param scene Scene used to run the animation
  109501. * @param frameRate Framerate (in frame/s) to use
  109502. * @param transition The transition type we want to use
  109503. * @param duration The duration of the animation, in milliseconds
  109504. * @param onAnimationEnd Callback trigger at the end of the animation
  109505. * @returns Nullable animation
  109506. */
  109507. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  109508. /**
  109509. * Return the array of runtime animations currently using this animation
  109510. */
  109511. get runtimeAnimations(): RuntimeAnimation[];
  109512. /**
  109513. * Specifies if any of the runtime animations are currently running
  109514. */
  109515. get hasRunningRuntimeAnimations(): boolean;
  109516. /**
  109517. * Initializes the animation
  109518. * @param name Name of the animation
  109519. * @param targetProperty Property to animate
  109520. * @param framePerSecond The frames per second of the animation
  109521. * @param dataType The data type of the animation
  109522. * @param loopMode The loop mode of the animation
  109523. * @param enableBlending Specifies if blending should be enabled
  109524. */
  109525. constructor(
  109526. /**Name of the animation */
  109527. name: string,
  109528. /**Property to animate */
  109529. targetProperty: string,
  109530. /**The frames per second of the animation */
  109531. framePerSecond: number,
  109532. /**The data type of the animation */
  109533. dataType: number,
  109534. /**The loop mode of the animation */
  109535. loopMode?: number | undefined,
  109536. /**Specifies if blending should be enabled */
  109537. enableBlending?: boolean | undefined);
  109538. /**
  109539. * Converts the animation to a string
  109540. * @param fullDetails support for multiple levels of logging within scene loading
  109541. * @returns String form of the animation
  109542. */
  109543. toString(fullDetails?: boolean): string;
  109544. /**
  109545. * Add an event to this animation
  109546. * @param event Event to add
  109547. */
  109548. addEvent(event: AnimationEvent): void;
  109549. /**
  109550. * Remove all events found at the given frame
  109551. * @param frame The frame to remove events from
  109552. */
  109553. removeEvents(frame: number): void;
  109554. /**
  109555. * Retrieves all the events from the animation
  109556. * @returns Events from the animation
  109557. */
  109558. getEvents(): AnimationEvent[];
  109559. /**
  109560. * Creates an animation range
  109561. * @param name Name of the animation range
  109562. * @param from Starting frame of the animation range
  109563. * @param to Ending frame of the animation
  109564. */
  109565. createRange(name: string, from: number, to: number): void;
  109566. /**
  109567. * Deletes an animation range by name
  109568. * @param name Name of the animation range to delete
  109569. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  109570. */
  109571. deleteRange(name: string, deleteFrames?: boolean): void;
  109572. /**
  109573. * Gets the animation range by name, or null if not defined
  109574. * @param name Name of the animation range
  109575. * @returns Nullable animation range
  109576. */
  109577. getRange(name: string): Nullable<AnimationRange>;
  109578. /**
  109579. * Gets the key frames from the animation
  109580. * @returns The key frames of the animation
  109581. */
  109582. getKeys(): Array<IAnimationKey>;
  109583. /**
  109584. * Gets the highest frame rate of the animation
  109585. * @returns Highest frame rate of the animation
  109586. */
  109587. getHighestFrame(): number;
  109588. /**
  109589. * Gets the easing function of the animation
  109590. * @returns Easing function of the animation
  109591. */
  109592. getEasingFunction(): IEasingFunction;
  109593. /**
  109594. * Sets the easing function of the animation
  109595. * @param easingFunction A custom mathematical formula for animation
  109596. */
  109597. setEasingFunction(easingFunction: EasingFunction): void;
  109598. /**
  109599. * Interpolates a scalar linearly
  109600. * @param startValue Start value of the animation curve
  109601. * @param endValue End value of the animation curve
  109602. * @param gradient Scalar amount to interpolate
  109603. * @returns Interpolated scalar value
  109604. */
  109605. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  109606. /**
  109607. * Interpolates a scalar cubically
  109608. * @param startValue Start value of the animation curve
  109609. * @param outTangent End tangent of the animation
  109610. * @param endValue End value of the animation curve
  109611. * @param inTangent Start tangent of the animation curve
  109612. * @param gradient Scalar amount to interpolate
  109613. * @returns Interpolated scalar value
  109614. */
  109615. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  109616. /**
  109617. * Interpolates a quaternion using a spherical linear interpolation
  109618. * @param startValue Start value of the animation curve
  109619. * @param endValue End value of the animation curve
  109620. * @param gradient Scalar amount to interpolate
  109621. * @returns Interpolated quaternion value
  109622. */
  109623. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  109624. /**
  109625. * Interpolates a quaternion cubically
  109626. * @param startValue Start value of the animation curve
  109627. * @param outTangent End tangent of the animation curve
  109628. * @param endValue End value of the animation curve
  109629. * @param inTangent Start tangent of the animation curve
  109630. * @param gradient Scalar amount to interpolate
  109631. * @returns Interpolated quaternion value
  109632. */
  109633. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  109634. /**
  109635. * Interpolates a Vector3 linearl
  109636. * @param startValue Start value of the animation curve
  109637. * @param endValue End value of the animation curve
  109638. * @param gradient Scalar amount to interpolate
  109639. * @returns Interpolated scalar value
  109640. */
  109641. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  109642. /**
  109643. * Interpolates a Vector3 cubically
  109644. * @param startValue Start value of the animation curve
  109645. * @param outTangent End tangent of the animation
  109646. * @param endValue End value of the animation curve
  109647. * @param inTangent Start tangent of the animation curve
  109648. * @param gradient Scalar amount to interpolate
  109649. * @returns InterpolatedVector3 value
  109650. */
  109651. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  109652. /**
  109653. * Interpolates a Vector2 linearly
  109654. * @param startValue Start value of the animation curve
  109655. * @param endValue End value of the animation curve
  109656. * @param gradient Scalar amount to interpolate
  109657. * @returns Interpolated Vector2 value
  109658. */
  109659. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  109660. /**
  109661. * Interpolates a Vector2 cubically
  109662. * @param startValue Start value of the animation curve
  109663. * @param outTangent End tangent of the animation
  109664. * @param endValue End value of the animation curve
  109665. * @param inTangent Start tangent of the animation curve
  109666. * @param gradient Scalar amount to interpolate
  109667. * @returns Interpolated Vector2 value
  109668. */
  109669. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  109670. /**
  109671. * Interpolates a size linearly
  109672. * @param startValue Start value of the animation curve
  109673. * @param endValue End value of the animation curve
  109674. * @param gradient Scalar amount to interpolate
  109675. * @returns Interpolated Size value
  109676. */
  109677. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  109678. /**
  109679. * Interpolates a Color3 linearly
  109680. * @param startValue Start value of the animation curve
  109681. * @param endValue End value of the animation curve
  109682. * @param gradient Scalar amount to interpolate
  109683. * @returns Interpolated Color3 value
  109684. */
  109685. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  109686. /**
  109687. * Interpolates a Color4 linearly
  109688. * @param startValue Start value of the animation curve
  109689. * @param endValue End value of the animation curve
  109690. * @param gradient Scalar amount to interpolate
  109691. * @returns Interpolated Color3 value
  109692. */
  109693. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  109694. /**
  109695. * @hidden Internal use only
  109696. */
  109697. _getKeyValue(value: any): any;
  109698. /**
  109699. * @hidden Internal use only
  109700. */
  109701. _interpolate(currentFrame: number, state: _IAnimationState): any;
  109702. /**
  109703. * Defines the function to use to interpolate matrices
  109704. * @param startValue defines the start matrix
  109705. * @param endValue defines the end matrix
  109706. * @param gradient defines the gradient between both matrices
  109707. * @param result defines an optional target matrix where to store the interpolation
  109708. * @returns the interpolated matrix
  109709. */
  109710. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  109711. /**
  109712. * Makes a copy of the animation
  109713. * @returns Cloned animation
  109714. */
  109715. clone(): Animation;
  109716. /**
  109717. * Sets the key frames of the animation
  109718. * @param values The animation key frames to set
  109719. */
  109720. setKeys(values: Array<IAnimationKey>): void;
  109721. /**
  109722. * Serializes the animation to an object
  109723. * @returns Serialized object
  109724. */
  109725. serialize(): any;
  109726. /**
  109727. * Float animation type
  109728. */
  109729. static readonly ANIMATIONTYPE_FLOAT: number;
  109730. /**
  109731. * Vector3 animation type
  109732. */
  109733. static readonly ANIMATIONTYPE_VECTOR3: number;
  109734. /**
  109735. * Quaternion animation type
  109736. */
  109737. static readonly ANIMATIONTYPE_QUATERNION: number;
  109738. /**
  109739. * Matrix animation type
  109740. */
  109741. static readonly ANIMATIONTYPE_MATRIX: number;
  109742. /**
  109743. * Color3 animation type
  109744. */
  109745. static readonly ANIMATIONTYPE_COLOR3: number;
  109746. /**
  109747. * Color3 animation type
  109748. */
  109749. static readonly ANIMATIONTYPE_COLOR4: number;
  109750. /**
  109751. * Vector2 animation type
  109752. */
  109753. static readonly ANIMATIONTYPE_VECTOR2: number;
  109754. /**
  109755. * Size animation type
  109756. */
  109757. static readonly ANIMATIONTYPE_SIZE: number;
  109758. /**
  109759. * Relative Loop Mode
  109760. */
  109761. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  109762. /**
  109763. * Cycle Loop Mode
  109764. */
  109765. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  109766. /**
  109767. * Constant Loop Mode
  109768. */
  109769. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  109770. /** @hidden */
  109771. static _UniversalLerp(left: any, right: any, amount: number): any;
  109772. /**
  109773. * Parses an animation object and creates an animation
  109774. * @param parsedAnimation Parsed animation object
  109775. * @returns Animation object
  109776. */
  109777. static Parse(parsedAnimation: any): Animation;
  109778. /**
  109779. * Appends the serialized animations from the source animations
  109780. * @param source Source containing the animations
  109781. * @param destination Target to store the animations
  109782. */
  109783. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109784. }
  109785. }
  109786. declare module BABYLON {
  109787. /**
  109788. * Interface containing an array of animations
  109789. */
  109790. export interface IAnimatable {
  109791. /**
  109792. * Array of animations
  109793. */
  109794. animations: Nullable<Array<Animation>>;
  109795. }
  109796. }
  109797. declare module BABYLON {
  109798. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  109799. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109800. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109801. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109802. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109803. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109804. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109805. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109806. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109807. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109808. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109809. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109810. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109811. /**
  109812. * Decorator used to define property that can be serialized as reference to a camera
  109813. * @param sourceName defines the name of the property to decorate
  109814. */
  109815. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109816. /**
  109817. * Class used to help serialization objects
  109818. */
  109819. export class SerializationHelper {
  109820. /** @hidden */
  109821. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  109822. /** @hidden */
  109823. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  109824. /** @hidden */
  109825. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  109826. /** @hidden */
  109827. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  109828. /**
  109829. * Appends the serialized animations from the source animations
  109830. * @param source Source containing the animations
  109831. * @param destination Target to store the animations
  109832. */
  109833. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109834. /**
  109835. * Static function used to serialized a specific entity
  109836. * @param entity defines the entity to serialize
  109837. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  109838. * @returns a JSON compatible object representing the serialization of the entity
  109839. */
  109840. static Serialize<T>(entity: T, serializationObject?: any): any;
  109841. /**
  109842. * Creates a new entity from a serialization data object
  109843. * @param creationFunction defines a function used to instanciated the new entity
  109844. * @param source defines the source serialization data
  109845. * @param scene defines the hosting scene
  109846. * @param rootUrl defines the root url for resources
  109847. * @returns a new entity
  109848. */
  109849. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  109850. /**
  109851. * Clones an object
  109852. * @param creationFunction defines the function used to instanciate the new object
  109853. * @param source defines the source object
  109854. * @returns the cloned object
  109855. */
  109856. static Clone<T>(creationFunction: () => T, source: T): T;
  109857. /**
  109858. * Instanciates a new object based on a source one (some data will be shared between both object)
  109859. * @param creationFunction defines the function used to instanciate the new object
  109860. * @param source defines the source object
  109861. * @returns the new object
  109862. */
  109863. static Instanciate<T>(creationFunction: () => T, source: T): T;
  109864. }
  109865. }
  109866. declare module BABYLON {
  109867. /**
  109868. * Base class of all the textures in babylon.
  109869. * It groups all the common properties the materials, post process, lights... might need
  109870. * in order to make a correct use of the texture.
  109871. */
  109872. export class BaseTexture implements IAnimatable {
  109873. /**
  109874. * Default anisotropic filtering level for the application.
  109875. * It is set to 4 as a good tradeoff between perf and quality.
  109876. */
  109877. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  109878. /**
  109879. * Gets or sets the unique id of the texture
  109880. */
  109881. uniqueId: number;
  109882. /**
  109883. * Define the name of the texture.
  109884. */
  109885. name: string;
  109886. /**
  109887. * Gets or sets an object used to store user defined information.
  109888. */
  109889. metadata: any;
  109890. /**
  109891. * For internal use only. Please do not use.
  109892. */
  109893. reservedDataStore: any;
  109894. private _hasAlpha;
  109895. /**
  109896. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  109897. */
  109898. set hasAlpha(value: boolean);
  109899. get hasAlpha(): boolean;
  109900. /**
  109901. * Defines if the alpha value should be determined via the rgb values.
  109902. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  109903. */
  109904. getAlphaFromRGB: boolean;
  109905. /**
  109906. * Intensity or strength of the texture.
  109907. * It is commonly used by materials to fine tune the intensity of the texture
  109908. */
  109909. level: number;
  109910. /**
  109911. * Define the UV chanel to use starting from 0 and defaulting to 0.
  109912. * This is part of the texture as textures usually maps to one uv set.
  109913. */
  109914. coordinatesIndex: number;
  109915. private _coordinatesMode;
  109916. /**
  109917. * How a texture is mapped.
  109918. *
  109919. * | Value | Type | Description |
  109920. * | ----- | ----------------------------------- | ----------- |
  109921. * | 0 | EXPLICIT_MODE | |
  109922. * | 1 | SPHERICAL_MODE | |
  109923. * | 2 | PLANAR_MODE | |
  109924. * | 3 | CUBIC_MODE | |
  109925. * | 4 | PROJECTION_MODE | |
  109926. * | 5 | SKYBOX_MODE | |
  109927. * | 6 | INVCUBIC_MODE | |
  109928. * | 7 | EQUIRECTANGULAR_MODE | |
  109929. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  109930. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  109931. */
  109932. set coordinatesMode(value: number);
  109933. get coordinatesMode(): number;
  109934. /**
  109935. * | Value | Type | Description |
  109936. * | ----- | ------------------ | ----------- |
  109937. * | 0 | CLAMP_ADDRESSMODE | |
  109938. * | 1 | WRAP_ADDRESSMODE | |
  109939. * | 2 | MIRROR_ADDRESSMODE | |
  109940. */
  109941. wrapU: number;
  109942. /**
  109943. * | Value | Type | Description |
  109944. * | ----- | ------------------ | ----------- |
  109945. * | 0 | CLAMP_ADDRESSMODE | |
  109946. * | 1 | WRAP_ADDRESSMODE | |
  109947. * | 2 | MIRROR_ADDRESSMODE | |
  109948. */
  109949. wrapV: number;
  109950. /**
  109951. * | Value | Type | Description |
  109952. * | ----- | ------------------ | ----------- |
  109953. * | 0 | CLAMP_ADDRESSMODE | |
  109954. * | 1 | WRAP_ADDRESSMODE | |
  109955. * | 2 | MIRROR_ADDRESSMODE | |
  109956. */
  109957. wrapR: number;
  109958. /**
  109959. * With compliant hardware and browser (supporting anisotropic filtering)
  109960. * this defines the level of anisotropic filtering in the texture.
  109961. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  109962. */
  109963. anisotropicFilteringLevel: number;
  109964. /**
  109965. * Define if the texture is a cube texture or if false a 2d texture.
  109966. */
  109967. get isCube(): boolean;
  109968. set isCube(value: boolean);
  109969. /**
  109970. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  109971. */
  109972. get is3D(): boolean;
  109973. set is3D(value: boolean);
  109974. /**
  109975. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  109976. */
  109977. get is2DArray(): boolean;
  109978. set is2DArray(value: boolean);
  109979. /**
  109980. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  109981. * HDR texture are usually stored in linear space.
  109982. * This only impacts the PBR and Background materials
  109983. */
  109984. gammaSpace: boolean;
  109985. /**
  109986. * Gets or sets whether or not the texture contains RGBD data.
  109987. */
  109988. get isRGBD(): boolean;
  109989. set isRGBD(value: boolean);
  109990. /**
  109991. * Is Z inverted in the texture (useful in a cube texture).
  109992. */
  109993. invertZ: boolean;
  109994. /**
  109995. * Are mip maps generated for this texture or not.
  109996. */
  109997. get noMipmap(): boolean;
  109998. /**
  109999. * @hidden
  110000. */
  110001. lodLevelInAlpha: boolean;
  110002. /**
  110003. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110004. */
  110005. get lodGenerationOffset(): number;
  110006. set lodGenerationOffset(value: number);
  110007. /**
  110008. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110009. */
  110010. get lodGenerationScale(): number;
  110011. set lodGenerationScale(value: number);
  110012. /**
  110013. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110014. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110015. * average roughness values.
  110016. */
  110017. get linearSpecularLOD(): boolean;
  110018. set linearSpecularLOD(value: boolean);
  110019. /**
  110020. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110021. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110022. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110023. */
  110024. get irradianceTexture(): Nullable<BaseTexture>;
  110025. set irradianceTexture(value: Nullable<BaseTexture>);
  110026. /**
  110027. * Define if the texture is a render target.
  110028. */
  110029. isRenderTarget: boolean;
  110030. /**
  110031. * Define the unique id of the texture in the scene.
  110032. */
  110033. get uid(): string;
  110034. /** @hidden */
  110035. _prefiltered: boolean;
  110036. /**
  110037. * Return a string representation of the texture.
  110038. * @returns the texture as a string
  110039. */
  110040. toString(): string;
  110041. /**
  110042. * Get the class name of the texture.
  110043. * @returns "BaseTexture"
  110044. */
  110045. getClassName(): string;
  110046. /**
  110047. * Define the list of animation attached to the texture.
  110048. */
  110049. animations: Animation[];
  110050. /**
  110051. * An event triggered when the texture is disposed.
  110052. */
  110053. onDisposeObservable: Observable<BaseTexture>;
  110054. private _onDisposeObserver;
  110055. /**
  110056. * Callback triggered when the texture has been disposed.
  110057. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110058. */
  110059. set onDispose(callback: () => void);
  110060. /**
  110061. * Define the current state of the loading sequence when in delayed load mode.
  110062. */
  110063. delayLoadState: number;
  110064. private _scene;
  110065. private _engine;
  110066. /** @hidden */
  110067. _texture: Nullable<InternalTexture>;
  110068. private _uid;
  110069. /**
  110070. * Define if the texture is preventinga material to render or not.
  110071. * If not and the texture is not ready, the engine will use a default black texture instead.
  110072. */
  110073. get isBlocking(): boolean;
  110074. /**
  110075. * Instantiates a new BaseTexture.
  110076. * Base class of all the textures in babylon.
  110077. * It groups all the common properties the materials, post process, lights... might need
  110078. * in order to make a correct use of the texture.
  110079. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110080. */
  110081. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110082. /**
  110083. * Get the scene the texture belongs to.
  110084. * @returns the scene or null if undefined
  110085. */
  110086. getScene(): Nullable<Scene>;
  110087. /** @hidden */
  110088. protected _getEngine(): Nullable<ThinEngine>;
  110089. /**
  110090. * Get the texture transform matrix used to offset tile the texture for istance.
  110091. * @returns the transformation matrix
  110092. */
  110093. getTextureMatrix(): Matrix;
  110094. /**
  110095. * Get the texture reflection matrix used to rotate/transform the reflection.
  110096. * @returns the reflection matrix
  110097. */
  110098. getReflectionTextureMatrix(): Matrix;
  110099. /**
  110100. * Get the underlying lower level texture from Babylon.
  110101. * @returns the insternal texture
  110102. */
  110103. getInternalTexture(): Nullable<InternalTexture>;
  110104. /**
  110105. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110106. * @returns true if ready or not blocking
  110107. */
  110108. isReadyOrNotBlocking(): boolean;
  110109. /**
  110110. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110111. * @returns true if fully ready
  110112. */
  110113. isReady(): boolean;
  110114. private _cachedSize;
  110115. /**
  110116. * Get the size of the texture.
  110117. * @returns the texture size.
  110118. */
  110119. getSize(): ISize;
  110120. /**
  110121. * Get the base size of the texture.
  110122. * It can be different from the size if the texture has been resized for POT for instance
  110123. * @returns the base size
  110124. */
  110125. getBaseSize(): ISize;
  110126. /**
  110127. * Update the sampling mode of the texture.
  110128. * Default is Trilinear mode.
  110129. *
  110130. * | Value | Type | Description |
  110131. * | ----- | ------------------ | ----------- |
  110132. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110133. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110134. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110135. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110136. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110137. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110138. * | 7 | NEAREST_LINEAR | |
  110139. * | 8 | NEAREST_NEAREST | |
  110140. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110141. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110142. * | 11 | LINEAR_LINEAR | |
  110143. * | 12 | LINEAR_NEAREST | |
  110144. *
  110145. * > _mag_: magnification filter (close to the viewer)
  110146. * > _min_: minification filter (far from the viewer)
  110147. * > _mip_: filter used between mip map levels
  110148. *@param samplingMode Define the new sampling mode of the texture
  110149. */
  110150. updateSamplingMode(samplingMode: number): void;
  110151. /**
  110152. * Scales the texture if is `canRescale()`
  110153. * @param ratio the resize factor we want to use to rescale
  110154. */
  110155. scale(ratio: number): void;
  110156. /**
  110157. * Get if the texture can rescale.
  110158. */
  110159. get canRescale(): boolean;
  110160. /** @hidden */
  110161. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110162. /** @hidden */
  110163. _rebuild(): void;
  110164. /**
  110165. * Triggers the load sequence in delayed load mode.
  110166. */
  110167. delayLoad(): void;
  110168. /**
  110169. * Clones the texture.
  110170. * @returns the cloned texture
  110171. */
  110172. clone(): Nullable<BaseTexture>;
  110173. /**
  110174. * Get the texture underlying type (INT, FLOAT...)
  110175. */
  110176. get textureType(): number;
  110177. /**
  110178. * Get the texture underlying format (RGB, RGBA...)
  110179. */
  110180. get textureFormat(): number;
  110181. /**
  110182. * Indicates that textures need to be re-calculated for all materials
  110183. */
  110184. protected _markAllSubMeshesAsTexturesDirty(): void;
  110185. /**
  110186. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110187. * This will returns an RGBA array buffer containing either in values (0-255) or
  110188. * float values (0-1) depending of the underlying buffer type.
  110189. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110190. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110191. * @param buffer defines a user defined buffer to fill with data (can be null)
  110192. * @returns The Array buffer containing the pixels data.
  110193. */
  110194. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110195. /**
  110196. * Release and destroy the underlying lower level texture aka internalTexture.
  110197. */
  110198. releaseInternalTexture(): void;
  110199. /** @hidden */
  110200. get _lodTextureHigh(): Nullable<BaseTexture>;
  110201. /** @hidden */
  110202. get _lodTextureMid(): Nullable<BaseTexture>;
  110203. /** @hidden */
  110204. get _lodTextureLow(): Nullable<BaseTexture>;
  110205. /**
  110206. * Dispose the texture and release its associated resources.
  110207. */
  110208. dispose(): void;
  110209. /**
  110210. * Serialize the texture into a JSON representation that can be parsed later on.
  110211. * @returns the JSON representation of the texture
  110212. */
  110213. serialize(): any;
  110214. /**
  110215. * Helper function to be called back once a list of texture contains only ready textures.
  110216. * @param textures Define the list of textures to wait for
  110217. * @param callback Define the callback triggered once the entire list will be ready
  110218. */
  110219. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110220. private static _isScene;
  110221. }
  110222. }
  110223. declare module BABYLON {
  110224. /**
  110225. * Options to be used when creating an effect.
  110226. */
  110227. export interface IEffectCreationOptions {
  110228. /**
  110229. * Atrributes that will be used in the shader.
  110230. */
  110231. attributes: string[];
  110232. /**
  110233. * Uniform varible names that will be set in the shader.
  110234. */
  110235. uniformsNames: string[];
  110236. /**
  110237. * Uniform buffer variable names that will be set in the shader.
  110238. */
  110239. uniformBuffersNames: string[];
  110240. /**
  110241. * Sampler texture variable names that will be set in the shader.
  110242. */
  110243. samplers: string[];
  110244. /**
  110245. * Define statements that will be set in the shader.
  110246. */
  110247. defines: any;
  110248. /**
  110249. * Possible fallbacks for this effect to improve performance when needed.
  110250. */
  110251. fallbacks: Nullable<IEffectFallbacks>;
  110252. /**
  110253. * Callback that will be called when the shader is compiled.
  110254. */
  110255. onCompiled: Nullable<(effect: Effect) => void>;
  110256. /**
  110257. * Callback that will be called if an error occurs during shader compilation.
  110258. */
  110259. onError: Nullable<(effect: Effect, errors: string) => void>;
  110260. /**
  110261. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110262. */
  110263. indexParameters?: any;
  110264. /**
  110265. * Max number of lights that can be used in the shader.
  110266. */
  110267. maxSimultaneousLights?: number;
  110268. /**
  110269. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  110270. */
  110271. transformFeedbackVaryings?: Nullable<string[]>;
  110272. /**
  110273. * 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
  110274. */
  110275. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110276. }
  110277. /**
  110278. * Effect containing vertex and fragment shader that can be executed on an object.
  110279. */
  110280. export class Effect implements IDisposable {
  110281. /**
  110282. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110283. */
  110284. static ShadersRepository: string;
  110285. /**
  110286. * Enable logging of the shader code when a compilation error occurs
  110287. */
  110288. static LogShaderCodeOnCompilationError: boolean;
  110289. /**
  110290. * Name of the effect.
  110291. */
  110292. name: any;
  110293. /**
  110294. * String container all the define statements that should be set on the shader.
  110295. */
  110296. defines: string;
  110297. /**
  110298. * Callback that will be called when the shader is compiled.
  110299. */
  110300. onCompiled: Nullable<(effect: Effect) => void>;
  110301. /**
  110302. * Callback that will be called if an error occurs during shader compilation.
  110303. */
  110304. onError: Nullable<(effect: Effect, errors: string) => void>;
  110305. /**
  110306. * Callback that will be called when effect is bound.
  110307. */
  110308. onBind: Nullable<(effect: Effect) => void>;
  110309. /**
  110310. * Unique ID of the effect.
  110311. */
  110312. uniqueId: number;
  110313. /**
  110314. * Observable that will be called when the shader is compiled.
  110315. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  110316. */
  110317. onCompileObservable: Observable<Effect>;
  110318. /**
  110319. * Observable that will be called if an error occurs during shader compilation.
  110320. */
  110321. onErrorObservable: Observable<Effect>;
  110322. /** @hidden */
  110323. _onBindObservable: Nullable<Observable<Effect>>;
  110324. /**
  110325. * @hidden
  110326. * Specifies if the effect was previously ready
  110327. */
  110328. _wasPreviouslyReady: boolean;
  110329. /**
  110330. * Observable that will be called when effect is bound.
  110331. */
  110332. get onBindObservable(): Observable<Effect>;
  110333. /** @hidden */
  110334. _bonesComputationForcedToCPU: boolean;
  110335. private static _uniqueIdSeed;
  110336. private _engine;
  110337. private _uniformBuffersNames;
  110338. private _uniformBuffersNamesList;
  110339. private _uniformsNames;
  110340. private _samplerList;
  110341. private _samplers;
  110342. private _isReady;
  110343. private _compilationError;
  110344. private _allFallbacksProcessed;
  110345. private _attributesNames;
  110346. private _attributes;
  110347. private _attributeLocationByName;
  110348. private _uniforms;
  110349. /**
  110350. * Key for the effect.
  110351. * @hidden
  110352. */
  110353. _key: string;
  110354. private _indexParameters;
  110355. private _fallbacks;
  110356. private _vertexSourceCode;
  110357. private _fragmentSourceCode;
  110358. private _vertexSourceCodeOverride;
  110359. private _fragmentSourceCodeOverride;
  110360. private _transformFeedbackVaryings;
  110361. /**
  110362. * Compiled shader to webGL program.
  110363. * @hidden
  110364. */
  110365. _pipelineContext: Nullable<IPipelineContext>;
  110366. private _valueCache;
  110367. private static _baseCache;
  110368. /**
  110369. * Instantiates an effect.
  110370. * An effect can be used to create/manage/execute vertex and fragment shaders.
  110371. * @param baseName Name of the effect.
  110372. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  110373. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  110374. * @param samplers List of sampler variables that will be passed to the shader.
  110375. * @param engine Engine to be used to render the effect
  110376. * @param defines Define statements to be added to the shader.
  110377. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  110378. * @param onCompiled Callback that will be called when the shader is compiled.
  110379. * @param onError Callback that will be called if an error occurs during shader compilation.
  110380. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110381. */
  110382. 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);
  110383. private _useFinalCode;
  110384. /**
  110385. * Unique key for this effect
  110386. */
  110387. get key(): string;
  110388. /**
  110389. * If the effect has been compiled and prepared.
  110390. * @returns if the effect is compiled and prepared.
  110391. */
  110392. isReady(): boolean;
  110393. private _isReadyInternal;
  110394. /**
  110395. * The engine the effect was initialized with.
  110396. * @returns the engine.
  110397. */
  110398. getEngine(): Engine;
  110399. /**
  110400. * The pipeline context for this effect
  110401. * @returns the associated pipeline context
  110402. */
  110403. getPipelineContext(): Nullable<IPipelineContext>;
  110404. /**
  110405. * The set of names of attribute variables for the shader.
  110406. * @returns An array of attribute names.
  110407. */
  110408. getAttributesNames(): string[];
  110409. /**
  110410. * Returns the attribute at the given index.
  110411. * @param index The index of the attribute.
  110412. * @returns The location of the attribute.
  110413. */
  110414. getAttributeLocation(index: number): number;
  110415. /**
  110416. * Returns the attribute based on the name of the variable.
  110417. * @param name of the attribute to look up.
  110418. * @returns the attribute location.
  110419. */
  110420. getAttributeLocationByName(name: string): number;
  110421. /**
  110422. * The number of attributes.
  110423. * @returns the numnber of attributes.
  110424. */
  110425. getAttributesCount(): number;
  110426. /**
  110427. * Gets the index of a uniform variable.
  110428. * @param uniformName of the uniform to look up.
  110429. * @returns the index.
  110430. */
  110431. getUniformIndex(uniformName: string): number;
  110432. /**
  110433. * Returns the attribute based on the name of the variable.
  110434. * @param uniformName of the uniform to look up.
  110435. * @returns the location of the uniform.
  110436. */
  110437. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  110438. /**
  110439. * Returns an array of sampler variable names
  110440. * @returns The array of sampler variable names.
  110441. */
  110442. getSamplers(): string[];
  110443. /**
  110444. * Returns an array of uniform variable names
  110445. * @returns The array of uniform variable names.
  110446. */
  110447. getUniformNames(): string[];
  110448. /**
  110449. * Returns an array of uniform buffer variable names
  110450. * @returns The array of uniform buffer variable names.
  110451. */
  110452. getUniformBuffersNames(): string[];
  110453. /**
  110454. * Returns the index parameters used to create the effect
  110455. * @returns The index parameters object
  110456. */
  110457. getIndexParameters(): any;
  110458. /**
  110459. * The error from the last compilation.
  110460. * @returns the error string.
  110461. */
  110462. getCompilationError(): string;
  110463. /**
  110464. * Gets a boolean indicating that all fallbacks were used during compilation
  110465. * @returns true if all fallbacks were used
  110466. */
  110467. allFallbacksProcessed(): boolean;
  110468. /**
  110469. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  110470. * @param func The callback to be used.
  110471. */
  110472. executeWhenCompiled(func: (effect: Effect) => void): void;
  110473. private _checkIsReady;
  110474. private _loadShader;
  110475. /**
  110476. * Gets the vertex shader source code of this effect
  110477. */
  110478. get vertexSourceCode(): string;
  110479. /**
  110480. * Gets the fragment shader source code of this effect
  110481. */
  110482. get fragmentSourceCode(): string;
  110483. /**
  110484. * Recompiles the webGL program
  110485. * @param vertexSourceCode The source code for the vertex shader.
  110486. * @param fragmentSourceCode The source code for the fragment shader.
  110487. * @param onCompiled Callback called when completed.
  110488. * @param onError Callback called on error.
  110489. * @hidden
  110490. */
  110491. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  110492. /**
  110493. * Prepares the effect
  110494. * @hidden
  110495. */
  110496. _prepareEffect(): void;
  110497. private _getShaderCodeAndErrorLine;
  110498. private _processCompilationErrors;
  110499. /**
  110500. * Checks if the effect is supported. (Must be called after compilation)
  110501. */
  110502. get isSupported(): boolean;
  110503. /**
  110504. * Binds a texture to the engine to be used as output of the shader.
  110505. * @param channel Name of the output variable.
  110506. * @param texture Texture to bind.
  110507. * @hidden
  110508. */
  110509. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  110510. /**
  110511. * Sets a texture on the engine to be used in the shader.
  110512. * @param channel Name of the sampler variable.
  110513. * @param texture Texture to set.
  110514. */
  110515. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  110516. /**
  110517. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  110518. * @param channel Name of the sampler variable.
  110519. * @param texture Texture to set.
  110520. */
  110521. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  110522. /**
  110523. * Sets an array of textures on the engine to be used in the shader.
  110524. * @param channel Name of the variable.
  110525. * @param textures Textures to set.
  110526. */
  110527. setTextureArray(channel: string, textures: BaseTexture[]): void;
  110528. /**
  110529. * 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)
  110530. * @param channel Name of the sampler variable.
  110531. * @param postProcess Post process to get the input texture from.
  110532. */
  110533. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  110534. /**
  110535. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  110536. * 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)
  110537. * @param channel Name of the sampler variable.
  110538. * @param postProcess Post process to get the output texture from.
  110539. */
  110540. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  110541. /** @hidden */
  110542. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  110543. /** @hidden */
  110544. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  110545. /** @hidden */
  110546. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  110547. /** @hidden */
  110548. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  110549. /**
  110550. * Binds a buffer to a uniform.
  110551. * @param buffer Buffer to bind.
  110552. * @param name Name of the uniform variable to bind to.
  110553. */
  110554. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  110555. /**
  110556. * Binds block to a uniform.
  110557. * @param blockName Name of the block to bind.
  110558. * @param index Index to bind.
  110559. */
  110560. bindUniformBlock(blockName: string, index: number): void;
  110561. /**
  110562. * Sets an interger value on a uniform variable.
  110563. * @param uniformName Name of the variable.
  110564. * @param value Value to be set.
  110565. * @returns this effect.
  110566. */
  110567. setInt(uniformName: string, value: number): Effect;
  110568. /**
  110569. * Sets an int array on a uniform variable.
  110570. * @param uniformName Name of the variable.
  110571. * @param array array to be set.
  110572. * @returns this effect.
  110573. */
  110574. setIntArray(uniformName: string, array: Int32Array): Effect;
  110575. /**
  110576. * 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)
  110577. * @param uniformName Name of the variable.
  110578. * @param array array to be set.
  110579. * @returns this effect.
  110580. */
  110581. setIntArray2(uniformName: string, array: Int32Array): Effect;
  110582. /**
  110583. * 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)
  110584. * @param uniformName Name of the variable.
  110585. * @param array array to be set.
  110586. * @returns this effect.
  110587. */
  110588. setIntArray3(uniformName: string, array: Int32Array): Effect;
  110589. /**
  110590. * 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)
  110591. * @param uniformName Name of the variable.
  110592. * @param array array to be set.
  110593. * @returns this effect.
  110594. */
  110595. setIntArray4(uniformName: string, array: Int32Array): Effect;
  110596. /**
  110597. * Sets an float array on a uniform variable.
  110598. * @param uniformName Name of the variable.
  110599. * @param array array to be set.
  110600. * @returns this effect.
  110601. */
  110602. setFloatArray(uniformName: string, array: Float32Array): Effect;
  110603. /**
  110604. * 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)
  110605. * @param uniformName Name of the variable.
  110606. * @param array array to be set.
  110607. * @returns this effect.
  110608. */
  110609. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  110610. /**
  110611. * 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)
  110612. * @param uniformName Name of the variable.
  110613. * @param array array to be set.
  110614. * @returns this effect.
  110615. */
  110616. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  110617. /**
  110618. * 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)
  110619. * @param uniformName Name of the variable.
  110620. * @param array array to be set.
  110621. * @returns this effect.
  110622. */
  110623. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  110624. /**
  110625. * Sets an array on a uniform variable.
  110626. * @param uniformName Name of the variable.
  110627. * @param array array to be set.
  110628. * @returns this effect.
  110629. */
  110630. setArray(uniformName: string, array: number[]): Effect;
  110631. /**
  110632. * 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)
  110633. * @param uniformName Name of the variable.
  110634. * @param array array to be set.
  110635. * @returns this effect.
  110636. */
  110637. setArray2(uniformName: string, array: number[]): Effect;
  110638. /**
  110639. * 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)
  110640. * @param uniformName Name of the variable.
  110641. * @param array array to be set.
  110642. * @returns this effect.
  110643. */
  110644. setArray3(uniformName: string, array: number[]): Effect;
  110645. /**
  110646. * 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)
  110647. * @param uniformName Name of the variable.
  110648. * @param array array to be set.
  110649. * @returns this effect.
  110650. */
  110651. setArray4(uniformName: string, array: number[]): Effect;
  110652. /**
  110653. * Sets matrices on a uniform variable.
  110654. * @param uniformName Name of the variable.
  110655. * @param matrices matrices to be set.
  110656. * @returns this effect.
  110657. */
  110658. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  110659. /**
  110660. * Sets matrix on a uniform variable.
  110661. * @param uniformName Name of the variable.
  110662. * @param matrix matrix to be set.
  110663. * @returns this effect.
  110664. */
  110665. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  110666. /**
  110667. * 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)
  110668. * @param uniformName Name of the variable.
  110669. * @param matrix matrix to be set.
  110670. * @returns this effect.
  110671. */
  110672. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  110673. /**
  110674. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  110675. * @param uniformName Name of the variable.
  110676. * @param matrix matrix to be set.
  110677. * @returns this effect.
  110678. */
  110679. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  110680. /**
  110681. * Sets a float on a uniform variable.
  110682. * @param uniformName Name of the variable.
  110683. * @param value value to be set.
  110684. * @returns this effect.
  110685. */
  110686. setFloat(uniformName: string, value: number): Effect;
  110687. /**
  110688. * Sets a boolean on a uniform variable.
  110689. * @param uniformName Name of the variable.
  110690. * @param bool value to be set.
  110691. * @returns this effect.
  110692. */
  110693. setBool(uniformName: string, bool: boolean): Effect;
  110694. /**
  110695. * Sets a Vector2 on a uniform variable.
  110696. * @param uniformName Name of the variable.
  110697. * @param vector2 vector2 to be set.
  110698. * @returns this effect.
  110699. */
  110700. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  110701. /**
  110702. * Sets a float2 on a uniform variable.
  110703. * @param uniformName Name of the variable.
  110704. * @param x First float in float2.
  110705. * @param y Second float in float2.
  110706. * @returns this effect.
  110707. */
  110708. setFloat2(uniformName: string, x: number, y: number): Effect;
  110709. /**
  110710. * Sets a Vector3 on a uniform variable.
  110711. * @param uniformName Name of the variable.
  110712. * @param vector3 Value to be set.
  110713. * @returns this effect.
  110714. */
  110715. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  110716. /**
  110717. * Sets a float3 on a uniform variable.
  110718. * @param uniformName Name of the variable.
  110719. * @param x First float in float3.
  110720. * @param y Second float in float3.
  110721. * @param z Third float in float3.
  110722. * @returns this effect.
  110723. */
  110724. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  110725. /**
  110726. * Sets a Vector4 on a uniform variable.
  110727. * @param uniformName Name of the variable.
  110728. * @param vector4 Value to be set.
  110729. * @returns this effect.
  110730. */
  110731. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  110732. /**
  110733. * Sets a float4 on a uniform variable.
  110734. * @param uniformName Name of the variable.
  110735. * @param x First float in float4.
  110736. * @param y Second float in float4.
  110737. * @param z Third float in float4.
  110738. * @param w Fourth float in float4.
  110739. * @returns this effect.
  110740. */
  110741. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  110742. /**
  110743. * Sets a Color3 on a uniform variable.
  110744. * @param uniformName Name of the variable.
  110745. * @param color3 Value to be set.
  110746. * @returns this effect.
  110747. */
  110748. setColor3(uniformName: string, color3: IColor3Like): Effect;
  110749. /**
  110750. * Sets a Color4 on a uniform variable.
  110751. * @param uniformName Name of the variable.
  110752. * @param color3 Value to be set.
  110753. * @param alpha Alpha value to be set.
  110754. * @returns this effect.
  110755. */
  110756. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  110757. /**
  110758. * Sets a Color4 on a uniform variable
  110759. * @param uniformName defines the name of the variable
  110760. * @param color4 defines the value to be set
  110761. * @returns this effect.
  110762. */
  110763. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  110764. /** Release all associated resources */
  110765. dispose(): void;
  110766. /**
  110767. * This function will add a new shader to the shader store
  110768. * @param name the name of the shader
  110769. * @param pixelShader optional pixel shader content
  110770. * @param vertexShader optional vertex shader content
  110771. */
  110772. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  110773. /**
  110774. * Store of each shader (The can be looked up using effect.key)
  110775. */
  110776. static ShadersStore: {
  110777. [key: string]: string;
  110778. };
  110779. /**
  110780. * Store of each included file for a shader (The can be looked up using effect.key)
  110781. */
  110782. static IncludesShadersStore: {
  110783. [key: string]: string;
  110784. };
  110785. /**
  110786. * Resets the cache of effects.
  110787. */
  110788. static ResetCache(): void;
  110789. }
  110790. }
  110791. declare module BABYLON {
  110792. /**
  110793. * Interface used to describe the capabilities of the engine relatively to the current browser
  110794. */
  110795. export interface EngineCapabilities {
  110796. /** Maximum textures units per fragment shader */
  110797. maxTexturesImageUnits: number;
  110798. /** Maximum texture units per vertex shader */
  110799. maxVertexTextureImageUnits: number;
  110800. /** Maximum textures units in the entire pipeline */
  110801. maxCombinedTexturesImageUnits: number;
  110802. /** Maximum texture size */
  110803. maxTextureSize: number;
  110804. /** Maximum texture samples */
  110805. maxSamples?: number;
  110806. /** Maximum cube texture size */
  110807. maxCubemapTextureSize: number;
  110808. /** Maximum render texture size */
  110809. maxRenderTextureSize: number;
  110810. /** Maximum number of vertex attributes */
  110811. maxVertexAttribs: number;
  110812. /** Maximum number of varyings */
  110813. maxVaryingVectors: number;
  110814. /** Maximum number of uniforms per vertex shader */
  110815. maxVertexUniformVectors: number;
  110816. /** Maximum number of uniforms per fragment shader */
  110817. maxFragmentUniformVectors: number;
  110818. /** Defines if standard derivates (dx/dy) are supported */
  110819. standardDerivatives: boolean;
  110820. /** Defines if s3tc texture compression is supported */
  110821. s3tc?: WEBGL_compressed_texture_s3tc;
  110822. /** Defines if pvrtc texture compression is supported */
  110823. pvrtc: any;
  110824. /** Defines if etc1 texture compression is supported */
  110825. etc1: any;
  110826. /** Defines if etc2 texture compression is supported */
  110827. etc2: any;
  110828. /** Defines if astc texture compression is supported */
  110829. astc: any;
  110830. /** Defines if float textures are supported */
  110831. textureFloat: boolean;
  110832. /** Defines if vertex array objects are supported */
  110833. vertexArrayObject: boolean;
  110834. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  110835. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  110836. /** Gets the maximum level of anisotropy supported */
  110837. maxAnisotropy: number;
  110838. /** Defines if instancing is supported */
  110839. instancedArrays: boolean;
  110840. /** Defines if 32 bits indices are supported */
  110841. uintIndices: boolean;
  110842. /** Defines if high precision shaders are supported */
  110843. highPrecisionShaderSupported: boolean;
  110844. /** Defines if depth reading in the fragment shader is supported */
  110845. fragmentDepthSupported: boolean;
  110846. /** Defines if float texture linear filtering is supported*/
  110847. textureFloatLinearFiltering: boolean;
  110848. /** Defines if rendering to float textures is supported */
  110849. textureFloatRender: boolean;
  110850. /** Defines if half float textures are supported*/
  110851. textureHalfFloat: boolean;
  110852. /** Defines if half float texture linear filtering is supported*/
  110853. textureHalfFloatLinearFiltering: boolean;
  110854. /** Defines if rendering to half float textures is supported */
  110855. textureHalfFloatRender: boolean;
  110856. /** Defines if textureLOD shader command is supported */
  110857. textureLOD: boolean;
  110858. /** Defines if draw buffers extension is supported */
  110859. drawBuffersExtension: boolean;
  110860. /** Defines if depth textures are supported */
  110861. depthTextureExtension: boolean;
  110862. /** Defines if float color buffer are supported */
  110863. colorBufferFloat: boolean;
  110864. /** Gets disjoint timer query extension (null if not supported) */
  110865. timerQuery?: EXT_disjoint_timer_query;
  110866. /** Defines if timestamp can be used with timer query */
  110867. canUseTimestampForTimerQuery: boolean;
  110868. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  110869. multiview?: any;
  110870. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  110871. oculusMultiview?: any;
  110872. /** Function used to let the system compiles shaders in background */
  110873. parallelShaderCompile?: {
  110874. COMPLETION_STATUS_KHR: number;
  110875. };
  110876. /** Max number of texture samples for MSAA */
  110877. maxMSAASamples: number;
  110878. /** Defines if the blend min max extension is supported */
  110879. blendMinMax: boolean;
  110880. }
  110881. }
  110882. declare module BABYLON {
  110883. /**
  110884. * @hidden
  110885. **/
  110886. export class DepthCullingState {
  110887. private _isDepthTestDirty;
  110888. private _isDepthMaskDirty;
  110889. private _isDepthFuncDirty;
  110890. private _isCullFaceDirty;
  110891. private _isCullDirty;
  110892. private _isZOffsetDirty;
  110893. private _isFrontFaceDirty;
  110894. private _depthTest;
  110895. private _depthMask;
  110896. private _depthFunc;
  110897. private _cull;
  110898. private _cullFace;
  110899. private _zOffset;
  110900. private _frontFace;
  110901. /**
  110902. * Initializes the state.
  110903. */
  110904. constructor();
  110905. get isDirty(): boolean;
  110906. get zOffset(): number;
  110907. set zOffset(value: number);
  110908. get cullFace(): Nullable<number>;
  110909. set cullFace(value: Nullable<number>);
  110910. get cull(): Nullable<boolean>;
  110911. set cull(value: Nullable<boolean>);
  110912. get depthFunc(): Nullable<number>;
  110913. set depthFunc(value: Nullable<number>);
  110914. get depthMask(): boolean;
  110915. set depthMask(value: boolean);
  110916. get depthTest(): boolean;
  110917. set depthTest(value: boolean);
  110918. get frontFace(): Nullable<number>;
  110919. set frontFace(value: Nullable<number>);
  110920. reset(): void;
  110921. apply(gl: WebGLRenderingContext): void;
  110922. }
  110923. }
  110924. declare module BABYLON {
  110925. /**
  110926. * @hidden
  110927. **/
  110928. export class StencilState {
  110929. /** 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 */
  110930. static readonly ALWAYS: number;
  110931. /** Passed to stencilOperation to specify that stencil value must be kept */
  110932. static readonly KEEP: number;
  110933. /** Passed to stencilOperation to specify that stencil value must be replaced */
  110934. static readonly REPLACE: number;
  110935. private _isStencilTestDirty;
  110936. private _isStencilMaskDirty;
  110937. private _isStencilFuncDirty;
  110938. private _isStencilOpDirty;
  110939. private _stencilTest;
  110940. private _stencilMask;
  110941. private _stencilFunc;
  110942. private _stencilFuncRef;
  110943. private _stencilFuncMask;
  110944. private _stencilOpStencilFail;
  110945. private _stencilOpDepthFail;
  110946. private _stencilOpStencilDepthPass;
  110947. get isDirty(): boolean;
  110948. get stencilFunc(): number;
  110949. set stencilFunc(value: number);
  110950. get stencilFuncRef(): number;
  110951. set stencilFuncRef(value: number);
  110952. get stencilFuncMask(): number;
  110953. set stencilFuncMask(value: number);
  110954. get stencilOpStencilFail(): number;
  110955. set stencilOpStencilFail(value: number);
  110956. get stencilOpDepthFail(): number;
  110957. set stencilOpDepthFail(value: number);
  110958. get stencilOpStencilDepthPass(): number;
  110959. set stencilOpStencilDepthPass(value: number);
  110960. get stencilMask(): number;
  110961. set stencilMask(value: number);
  110962. get stencilTest(): boolean;
  110963. set stencilTest(value: boolean);
  110964. constructor();
  110965. reset(): void;
  110966. apply(gl: WebGLRenderingContext): void;
  110967. }
  110968. }
  110969. declare module BABYLON {
  110970. /**
  110971. * @hidden
  110972. **/
  110973. export class AlphaState {
  110974. private _isAlphaBlendDirty;
  110975. private _isBlendFunctionParametersDirty;
  110976. private _isBlendEquationParametersDirty;
  110977. private _isBlendConstantsDirty;
  110978. private _alphaBlend;
  110979. private _blendFunctionParameters;
  110980. private _blendEquationParameters;
  110981. private _blendConstants;
  110982. /**
  110983. * Initializes the state.
  110984. */
  110985. constructor();
  110986. get isDirty(): boolean;
  110987. get alphaBlend(): boolean;
  110988. set alphaBlend(value: boolean);
  110989. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  110990. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  110991. setAlphaEquationParameters(rgb: number, alpha: number): void;
  110992. reset(): void;
  110993. apply(gl: WebGLRenderingContext): void;
  110994. }
  110995. }
  110996. declare module BABYLON {
  110997. /** @hidden */
  110998. export class WebGL2ShaderProcessor implements IShaderProcessor {
  110999. attributeProcessor(attribute: string): string;
  111000. varyingProcessor(varying: string, isFragment: boolean): string;
  111001. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111002. }
  111003. }
  111004. declare module BABYLON {
  111005. /**
  111006. * Interface for attribute information associated with buffer instanciation
  111007. */
  111008. export interface InstancingAttributeInfo {
  111009. /**
  111010. * Name of the GLSL attribute
  111011. * if attribute index is not specified, this is used to retrieve the index from the effect
  111012. */
  111013. attributeName: string;
  111014. /**
  111015. * Index/offset of the attribute in the vertex shader
  111016. * if not specified, this will be computes from the name.
  111017. */
  111018. index?: number;
  111019. /**
  111020. * size of the attribute, 1, 2, 3 or 4
  111021. */
  111022. attributeSize: number;
  111023. /**
  111024. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111025. */
  111026. offset: number;
  111027. /**
  111028. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111029. * default to 1
  111030. */
  111031. divisor?: number;
  111032. /**
  111033. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111034. * default is FLOAT
  111035. */
  111036. attributeType?: number;
  111037. /**
  111038. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111039. */
  111040. normalized?: boolean;
  111041. }
  111042. }
  111043. declare module BABYLON {
  111044. interface ThinEngine {
  111045. /**
  111046. * Update a video texture
  111047. * @param texture defines the texture to update
  111048. * @param video defines the video element to use
  111049. * @param invertY defines if data must be stored with Y axis inverted
  111050. */
  111051. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111052. }
  111053. }
  111054. declare module BABYLON {
  111055. /**
  111056. * Settings for finer control over video usage
  111057. */
  111058. export interface VideoTextureSettings {
  111059. /**
  111060. * Applies `autoplay` to video, if specified
  111061. */
  111062. autoPlay?: boolean;
  111063. /**
  111064. * Applies `loop` to video, if specified
  111065. */
  111066. loop?: boolean;
  111067. /**
  111068. * Automatically updates internal texture from video at every frame in the render loop
  111069. */
  111070. autoUpdateTexture: boolean;
  111071. /**
  111072. * Image src displayed during the video loading or until the user interacts with the video.
  111073. */
  111074. poster?: string;
  111075. }
  111076. /**
  111077. * If you want to display a video in your scene, this is the special texture for that.
  111078. * This special texture works similar to other textures, with the exception of a few parameters.
  111079. * @see https://doc.babylonjs.com/how_to/video_texture
  111080. */
  111081. export class VideoTexture extends Texture {
  111082. /**
  111083. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111084. */
  111085. readonly autoUpdateTexture: boolean;
  111086. /**
  111087. * The video instance used by the texture internally
  111088. */
  111089. readonly video: HTMLVideoElement;
  111090. private _onUserActionRequestedObservable;
  111091. /**
  111092. * Event triggerd when a dom action is required by the user to play the video.
  111093. * This happens due to recent changes in browser policies preventing video to auto start.
  111094. */
  111095. get onUserActionRequestedObservable(): Observable<Texture>;
  111096. private _generateMipMaps;
  111097. private _stillImageCaptured;
  111098. private _displayingPosterTexture;
  111099. private _settings;
  111100. private _createInternalTextureOnEvent;
  111101. private _frameId;
  111102. private _currentSrc;
  111103. /**
  111104. * Creates a video texture.
  111105. * If you want to display a video in your scene, this is the special texture for that.
  111106. * This special texture works similar to other textures, with the exception of a few parameters.
  111107. * @see https://doc.babylonjs.com/how_to/video_texture
  111108. * @param name optional name, will detect from video source, if not defined
  111109. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111110. * @param scene is obviously the current scene.
  111111. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111112. * @param invertY is false by default but can be used to invert video on Y axis
  111113. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111114. * @param settings allows finer control over video usage
  111115. */
  111116. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111117. private _getName;
  111118. private _getVideo;
  111119. private _createInternalTexture;
  111120. private reset;
  111121. /**
  111122. * @hidden Internal method to initiate `update`.
  111123. */
  111124. _rebuild(): void;
  111125. /**
  111126. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111127. */
  111128. update(): void;
  111129. /**
  111130. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111131. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111132. */
  111133. updateTexture(isVisible: boolean): void;
  111134. protected _updateInternalTexture: () => void;
  111135. /**
  111136. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111137. * @param url New url.
  111138. */
  111139. updateURL(url: string): void;
  111140. /**
  111141. * Clones the texture.
  111142. * @returns the cloned texture
  111143. */
  111144. clone(): VideoTexture;
  111145. /**
  111146. * Dispose the texture and release its associated resources.
  111147. */
  111148. dispose(): void;
  111149. /**
  111150. * Creates a video texture straight from a stream.
  111151. * @param scene Define the scene the texture should be created in
  111152. * @param stream Define the stream the texture should be created from
  111153. * @returns The created video texture as a promise
  111154. */
  111155. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111156. /**
  111157. * Creates a video texture straight from your WebCam video feed.
  111158. * @param scene Define the scene the texture should be created in
  111159. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111160. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111161. * @returns The created video texture as a promise
  111162. */
  111163. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111164. minWidth: number;
  111165. maxWidth: number;
  111166. minHeight: number;
  111167. maxHeight: number;
  111168. deviceId: string;
  111169. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111170. /**
  111171. * Creates a video texture straight from your WebCam video feed.
  111172. * @param scene Define the scene the texture should be created in
  111173. * @param onReady Define a callback to triggered once the texture will be ready
  111174. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111175. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111176. */
  111177. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111178. minWidth: number;
  111179. maxWidth: number;
  111180. minHeight: number;
  111181. maxHeight: number;
  111182. deviceId: string;
  111183. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111184. }
  111185. }
  111186. declare module BABYLON {
  111187. /**
  111188. * Defines the interface used by objects working like Scene
  111189. * @hidden
  111190. */
  111191. export interface ISceneLike {
  111192. _addPendingData(data: any): void;
  111193. _removePendingData(data: any): void;
  111194. offlineProvider: IOfflineProvider;
  111195. }
  111196. /** Interface defining initialization parameters for Engine class */
  111197. export interface EngineOptions extends WebGLContextAttributes {
  111198. /**
  111199. * Defines if the engine should no exceed a specified device ratio
  111200. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111201. */
  111202. limitDeviceRatio?: number;
  111203. /**
  111204. * Defines if webvr should be enabled automatically
  111205. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111206. */
  111207. autoEnableWebVR?: boolean;
  111208. /**
  111209. * Defines if webgl2 should be turned off even if supported
  111210. * @see http://doc.babylonjs.com/features/webgl2
  111211. */
  111212. disableWebGL2Support?: boolean;
  111213. /**
  111214. * Defines if webaudio should be initialized as well
  111215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111216. */
  111217. audioEngine?: boolean;
  111218. /**
  111219. * Defines if animations should run using a deterministic lock step
  111220. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111221. */
  111222. deterministicLockstep?: boolean;
  111223. /** Defines the maximum steps to use with deterministic lock step mode */
  111224. lockstepMaxSteps?: number;
  111225. /** Defines the seconds between each deterministic lock step */
  111226. timeStep?: number;
  111227. /**
  111228. * Defines that engine should ignore context lost events
  111229. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111230. */
  111231. doNotHandleContextLost?: boolean;
  111232. /**
  111233. * Defines that engine should ignore modifying touch action attribute and style
  111234. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111235. */
  111236. doNotHandleTouchAction?: boolean;
  111237. /**
  111238. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  111239. */
  111240. useHighPrecisionFloats?: boolean;
  111241. }
  111242. /**
  111243. * The base engine class (root of all engines)
  111244. */
  111245. export class ThinEngine {
  111246. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  111247. static ExceptionList: ({
  111248. key: string;
  111249. capture: string;
  111250. captureConstraint: number;
  111251. targets: string[];
  111252. } | {
  111253. key: string;
  111254. capture: null;
  111255. captureConstraint: null;
  111256. targets: string[];
  111257. })[];
  111258. /** @hidden */
  111259. static _TextureLoaders: IInternalTextureLoader[];
  111260. /**
  111261. * Returns the current npm package of the sdk
  111262. */
  111263. static get NpmPackage(): string;
  111264. /**
  111265. * Returns the current version of the framework
  111266. */
  111267. static get Version(): string;
  111268. /**
  111269. * Returns a string describing the current engine
  111270. */
  111271. get description(): string;
  111272. /**
  111273. * Gets or sets the epsilon value used by collision engine
  111274. */
  111275. static CollisionsEpsilon: number;
  111276. /**
  111277. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111278. */
  111279. static get ShadersRepository(): string;
  111280. static set ShadersRepository(value: string);
  111281. /** @hidden */
  111282. _shaderProcessor: IShaderProcessor;
  111283. /**
  111284. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  111285. */
  111286. forcePOTTextures: boolean;
  111287. /**
  111288. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  111289. */
  111290. isFullscreen: boolean;
  111291. /**
  111292. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  111293. */
  111294. cullBackFaces: boolean;
  111295. /**
  111296. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  111297. */
  111298. renderEvenInBackground: boolean;
  111299. /**
  111300. * Gets or sets a boolean indicating that cache can be kept between frames
  111301. */
  111302. preventCacheWipeBetweenFrames: boolean;
  111303. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  111304. validateShaderPrograms: boolean;
  111305. /**
  111306. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  111307. * This can provide greater z depth for distant objects.
  111308. */
  111309. useReverseDepthBuffer: boolean;
  111310. /**
  111311. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  111312. */
  111313. disableUniformBuffers: boolean;
  111314. /** @hidden */
  111315. _uniformBuffers: UniformBuffer[];
  111316. /**
  111317. * Gets a boolean indicating that the engine supports uniform buffers
  111318. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  111319. */
  111320. get supportsUniformBuffers(): boolean;
  111321. /** @hidden */
  111322. _gl: WebGLRenderingContext;
  111323. /** @hidden */
  111324. _webGLVersion: number;
  111325. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  111326. protected _windowIsBackground: boolean;
  111327. protected _creationOptions: EngineOptions;
  111328. protected _highPrecisionShadersAllowed: boolean;
  111329. /** @hidden */
  111330. get _shouldUseHighPrecisionShader(): boolean;
  111331. /**
  111332. * Gets a boolean indicating that only power of 2 textures are supported
  111333. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  111334. */
  111335. get needPOTTextures(): boolean;
  111336. /** @hidden */
  111337. _badOS: boolean;
  111338. /** @hidden */
  111339. _badDesktopOS: boolean;
  111340. private _hardwareScalingLevel;
  111341. /** @hidden */
  111342. _caps: EngineCapabilities;
  111343. private _isStencilEnable;
  111344. private _glVersion;
  111345. private _glRenderer;
  111346. private _glVendor;
  111347. /** @hidden */
  111348. _videoTextureSupported: boolean;
  111349. protected _renderingQueueLaunched: boolean;
  111350. protected _activeRenderLoops: (() => void)[];
  111351. /**
  111352. * Observable signaled when a context lost event is raised
  111353. */
  111354. onContextLostObservable: Observable<ThinEngine>;
  111355. /**
  111356. * Observable signaled when a context restored event is raised
  111357. */
  111358. onContextRestoredObservable: Observable<ThinEngine>;
  111359. private _onContextLost;
  111360. private _onContextRestored;
  111361. protected _contextWasLost: boolean;
  111362. /** @hidden */
  111363. _doNotHandleContextLost: boolean;
  111364. /**
  111365. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  111366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  111367. */
  111368. get doNotHandleContextLost(): boolean;
  111369. set doNotHandleContextLost(value: boolean);
  111370. /**
  111371. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  111372. */
  111373. disableVertexArrayObjects: boolean;
  111374. /** @hidden */
  111375. protected _colorWrite: boolean;
  111376. /** @hidden */
  111377. protected _colorWriteChanged: boolean;
  111378. /** @hidden */
  111379. protected _depthCullingState: DepthCullingState;
  111380. /** @hidden */
  111381. protected _stencilState: StencilState;
  111382. /** @hidden */
  111383. _alphaState: AlphaState;
  111384. /** @hidden */
  111385. _alphaMode: number;
  111386. /** @hidden */
  111387. _alphaEquation: number;
  111388. /** @hidden */
  111389. _internalTexturesCache: InternalTexture[];
  111390. /** @hidden */
  111391. protected _activeChannel: number;
  111392. private _currentTextureChannel;
  111393. /** @hidden */
  111394. protected _boundTexturesCache: {
  111395. [key: string]: Nullable<InternalTexture>;
  111396. };
  111397. /** @hidden */
  111398. protected _currentEffect: Nullable<Effect>;
  111399. /** @hidden */
  111400. protected _currentProgram: Nullable<WebGLProgram>;
  111401. private _compiledEffects;
  111402. private _vertexAttribArraysEnabled;
  111403. /** @hidden */
  111404. protected _cachedViewport: Nullable<IViewportLike>;
  111405. private _cachedVertexArrayObject;
  111406. /** @hidden */
  111407. protected _cachedVertexBuffers: any;
  111408. /** @hidden */
  111409. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  111410. /** @hidden */
  111411. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  111412. /** @hidden */
  111413. _currentRenderTarget: Nullable<InternalTexture>;
  111414. private _uintIndicesCurrentlySet;
  111415. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  111416. /** @hidden */
  111417. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  111418. /** @hidden */
  111419. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  111420. private _currentBufferPointers;
  111421. private _currentInstanceLocations;
  111422. private _currentInstanceBuffers;
  111423. private _textureUnits;
  111424. /** @hidden */
  111425. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  111426. /** @hidden */
  111427. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  111428. /** @hidden */
  111429. _boundRenderFunction: any;
  111430. private _vaoRecordInProgress;
  111431. private _mustWipeVertexAttributes;
  111432. private _emptyTexture;
  111433. private _emptyCubeTexture;
  111434. private _emptyTexture3D;
  111435. private _emptyTexture2DArray;
  111436. /** @hidden */
  111437. _frameHandler: number;
  111438. private _nextFreeTextureSlots;
  111439. private _maxSimultaneousTextures;
  111440. private _activeRequests;
  111441. /** @hidden */
  111442. _transformTextureUrl: Nullable<(url: string) => string>;
  111443. protected get _supportsHardwareTextureRescaling(): boolean;
  111444. private _framebufferDimensionsObject;
  111445. /**
  111446. * sets the object from which width and height will be taken from when getting render width and height
  111447. * Will fallback to the gl object
  111448. * @param dimensions the framebuffer width and height that will be used.
  111449. */
  111450. set framebufferDimensionsObject(dimensions: Nullable<{
  111451. framebufferWidth: number;
  111452. framebufferHeight: number;
  111453. }>);
  111454. /**
  111455. * Gets the current viewport
  111456. */
  111457. get currentViewport(): Nullable<IViewportLike>;
  111458. /**
  111459. * Gets the default empty texture
  111460. */
  111461. get emptyTexture(): InternalTexture;
  111462. /**
  111463. * Gets the default empty 3D texture
  111464. */
  111465. get emptyTexture3D(): InternalTexture;
  111466. /**
  111467. * Gets the default empty 2D array texture
  111468. */
  111469. get emptyTexture2DArray(): InternalTexture;
  111470. /**
  111471. * Gets the default empty cube texture
  111472. */
  111473. get emptyCubeTexture(): InternalTexture;
  111474. /**
  111475. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  111476. */
  111477. readonly premultipliedAlpha: boolean;
  111478. /**
  111479. * Observable event triggered before each texture is initialized
  111480. */
  111481. onBeforeTextureInitObservable: Observable<Texture>;
  111482. /**
  111483. * Creates a new engine
  111484. * @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
  111485. * @param antialias defines enable antialiasing (default: false)
  111486. * @param options defines further options to be sent to the getContext() function
  111487. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  111488. */
  111489. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  111490. private _rebuildInternalTextures;
  111491. private _rebuildEffects;
  111492. /**
  111493. * Gets a boolean indicating if all created effects are ready
  111494. * @returns true if all effects are ready
  111495. */
  111496. areAllEffectsReady(): boolean;
  111497. protected _rebuildBuffers(): void;
  111498. protected _initGLContext(): void;
  111499. /**
  111500. * Gets version of the current webGL context
  111501. */
  111502. get webGLVersion(): number;
  111503. /**
  111504. * Gets a string idenfifying the name of the class
  111505. * @returns "Engine" string
  111506. */
  111507. getClassName(): string;
  111508. /**
  111509. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  111510. */
  111511. get isStencilEnable(): boolean;
  111512. /** @hidden */
  111513. _prepareWorkingCanvas(): void;
  111514. /**
  111515. * Reset the texture cache to empty state
  111516. */
  111517. resetTextureCache(): void;
  111518. /**
  111519. * Gets an object containing information about the current webGL context
  111520. * @returns an object containing the vender, the renderer and the version of the current webGL context
  111521. */
  111522. getGlInfo(): {
  111523. vendor: string;
  111524. renderer: string;
  111525. version: string;
  111526. };
  111527. /**
  111528. * Defines the hardware scaling level.
  111529. * By default the hardware scaling level is computed from the window device ratio.
  111530. * 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.
  111531. * @param level defines the level to use
  111532. */
  111533. setHardwareScalingLevel(level: number): void;
  111534. /**
  111535. * Gets the current hardware scaling level.
  111536. * By default the hardware scaling level is computed from the window device ratio.
  111537. * 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.
  111538. * @returns a number indicating the current hardware scaling level
  111539. */
  111540. getHardwareScalingLevel(): number;
  111541. /**
  111542. * Gets the list of loaded textures
  111543. * @returns an array containing all loaded textures
  111544. */
  111545. getLoadedTexturesCache(): InternalTexture[];
  111546. /**
  111547. * Gets the object containing all engine capabilities
  111548. * @returns the EngineCapabilities object
  111549. */
  111550. getCaps(): EngineCapabilities;
  111551. /**
  111552. * stop executing a render loop function and remove it from the execution array
  111553. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  111554. */
  111555. stopRenderLoop(renderFunction?: () => void): void;
  111556. /** @hidden */
  111557. _renderLoop(): void;
  111558. /**
  111559. * Gets the HTML canvas attached with the current webGL context
  111560. * @returns a HTML canvas
  111561. */
  111562. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  111563. /**
  111564. * Gets host window
  111565. * @returns the host window object
  111566. */
  111567. getHostWindow(): Nullable<Window>;
  111568. /**
  111569. * Gets the current render width
  111570. * @param useScreen defines if screen size must be used (or the current render target if any)
  111571. * @returns a number defining the current render width
  111572. */
  111573. getRenderWidth(useScreen?: boolean): number;
  111574. /**
  111575. * Gets the current render height
  111576. * @param useScreen defines if screen size must be used (or the current render target if any)
  111577. * @returns a number defining the current render height
  111578. */
  111579. getRenderHeight(useScreen?: boolean): number;
  111580. /**
  111581. * Can be used to override the current requestAnimationFrame requester.
  111582. * @hidden
  111583. */
  111584. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  111585. /**
  111586. * Register and execute a render loop. The engine can have more than one render function
  111587. * @param renderFunction defines the function to continuously execute
  111588. */
  111589. runRenderLoop(renderFunction: () => void): void;
  111590. /**
  111591. * Clear the current render buffer or the current render target (if any is set up)
  111592. * @param color defines the color to use
  111593. * @param backBuffer defines if the back buffer must be cleared
  111594. * @param depth defines if the depth buffer must be cleared
  111595. * @param stencil defines if the stencil buffer must be cleared
  111596. */
  111597. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111598. private _viewportCached;
  111599. /** @hidden */
  111600. _viewport(x: number, y: number, width: number, height: number): void;
  111601. /**
  111602. * Set the WebGL's viewport
  111603. * @param viewport defines the viewport element to be used
  111604. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111605. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111606. */
  111607. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111608. /**
  111609. * Begin a new frame
  111610. */
  111611. beginFrame(): void;
  111612. /**
  111613. * Enf the current frame
  111614. */
  111615. endFrame(): void;
  111616. /**
  111617. * Resize the view according to the canvas' size
  111618. */
  111619. resize(): void;
  111620. /**
  111621. * Force a specific size of the canvas
  111622. * @param width defines the new canvas' width
  111623. * @param height defines the new canvas' height
  111624. */
  111625. setSize(width: number, height: number): void;
  111626. /**
  111627. * Binds the frame buffer to the specified texture.
  111628. * @param texture The texture to render to or null for the default canvas
  111629. * @param faceIndex The face of the texture to render to in case of cube texture
  111630. * @param requiredWidth The width of the target to render to
  111631. * @param requiredHeight The height of the target to render to
  111632. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111633. * @param lodLevel defines the lod level to bind to the frame buffer
  111634. * @param layer defines the 2d array index to bind to frame buffer to
  111635. */
  111636. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  111637. /** @hidden */
  111638. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  111639. /**
  111640. * Unbind the current render target texture from the webGL context
  111641. * @param texture defines the render target texture to unbind
  111642. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111643. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111644. */
  111645. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111646. /**
  111647. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  111648. */
  111649. flushFramebuffer(): void;
  111650. /**
  111651. * Unbind the current render target and bind the default framebuffer
  111652. */
  111653. restoreDefaultFramebuffer(): void;
  111654. /** @hidden */
  111655. protected _resetVertexBufferBinding(): void;
  111656. /**
  111657. * Creates a vertex buffer
  111658. * @param data the data for the vertex buffer
  111659. * @returns the new WebGL static buffer
  111660. */
  111661. createVertexBuffer(data: DataArray): DataBuffer;
  111662. private _createVertexBuffer;
  111663. /**
  111664. * Creates a dynamic vertex buffer
  111665. * @param data the data for the dynamic vertex buffer
  111666. * @returns the new WebGL dynamic buffer
  111667. */
  111668. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111669. protected _resetIndexBufferBinding(): void;
  111670. /**
  111671. * Creates a new index buffer
  111672. * @param indices defines the content of the index buffer
  111673. * @param updatable defines if the index buffer must be updatable
  111674. * @returns a new webGL buffer
  111675. */
  111676. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  111677. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  111678. /**
  111679. * Bind a webGL buffer to the webGL context
  111680. * @param buffer defines the buffer to bind
  111681. */
  111682. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  111683. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  111684. private bindBuffer;
  111685. /**
  111686. * update the bound buffer with the given data
  111687. * @param data defines the data to update
  111688. */
  111689. updateArrayBuffer(data: Float32Array): void;
  111690. private _vertexAttribPointer;
  111691. /** @hidden */
  111692. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  111693. private _bindVertexBuffersAttributes;
  111694. /**
  111695. * Records a vertex array object
  111696. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111697. * @param vertexBuffers defines the list of vertex buffers to store
  111698. * @param indexBuffer defines the index buffer to store
  111699. * @param effect defines the effect to store
  111700. * @returns the new vertex array object
  111701. */
  111702. recordVertexArrayObject(vertexBuffers: {
  111703. [key: string]: VertexBuffer;
  111704. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111705. /**
  111706. * Bind a specific vertex array object
  111707. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111708. * @param vertexArrayObject defines the vertex array object to bind
  111709. * @param indexBuffer defines the index buffer to bind
  111710. */
  111711. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  111712. /**
  111713. * Bind webGl buffers directly to the webGL context
  111714. * @param vertexBuffer defines the vertex buffer to bind
  111715. * @param indexBuffer defines the index buffer to bind
  111716. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111717. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111718. * @param effect defines the effect associated with the vertex buffer
  111719. */
  111720. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  111721. private _unbindVertexArrayObject;
  111722. /**
  111723. * Bind a list of vertex buffers to the webGL context
  111724. * @param vertexBuffers defines the list of vertex buffers to bind
  111725. * @param indexBuffer defines the index buffer to bind
  111726. * @param effect defines the effect associated with the vertex buffers
  111727. */
  111728. bindBuffers(vertexBuffers: {
  111729. [key: string]: Nullable<VertexBuffer>;
  111730. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  111731. /**
  111732. * Unbind all instance attributes
  111733. */
  111734. unbindInstanceAttributes(): void;
  111735. /**
  111736. * Release and free the memory of a vertex array object
  111737. * @param vao defines the vertex array object to delete
  111738. */
  111739. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  111740. /** @hidden */
  111741. _releaseBuffer(buffer: DataBuffer): boolean;
  111742. protected _deleteBuffer(buffer: DataBuffer): void;
  111743. /**
  111744. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  111745. * @param instancesBuffer defines the webGL buffer to update and bind
  111746. * @param data defines the data to store in the buffer
  111747. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  111748. */
  111749. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  111750. /**
  111751. * Bind the content of a webGL buffer used with instantiation
  111752. * @param instancesBuffer defines the webGL buffer to bind
  111753. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  111754. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  111755. */
  111756. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  111757. /**
  111758. * Disable the instance attribute corresponding to the name in parameter
  111759. * @param name defines the name of the attribute to disable
  111760. */
  111761. disableInstanceAttributeByName(name: string): void;
  111762. /**
  111763. * Disable the instance attribute corresponding to the location in parameter
  111764. * @param attributeLocation defines the attribute location of the attribute to disable
  111765. */
  111766. disableInstanceAttribute(attributeLocation: number): void;
  111767. /**
  111768. * Disable the attribute corresponding to the location in parameter
  111769. * @param attributeLocation defines the attribute location of the attribute to disable
  111770. */
  111771. disableAttributeByIndex(attributeLocation: number): void;
  111772. /**
  111773. * Send a draw order
  111774. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111775. * @param indexStart defines the starting index
  111776. * @param indexCount defines the number of index to draw
  111777. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111778. */
  111779. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111780. /**
  111781. * Draw a list of points
  111782. * @param verticesStart defines the index of first vertex to draw
  111783. * @param verticesCount defines the count of vertices to draw
  111784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111785. */
  111786. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111787. /**
  111788. * Draw a list of unindexed primitives
  111789. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111790. * @param verticesStart defines the index of first vertex to draw
  111791. * @param verticesCount defines the count of vertices to draw
  111792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111793. */
  111794. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111795. /**
  111796. * Draw a list of indexed primitives
  111797. * @param fillMode defines the primitive to use
  111798. * @param indexStart defines the starting index
  111799. * @param indexCount defines the number of index to draw
  111800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111801. */
  111802. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111803. /**
  111804. * Draw a list of unindexed primitives
  111805. * @param fillMode defines the primitive to use
  111806. * @param verticesStart defines the index of first vertex to draw
  111807. * @param verticesCount defines the count of vertices to draw
  111808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111809. */
  111810. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111811. private _drawMode;
  111812. /** @hidden */
  111813. protected _reportDrawCall(): void;
  111814. /** @hidden */
  111815. _releaseEffect(effect: Effect): void;
  111816. /** @hidden */
  111817. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111818. /**
  111819. * Create a new effect (used to store vertex/fragment shaders)
  111820. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  111821. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  111822. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  111823. * @param samplers defines an array of string used to represent textures
  111824. * @param defines defines the string containing the defines to use to compile the shaders
  111825. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111826. * @param onCompiled defines a function to call when the effect creation is successful
  111827. * @param onError defines a function to call when the effect creation has failed
  111828. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  111829. * @returns the new Effect
  111830. */
  111831. 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;
  111832. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  111833. private _compileShader;
  111834. private _compileRawShader;
  111835. /** @hidden */
  111836. _getShaderSource(shader: WebGLShader): Nullable<string>;
  111837. /**
  111838. * Directly creates a webGL program
  111839. * @param pipelineContext defines the pipeline context to attach to
  111840. * @param vertexCode defines the vertex shader code to use
  111841. * @param fragmentCode defines the fragment shader code to use
  111842. * @param context defines the webGL context to use (if not set, the current one will be used)
  111843. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111844. * @returns the new webGL program
  111845. */
  111846. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111847. /**
  111848. * Creates a webGL program
  111849. * @param pipelineContext defines the pipeline context to attach to
  111850. * @param vertexCode defines the vertex shader code to use
  111851. * @param fragmentCode defines the fragment shader code to use
  111852. * @param defines defines the string containing the defines to use to compile the shaders
  111853. * @param context defines the webGL context to use (if not set, the current one will be used)
  111854. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111855. * @returns the new webGL program
  111856. */
  111857. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111858. /**
  111859. * Creates a new pipeline context
  111860. * @returns the new pipeline
  111861. */
  111862. createPipelineContext(): IPipelineContext;
  111863. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111864. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  111865. /** @hidden */
  111866. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111867. /** @hidden */
  111868. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111869. /** @hidden */
  111870. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111871. /**
  111872. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111873. * @param pipelineContext defines the pipeline context to use
  111874. * @param uniformsNames defines the list of uniform names
  111875. * @returns an array of webGL uniform locations
  111876. */
  111877. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111878. /**
  111879. * Gets the lsit of active attributes for a given webGL program
  111880. * @param pipelineContext defines the pipeline context to use
  111881. * @param attributesNames defines the list of attribute names to get
  111882. * @returns an array of indices indicating the offset of each attribute
  111883. */
  111884. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111885. /**
  111886. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111887. * @param effect defines the effect to activate
  111888. */
  111889. enableEffect(effect: Nullable<Effect>): void;
  111890. /**
  111891. * Set the value of an uniform to a number (int)
  111892. * @param uniform defines the webGL uniform location where to store the value
  111893. * @param value defines the int number to store
  111894. */
  111895. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111896. /**
  111897. * Set the value of an uniform to an array of int32
  111898. * @param uniform defines the webGL uniform location where to store the value
  111899. * @param array defines the array of int32 to store
  111900. */
  111901. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111902. /**
  111903. * Set the value of an uniform to an array of int32 (stored as vec2)
  111904. * @param uniform defines the webGL uniform location where to store the value
  111905. * @param array defines the array of int32 to store
  111906. */
  111907. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111908. /**
  111909. * Set the value of an uniform to an array of int32 (stored as vec3)
  111910. * @param uniform defines the webGL uniform location where to store the value
  111911. * @param array defines the array of int32 to store
  111912. */
  111913. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111914. /**
  111915. * Set the value of an uniform to an array of int32 (stored as vec4)
  111916. * @param uniform defines the webGL uniform location where to store the value
  111917. * @param array defines the array of int32 to store
  111918. */
  111919. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111920. /**
  111921. * Set the value of an uniform to an array of number
  111922. * @param uniform defines the webGL uniform location where to store the value
  111923. * @param array defines the array of number to store
  111924. */
  111925. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111926. /**
  111927. * Set the value of an uniform to an array of number (stored as vec2)
  111928. * @param uniform defines the webGL uniform location where to store the value
  111929. * @param array defines the array of number to store
  111930. */
  111931. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111932. /**
  111933. * Set the value of an uniform to an array of number (stored as vec3)
  111934. * @param uniform defines the webGL uniform location where to store the value
  111935. * @param array defines the array of number to store
  111936. */
  111937. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111938. /**
  111939. * Set the value of an uniform to an array of number (stored as vec4)
  111940. * @param uniform defines the webGL uniform location where to store the value
  111941. * @param array defines the array of number to store
  111942. */
  111943. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111944. /**
  111945. * Set the value of an uniform to an array of float32 (stored as matrices)
  111946. * @param uniform defines the webGL uniform location where to store the value
  111947. * @param matrices defines the array of float32 to store
  111948. */
  111949. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  111950. /**
  111951. * Set the value of an uniform to a matrix (3x3)
  111952. * @param uniform defines the webGL uniform location where to store the value
  111953. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111954. */
  111955. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111956. /**
  111957. * Set the value of an uniform to a matrix (2x2)
  111958. * @param uniform defines the webGL uniform location where to store the value
  111959. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111960. */
  111961. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111962. /**
  111963. * Set the value of an uniform to a number (float)
  111964. * @param uniform defines the webGL uniform location where to store the value
  111965. * @param value defines the float number to store
  111966. */
  111967. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111968. /**
  111969. * Set the value of an uniform to a vec2
  111970. * @param uniform defines the webGL uniform location where to store the value
  111971. * @param x defines the 1st component of the value
  111972. * @param y defines the 2nd component of the value
  111973. */
  111974. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  111975. /**
  111976. * Set the value of an uniform to a vec3
  111977. * @param uniform defines the webGL uniform location where to store the value
  111978. * @param x defines the 1st component of the value
  111979. * @param y defines the 2nd component of the value
  111980. * @param z defines the 3rd component of the value
  111981. */
  111982. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  111983. /**
  111984. * Set the value of an uniform to a vec4
  111985. * @param uniform defines the webGL uniform location where to store the value
  111986. * @param x defines the 1st component of the value
  111987. * @param y defines the 2nd component of the value
  111988. * @param z defines the 3rd component of the value
  111989. * @param w defines the 4th component of the value
  111990. */
  111991. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  111992. /**
  111993. * Apply all cached states (depth, culling, stencil and alpha)
  111994. */
  111995. applyStates(): void;
  111996. /**
  111997. * Enable or disable color writing
  111998. * @param enable defines the state to set
  111999. */
  112000. setColorWrite(enable: boolean): void;
  112001. /**
  112002. * Gets a boolean indicating if color writing is enabled
  112003. * @returns the current color writing state
  112004. */
  112005. getColorWrite(): boolean;
  112006. /**
  112007. * Gets the depth culling state manager
  112008. */
  112009. get depthCullingState(): DepthCullingState;
  112010. /**
  112011. * Gets the alpha state manager
  112012. */
  112013. get alphaState(): AlphaState;
  112014. /**
  112015. * Gets the stencil state manager
  112016. */
  112017. get stencilState(): StencilState;
  112018. /**
  112019. * Clears the list of texture accessible through engine.
  112020. * This can help preventing texture load conflict due to name collision.
  112021. */
  112022. clearInternalTexturesCache(): void;
  112023. /**
  112024. * Force the entire cache to be cleared
  112025. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112026. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112027. */
  112028. wipeCaches(bruteForce?: boolean): void;
  112029. /** @hidden */
  112030. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112031. min: number;
  112032. mag: number;
  112033. };
  112034. /** @hidden */
  112035. _createTexture(): WebGLTexture;
  112036. /**
  112037. * Usually called from Texture.ts.
  112038. * Passed information to create a WebGLTexture
  112039. * @param url defines a value which contains one of the following:
  112040. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112041. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112042. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112043. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112044. * @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)
  112045. * @param scene needed for loading to the correct scene
  112046. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112047. * @param onLoad optional callback to be called upon successful completion
  112048. * @param onError optional callback to be called upon failure
  112049. * @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
  112050. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112051. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112052. * @param forcedExtension defines the extension to use to pick the right loader
  112053. * @param mimeType defines an optional mime type
  112054. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112055. */
  112056. 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;
  112057. /**
  112058. * Loads an image as an HTMLImageElement.
  112059. * @param input url string, ArrayBuffer, or Blob to load
  112060. * @param onLoad callback called when the image successfully loads
  112061. * @param onError callback called when the image fails to load
  112062. * @param offlineProvider offline provider for caching
  112063. * @param mimeType optional mime type
  112064. * @returns the HTMLImageElement of the loaded image
  112065. * @hidden
  112066. */
  112067. 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>;
  112068. /**
  112069. * @hidden
  112070. */
  112071. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112072. private _unpackFlipYCached;
  112073. /**
  112074. * In case you are sharing the context with other applications, it might
  112075. * be interested to not cache the unpack flip y state to ensure a consistent
  112076. * value would be set.
  112077. */
  112078. enableUnpackFlipYCached: boolean;
  112079. /** @hidden */
  112080. _unpackFlipY(value: boolean): void;
  112081. /** @hidden */
  112082. _getUnpackAlignement(): number;
  112083. private _getTextureTarget;
  112084. /**
  112085. * Update the sampling mode of a given texture
  112086. * @param samplingMode defines the required sampling mode
  112087. * @param texture defines the texture to update
  112088. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112089. */
  112090. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112091. /**
  112092. * Update the sampling mode of a given texture
  112093. * @param texture defines the texture to update
  112094. * @param wrapU defines the texture wrap mode of the u coordinates
  112095. * @param wrapV defines the texture wrap mode of the v coordinates
  112096. * @param wrapR defines the texture wrap mode of the r coordinates
  112097. */
  112098. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112099. /** @hidden */
  112100. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112101. width: number;
  112102. height: number;
  112103. layers?: number;
  112104. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112105. /** @hidden */
  112106. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112107. /** @hidden */
  112108. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112109. /**
  112110. * Update a portion of an internal texture
  112111. * @param texture defines the texture to update
  112112. * @param imageData defines the data to store into the texture
  112113. * @param xOffset defines the x coordinates of the update rectangle
  112114. * @param yOffset defines the y coordinates of the update rectangle
  112115. * @param width defines the width of the update rectangle
  112116. * @param height defines the height of the update rectangle
  112117. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112118. * @param lod defines the lod level to update (0 by default)
  112119. */
  112120. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112121. /** @hidden */
  112122. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112123. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112124. private _prepareWebGLTexture;
  112125. /** @hidden */
  112126. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112127. private _getDepthStencilBuffer;
  112128. /** @hidden */
  112129. _releaseFramebufferObjects(texture: InternalTexture): void;
  112130. /** @hidden */
  112131. _releaseTexture(texture: InternalTexture): void;
  112132. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112133. protected _setProgram(program: WebGLProgram): void;
  112134. protected _boundUniforms: {
  112135. [key: number]: WebGLUniformLocation;
  112136. };
  112137. /**
  112138. * Binds an effect to the webGL context
  112139. * @param effect defines the effect to bind
  112140. */
  112141. bindSamplers(effect: Effect): void;
  112142. private _activateCurrentTexture;
  112143. /** @hidden */
  112144. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112145. /** @hidden */
  112146. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112147. /**
  112148. * Unbind all textures from the webGL context
  112149. */
  112150. unbindAllTextures(): void;
  112151. /**
  112152. * Sets a texture to the according uniform.
  112153. * @param channel The texture channel
  112154. * @param uniform The uniform to set
  112155. * @param texture The texture to apply
  112156. */
  112157. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112158. private _bindSamplerUniformToChannel;
  112159. private _getTextureWrapMode;
  112160. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112161. /**
  112162. * Sets an array of texture to the webGL context
  112163. * @param channel defines the channel where the texture array must be set
  112164. * @param uniform defines the associated uniform location
  112165. * @param textures defines the array of textures to bind
  112166. */
  112167. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112168. /** @hidden */
  112169. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112170. private _setTextureParameterFloat;
  112171. private _setTextureParameterInteger;
  112172. /**
  112173. * Unbind all vertex attributes from the webGL context
  112174. */
  112175. unbindAllAttributes(): void;
  112176. /**
  112177. * 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
  112178. */
  112179. releaseEffects(): void;
  112180. /**
  112181. * Dispose and release all associated resources
  112182. */
  112183. dispose(): void;
  112184. /**
  112185. * Attach a new callback raised when context lost event is fired
  112186. * @param callback defines the callback to call
  112187. */
  112188. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112189. /**
  112190. * Attach a new callback raised when context restored event is fired
  112191. * @param callback defines the callback to call
  112192. */
  112193. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112194. /**
  112195. * Get the current error code of the webGL context
  112196. * @returns the error code
  112197. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112198. */
  112199. getError(): number;
  112200. private _canRenderToFloatFramebuffer;
  112201. private _canRenderToHalfFloatFramebuffer;
  112202. private _canRenderToFramebuffer;
  112203. /** @hidden */
  112204. _getWebGLTextureType(type: number): number;
  112205. /** @hidden */
  112206. _getInternalFormat(format: number): number;
  112207. /** @hidden */
  112208. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112209. /** @hidden */
  112210. _getRGBAMultiSampleBufferFormat(type: number): number;
  112211. /** @hidden */
  112212. _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;
  112213. /**
  112214. * Loads a file from a url
  112215. * @param url url to load
  112216. * @param onSuccess callback called when the file successfully loads
  112217. * @param onProgress callback called while file is loading (if the server supports this mode)
  112218. * @param offlineProvider defines the offline provider for caching
  112219. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112220. * @param onError callback called when the file fails to load
  112221. * @returns a file request object
  112222. * @hidden
  112223. */
  112224. 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;
  112225. /**
  112226. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112227. * @param x defines the x coordinate of the rectangle where pixels must be read
  112228. * @param y defines the y coordinate of the rectangle where pixels must be read
  112229. * @param width defines the width of the rectangle where pixels must be read
  112230. * @param height defines the height of the rectangle where pixels must be read
  112231. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  112232. * @returns a Uint8Array containing RGBA colors
  112233. */
  112234. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  112235. private static _isSupported;
  112236. /**
  112237. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  112238. * @returns true if the engine can be created
  112239. * @ignorenaming
  112240. */
  112241. static isSupported(): boolean;
  112242. /**
  112243. * Find the next highest power of two.
  112244. * @param x Number to start search from.
  112245. * @return Next highest power of two.
  112246. */
  112247. static CeilingPOT(x: number): number;
  112248. /**
  112249. * Find the next lowest power of two.
  112250. * @param x Number to start search from.
  112251. * @return Next lowest power of two.
  112252. */
  112253. static FloorPOT(x: number): number;
  112254. /**
  112255. * Find the nearest power of two.
  112256. * @param x Number to start search from.
  112257. * @return Next nearest power of two.
  112258. */
  112259. static NearestPOT(x: number): number;
  112260. /**
  112261. * Get the closest exponent of two
  112262. * @param value defines the value to approximate
  112263. * @param max defines the maximum value to return
  112264. * @param mode defines how to define the closest value
  112265. * @returns closest exponent of two of the given value
  112266. */
  112267. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  112268. /**
  112269. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  112270. * @param func - the function to be called
  112271. * @param requester - the object that will request the next frame. Falls back to window.
  112272. * @returns frame number
  112273. */
  112274. static QueueNewFrame(func: () => void, requester?: any): number;
  112275. /**
  112276. * Gets host document
  112277. * @returns the host document object
  112278. */
  112279. getHostDocument(): Nullable<Document>;
  112280. }
  112281. }
  112282. declare module BABYLON {
  112283. /**
  112284. * Class representing spherical harmonics coefficients to the 3rd degree
  112285. */
  112286. export class SphericalHarmonics {
  112287. /**
  112288. * Defines whether or not the harmonics have been prescaled for rendering.
  112289. */
  112290. preScaled: boolean;
  112291. /**
  112292. * The l0,0 coefficients of the spherical harmonics
  112293. */
  112294. l00: Vector3;
  112295. /**
  112296. * The l1,-1 coefficients of the spherical harmonics
  112297. */
  112298. l1_1: Vector3;
  112299. /**
  112300. * The l1,0 coefficients of the spherical harmonics
  112301. */
  112302. l10: Vector3;
  112303. /**
  112304. * The l1,1 coefficients of the spherical harmonics
  112305. */
  112306. l11: Vector3;
  112307. /**
  112308. * The l2,-2 coefficients of the spherical harmonics
  112309. */
  112310. l2_2: Vector3;
  112311. /**
  112312. * The l2,-1 coefficients of the spherical harmonics
  112313. */
  112314. l2_1: Vector3;
  112315. /**
  112316. * The l2,0 coefficients of the spherical harmonics
  112317. */
  112318. l20: Vector3;
  112319. /**
  112320. * The l2,1 coefficients of the spherical harmonics
  112321. */
  112322. l21: Vector3;
  112323. /**
  112324. * The l2,2 coefficients of the spherical harmonics
  112325. */
  112326. l22: Vector3;
  112327. /**
  112328. * Adds a light to the spherical harmonics
  112329. * @param direction the direction of the light
  112330. * @param color the color of the light
  112331. * @param deltaSolidAngle the delta solid angle of the light
  112332. */
  112333. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  112334. /**
  112335. * Scales the spherical harmonics by the given amount
  112336. * @param scale the amount to scale
  112337. */
  112338. scaleInPlace(scale: number): void;
  112339. /**
  112340. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  112341. *
  112342. * ```
  112343. * E_lm = A_l * L_lm
  112344. * ```
  112345. *
  112346. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  112347. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  112348. * the scaling factors are given in equation 9.
  112349. */
  112350. convertIncidentRadianceToIrradiance(): void;
  112351. /**
  112352. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  112353. *
  112354. * ```
  112355. * L = (1/pi) * E * rho
  112356. * ```
  112357. *
  112358. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  112359. */
  112360. convertIrradianceToLambertianRadiance(): void;
  112361. /**
  112362. * Integrates the reconstruction coefficients directly in to the SH preventing further
  112363. * required operations at run time.
  112364. *
  112365. * This is simply done by scaling back the SH with Ylm constants parameter.
  112366. * The trigonometric part being applied by the shader at run time.
  112367. */
  112368. preScaleForRendering(): void;
  112369. /**
  112370. * Constructs a spherical harmonics from an array.
  112371. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  112372. * @returns the spherical harmonics
  112373. */
  112374. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  112375. /**
  112376. * Gets the spherical harmonics from polynomial
  112377. * @param polynomial the spherical polynomial
  112378. * @returns the spherical harmonics
  112379. */
  112380. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  112381. }
  112382. /**
  112383. * Class representing spherical polynomial coefficients to the 3rd degree
  112384. */
  112385. export class SphericalPolynomial {
  112386. private _harmonics;
  112387. /**
  112388. * The spherical harmonics used to create the polynomials.
  112389. */
  112390. get preScaledHarmonics(): SphericalHarmonics;
  112391. /**
  112392. * The x coefficients of the spherical polynomial
  112393. */
  112394. x: Vector3;
  112395. /**
  112396. * The y coefficients of the spherical polynomial
  112397. */
  112398. y: Vector3;
  112399. /**
  112400. * The z coefficients of the spherical polynomial
  112401. */
  112402. z: Vector3;
  112403. /**
  112404. * The xx coefficients of the spherical polynomial
  112405. */
  112406. xx: Vector3;
  112407. /**
  112408. * The yy coefficients of the spherical polynomial
  112409. */
  112410. yy: Vector3;
  112411. /**
  112412. * The zz coefficients of the spherical polynomial
  112413. */
  112414. zz: Vector3;
  112415. /**
  112416. * The xy coefficients of the spherical polynomial
  112417. */
  112418. xy: Vector3;
  112419. /**
  112420. * The yz coefficients of the spherical polynomial
  112421. */
  112422. yz: Vector3;
  112423. /**
  112424. * The zx coefficients of the spherical polynomial
  112425. */
  112426. zx: Vector3;
  112427. /**
  112428. * Adds an ambient color to the spherical polynomial
  112429. * @param color the color to add
  112430. */
  112431. addAmbient(color: Color3): void;
  112432. /**
  112433. * Scales the spherical polynomial by the given amount
  112434. * @param scale the amount to scale
  112435. */
  112436. scaleInPlace(scale: number): void;
  112437. /**
  112438. * Gets the spherical polynomial from harmonics
  112439. * @param harmonics the spherical harmonics
  112440. * @returns the spherical polynomial
  112441. */
  112442. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  112443. /**
  112444. * Constructs a spherical polynomial from an array.
  112445. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  112446. * @returns the spherical polynomial
  112447. */
  112448. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  112449. }
  112450. }
  112451. declare module BABYLON {
  112452. /**
  112453. * Defines the source of the internal texture
  112454. */
  112455. export enum InternalTextureSource {
  112456. /**
  112457. * The source of the texture data is unknown
  112458. */
  112459. Unknown = 0,
  112460. /**
  112461. * Texture data comes from an URL
  112462. */
  112463. Url = 1,
  112464. /**
  112465. * Texture data is only used for temporary storage
  112466. */
  112467. Temp = 2,
  112468. /**
  112469. * Texture data comes from raw data (ArrayBuffer)
  112470. */
  112471. Raw = 3,
  112472. /**
  112473. * Texture content is dynamic (video or dynamic texture)
  112474. */
  112475. Dynamic = 4,
  112476. /**
  112477. * Texture content is generated by rendering to it
  112478. */
  112479. RenderTarget = 5,
  112480. /**
  112481. * Texture content is part of a multi render target process
  112482. */
  112483. MultiRenderTarget = 6,
  112484. /**
  112485. * Texture data comes from a cube data file
  112486. */
  112487. Cube = 7,
  112488. /**
  112489. * Texture data comes from a raw cube data
  112490. */
  112491. CubeRaw = 8,
  112492. /**
  112493. * Texture data come from a prefiltered cube data file
  112494. */
  112495. CubePrefiltered = 9,
  112496. /**
  112497. * Texture content is raw 3D data
  112498. */
  112499. Raw3D = 10,
  112500. /**
  112501. * Texture content is raw 2D array data
  112502. */
  112503. Raw2DArray = 11,
  112504. /**
  112505. * Texture content is a depth texture
  112506. */
  112507. Depth = 12,
  112508. /**
  112509. * Texture data comes from a raw cube data encoded with RGBD
  112510. */
  112511. CubeRawRGBD = 13
  112512. }
  112513. /**
  112514. * Class used to store data associated with WebGL texture data for the engine
  112515. * This class should not be used directly
  112516. */
  112517. export class InternalTexture {
  112518. /** @hidden */
  112519. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  112520. /**
  112521. * Defines if the texture is ready
  112522. */
  112523. isReady: boolean;
  112524. /**
  112525. * Defines if the texture is a cube texture
  112526. */
  112527. isCube: boolean;
  112528. /**
  112529. * Defines if the texture contains 3D data
  112530. */
  112531. is3D: boolean;
  112532. /**
  112533. * Defines if the texture contains 2D array data
  112534. */
  112535. is2DArray: boolean;
  112536. /**
  112537. * Defines if the texture contains multiview data
  112538. */
  112539. isMultiview: boolean;
  112540. /**
  112541. * Gets the URL used to load this texture
  112542. */
  112543. url: string;
  112544. /**
  112545. * Gets the sampling mode of the texture
  112546. */
  112547. samplingMode: number;
  112548. /**
  112549. * Gets a boolean indicating if the texture needs mipmaps generation
  112550. */
  112551. generateMipMaps: boolean;
  112552. /**
  112553. * Gets the number of samples used by the texture (WebGL2+ only)
  112554. */
  112555. samples: number;
  112556. /**
  112557. * Gets the type of the texture (int, float...)
  112558. */
  112559. type: number;
  112560. /**
  112561. * Gets the format of the texture (RGB, RGBA...)
  112562. */
  112563. format: number;
  112564. /**
  112565. * Observable called when the texture is loaded
  112566. */
  112567. onLoadedObservable: Observable<InternalTexture>;
  112568. /**
  112569. * Gets the width of the texture
  112570. */
  112571. width: number;
  112572. /**
  112573. * Gets the height of the texture
  112574. */
  112575. height: number;
  112576. /**
  112577. * Gets the depth of the texture
  112578. */
  112579. depth: number;
  112580. /**
  112581. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  112582. */
  112583. baseWidth: number;
  112584. /**
  112585. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  112586. */
  112587. baseHeight: number;
  112588. /**
  112589. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  112590. */
  112591. baseDepth: number;
  112592. /**
  112593. * Gets a boolean indicating if the texture is inverted on Y axis
  112594. */
  112595. invertY: boolean;
  112596. /** @hidden */
  112597. _invertVScale: boolean;
  112598. /** @hidden */
  112599. _associatedChannel: number;
  112600. /** @hidden */
  112601. _source: InternalTextureSource;
  112602. /** @hidden */
  112603. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  112604. /** @hidden */
  112605. _bufferView: Nullable<ArrayBufferView>;
  112606. /** @hidden */
  112607. _bufferViewArray: Nullable<ArrayBufferView[]>;
  112608. /** @hidden */
  112609. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  112610. /** @hidden */
  112611. _size: number;
  112612. /** @hidden */
  112613. _extension: string;
  112614. /** @hidden */
  112615. _files: Nullable<string[]>;
  112616. /** @hidden */
  112617. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112618. /** @hidden */
  112619. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112620. /** @hidden */
  112621. _framebuffer: Nullable<WebGLFramebuffer>;
  112622. /** @hidden */
  112623. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  112624. /** @hidden */
  112625. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  112626. /** @hidden */
  112627. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  112628. /** @hidden */
  112629. _attachments: Nullable<number[]>;
  112630. /** @hidden */
  112631. _cachedCoordinatesMode: Nullable<number>;
  112632. /** @hidden */
  112633. _cachedWrapU: Nullable<number>;
  112634. /** @hidden */
  112635. _cachedWrapV: Nullable<number>;
  112636. /** @hidden */
  112637. _cachedWrapR: Nullable<number>;
  112638. /** @hidden */
  112639. _cachedAnisotropicFilteringLevel: Nullable<number>;
  112640. /** @hidden */
  112641. _isDisabled: boolean;
  112642. /** @hidden */
  112643. _compression: Nullable<string>;
  112644. /** @hidden */
  112645. _generateStencilBuffer: boolean;
  112646. /** @hidden */
  112647. _generateDepthBuffer: boolean;
  112648. /** @hidden */
  112649. _comparisonFunction: number;
  112650. /** @hidden */
  112651. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  112652. /** @hidden */
  112653. _lodGenerationScale: number;
  112654. /** @hidden */
  112655. _lodGenerationOffset: number;
  112656. /** @hidden */
  112657. _depthStencilTexture: Nullable<InternalTexture>;
  112658. /** @hidden */
  112659. _colorTextureArray: Nullable<WebGLTexture>;
  112660. /** @hidden */
  112661. _depthStencilTextureArray: Nullable<WebGLTexture>;
  112662. /** @hidden */
  112663. _lodTextureHigh: Nullable<BaseTexture>;
  112664. /** @hidden */
  112665. _lodTextureMid: Nullable<BaseTexture>;
  112666. /** @hidden */
  112667. _lodTextureLow: Nullable<BaseTexture>;
  112668. /** @hidden */
  112669. _isRGBD: boolean;
  112670. /** @hidden */
  112671. _linearSpecularLOD: boolean;
  112672. /** @hidden */
  112673. _irradianceTexture: Nullable<BaseTexture>;
  112674. /** @hidden */
  112675. _webGLTexture: Nullable<WebGLTexture>;
  112676. /** @hidden */
  112677. _references: number;
  112678. private _engine;
  112679. /**
  112680. * Gets the Engine the texture belongs to.
  112681. * @returns The babylon engine
  112682. */
  112683. getEngine(): ThinEngine;
  112684. /**
  112685. * Gets the data source type of the texture
  112686. */
  112687. get source(): InternalTextureSource;
  112688. /**
  112689. * Creates a new InternalTexture
  112690. * @param engine defines the engine to use
  112691. * @param source defines the type of data that will be used
  112692. * @param delayAllocation if the texture allocation should be delayed (default: false)
  112693. */
  112694. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  112695. /**
  112696. * Increments the number of references (ie. the number of Texture that point to it)
  112697. */
  112698. incrementReferences(): void;
  112699. /**
  112700. * Change the size of the texture (not the size of the content)
  112701. * @param width defines the new width
  112702. * @param height defines the new height
  112703. * @param depth defines the new depth (1 by default)
  112704. */
  112705. updateSize(width: int, height: int, depth?: int): void;
  112706. /** @hidden */
  112707. _rebuild(): void;
  112708. /** @hidden */
  112709. _swapAndDie(target: InternalTexture): void;
  112710. /**
  112711. * Dispose the current allocated resources
  112712. */
  112713. dispose(): void;
  112714. }
  112715. }
  112716. declare module BABYLON {
  112717. /**
  112718. * Class used to work with sound analyzer using fast fourier transform (FFT)
  112719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112720. */
  112721. export class Analyser {
  112722. /**
  112723. * Gets or sets the smoothing
  112724. * @ignorenaming
  112725. */
  112726. SMOOTHING: number;
  112727. /**
  112728. * Gets or sets the FFT table size
  112729. * @ignorenaming
  112730. */
  112731. FFT_SIZE: number;
  112732. /**
  112733. * Gets or sets the bar graph amplitude
  112734. * @ignorenaming
  112735. */
  112736. BARGRAPHAMPLITUDE: number;
  112737. /**
  112738. * Gets or sets the position of the debug canvas
  112739. * @ignorenaming
  112740. */
  112741. DEBUGCANVASPOS: {
  112742. x: number;
  112743. y: number;
  112744. };
  112745. /**
  112746. * Gets or sets the debug canvas size
  112747. * @ignorenaming
  112748. */
  112749. DEBUGCANVASSIZE: {
  112750. width: number;
  112751. height: number;
  112752. };
  112753. private _byteFreqs;
  112754. private _byteTime;
  112755. private _floatFreqs;
  112756. private _webAudioAnalyser;
  112757. private _debugCanvas;
  112758. private _debugCanvasContext;
  112759. private _scene;
  112760. private _registerFunc;
  112761. private _audioEngine;
  112762. /**
  112763. * Creates a new analyser
  112764. * @param scene defines hosting scene
  112765. */
  112766. constructor(scene: Scene);
  112767. /**
  112768. * Get the number of data values you will have to play with for the visualization
  112769. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  112770. * @returns a number
  112771. */
  112772. getFrequencyBinCount(): number;
  112773. /**
  112774. * Gets the current frequency data as a byte array
  112775. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112776. * @returns a Uint8Array
  112777. */
  112778. getByteFrequencyData(): Uint8Array;
  112779. /**
  112780. * Gets the current waveform as a byte array
  112781. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  112782. * @returns a Uint8Array
  112783. */
  112784. getByteTimeDomainData(): Uint8Array;
  112785. /**
  112786. * Gets the current frequency data as a float array
  112787. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112788. * @returns a Float32Array
  112789. */
  112790. getFloatFrequencyData(): Float32Array;
  112791. /**
  112792. * Renders the debug canvas
  112793. */
  112794. drawDebugCanvas(): void;
  112795. /**
  112796. * Stops rendering the debug canvas and removes it
  112797. */
  112798. stopDebugCanvas(): void;
  112799. /**
  112800. * Connects two audio nodes
  112801. * @param inputAudioNode defines first node to connect
  112802. * @param outputAudioNode defines second node to connect
  112803. */
  112804. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  112805. /**
  112806. * Releases all associated resources
  112807. */
  112808. dispose(): void;
  112809. }
  112810. }
  112811. declare module BABYLON {
  112812. /**
  112813. * This represents an audio engine and it is responsible
  112814. * to play, synchronize and analyse sounds throughout the application.
  112815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112816. */
  112817. export interface IAudioEngine extends IDisposable {
  112818. /**
  112819. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112820. */
  112821. readonly canUseWebAudio: boolean;
  112822. /**
  112823. * Gets the current AudioContext if available.
  112824. */
  112825. readonly audioContext: Nullable<AudioContext>;
  112826. /**
  112827. * The master gain node defines the global audio volume of your audio engine.
  112828. */
  112829. readonly masterGain: GainNode;
  112830. /**
  112831. * Gets whether or not mp3 are supported by your browser.
  112832. */
  112833. readonly isMP3supported: boolean;
  112834. /**
  112835. * Gets whether or not ogg are supported by your browser.
  112836. */
  112837. readonly isOGGsupported: boolean;
  112838. /**
  112839. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112840. * @ignoreNaming
  112841. */
  112842. WarnedWebAudioUnsupported: boolean;
  112843. /**
  112844. * Defines if the audio engine relies on a custom unlocked button.
  112845. * In this case, the embedded button will not be displayed.
  112846. */
  112847. useCustomUnlockedButton: boolean;
  112848. /**
  112849. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  112850. */
  112851. readonly unlocked: boolean;
  112852. /**
  112853. * Event raised when audio has been unlocked on the browser.
  112854. */
  112855. onAudioUnlockedObservable: Observable<AudioEngine>;
  112856. /**
  112857. * Event raised when audio has been locked on the browser.
  112858. */
  112859. onAudioLockedObservable: Observable<AudioEngine>;
  112860. /**
  112861. * Flags the audio engine in Locked state.
  112862. * This happens due to new browser policies preventing audio to autoplay.
  112863. */
  112864. lock(): void;
  112865. /**
  112866. * Unlocks the audio engine once a user action has been done on the dom.
  112867. * This is helpful to resume play once browser policies have been satisfied.
  112868. */
  112869. unlock(): void;
  112870. /**
  112871. * Gets the global volume sets on the master gain.
  112872. * @returns the global volume if set or -1 otherwise
  112873. */
  112874. getGlobalVolume(): number;
  112875. /**
  112876. * Sets the global volume of your experience (sets on the master gain).
  112877. * @param newVolume Defines the new global volume of the application
  112878. */
  112879. setGlobalVolume(newVolume: number): void;
  112880. /**
  112881. * Connect the audio engine to an audio analyser allowing some amazing
  112882. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112884. * @param analyser The analyser to connect to the engine
  112885. */
  112886. connectToAnalyser(analyser: Analyser): void;
  112887. }
  112888. /**
  112889. * This represents the default audio engine used in babylon.
  112890. * It is responsible to play, synchronize and analyse sounds throughout the application.
  112891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112892. */
  112893. export class AudioEngine implements IAudioEngine {
  112894. private _audioContext;
  112895. private _audioContextInitialized;
  112896. private _muteButton;
  112897. private _hostElement;
  112898. /**
  112899. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112900. */
  112901. canUseWebAudio: boolean;
  112902. /**
  112903. * The master gain node defines the global audio volume of your audio engine.
  112904. */
  112905. masterGain: GainNode;
  112906. /**
  112907. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112908. * @ignoreNaming
  112909. */
  112910. WarnedWebAudioUnsupported: boolean;
  112911. /**
  112912. * Gets whether or not mp3 are supported by your browser.
  112913. */
  112914. isMP3supported: boolean;
  112915. /**
  112916. * Gets whether or not ogg are supported by your browser.
  112917. */
  112918. isOGGsupported: boolean;
  112919. /**
  112920. * Gets whether audio has been unlocked on the device.
  112921. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  112922. * a user interaction has happened.
  112923. */
  112924. unlocked: boolean;
  112925. /**
  112926. * Defines if the audio engine relies on a custom unlocked button.
  112927. * In this case, the embedded button will not be displayed.
  112928. */
  112929. useCustomUnlockedButton: boolean;
  112930. /**
  112931. * Event raised when audio has been unlocked on the browser.
  112932. */
  112933. onAudioUnlockedObservable: Observable<AudioEngine>;
  112934. /**
  112935. * Event raised when audio has been locked on the browser.
  112936. */
  112937. onAudioLockedObservable: Observable<AudioEngine>;
  112938. /**
  112939. * Gets the current AudioContext if available.
  112940. */
  112941. get audioContext(): Nullable<AudioContext>;
  112942. private _connectedAnalyser;
  112943. /**
  112944. * Instantiates a new audio engine.
  112945. *
  112946. * There should be only one per page as some browsers restrict the number
  112947. * of audio contexts you can create.
  112948. * @param hostElement defines the host element where to display the mute icon if necessary
  112949. */
  112950. constructor(hostElement?: Nullable<HTMLElement>);
  112951. /**
  112952. * Flags the audio engine in Locked state.
  112953. * This happens due to new browser policies preventing audio to autoplay.
  112954. */
  112955. lock(): void;
  112956. /**
  112957. * Unlocks the audio engine once a user action has been done on the dom.
  112958. * This is helpful to resume play once browser policies have been satisfied.
  112959. */
  112960. unlock(): void;
  112961. private _resumeAudioContext;
  112962. private _initializeAudioContext;
  112963. private _tryToRun;
  112964. private _triggerRunningState;
  112965. private _triggerSuspendedState;
  112966. private _displayMuteButton;
  112967. private _moveButtonToTopLeft;
  112968. private _onResize;
  112969. private _hideMuteButton;
  112970. /**
  112971. * Destroy and release the resources associated with the audio ccontext.
  112972. */
  112973. dispose(): void;
  112974. /**
  112975. * Gets the global volume sets on the master gain.
  112976. * @returns the global volume if set or -1 otherwise
  112977. */
  112978. getGlobalVolume(): number;
  112979. /**
  112980. * Sets the global volume of your experience (sets on the master gain).
  112981. * @param newVolume Defines the new global volume of the application
  112982. */
  112983. setGlobalVolume(newVolume: number): void;
  112984. /**
  112985. * Connect the audio engine to an audio analyser allowing some amazing
  112986. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112988. * @param analyser The analyser to connect to the engine
  112989. */
  112990. connectToAnalyser(analyser: Analyser): void;
  112991. }
  112992. }
  112993. declare module BABYLON {
  112994. /**
  112995. * Interface used to present a loading screen while loading a scene
  112996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112997. */
  112998. export interface ILoadingScreen {
  112999. /**
  113000. * Function called to display the loading screen
  113001. */
  113002. displayLoadingUI: () => void;
  113003. /**
  113004. * Function called to hide the loading screen
  113005. */
  113006. hideLoadingUI: () => void;
  113007. /**
  113008. * Gets or sets the color to use for the background
  113009. */
  113010. loadingUIBackgroundColor: string;
  113011. /**
  113012. * Gets or sets the text to display while loading
  113013. */
  113014. loadingUIText: string;
  113015. }
  113016. /**
  113017. * Class used for the default loading screen
  113018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113019. */
  113020. export class DefaultLoadingScreen implements ILoadingScreen {
  113021. private _renderingCanvas;
  113022. private _loadingText;
  113023. private _loadingDivBackgroundColor;
  113024. private _loadingDiv;
  113025. private _loadingTextDiv;
  113026. /** Gets or sets the logo url to use for the default loading screen */
  113027. static DefaultLogoUrl: string;
  113028. /** Gets or sets the spinner url to use for the default loading screen */
  113029. static DefaultSpinnerUrl: string;
  113030. /**
  113031. * Creates a new default loading screen
  113032. * @param _renderingCanvas defines the canvas used to render the scene
  113033. * @param _loadingText defines the default text to display
  113034. * @param _loadingDivBackgroundColor defines the default background color
  113035. */
  113036. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113037. /**
  113038. * Function called to display the loading screen
  113039. */
  113040. displayLoadingUI(): void;
  113041. /**
  113042. * Function called to hide the loading screen
  113043. */
  113044. hideLoadingUI(): void;
  113045. /**
  113046. * Gets or sets the text to display while loading
  113047. */
  113048. set loadingUIText(text: string);
  113049. get loadingUIText(): string;
  113050. /**
  113051. * Gets or sets the color to use for the background
  113052. */
  113053. get loadingUIBackgroundColor(): string;
  113054. set loadingUIBackgroundColor(color: string);
  113055. private _resizeLoadingUI;
  113056. }
  113057. }
  113058. declare module BABYLON {
  113059. /**
  113060. * Interface for any object that can request an animation frame
  113061. */
  113062. export interface ICustomAnimationFrameRequester {
  113063. /**
  113064. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113065. */
  113066. renderFunction?: Function;
  113067. /**
  113068. * Called to request the next frame to render to
  113069. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113070. */
  113071. requestAnimationFrame: Function;
  113072. /**
  113073. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113074. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113075. */
  113076. requestID?: number;
  113077. }
  113078. }
  113079. declare module BABYLON {
  113080. /**
  113081. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113082. */
  113083. export class PerformanceMonitor {
  113084. private _enabled;
  113085. private _rollingFrameTime;
  113086. private _lastFrameTimeMs;
  113087. /**
  113088. * constructor
  113089. * @param frameSampleSize The number of samples required to saturate the sliding window
  113090. */
  113091. constructor(frameSampleSize?: number);
  113092. /**
  113093. * Samples current frame
  113094. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113095. */
  113096. sampleFrame(timeMs?: number): void;
  113097. /**
  113098. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113099. */
  113100. get averageFrameTime(): number;
  113101. /**
  113102. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113103. */
  113104. get averageFrameTimeVariance(): number;
  113105. /**
  113106. * Returns the frame time of the most recent frame
  113107. */
  113108. get instantaneousFrameTime(): number;
  113109. /**
  113110. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113111. */
  113112. get averageFPS(): number;
  113113. /**
  113114. * Returns the average framerate in frames per second using the most recent frame time
  113115. */
  113116. get instantaneousFPS(): number;
  113117. /**
  113118. * Returns true if enough samples have been taken to completely fill the sliding window
  113119. */
  113120. get isSaturated(): boolean;
  113121. /**
  113122. * Enables contributions to the sliding window sample set
  113123. */
  113124. enable(): void;
  113125. /**
  113126. * Disables contributions to the sliding window sample set
  113127. * Samples will not be interpolated over the disabled period
  113128. */
  113129. disable(): void;
  113130. /**
  113131. * Returns true if sampling is enabled
  113132. */
  113133. get isEnabled(): boolean;
  113134. /**
  113135. * Resets performance monitor
  113136. */
  113137. reset(): void;
  113138. }
  113139. /**
  113140. * RollingAverage
  113141. *
  113142. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113143. */
  113144. export class RollingAverage {
  113145. /**
  113146. * Current average
  113147. */
  113148. average: number;
  113149. /**
  113150. * Current variance
  113151. */
  113152. variance: number;
  113153. protected _samples: Array<number>;
  113154. protected _sampleCount: number;
  113155. protected _pos: number;
  113156. protected _m2: number;
  113157. /**
  113158. * constructor
  113159. * @param length The number of samples required to saturate the sliding window
  113160. */
  113161. constructor(length: number);
  113162. /**
  113163. * Adds a sample to the sample set
  113164. * @param v The sample value
  113165. */
  113166. add(v: number): void;
  113167. /**
  113168. * Returns previously added values or null if outside of history or outside the sliding window domain
  113169. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113170. * @return Value previously recorded with add() or null if outside of range
  113171. */
  113172. history(i: number): number;
  113173. /**
  113174. * Returns true if enough samples have been taken to completely fill the sliding window
  113175. * @return true if sample-set saturated
  113176. */
  113177. isSaturated(): boolean;
  113178. /**
  113179. * Resets the rolling average (equivalent to 0 samples taken so far)
  113180. */
  113181. reset(): void;
  113182. /**
  113183. * Wraps a value around the sample range boundaries
  113184. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113185. * @return Wrapped position in sample range
  113186. */
  113187. protected _wrapPosition(i: number): number;
  113188. }
  113189. }
  113190. declare module BABYLON {
  113191. /**
  113192. * This class is used to track a performance counter which is number based.
  113193. * The user has access to many properties which give statistics of different nature.
  113194. *
  113195. * The implementer can track two kinds of Performance Counter: time and count.
  113196. * 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.
  113197. * 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.
  113198. */
  113199. export class PerfCounter {
  113200. /**
  113201. * Gets or sets a global boolean to turn on and off all the counters
  113202. */
  113203. static Enabled: boolean;
  113204. /**
  113205. * Returns the smallest value ever
  113206. */
  113207. get min(): number;
  113208. /**
  113209. * Returns the biggest value ever
  113210. */
  113211. get max(): number;
  113212. /**
  113213. * Returns the average value since the performance counter is running
  113214. */
  113215. get average(): number;
  113216. /**
  113217. * Returns the average value of the last second the counter was monitored
  113218. */
  113219. get lastSecAverage(): number;
  113220. /**
  113221. * Returns the current value
  113222. */
  113223. get current(): number;
  113224. /**
  113225. * Gets the accumulated total
  113226. */
  113227. get total(): number;
  113228. /**
  113229. * Gets the total value count
  113230. */
  113231. get count(): number;
  113232. /**
  113233. * Creates a new counter
  113234. */
  113235. constructor();
  113236. /**
  113237. * Call this method to start monitoring a new frame.
  113238. * 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.
  113239. */
  113240. fetchNewFrame(): void;
  113241. /**
  113242. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  113243. * @param newCount the count value to add to the monitored count
  113244. * @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.
  113245. */
  113246. addCount(newCount: number, fetchResult: boolean): void;
  113247. /**
  113248. * Start monitoring this performance counter
  113249. */
  113250. beginMonitoring(): void;
  113251. /**
  113252. * Compute the time lapsed since the previous beginMonitoring() call.
  113253. * @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
  113254. */
  113255. endMonitoring(newFrame?: boolean): void;
  113256. private _fetchResult;
  113257. private _startMonitoringTime;
  113258. private _min;
  113259. private _max;
  113260. private _average;
  113261. private _current;
  113262. private _totalValueCount;
  113263. private _totalAccumulated;
  113264. private _lastSecAverage;
  113265. private _lastSecAccumulated;
  113266. private _lastSecTime;
  113267. private _lastSecValueCount;
  113268. }
  113269. }
  113270. declare module BABYLON {
  113271. interface ThinEngine {
  113272. /**
  113273. * Sets alpha constants used by some alpha blending modes
  113274. * @param r defines the red component
  113275. * @param g defines the green component
  113276. * @param b defines the blue component
  113277. * @param a defines the alpha component
  113278. */
  113279. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113280. /**
  113281. * Sets the current alpha mode
  113282. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113283. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113284. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113285. */
  113286. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113287. /**
  113288. * Gets the current alpha mode
  113289. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113290. * @returns the current alpha mode
  113291. */
  113292. getAlphaMode(): number;
  113293. /**
  113294. * Sets the current alpha equation
  113295. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  113296. */
  113297. setAlphaEquation(equation: number): void;
  113298. /**
  113299. * Gets the current alpha equation.
  113300. * @returns the current alpha equation
  113301. */
  113302. getAlphaEquation(): number;
  113303. }
  113304. }
  113305. declare module BABYLON {
  113306. interface ThinEngine {
  113307. /** @hidden */
  113308. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  113309. }
  113310. }
  113311. declare module BABYLON {
  113312. /**
  113313. * Defines the interface used by display changed events
  113314. */
  113315. export interface IDisplayChangedEventArgs {
  113316. /** Gets the vrDisplay object (if any) */
  113317. vrDisplay: Nullable<any>;
  113318. /** Gets a boolean indicating if webVR is supported */
  113319. vrSupported: boolean;
  113320. }
  113321. /**
  113322. * Defines the interface used by objects containing a viewport (like a camera)
  113323. */
  113324. interface IViewportOwnerLike {
  113325. /**
  113326. * Gets or sets the viewport
  113327. */
  113328. viewport: IViewportLike;
  113329. }
  113330. /**
  113331. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  113332. */
  113333. export class Engine extends ThinEngine {
  113334. /** Defines that alpha blending is disabled */
  113335. static readonly ALPHA_DISABLE: number;
  113336. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  113337. static readonly ALPHA_ADD: number;
  113338. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  113339. static readonly ALPHA_COMBINE: number;
  113340. /** Defines that alpha blending to DEST - SRC * DEST */
  113341. static readonly ALPHA_SUBTRACT: number;
  113342. /** Defines that alpha blending to SRC * DEST */
  113343. static readonly ALPHA_MULTIPLY: number;
  113344. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  113345. static readonly ALPHA_MAXIMIZED: number;
  113346. /** Defines that alpha blending to SRC + DEST */
  113347. static readonly ALPHA_ONEONE: number;
  113348. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  113349. static readonly ALPHA_PREMULTIPLIED: number;
  113350. /**
  113351. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  113352. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  113353. */
  113354. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  113355. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  113356. static readonly ALPHA_INTERPOLATE: number;
  113357. /**
  113358. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  113359. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  113360. */
  113361. static readonly ALPHA_SCREENMODE: number;
  113362. /** Defines that the ressource is not delayed*/
  113363. static readonly DELAYLOADSTATE_NONE: number;
  113364. /** Defines that the ressource was successfully delay loaded */
  113365. static readonly DELAYLOADSTATE_LOADED: number;
  113366. /** Defines that the ressource is currently delay loading */
  113367. static readonly DELAYLOADSTATE_LOADING: number;
  113368. /** Defines that the ressource is delayed and has not started loading */
  113369. static readonly DELAYLOADSTATE_NOTLOADED: number;
  113370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  113371. static readonly NEVER: number;
  113372. /** 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 */
  113373. static readonly ALWAYS: number;
  113374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  113375. static readonly LESS: number;
  113376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  113377. static readonly EQUAL: number;
  113378. /** 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 */
  113379. static readonly LEQUAL: number;
  113380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  113381. static readonly GREATER: number;
  113382. /** 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 */
  113383. static readonly GEQUAL: number;
  113384. /** 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 */
  113385. static readonly NOTEQUAL: number;
  113386. /** Passed to stencilOperation to specify that stencil value must be kept */
  113387. static readonly KEEP: number;
  113388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113389. static readonly REPLACE: number;
  113390. /** Passed to stencilOperation to specify that stencil value must be incremented */
  113391. static readonly INCR: number;
  113392. /** Passed to stencilOperation to specify that stencil value must be decremented */
  113393. static readonly DECR: number;
  113394. /** Passed to stencilOperation to specify that stencil value must be inverted */
  113395. static readonly INVERT: number;
  113396. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  113397. static readonly INCR_WRAP: number;
  113398. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  113399. static readonly DECR_WRAP: number;
  113400. /** Texture is not repeating outside of 0..1 UVs */
  113401. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  113402. /** Texture is repeating outside of 0..1 UVs */
  113403. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  113404. /** Texture is repeating and mirrored */
  113405. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  113406. /** ALPHA */
  113407. static readonly TEXTUREFORMAT_ALPHA: number;
  113408. /** LUMINANCE */
  113409. static readonly TEXTUREFORMAT_LUMINANCE: number;
  113410. /** LUMINANCE_ALPHA */
  113411. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  113412. /** RGB */
  113413. static readonly TEXTUREFORMAT_RGB: number;
  113414. /** RGBA */
  113415. static readonly TEXTUREFORMAT_RGBA: number;
  113416. /** RED */
  113417. static readonly TEXTUREFORMAT_RED: number;
  113418. /** RED (2nd reference) */
  113419. static readonly TEXTUREFORMAT_R: number;
  113420. /** RG */
  113421. static readonly TEXTUREFORMAT_RG: number;
  113422. /** RED_INTEGER */
  113423. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  113424. /** RED_INTEGER (2nd reference) */
  113425. static readonly TEXTUREFORMAT_R_INTEGER: number;
  113426. /** RG_INTEGER */
  113427. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  113428. /** RGB_INTEGER */
  113429. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  113430. /** RGBA_INTEGER */
  113431. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  113432. /** UNSIGNED_BYTE */
  113433. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  113434. /** UNSIGNED_BYTE (2nd reference) */
  113435. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  113436. /** FLOAT */
  113437. static readonly TEXTURETYPE_FLOAT: number;
  113438. /** HALF_FLOAT */
  113439. static readonly TEXTURETYPE_HALF_FLOAT: number;
  113440. /** BYTE */
  113441. static readonly TEXTURETYPE_BYTE: number;
  113442. /** SHORT */
  113443. static readonly TEXTURETYPE_SHORT: number;
  113444. /** UNSIGNED_SHORT */
  113445. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  113446. /** INT */
  113447. static readonly TEXTURETYPE_INT: number;
  113448. /** UNSIGNED_INT */
  113449. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  113450. /** UNSIGNED_SHORT_4_4_4_4 */
  113451. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  113452. /** UNSIGNED_SHORT_5_5_5_1 */
  113453. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  113454. /** UNSIGNED_SHORT_5_6_5 */
  113455. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  113456. /** UNSIGNED_INT_2_10_10_10_REV */
  113457. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  113458. /** UNSIGNED_INT_24_8 */
  113459. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  113460. /** UNSIGNED_INT_10F_11F_11F_REV */
  113461. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  113462. /** UNSIGNED_INT_5_9_9_9_REV */
  113463. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  113464. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  113465. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113466. /** nearest is mag = nearest and min = nearest and mip = linear */
  113467. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  113468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113469. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  113470. /** Trilinear is mag = linear and min = linear and mip = linear */
  113471. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  113472. /** nearest is mag = nearest and min = nearest and mip = linear */
  113473. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  113474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113475. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  113476. /** Trilinear is mag = linear and min = linear and mip = linear */
  113477. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  113478. /** mag = nearest and min = nearest and mip = nearest */
  113479. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  113480. /** mag = nearest and min = linear and mip = nearest */
  113481. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  113482. /** mag = nearest and min = linear and mip = linear */
  113483. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  113484. /** mag = nearest and min = linear and mip = none */
  113485. static readonly TEXTURE_NEAREST_LINEAR: number;
  113486. /** mag = nearest and min = nearest and mip = none */
  113487. static readonly TEXTURE_NEAREST_NEAREST: number;
  113488. /** mag = linear and min = nearest and mip = nearest */
  113489. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  113490. /** mag = linear and min = nearest and mip = linear */
  113491. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  113492. /** mag = linear and min = linear and mip = none */
  113493. static readonly TEXTURE_LINEAR_LINEAR: number;
  113494. /** mag = linear and min = nearest and mip = none */
  113495. static readonly TEXTURE_LINEAR_NEAREST: number;
  113496. /** Explicit coordinates mode */
  113497. static readonly TEXTURE_EXPLICIT_MODE: number;
  113498. /** Spherical coordinates mode */
  113499. static readonly TEXTURE_SPHERICAL_MODE: number;
  113500. /** Planar coordinates mode */
  113501. static readonly TEXTURE_PLANAR_MODE: number;
  113502. /** Cubic coordinates mode */
  113503. static readonly TEXTURE_CUBIC_MODE: number;
  113504. /** Projection coordinates mode */
  113505. static readonly TEXTURE_PROJECTION_MODE: number;
  113506. /** Skybox coordinates mode */
  113507. static readonly TEXTURE_SKYBOX_MODE: number;
  113508. /** Inverse Cubic coordinates mode */
  113509. static readonly TEXTURE_INVCUBIC_MODE: number;
  113510. /** Equirectangular coordinates mode */
  113511. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  113512. /** Equirectangular Fixed coordinates mode */
  113513. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  113514. /** Equirectangular Fixed Mirrored coordinates mode */
  113515. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  113516. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  113517. static readonly SCALEMODE_FLOOR: number;
  113518. /** Defines that texture rescaling will look for the nearest power of 2 size */
  113519. static readonly SCALEMODE_NEAREST: number;
  113520. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  113521. static readonly SCALEMODE_CEILING: number;
  113522. /**
  113523. * Returns the current npm package of the sdk
  113524. */
  113525. static get NpmPackage(): string;
  113526. /**
  113527. * Returns the current version of the framework
  113528. */
  113529. static get Version(): string;
  113530. /** Gets the list of created engines */
  113531. static get Instances(): Engine[];
  113532. /**
  113533. * Gets the latest created engine
  113534. */
  113535. static get LastCreatedEngine(): Nullable<Engine>;
  113536. /**
  113537. * Gets the latest created scene
  113538. */
  113539. static get LastCreatedScene(): Nullable<Scene>;
  113540. /**
  113541. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  113542. * @param flag defines which part of the materials must be marked as dirty
  113543. * @param predicate defines a predicate used to filter which materials should be affected
  113544. */
  113545. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113546. /**
  113547. * Method called to create the default loading screen.
  113548. * This can be overriden in your own app.
  113549. * @param canvas The rendering canvas element
  113550. * @returns The loading screen
  113551. */
  113552. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  113553. /**
  113554. * Method called to create the default rescale post process on each engine.
  113555. */
  113556. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  113557. /**
  113558. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  113559. **/
  113560. enableOfflineSupport: boolean;
  113561. /**
  113562. * 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)
  113563. **/
  113564. disableManifestCheck: boolean;
  113565. /**
  113566. * Gets the list of created scenes
  113567. */
  113568. scenes: Scene[];
  113569. /**
  113570. * Event raised when a new scene is created
  113571. */
  113572. onNewSceneAddedObservable: Observable<Scene>;
  113573. /**
  113574. * Gets the list of created postprocesses
  113575. */
  113576. postProcesses: PostProcess[];
  113577. /**
  113578. * Gets a boolean indicating if the pointer is currently locked
  113579. */
  113580. isPointerLock: boolean;
  113581. /**
  113582. * Observable event triggered each time the rendering canvas is resized
  113583. */
  113584. onResizeObservable: Observable<Engine>;
  113585. /**
  113586. * Observable event triggered each time the canvas loses focus
  113587. */
  113588. onCanvasBlurObservable: Observable<Engine>;
  113589. /**
  113590. * Observable event triggered each time the canvas gains focus
  113591. */
  113592. onCanvasFocusObservable: Observable<Engine>;
  113593. /**
  113594. * Observable event triggered each time the canvas receives pointerout event
  113595. */
  113596. onCanvasPointerOutObservable: Observable<PointerEvent>;
  113597. /**
  113598. * Observable raised when the engine begins a new frame
  113599. */
  113600. onBeginFrameObservable: Observable<Engine>;
  113601. /**
  113602. * If set, will be used to request the next animation frame for the render loop
  113603. */
  113604. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  113605. /**
  113606. * Observable raised when the engine ends the current frame
  113607. */
  113608. onEndFrameObservable: Observable<Engine>;
  113609. /**
  113610. * Observable raised when the engine is about to compile a shader
  113611. */
  113612. onBeforeShaderCompilationObservable: Observable<Engine>;
  113613. /**
  113614. * Observable raised when the engine has jsut compiled a shader
  113615. */
  113616. onAfterShaderCompilationObservable: Observable<Engine>;
  113617. /**
  113618. * Gets the audio engine
  113619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113620. * @ignorenaming
  113621. */
  113622. static audioEngine: IAudioEngine;
  113623. /**
  113624. * Default AudioEngine factory responsible of creating the Audio Engine.
  113625. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  113626. */
  113627. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  113628. /**
  113629. * Default offline support factory responsible of creating a tool used to store data locally.
  113630. * By default, this will create a Database object if the workload has been embedded.
  113631. */
  113632. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  113633. private _loadingScreen;
  113634. private _pointerLockRequested;
  113635. private _rescalePostProcess;
  113636. private _deterministicLockstep;
  113637. private _lockstepMaxSteps;
  113638. private _timeStep;
  113639. protected get _supportsHardwareTextureRescaling(): boolean;
  113640. private _fps;
  113641. private _deltaTime;
  113642. /** @hidden */
  113643. _drawCalls: PerfCounter;
  113644. /** 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 */
  113645. canvasTabIndex: number;
  113646. /**
  113647. * Turn this value on if you want to pause FPS computation when in background
  113648. */
  113649. disablePerformanceMonitorInBackground: boolean;
  113650. private _performanceMonitor;
  113651. /**
  113652. * Gets the performance monitor attached to this engine
  113653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113654. */
  113655. get performanceMonitor(): PerformanceMonitor;
  113656. private _onFocus;
  113657. private _onBlur;
  113658. private _onCanvasPointerOut;
  113659. private _onCanvasBlur;
  113660. private _onCanvasFocus;
  113661. private _onFullscreenChange;
  113662. private _onPointerLockChange;
  113663. /**
  113664. * Gets the HTML element used to attach event listeners
  113665. * @returns a HTML element
  113666. */
  113667. getInputElement(): Nullable<HTMLElement>;
  113668. /**
  113669. * Creates a new engine
  113670. * @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
  113671. * @param antialias defines enable antialiasing (default: false)
  113672. * @param options defines further options to be sent to the getContext() function
  113673. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113674. */
  113675. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113676. /**
  113677. * Gets current aspect ratio
  113678. * @param viewportOwner defines the camera to use to get the aspect ratio
  113679. * @param useScreen defines if screen size must be used (or the current render target if any)
  113680. * @returns a number defining the aspect ratio
  113681. */
  113682. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  113683. /**
  113684. * Gets current screen aspect ratio
  113685. * @returns a number defining the aspect ratio
  113686. */
  113687. getScreenAspectRatio(): number;
  113688. /**
  113689. * Gets the client rect of the HTML canvas attached with the current webGL context
  113690. * @returns a client rectanglee
  113691. */
  113692. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  113693. /**
  113694. * Gets the client rect of the HTML element used for events
  113695. * @returns a client rectanglee
  113696. */
  113697. getInputElementClientRect(): Nullable<ClientRect>;
  113698. /**
  113699. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113700. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113701. * @returns true if engine is in deterministic lock step mode
  113702. */
  113703. isDeterministicLockStep(): boolean;
  113704. /**
  113705. * Gets the max steps when engine is running in deterministic lock step
  113706. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113707. * @returns the max steps
  113708. */
  113709. getLockstepMaxSteps(): number;
  113710. /**
  113711. * Returns the time in ms between steps when using deterministic lock step.
  113712. * @returns time step in (ms)
  113713. */
  113714. getTimeStep(): number;
  113715. /**
  113716. * Force the mipmap generation for the given render target texture
  113717. * @param texture defines the render target texture to use
  113718. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  113719. */
  113720. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  113721. /** States */
  113722. /**
  113723. * Set various states to the webGL context
  113724. * @param culling defines backface culling state
  113725. * @param zOffset defines the value to apply to zOffset (0 by default)
  113726. * @param force defines if states must be applied even if cache is up to date
  113727. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113728. */
  113729. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113730. /**
  113731. * Set the z offset to apply to current rendering
  113732. * @param value defines the offset to apply
  113733. */
  113734. setZOffset(value: number): void;
  113735. /**
  113736. * Gets the current value of the zOffset
  113737. * @returns the current zOffset state
  113738. */
  113739. getZOffset(): number;
  113740. /**
  113741. * Enable or disable depth buffering
  113742. * @param enable defines the state to set
  113743. */
  113744. setDepthBuffer(enable: boolean): void;
  113745. /**
  113746. * Gets a boolean indicating if depth writing is enabled
  113747. * @returns the current depth writing state
  113748. */
  113749. getDepthWrite(): boolean;
  113750. /**
  113751. * Enable or disable depth writing
  113752. * @param enable defines the state to set
  113753. */
  113754. setDepthWrite(enable: boolean): void;
  113755. /**
  113756. * Gets a boolean indicating if stencil buffer is enabled
  113757. * @returns the current stencil buffer state
  113758. */
  113759. getStencilBuffer(): boolean;
  113760. /**
  113761. * Enable or disable the stencil buffer
  113762. * @param enable defines if the stencil buffer must be enabled or disabled
  113763. */
  113764. setStencilBuffer(enable: boolean): void;
  113765. /**
  113766. * Gets the current stencil mask
  113767. * @returns a number defining the new stencil mask to use
  113768. */
  113769. getStencilMask(): number;
  113770. /**
  113771. * Sets the current stencil mask
  113772. * @param mask defines the new stencil mask to use
  113773. */
  113774. setStencilMask(mask: number): void;
  113775. /**
  113776. * Gets the current stencil function
  113777. * @returns a number defining the stencil function to use
  113778. */
  113779. getStencilFunction(): number;
  113780. /**
  113781. * Gets the current stencil reference value
  113782. * @returns a number defining the stencil reference value to use
  113783. */
  113784. getStencilFunctionReference(): number;
  113785. /**
  113786. * Gets the current stencil mask
  113787. * @returns a number defining the stencil mask to use
  113788. */
  113789. getStencilFunctionMask(): number;
  113790. /**
  113791. * Sets the current stencil function
  113792. * @param stencilFunc defines the new stencil function to use
  113793. */
  113794. setStencilFunction(stencilFunc: number): void;
  113795. /**
  113796. * Sets the current stencil reference
  113797. * @param reference defines the new stencil reference to use
  113798. */
  113799. setStencilFunctionReference(reference: number): void;
  113800. /**
  113801. * Sets the current stencil mask
  113802. * @param mask defines the new stencil mask to use
  113803. */
  113804. setStencilFunctionMask(mask: number): void;
  113805. /**
  113806. * Gets the current stencil operation when stencil fails
  113807. * @returns a number defining stencil operation to use when stencil fails
  113808. */
  113809. getStencilOperationFail(): number;
  113810. /**
  113811. * Gets the current stencil operation when depth fails
  113812. * @returns a number defining stencil operation to use when depth fails
  113813. */
  113814. getStencilOperationDepthFail(): number;
  113815. /**
  113816. * Gets the current stencil operation when stencil passes
  113817. * @returns a number defining stencil operation to use when stencil passes
  113818. */
  113819. getStencilOperationPass(): number;
  113820. /**
  113821. * Sets the stencil operation to use when stencil fails
  113822. * @param operation defines the stencil operation to use when stencil fails
  113823. */
  113824. setStencilOperationFail(operation: number): void;
  113825. /**
  113826. * Sets the stencil operation to use when depth fails
  113827. * @param operation defines the stencil operation to use when depth fails
  113828. */
  113829. setStencilOperationDepthFail(operation: number): void;
  113830. /**
  113831. * Sets the stencil operation to use when stencil passes
  113832. * @param operation defines the stencil operation to use when stencil passes
  113833. */
  113834. setStencilOperationPass(operation: number): void;
  113835. /**
  113836. * Sets a boolean indicating if the dithering state is enabled or disabled
  113837. * @param value defines the dithering state
  113838. */
  113839. setDitheringState(value: boolean): void;
  113840. /**
  113841. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  113842. * @param value defines the rasterizer state
  113843. */
  113844. setRasterizerState(value: boolean): void;
  113845. /**
  113846. * Gets the current depth function
  113847. * @returns a number defining the depth function
  113848. */
  113849. getDepthFunction(): Nullable<number>;
  113850. /**
  113851. * Sets the current depth function
  113852. * @param depthFunc defines the function to use
  113853. */
  113854. setDepthFunction(depthFunc: number): void;
  113855. /**
  113856. * Sets the current depth function to GREATER
  113857. */
  113858. setDepthFunctionToGreater(): void;
  113859. /**
  113860. * Sets the current depth function to GEQUAL
  113861. */
  113862. setDepthFunctionToGreaterOrEqual(): void;
  113863. /**
  113864. * Sets the current depth function to LESS
  113865. */
  113866. setDepthFunctionToLess(): void;
  113867. /**
  113868. * Sets the current depth function to LEQUAL
  113869. */
  113870. setDepthFunctionToLessOrEqual(): void;
  113871. private _cachedStencilBuffer;
  113872. private _cachedStencilFunction;
  113873. private _cachedStencilMask;
  113874. private _cachedStencilOperationPass;
  113875. private _cachedStencilOperationFail;
  113876. private _cachedStencilOperationDepthFail;
  113877. private _cachedStencilReference;
  113878. /**
  113879. * Caches the the state of the stencil buffer
  113880. */
  113881. cacheStencilState(): void;
  113882. /**
  113883. * Restores the state of the stencil buffer
  113884. */
  113885. restoreStencilState(): void;
  113886. /**
  113887. * Directly set the WebGL Viewport
  113888. * @param x defines the x coordinate of the viewport (in screen space)
  113889. * @param y defines the y coordinate of the viewport (in screen space)
  113890. * @param width defines the width of the viewport (in screen space)
  113891. * @param height defines the height of the viewport (in screen space)
  113892. * @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
  113893. */
  113894. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  113895. /**
  113896. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  113897. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113898. * @param y defines the y-coordinate of the corner of the clear rectangle
  113899. * @param width defines the width of the clear rectangle
  113900. * @param height defines the height of the clear rectangle
  113901. * @param clearColor defines the clear color
  113902. */
  113903. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  113904. /**
  113905. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  113906. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113907. * @param y defines the y-coordinate of the corner of the clear rectangle
  113908. * @param width defines the width of the clear rectangle
  113909. * @param height defines the height of the clear rectangle
  113910. */
  113911. enableScissor(x: number, y: number, width: number, height: number): void;
  113912. /**
  113913. * Disable previously set scissor test rectangle
  113914. */
  113915. disableScissor(): void;
  113916. protected _reportDrawCall(): void;
  113917. /**
  113918. * Initializes a webVR display and starts listening to display change events
  113919. * The onVRDisplayChangedObservable will be notified upon these changes
  113920. * @returns The onVRDisplayChangedObservable
  113921. */
  113922. initWebVR(): Observable<IDisplayChangedEventArgs>;
  113923. /** @hidden */
  113924. _prepareVRComponent(): void;
  113925. /** @hidden */
  113926. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  113927. /** @hidden */
  113928. _submitVRFrame(): void;
  113929. /**
  113930. * Call this function to leave webVR mode
  113931. * Will do nothing if webVR is not supported or if there is no webVR device
  113932. * @see http://doc.babylonjs.com/how_to/webvr_camera
  113933. */
  113934. disableVR(): void;
  113935. /**
  113936. * Gets a boolean indicating that the system is in VR mode and is presenting
  113937. * @returns true if VR mode is engaged
  113938. */
  113939. isVRPresenting(): boolean;
  113940. /** @hidden */
  113941. _requestVRFrame(): void;
  113942. /** @hidden */
  113943. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113944. /**
  113945. * Gets the source code of the vertex shader associated with a specific webGL program
  113946. * @param program defines the program to use
  113947. * @returns a string containing the source code of the vertex shader associated with the program
  113948. */
  113949. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  113950. /**
  113951. * Gets the source code of the fragment shader associated with a specific webGL program
  113952. * @param program defines the program to use
  113953. * @returns a string containing the source code of the fragment shader associated with the program
  113954. */
  113955. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  113956. /**
  113957. * Sets a depth stencil texture from a render target to the according uniform.
  113958. * @param channel The texture channel
  113959. * @param uniform The uniform to set
  113960. * @param texture The render target texture containing the depth stencil texture to apply
  113961. */
  113962. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  113963. /**
  113964. * Sets a texture to the webGL context from a postprocess
  113965. * @param channel defines the channel to use
  113966. * @param postProcess defines the source postprocess
  113967. */
  113968. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  113969. /**
  113970. * Binds the output of the passed in post process to the texture channel specified
  113971. * @param channel The channel the texture should be bound to
  113972. * @param postProcess The post process which's output should be bound
  113973. */
  113974. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  113975. protected _rebuildBuffers(): void;
  113976. /** @hidden */
  113977. _renderFrame(): void;
  113978. _renderLoop(): void;
  113979. /** @hidden */
  113980. _renderViews(): boolean;
  113981. /**
  113982. * Toggle full screen mode
  113983. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113984. */
  113985. switchFullscreen(requestPointerLock: boolean): void;
  113986. /**
  113987. * Enters full screen mode
  113988. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113989. */
  113990. enterFullscreen(requestPointerLock: boolean): void;
  113991. /**
  113992. * Exits full screen mode
  113993. */
  113994. exitFullscreen(): void;
  113995. /**
  113996. * Enters Pointerlock mode
  113997. */
  113998. enterPointerlock(): void;
  113999. /**
  114000. * Exits Pointerlock mode
  114001. */
  114002. exitPointerlock(): void;
  114003. /**
  114004. * Begin a new frame
  114005. */
  114006. beginFrame(): void;
  114007. /**
  114008. * Enf the current frame
  114009. */
  114010. endFrame(): void;
  114011. resize(): void;
  114012. /**
  114013. * Force a specific size of the canvas
  114014. * @param width defines the new canvas' width
  114015. * @param height defines the new canvas' height
  114016. */
  114017. setSize(width: number, height: number): void;
  114018. /**
  114019. * Updates a dynamic vertex buffer.
  114020. * @param vertexBuffer the vertex buffer to update
  114021. * @param data the data used to update the vertex buffer
  114022. * @param byteOffset the byte offset of the data
  114023. * @param byteLength the byte length of the data
  114024. */
  114025. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114026. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114027. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114028. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114029. _releaseTexture(texture: InternalTexture): void;
  114030. /**
  114031. * @hidden
  114032. * Rescales a texture
  114033. * @param source input texutre
  114034. * @param destination destination texture
  114035. * @param scene scene to use to render the resize
  114036. * @param internalFormat format to use when resizing
  114037. * @param onComplete callback to be called when resize has completed
  114038. */
  114039. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114040. /**
  114041. * Gets the current framerate
  114042. * @returns a number representing the framerate
  114043. */
  114044. getFps(): number;
  114045. /**
  114046. * Gets the time spent between current and previous frame
  114047. * @returns a number representing the delta time in ms
  114048. */
  114049. getDeltaTime(): number;
  114050. private _measureFps;
  114051. /** @hidden */
  114052. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114053. /**
  114054. * Update a dynamic index buffer
  114055. * @param indexBuffer defines the target index buffer
  114056. * @param indices defines the data to update
  114057. * @param offset defines the offset in the target index buffer where update should start
  114058. */
  114059. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114060. /**
  114061. * Updates the sample count of a render target texture
  114062. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114063. * @param texture defines the texture to update
  114064. * @param samples defines the sample count to set
  114065. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114066. */
  114067. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114068. /**
  114069. * Updates a depth texture Comparison Mode and Function.
  114070. * If the comparison Function is equal to 0, the mode will be set to none.
  114071. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114072. * @param texture The texture to set the comparison function for
  114073. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114074. */
  114075. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114076. /**
  114077. * Creates a webGL buffer to use with instanciation
  114078. * @param capacity defines the size of the buffer
  114079. * @returns the webGL buffer
  114080. */
  114081. createInstancesBuffer(capacity: number): DataBuffer;
  114082. /**
  114083. * Delete a webGL buffer used with instanciation
  114084. * @param buffer defines the webGL buffer to delete
  114085. */
  114086. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114087. private _clientWaitAsync;
  114088. /** @hidden */
  114089. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114090. dispose(): void;
  114091. private _disableTouchAction;
  114092. /**
  114093. * Display the loading screen
  114094. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114095. */
  114096. displayLoadingUI(): void;
  114097. /**
  114098. * Hide the loading screen
  114099. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114100. */
  114101. hideLoadingUI(): void;
  114102. /**
  114103. * Gets the current loading screen object
  114104. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114105. */
  114106. get loadingScreen(): ILoadingScreen;
  114107. /**
  114108. * Sets the current loading screen object
  114109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114110. */
  114111. set loadingScreen(loadingScreen: ILoadingScreen);
  114112. /**
  114113. * Sets the current loading screen text
  114114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114115. */
  114116. set loadingUIText(text: string);
  114117. /**
  114118. * Sets the current loading screen background color
  114119. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114120. */
  114121. set loadingUIBackgroundColor(color: string);
  114122. /** Pointerlock and fullscreen */
  114123. /**
  114124. * Ask the browser to promote the current element to pointerlock mode
  114125. * @param element defines the DOM element to promote
  114126. */
  114127. static _RequestPointerlock(element: HTMLElement): void;
  114128. /**
  114129. * Asks the browser to exit pointerlock mode
  114130. */
  114131. static _ExitPointerlock(): void;
  114132. /**
  114133. * Ask the browser to promote the current element to fullscreen rendering mode
  114134. * @param element defines the DOM element to promote
  114135. */
  114136. static _RequestFullscreen(element: HTMLElement): void;
  114137. /**
  114138. * Asks the browser to exit fullscreen mode
  114139. */
  114140. static _ExitFullscreen(): void;
  114141. }
  114142. }
  114143. declare module BABYLON {
  114144. /**
  114145. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114146. * during the life time of the application.
  114147. */
  114148. export class EngineStore {
  114149. /** Gets the list of created engines */
  114150. static Instances: Engine[];
  114151. /** @hidden */
  114152. static _LastCreatedScene: Nullable<Scene>;
  114153. /**
  114154. * Gets the latest created engine
  114155. */
  114156. static get LastCreatedEngine(): Nullable<Engine>;
  114157. /**
  114158. * Gets the latest created scene
  114159. */
  114160. static get LastCreatedScene(): Nullable<Scene>;
  114161. /**
  114162. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114163. * @ignorenaming
  114164. */
  114165. static UseFallbackTexture: boolean;
  114166. /**
  114167. * Texture content used if a texture cannot loaded
  114168. * @ignorenaming
  114169. */
  114170. static FallbackTexture: string;
  114171. }
  114172. }
  114173. declare module BABYLON {
  114174. /**
  114175. * Helper class that provides a small promise polyfill
  114176. */
  114177. export class PromisePolyfill {
  114178. /**
  114179. * Static function used to check if the polyfill is required
  114180. * If this is the case then the function will inject the polyfill to window.Promise
  114181. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114182. */
  114183. static Apply(force?: boolean): void;
  114184. }
  114185. }
  114186. declare module BABYLON {
  114187. /**
  114188. * Interface for screenshot methods with describe argument called `size` as object with options
  114189. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114190. */
  114191. export interface IScreenshotSize {
  114192. /**
  114193. * number in pixels for canvas height
  114194. */
  114195. height?: number;
  114196. /**
  114197. * multiplier allowing render at a higher or lower resolution
  114198. * If value is defined then height and width will be ignored and taken from camera
  114199. */
  114200. precision?: number;
  114201. /**
  114202. * number in pixels for canvas width
  114203. */
  114204. width?: number;
  114205. }
  114206. }
  114207. declare module BABYLON {
  114208. interface IColor4Like {
  114209. r: float;
  114210. g: float;
  114211. b: float;
  114212. a: float;
  114213. }
  114214. /**
  114215. * Class containing a set of static utilities functions
  114216. */
  114217. export class Tools {
  114218. /**
  114219. * Gets or sets the base URL to use to load assets
  114220. */
  114221. static get BaseUrl(): string;
  114222. static set BaseUrl(value: string);
  114223. /**
  114224. * Enable/Disable Custom HTTP Request Headers globally.
  114225. * default = false
  114226. * @see CustomRequestHeaders
  114227. */
  114228. static UseCustomRequestHeaders: boolean;
  114229. /**
  114230. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114231. * i.e. when loading files, where the server/service expects an Authorization header
  114232. */
  114233. static CustomRequestHeaders: {
  114234. [key: string]: string;
  114235. };
  114236. /**
  114237. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  114238. */
  114239. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  114240. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  114241. /**
  114242. * Default behaviour for cors in the application.
  114243. * It can be a string if the expected behavior is identical in the entire app.
  114244. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  114245. */
  114246. static get CorsBehavior(): string | ((url: string | string[]) => string);
  114247. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  114248. /**
  114249. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114250. * @ignorenaming
  114251. */
  114252. static get UseFallbackTexture(): boolean;
  114253. static set UseFallbackTexture(value: boolean);
  114254. /**
  114255. * Use this object to register external classes like custom textures or material
  114256. * to allow the laoders to instantiate them
  114257. */
  114258. static get RegisteredExternalClasses(): {
  114259. [key: string]: Object;
  114260. };
  114261. static set RegisteredExternalClasses(classes: {
  114262. [key: string]: Object;
  114263. });
  114264. /**
  114265. * Texture content used if a texture cannot loaded
  114266. * @ignorenaming
  114267. */
  114268. static get fallbackTexture(): string;
  114269. static set fallbackTexture(value: string);
  114270. /**
  114271. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  114272. * @param u defines the coordinate on X axis
  114273. * @param v defines the coordinate on Y axis
  114274. * @param width defines the width of the source data
  114275. * @param height defines the height of the source data
  114276. * @param pixels defines the source byte array
  114277. * @param color defines the output color
  114278. */
  114279. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  114280. /**
  114281. * Interpolates between a and b via alpha
  114282. * @param a The lower value (returned when alpha = 0)
  114283. * @param b The upper value (returned when alpha = 1)
  114284. * @param alpha The interpolation-factor
  114285. * @return The mixed value
  114286. */
  114287. static Mix(a: number, b: number, alpha: number): number;
  114288. /**
  114289. * Tries to instantiate a new object from a given class name
  114290. * @param className defines the class name to instantiate
  114291. * @returns the new object or null if the system was not able to do the instantiation
  114292. */
  114293. static Instantiate(className: string): any;
  114294. /**
  114295. * Provides a slice function that will work even on IE
  114296. * @param data defines the array to slice
  114297. * @param start defines the start of the data (optional)
  114298. * @param end defines the end of the data (optional)
  114299. * @returns the new sliced array
  114300. */
  114301. static Slice<T>(data: T, start?: number, end?: number): T;
  114302. /**
  114303. * Polyfill for setImmediate
  114304. * @param action defines the action to execute after the current execution block
  114305. */
  114306. static SetImmediate(action: () => void): void;
  114307. /**
  114308. * Function indicating if a number is an exponent of 2
  114309. * @param value defines the value to test
  114310. * @returns true if the value is an exponent of 2
  114311. */
  114312. static IsExponentOfTwo(value: number): boolean;
  114313. private static _tmpFloatArray;
  114314. /**
  114315. * Returns the nearest 32-bit single precision float representation of a Number
  114316. * @param value A Number. If the parameter is of a different type, it will get converted
  114317. * to a number or to NaN if it cannot be converted
  114318. * @returns number
  114319. */
  114320. static FloatRound(value: number): number;
  114321. /**
  114322. * Extracts the filename from a path
  114323. * @param path defines the path to use
  114324. * @returns the filename
  114325. */
  114326. static GetFilename(path: string): string;
  114327. /**
  114328. * Extracts the "folder" part of a path (everything before the filename).
  114329. * @param uri The URI to extract the info from
  114330. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  114331. * @returns The "folder" part of the path
  114332. */
  114333. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  114334. /**
  114335. * Extracts text content from a DOM element hierarchy
  114336. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  114337. */
  114338. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  114339. /**
  114340. * Convert an angle in radians to degrees
  114341. * @param angle defines the angle to convert
  114342. * @returns the angle in degrees
  114343. */
  114344. static ToDegrees(angle: number): number;
  114345. /**
  114346. * Convert an angle in degrees to radians
  114347. * @param angle defines the angle to convert
  114348. * @returns the angle in radians
  114349. */
  114350. static ToRadians(angle: number): number;
  114351. /**
  114352. * Returns an array if obj is not an array
  114353. * @param obj defines the object to evaluate as an array
  114354. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  114355. * @returns either obj directly if obj is an array or a new array containing obj
  114356. */
  114357. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  114358. /**
  114359. * Gets the pointer prefix to use
  114360. * @param engine defines the engine we are finding the prefix for
  114361. * @returns "pointer" if touch is enabled. Else returns "mouse"
  114362. */
  114363. static GetPointerPrefix(engine: Engine): string;
  114364. /**
  114365. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  114366. * @param url define the url we are trying
  114367. * @param element define the dom element where to configure the cors policy
  114368. */
  114369. static SetCorsBehavior(url: string | string[], element: {
  114370. crossOrigin: string | null;
  114371. }): void;
  114372. /**
  114373. * Removes unwanted characters from an url
  114374. * @param url defines the url to clean
  114375. * @returns the cleaned url
  114376. */
  114377. static CleanUrl(url: string): string;
  114378. /**
  114379. * Gets or sets a function used to pre-process url before using them to load assets
  114380. */
  114381. static get PreprocessUrl(): (url: string) => string;
  114382. static set PreprocessUrl(processor: (url: string) => string);
  114383. /**
  114384. * Loads an image as an HTMLImageElement.
  114385. * @param input url string, ArrayBuffer, or Blob to load
  114386. * @param onLoad callback called when the image successfully loads
  114387. * @param onError callback called when the image fails to load
  114388. * @param offlineProvider offline provider for caching
  114389. * @param mimeType optional mime type
  114390. * @returns the HTMLImageElement of the loaded image
  114391. */
  114392. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  114393. /**
  114394. * Loads a file from a url
  114395. * @param url url string, ArrayBuffer, or Blob to load
  114396. * @param onSuccess callback called when the file successfully loads
  114397. * @param onProgress callback called while file is loading (if the server supports this mode)
  114398. * @param offlineProvider defines the offline provider for caching
  114399. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114400. * @param onError callback called when the file fails to load
  114401. * @returns a file request object
  114402. */
  114403. 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;
  114404. /**
  114405. * Loads a file from a url
  114406. * @param url the file url to load
  114407. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114408. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  114409. */
  114410. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  114411. /**
  114412. * Load a script (identified by an url). When the url returns, the
  114413. * content of this file is added into a new script element, attached to the DOM (body element)
  114414. * @param scriptUrl defines the url of the script to laod
  114415. * @param onSuccess defines the callback called when the script is loaded
  114416. * @param onError defines the callback to call if an error occurs
  114417. * @param scriptId defines the id of the script element
  114418. */
  114419. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  114420. /**
  114421. * Load an asynchronous script (identified by an url). When the url returns, the
  114422. * content of this file is added into a new script element, attached to the DOM (body element)
  114423. * @param scriptUrl defines the url of the script to laod
  114424. * @param scriptId defines the id of the script element
  114425. * @returns a promise request object
  114426. */
  114427. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  114428. /**
  114429. * Loads a file from a blob
  114430. * @param fileToLoad defines the blob to use
  114431. * @param callback defines the callback to call when data is loaded
  114432. * @param progressCallback defines the callback to call during loading process
  114433. * @returns a file request object
  114434. */
  114435. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  114436. /**
  114437. * Reads a file from a File object
  114438. * @param file defines the file to load
  114439. * @param onSuccess defines the callback to call when data is loaded
  114440. * @param onProgress defines the callback to call during loading process
  114441. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114442. * @param onError defines the callback to call when an error occurs
  114443. * @returns a file request object
  114444. */
  114445. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  114446. /**
  114447. * Creates a data url from a given string content
  114448. * @param content defines the content to convert
  114449. * @returns the new data url link
  114450. */
  114451. static FileAsURL(content: string): string;
  114452. /**
  114453. * Format the given number to a specific decimal format
  114454. * @param value defines the number to format
  114455. * @param decimals defines the number of decimals to use
  114456. * @returns the formatted string
  114457. */
  114458. static Format(value: number, decimals?: number): string;
  114459. /**
  114460. * Tries to copy an object by duplicating every property
  114461. * @param source defines the source object
  114462. * @param destination defines the target object
  114463. * @param doNotCopyList defines a list of properties to avoid
  114464. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  114465. */
  114466. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  114467. /**
  114468. * Gets a boolean indicating if the given object has no own property
  114469. * @param obj defines the object to test
  114470. * @returns true if object has no own property
  114471. */
  114472. static IsEmpty(obj: any): boolean;
  114473. /**
  114474. * Function used to register events at window level
  114475. * @param windowElement defines the Window object to use
  114476. * @param events defines the events to register
  114477. */
  114478. static RegisterTopRootEvents(windowElement: Window, events: {
  114479. name: string;
  114480. handler: Nullable<(e: FocusEvent) => any>;
  114481. }[]): void;
  114482. /**
  114483. * Function used to unregister events from window level
  114484. * @param windowElement defines the Window object to use
  114485. * @param events defines the events to unregister
  114486. */
  114487. static UnregisterTopRootEvents(windowElement: Window, events: {
  114488. name: string;
  114489. handler: Nullable<(e: FocusEvent) => any>;
  114490. }[]): void;
  114491. /**
  114492. * @ignore
  114493. */
  114494. static _ScreenshotCanvas: HTMLCanvasElement;
  114495. /**
  114496. * Dumps the current bound framebuffer
  114497. * @param width defines the rendering width
  114498. * @param height defines the rendering height
  114499. * @param engine defines the hosting engine
  114500. * @param successCallback defines the callback triggered once the data are available
  114501. * @param mimeType defines the mime type of the result
  114502. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  114503. */
  114504. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114505. /**
  114506. * Converts the canvas data to blob.
  114507. * This acts as a polyfill for browsers not supporting the to blob function.
  114508. * @param canvas Defines the canvas to extract the data from
  114509. * @param successCallback Defines the callback triggered once the data are available
  114510. * @param mimeType Defines the mime type of the result
  114511. */
  114512. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  114513. /**
  114514. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  114515. * @param successCallback defines the callback triggered once the data are available
  114516. * @param mimeType defines the mime type of the result
  114517. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  114518. */
  114519. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114520. /**
  114521. * Downloads a blob in the browser
  114522. * @param blob defines the blob to download
  114523. * @param fileName defines the name of the downloaded file
  114524. */
  114525. static Download(blob: Blob, fileName: string): void;
  114526. /**
  114527. * Captures a screenshot of the current rendering
  114528. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114529. * @param engine defines the rendering engine
  114530. * @param camera defines the source camera
  114531. * @param size This parameter can be set to a single number or to an object with the
  114532. * following (optional) properties: precision, width, height. If a single number is passed,
  114533. * it will be used for both width and height. If an object is passed, the screenshot size
  114534. * will be derived from the parameters. The precision property is a multiplier allowing
  114535. * rendering at a higher or lower resolution
  114536. * @param successCallback defines the callback receives a single parameter which contains the
  114537. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114538. * src parameter of an <img> to display it
  114539. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114540. * Check your browser for supported MIME types
  114541. */
  114542. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  114543. /**
  114544. * Captures a screenshot of the current rendering
  114545. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114546. * @param engine defines the rendering engine
  114547. * @param camera defines the source camera
  114548. * @param size This parameter can be set to a single number or to an object with the
  114549. * following (optional) properties: precision, width, height. If a single number is passed,
  114550. * it will be used for both width and height. If an object is passed, the screenshot size
  114551. * will be derived from the parameters. The precision property is a multiplier allowing
  114552. * rendering at a higher or lower resolution
  114553. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114554. * Check your browser for supported MIME types
  114555. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114556. * to the src parameter of an <img> to display it
  114557. */
  114558. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  114559. /**
  114560. * Generates an image screenshot from the specified camera.
  114561. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114562. * @param engine The engine to use for rendering
  114563. * @param camera The camera to use for rendering
  114564. * @param size This parameter can be set to a single number or to an object with the
  114565. * following (optional) properties: precision, width, height. If a single number is passed,
  114566. * it will be used for both width and height. If an object is passed, the screenshot size
  114567. * will be derived from the parameters. The precision property is a multiplier allowing
  114568. * rendering at a higher or lower resolution
  114569. * @param successCallback The callback receives a single parameter which contains the
  114570. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114571. * src parameter of an <img> to display it
  114572. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114573. * Check your browser for supported MIME types
  114574. * @param samples Texture samples (default: 1)
  114575. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114576. * @param fileName A name for for the downloaded file.
  114577. */
  114578. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114579. /**
  114580. * Generates an image screenshot from the specified camera.
  114581. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114582. * @param engine The engine to use for rendering
  114583. * @param camera The camera to use for rendering
  114584. * @param size This parameter can be set to a single number or to an object with the
  114585. * following (optional) properties: precision, width, height. If a single number is passed,
  114586. * it will be used for both width and height. If an object is passed, the screenshot size
  114587. * will be derived from the parameters. The precision property is a multiplier allowing
  114588. * rendering at a higher or lower resolution
  114589. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114590. * Check your browser for supported MIME types
  114591. * @param samples Texture samples (default: 1)
  114592. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114593. * @param fileName A name for for the downloaded file.
  114594. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114595. * to the src parameter of an <img> to display it
  114596. */
  114597. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  114598. /**
  114599. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  114600. * Be aware Math.random() could cause collisions, but:
  114601. * "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"
  114602. * @returns a pseudo random id
  114603. */
  114604. static RandomId(): string;
  114605. /**
  114606. * Test if the given uri is a base64 string
  114607. * @param uri The uri to test
  114608. * @return True if the uri is a base64 string or false otherwise
  114609. */
  114610. static IsBase64(uri: string): boolean;
  114611. /**
  114612. * Decode the given base64 uri.
  114613. * @param uri The uri to decode
  114614. * @return The decoded base64 data.
  114615. */
  114616. static DecodeBase64(uri: string): ArrayBuffer;
  114617. /**
  114618. * Gets the absolute url.
  114619. * @param url the input url
  114620. * @return the absolute url
  114621. */
  114622. static GetAbsoluteUrl(url: string): string;
  114623. /**
  114624. * No log
  114625. */
  114626. static readonly NoneLogLevel: number;
  114627. /**
  114628. * Only message logs
  114629. */
  114630. static readonly MessageLogLevel: number;
  114631. /**
  114632. * Only warning logs
  114633. */
  114634. static readonly WarningLogLevel: number;
  114635. /**
  114636. * Only error logs
  114637. */
  114638. static readonly ErrorLogLevel: number;
  114639. /**
  114640. * All logs
  114641. */
  114642. static readonly AllLogLevel: number;
  114643. /**
  114644. * Gets a value indicating the number of loading errors
  114645. * @ignorenaming
  114646. */
  114647. static get errorsCount(): number;
  114648. /**
  114649. * Callback called when a new log is added
  114650. */
  114651. static OnNewCacheEntry: (entry: string) => void;
  114652. /**
  114653. * Log a message to the console
  114654. * @param message defines the message to log
  114655. */
  114656. static Log(message: string): void;
  114657. /**
  114658. * Write a warning message to the console
  114659. * @param message defines the message to log
  114660. */
  114661. static Warn(message: string): void;
  114662. /**
  114663. * Write an error message to the console
  114664. * @param message defines the message to log
  114665. */
  114666. static Error(message: string): void;
  114667. /**
  114668. * Gets current log cache (list of logs)
  114669. */
  114670. static get LogCache(): string;
  114671. /**
  114672. * Clears the log cache
  114673. */
  114674. static ClearLogCache(): void;
  114675. /**
  114676. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  114677. */
  114678. static set LogLevels(level: number);
  114679. /**
  114680. * Checks if the window object exists
  114681. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  114682. */
  114683. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  114684. /**
  114685. * No performance log
  114686. */
  114687. static readonly PerformanceNoneLogLevel: number;
  114688. /**
  114689. * Use user marks to log performance
  114690. */
  114691. static readonly PerformanceUserMarkLogLevel: number;
  114692. /**
  114693. * Log performance to the console
  114694. */
  114695. static readonly PerformanceConsoleLogLevel: number;
  114696. private static _performance;
  114697. /**
  114698. * Sets the current performance log level
  114699. */
  114700. static set PerformanceLogLevel(level: number);
  114701. private static _StartPerformanceCounterDisabled;
  114702. private static _EndPerformanceCounterDisabled;
  114703. private static _StartUserMark;
  114704. private static _EndUserMark;
  114705. private static _StartPerformanceConsole;
  114706. private static _EndPerformanceConsole;
  114707. /**
  114708. * Starts a performance counter
  114709. */
  114710. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114711. /**
  114712. * Ends a specific performance coutner
  114713. */
  114714. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114715. /**
  114716. * Gets either window.performance.now() if supported or Date.now() else
  114717. */
  114718. static get Now(): number;
  114719. /**
  114720. * This method will return the name of the class used to create the instance of the given object.
  114721. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  114722. * @param object the object to get the class name from
  114723. * @param isType defines if the object is actually a type
  114724. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  114725. */
  114726. static GetClassName(object: any, isType?: boolean): string;
  114727. /**
  114728. * Gets the first element of an array satisfying a given predicate
  114729. * @param array defines the array to browse
  114730. * @param predicate defines the predicate to use
  114731. * @returns null if not found or the element
  114732. */
  114733. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  114734. /**
  114735. * This method will return the name of the full name of the class, including its owning module (if any).
  114736. * 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).
  114737. * @param object the object to get the class name from
  114738. * @param isType defines if the object is actually a type
  114739. * @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.
  114740. * @ignorenaming
  114741. */
  114742. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  114743. /**
  114744. * Returns a promise that resolves after the given amount of time.
  114745. * @param delay Number of milliseconds to delay
  114746. * @returns Promise that resolves after the given amount of time
  114747. */
  114748. static DelayAsync(delay: number): Promise<void>;
  114749. /**
  114750. * Utility function to detect if the current user agent is Safari
  114751. * @returns whether or not the current user agent is safari
  114752. */
  114753. static IsSafari(): boolean;
  114754. }
  114755. /**
  114756. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  114757. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  114758. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  114759. * @param name The name of the class, case should be preserved
  114760. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  114761. */
  114762. export function className(name: string, module?: string): (target: Object) => void;
  114763. /**
  114764. * An implementation of a loop for asynchronous functions.
  114765. */
  114766. export class AsyncLoop {
  114767. /**
  114768. * Defines the number of iterations for the loop
  114769. */
  114770. iterations: number;
  114771. /**
  114772. * Defines the current index of the loop.
  114773. */
  114774. index: number;
  114775. private _done;
  114776. private _fn;
  114777. private _successCallback;
  114778. /**
  114779. * Constructor.
  114780. * @param iterations the number of iterations.
  114781. * @param func the function to run each iteration
  114782. * @param successCallback the callback that will be called upon succesful execution
  114783. * @param offset starting offset.
  114784. */
  114785. constructor(
  114786. /**
  114787. * Defines the number of iterations for the loop
  114788. */
  114789. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  114790. /**
  114791. * Execute the next iteration. Must be called after the last iteration was finished.
  114792. */
  114793. executeNext(): void;
  114794. /**
  114795. * Break the loop and run the success callback.
  114796. */
  114797. breakLoop(): void;
  114798. /**
  114799. * Create and run an async loop.
  114800. * @param iterations the number of iterations.
  114801. * @param fn the function to run each iteration
  114802. * @param successCallback the callback that will be called upon succesful execution
  114803. * @param offset starting offset.
  114804. * @returns the created async loop object
  114805. */
  114806. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  114807. /**
  114808. * A for-loop that will run a given number of iterations synchronous and the rest async.
  114809. * @param iterations total number of iterations
  114810. * @param syncedIterations number of synchronous iterations in each async iteration.
  114811. * @param fn the function to call each iteration.
  114812. * @param callback a success call back that will be called when iterating stops.
  114813. * @param breakFunction a break condition (optional)
  114814. * @param timeout timeout settings for the setTimeout function. default - 0.
  114815. * @returns the created async loop object
  114816. */
  114817. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  114818. }
  114819. }
  114820. declare module BABYLON {
  114821. /**
  114822. * This class implement a typical dictionary using a string as key and the generic type T as value.
  114823. * The underlying implementation relies on an associative array to ensure the best performances.
  114824. * The value can be anything including 'null' but except 'undefined'
  114825. */
  114826. export class StringDictionary<T> {
  114827. /**
  114828. * This will clear this dictionary and copy the content from the 'source' one.
  114829. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  114830. * @param source the dictionary to take the content from and copy to this dictionary
  114831. */
  114832. copyFrom(source: StringDictionary<T>): void;
  114833. /**
  114834. * Get a value based from its key
  114835. * @param key the given key to get the matching value from
  114836. * @return the value if found, otherwise undefined is returned
  114837. */
  114838. get(key: string): T | undefined;
  114839. /**
  114840. * Get a value from its key or add it if it doesn't exist.
  114841. * This method will ensure you that a given key/data will be present in the dictionary.
  114842. * @param key the given key to get the matching value from
  114843. * @param factory the factory that will create the value if the key is not present in the dictionary.
  114844. * The factory will only be invoked if there's no data for the given key.
  114845. * @return the value corresponding to the key.
  114846. */
  114847. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  114848. /**
  114849. * Get a value from its key if present in the dictionary otherwise add it
  114850. * @param key the key to get the value from
  114851. * @param val if there's no such key/value pair in the dictionary add it with this value
  114852. * @return the value corresponding to the key
  114853. */
  114854. getOrAdd(key: string, val: T): T;
  114855. /**
  114856. * Check if there's a given key in the dictionary
  114857. * @param key the key to check for
  114858. * @return true if the key is present, false otherwise
  114859. */
  114860. contains(key: string): boolean;
  114861. /**
  114862. * Add a new key and its corresponding value
  114863. * @param key the key to add
  114864. * @param value the value corresponding to the key
  114865. * @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
  114866. */
  114867. add(key: string, value: T): boolean;
  114868. /**
  114869. * Update a specific value associated to a key
  114870. * @param key defines the key to use
  114871. * @param value defines the value to store
  114872. * @returns true if the value was updated (or false if the key was not found)
  114873. */
  114874. set(key: string, value: T): boolean;
  114875. /**
  114876. * Get the element of the given key and remove it from the dictionary
  114877. * @param key defines the key to search
  114878. * @returns the value associated with the key or null if not found
  114879. */
  114880. getAndRemove(key: string): Nullable<T>;
  114881. /**
  114882. * Remove a key/value from the dictionary.
  114883. * @param key the key to remove
  114884. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  114885. */
  114886. remove(key: string): boolean;
  114887. /**
  114888. * Clear the whole content of the dictionary
  114889. */
  114890. clear(): void;
  114891. /**
  114892. * Gets the current count
  114893. */
  114894. get count(): number;
  114895. /**
  114896. * Execute a callback on each key/val of the dictionary.
  114897. * Note that you can remove any element in this dictionary in the callback implementation
  114898. * @param callback the callback to execute on a given key/value pair
  114899. */
  114900. forEach(callback: (key: string, val: T) => void): void;
  114901. /**
  114902. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  114903. * If the callback returns null or undefined the method will iterate to the next key/value pair
  114904. * Note that you can remove any element in this dictionary in the callback implementation
  114905. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  114906. * @returns the first item
  114907. */
  114908. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  114909. private _count;
  114910. private _data;
  114911. }
  114912. }
  114913. declare module BABYLON {
  114914. /** @hidden */
  114915. export interface ICollisionCoordinator {
  114916. createCollider(): Collider;
  114917. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114918. init(scene: Scene): void;
  114919. }
  114920. /** @hidden */
  114921. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  114922. private _scene;
  114923. private _scaledPosition;
  114924. private _scaledVelocity;
  114925. private _finalPosition;
  114926. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114927. createCollider(): Collider;
  114928. init(scene: Scene): void;
  114929. private _collideWithWorld;
  114930. }
  114931. }
  114932. declare module BABYLON {
  114933. /**
  114934. * Class used to manage all inputs for the scene.
  114935. */
  114936. export class InputManager {
  114937. /** The distance in pixel that you have to move to prevent some events */
  114938. static DragMovementThreshold: number;
  114939. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  114940. static LongPressDelay: number;
  114941. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  114942. static DoubleClickDelay: number;
  114943. /** If you need to check double click without raising a single click at first click, enable this flag */
  114944. static ExclusiveDoubleClickMode: boolean;
  114945. private _wheelEventName;
  114946. private _onPointerMove;
  114947. private _onPointerDown;
  114948. private _onPointerUp;
  114949. private _initClickEvent;
  114950. private _initActionManager;
  114951. private _delayedSimpleClick;
  114952. private _delayedSimpleClickTimeout;
  114953. private _previousDelayedSimpleClickTimeout;
  114954. private _meshPickProceed;
  114955. private _previousButtonPressed;
  114956. private _currentPickResult;
  114957. private _previousPickResult;
  114958. private _totalPointersPressed;
  114959. private _doubleClickOccured;
  114960. private _pointerOverMesh;
  114961. private _pickedDownMesh;
  114962. private _pickedUpMesh;
  114963. private _pointerX;
  114964. private _pointerY;
  114965. private _unTranslatedPointerX;
  114966. private _unTranslatedPointerY;
  114967. private _startingPointerPosition;
  114968. private _previousStartingPointerPosition;
  114969. private _startingPointerTime;
  114970. private _previousStartingPointerTime;
  114971. private _pointerCaptures;
  114972. private _onKeyDown;
  114973. private _onKeyUp;
  114974. private _onCanvasFocusObserver;
  114975. private _onCanvasBlurObserver;
  114976. private _scene;
  114977. /**
  114978. * Creates a new InputManager
  114979. * @param scene defines the hosting scene
  114980. */
  114981. constructor(scene: Scene);
  114982. /**
  114983. * Gets the mesh that is currently under the pointer
  114984. */
  114985. get meshUnderPointer(): Nullable<AbstractMesh>;
  114986. /**
  114987. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  114988. */
  114989. get unTranslatedPointer(): Vector2;
  114990. /**
  114991. * Gets or sets the current on-screen X position of the pointer
  114992. */
  114993. get pointerX(): number;
  114994. set pointerX(value: number);
  114995. /**
  114996. * Gets or sets the current on-screen Y position of the pointer
  114997. */
  114998. get pointerY(): number;
  114999. set pointerY(value: number);
  115000. private _updatePointerPosition;
  115001. private _processPointerMove;
  115002. private _setRayOnPointerInfo;
  115003. private _checkPrePointerObservable;
  115004. /**
  115005. * Use this method to simulate a pointer move on a mesh
  115006. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115007. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115008. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115009. */
  115010. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115011. /**
  115012. * Use this method to simulate a pointer down on a mesh
  115013. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115014. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115015. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115016. */
  115017. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115018. private _processPointerDown;
  115019. /** @hidden */
  115020. _isPointerSwiping(): boolean;
  115021. /**
  115022. * Use this method to simulate a pointer up on a mesh
  115023. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115024. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115025. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115026. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115027. */
  115028. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115029. private _processPointerUp;
  115030. /**
  115031. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115032. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115033. * @returns true if the pointer was captured
  115034. */
  115035. isPointerCaptured(pointerId?: number): boolean;
  115036. /**
  115037. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115038. * @param attachUp defines if you want to attach events to pointerup
  115039. * @param attachDown defines if you want to attach events to pointerdown
  115040. * @param attachMove defines if you want to attach events to pointermove
  115041. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115042. */
  115043. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115044. /**
  115045. * Detaches all event handlers
  115046. */
  115047. detachControl(): void;
  115048. /**
  115049. * Force the value of meshUnderPointer
  115050. * @param mesh defines the mesh to use
  115051. */
  115052. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115053. /**
  115054. * Gets the mesh under the pointer
  115055. * @returns a Mesh or null if no mesh is under the pointer
  115056. */
  115057. getPointerOverMesh(): Nullable<AbstractMesh>;
  115058. }
  115059. }
  115060. declare module BABYLON {
  115061. /**
  115062. * This class defines the direct association between an animation and a target
  115063. */
  115064. export class TargetedAnimation {
  115065. /**
  115066. * Animation to perform
  115067. */
  115068. animation: Animation;
  115069. /**
  115070. * Target to animate
  115071. */
  115072. target: any;
  115073. /**
  115074. * Returns the string "TargetedAnimation"
  115075. * @returns "TargetedAnimation"
  115076. */
  115077. getClassName(): string;
  115078. /**
  115079. * Serialize the object
  115080. * @returns the JSON object representing the current entity
  115081. */
  115082. serialize(): any;
  115083. }
  115084. /**
  115085. * Use this class to create coordinated animations on multiple targets
  115086. */
  115087. export class AnimationGroup implements IDisposable {
  115088. /** The name of the animation group */
  115089. name: string;
  115090. private _scene;
  115091. private _targetedAnimations;
  115092. private _animatables;
  115093. private _from;
  115094. private _to;
  115095. private _isStarted;
  115096. private _isPaused;
  115097. private _speedRatio;
  115098. private _loopAnimation;
  115099. private _isAdditive;
  115100. /**
  115101. * Gets or sets the unique id of the node
  115102. */
  115103. uniqueId: number;
  115104. /**
  115105. * This observable will notify when one animation have ended
  115106. */
  115107. onAnimationEndObservable: Observable<TargetedAnimation>;
  115108. /**
  115109. * Observer raised when one animation loops
  115110. */
  115111. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115112. /**
  115113. * Observer raised when all animations have looped
  115114. */
  115115. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115116. /**
  115117. * This observable will notify when all animations have ended.
  115118. */
  115119. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115120. /**
  115121. * This observable will notify when all animations have paused.
  115122. */
  115123. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115124. /**
  115125. * This observable will notify when all animations are playing.
  115126. */
  115127. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115128. /**
  115129. * Gets the first frame
  115130. */
  115131. get from(): number;
  115132. /**
  115133. * Gets the last frame
  115134. */
  115135. get to(): number;
  115136. /**
  115137. * Define if the animations are started
  115138. */
  115139. get isStarted(): boolean;
  115140. /**
  115141. * Gets a value indicating that the current group is playing
  115142. */
  115143. get isPlaying(): boolean;
  115144. /**
  115145. * Gets or sets the speed ratio to use for all animations
  115146. */
  115147. get speedRatio(): number;
  115148. /**
  115149. * Gets or sets the speed ratio to use for all animations
  115150. */
  115151. set speedRatio(value: number);
  115152. /**
  115153. * Gets or sets if all animations should loop or not
  115154. */
  115155. get loopAnimation(): boolean;
  115156. set loopAnimation(value: boolean);
  115157. /**
  115158. * Gets or sets if all animations should be evaluated additively
  115159. */
  115160. get isAdditive(): boolean;
  115161. set isAdditive(value: boolean);
  115162. /**
  115163. * Gets the targeted animations for this animation group
  115164. */
  115165. get targetedAnimations(): Array<TargetedAnimation>;
  115166. /**
  115167. * returning the list of animatables controlled by this animation group.
  115168. */
  115169. get animatables(): Array<Animatable>;
  115170. /**
  115171. * Gets the list of target animations
  115172. */
  115173. get children(): TargetedAnimation[];
  115174. /**
  115175. * Instantiates a new Animation Group.
  115176. * This helps managing several animations at once.
  115177. * @see http://doc.babylonjs.com/how_to/group
  115178. * @param name Defines the name of the group
  115179. * @param scene Defines the scene the group belongs to
  115180. */
  115181. constructor(
  115182. /** The name of the animation group */
  115183. name: string, scene?: Nullable<Scene>);
  115184. /**
  115185. * Add an animation (with its target) in the group
  115186. * @param animation defines the animation we want to add
  115187. * @param target defines the target of the animation
  115188. * @returns the TargetedAnimation object
  115189. */
  115190. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115191. /**
  115192. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115193. * It can add constant keys at begin or end
  115194. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115195. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115196. * @returns the animation group
  115197. */
  115198. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115199. private _animationLoopCount;
  115200. private _animationLoopFlags;
  115201. private _processLoop;
  115202. /**
  115203. * Start all animations on given targets
  115204. * @param loop defines if animations must loop
  115205. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115206. * @param from defines the from key (optional)
  115207. * @param to defines the to key (optional)
  115208. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115209. * @returns the current animation group
  115210. */
  115211. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115212. /**
  115213. * Pause all animations
  115214. * @returns the animation group
  115215. */
  115216. pause(): AnimationGroup;
  115217. /**
  115218. * Play all animations to initial state
  115219. * This function will start() the animations if they were not started or will restart() them if they were paused
  115220. * @param loop defines if animations must loop
  115221. * @returns the animation group
  115222. */
  115223. play(loop?: boolean): AnimationGroup;
  115224. /**
  115225. * Reset all animations to initial state
  115226. * @returns the animation group
  115227. */
  115228. reset(): AnimationGroup;
  115229. /**
  115230. * Restart animations from key 0
  115231. * @returns the animation group
  115232. */
  115233. restart(): AnimationGroup;
  115234. /**
  115235. * Stop all animations
  115236. * @returns the animation group
  115237. */
  115238. stop(): AnimationGroup;
  115239. /**
  115240. * Set animation weight for all animatables
  115241. * @param weight defines the weight to use
  115242. * @return the animationGroup
  115243. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115244. */
  115245. setWeightForAllAnimatables(weight: number): AnimationGroup;
  115246. /**
  115247. * Synchronize and normalize all animatables with a source animatable
  115248. * @param root defines the root animatable to synchronize with
  115249. * @return the animationGroup
  115250. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115251. */
  115252. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  115253. /**
  115254. * Goes to a specific frame in this animation group
  115255. * @param frame the frame number to go to
  115256. * @return the animationGroup
  115257. */
  115258. goToFrame(frame: number): AnimationGroup;
  115259. /**
  115260. * Dispose all associated resources
  115261. */
  115262. dispose(): void;
  115263. private _checkAnimationGroupEnded;
  115264. /**
  115265. * Clone the current animation group and returns a copy
  115266. * @param newName defines the name of the new group
  115267. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  115268. * @returns the new aniamtion group
  115269. */
  115270. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  115271. /**
  115272. * Serializes the animationGroup to an object
  115273. * @returns Serialized object
  115274. */
  115275. serialize(): any;
  115276. /**
  115277. * Returns a new AnimationGroup object parsed from the source provided.
  115278. * @param parsedAnimationGroup defines the source
  115279. * @param scene defines the scene that will receive the animationGroup
  115280. * @returns a new AnimationGroup
  115281. */
  115282. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  115283. /**
  115284. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  115285. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  115286. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  115287. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  115288. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  115289. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  115290. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  115291. */
  115292. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  115293. /**
  115294. * Returns the string "AnimationGroup"
  115295. * @returns "AnimationGroup"
  115296. */
  115297. getClassName(): string;
  115298. /**
  115299. * Creates a detailled string about the object
  115300. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  115301. * @returns a string representing the object
  115302. */
  115303. toString(fullDetails?: boolean): string;
  115304. }
  115305. }
  115306. declare module BABYLON {
  115307. /**
  115308. * Define an interface for all classes that will hold resources
  115309. */
  115310. export interface IDisposable {
  115311. /**
  115312. * Releases all held resources
  115313. */
  115314. dispose(): void;
  115315. }
  115316. /** Interface defining initialization parameters for Scene class */
  115317. export interface SceneOptions {
  115318. /**
  115319. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  115320. * It will improve performance when the number of geometries becomes important.
  115321. */
  115322. useGeometryUniqueIdsMap?: boolean;
  115323. /**
  115324. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  115325. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115326. */
  115327. useMaterialMeshMap?: boolean;
  115328. /**
  115329. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  115330. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115331. */
  115332. useClonedMeshMap?: boolean;
  115333. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  115334. virtual?: boolean;
  115335. }
  115336. /**
  115337. * Represents a scene to be rendered by the engine.
  115338. * @see http://doc.babylonjs.com/features/scene
  115339. */
  115340. export class Scene extends AbstractScene implements IAnimatable {
  115341. /** The fog is deactivated */
  115342. static readonly FOGMODE_NONE: number;
  115343. /** The fog density is following an exponential function */
  115344. static readonly FOGMODE_EXP: number;
  115345. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  115346. static readonly FOGMODE_EXP2: number;
  115347. /** The fog density is following a linear function. */
  115348. static readonly FOGMODE_LINEAR: number;
  115349. /**
  115350. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  115351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115352. */
  115353. static MinDeltaTime: number;
  115354. /**
  115355. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  115356. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115357. */
  115358. static MaxDeltaTime: number;
  115359. /**
  115360. * Factory used to create the default material.
  115361. * @param name The name of the material to create
  115362. * @param scene The scene to create the material for
  115363. * @returns The default material
  115364. */
  115365. static DefaultMaterialFactory(scene: Scene): Material;
  115366. /**
  115367. * Factory used to create the a collision coordinator.
  115368. * @returns The collision coordinator
  115369. */
  115370. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  115371. /** @hidden */
  115372. _inputManager: InputManager;
  115373. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  115374. cameraToUseForPointers: Nullable<Camera>;
  115375. /** @hidden */
  115376. readonly _isScene: boolean;
  115377. /** @hidden */
  115378. _blockEntityCollection: boolean;
  115379. /**
  115380. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  115381. */
  115382. autoClear: boolean;
  115383. /**
  115384. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  115385. */
  115386. autoClearDepthAndStencil: boolean;
  115387. /**
  115388. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  115389. */
  115390. clearColor: Color4;
  115391. /**
  115392. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  115393. */
  115394. ambientColor: Color3;
  115395. /**
  115396. * This is use to store the default BRDF lookup for PBR materials in your scene.
  115397. * It should only be one of the following (if not the default embedded one):
  115398. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115399. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  115400. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115401. * The material properties need to be setup according to the type of texture in use.
  115402. */
  115403. environmentBRDFTexture: BaseTexture;
  115404. /** @hidden */
  115405. protected _environmentTexture: Nullable<BaseTexture>;
  115406. /**
  115407. * Texture used in all pbr material as the reflection texture.
  115408. * As in the majority of the scene they are the same (exception for multi room and so on),
  115409. * this is easier to reference from here than from all the materials.
  115410. */
  115411. get environmentTexture(): Nullable<BaseTexture>;
  115412. /**
  115413. * Texture used in all pbr material as the reflection texture.
  115414. * As in the majority of the scene they are the same (exception for multi room and so on),
  115415. * this is easier to set here than in all the materials.
  115416. */
  115417. set environmentTexture(value: Nullable<BaseTexture>);
  115418. /** @hidden */
  115419. protected _environmentIntensity: number;
  115420. /**
  115421. * Intensity of the environment in all pbr material.
  115422. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115423. * As in the majority of the scene they are the same (exception for multi room and so on),
  115424. * this is easier to reference from here than from all the materials.
  115425. */
  115426. get environmentIntensity(): number;
  115427. /**
  115428. * Intensity of the environment in all pbr material.
  115429. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115430. * As in the majority of the scene they are the same (exception for multi room and so on),
  115431. * this is easier to set here than in all the materials.
  115432. */
  115433. set environmentIntensity(value: number);
  115434. /** @hidden */
  115435. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115436. /**
  115437. * Default image processing configuration used either in the rendering
  115438. * Forward main pass or through the imageProcessingPostProcess if present.
  115439. * As in the majority of the scene they are the same (exception for multi camera),
  115440. * this is easier to reference from here than from all the materials and post process.
  115441. *
  115442. * No setter as we it is a shared configuration, you can set the values instead.
  115443. */
  115444. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115445. private _forceWireframe;
  115446. /**
  115447. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  115448. */
  115449. set forceWireframe(value: boolean);
  115450. get forceWireframe(): boolean;
  115451. private _skipFrustumClipping;
  115452. /**
  115453. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  115454. */
  115455. set skipFrustumClipping(value: boolean);
  115456. get skipFrustumClipping(): boolean;
  115457. private _forcePointsCloud;
  115458. /**
  115459. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  115460. */
  115461. set forcePointsCloud(value: boolean);
  115462. get forcePointsCloud(): boolean;
  115463. /**
  115464. * Gets or sets the active clipplane 1
  115465. */
  115466. clipPlane: Nullable<Plane>;
  115467. /**
  115468. * Gets or sets the active clipplane 2
  115469. */
  115470. clipPlane2: Nullable<Plane>;
  115471. /**
  115472. * Gets or sets the active clipplane 3
  115473. */
  115474. clipPlane3: Nullable<Plane>;
  115475. /**
  115476. * Gets or sets the active clipplane 4
  115477. */
  115478. clipPlane4: Nullable<Plane>;
  115479. /**
  115480. * Gets or sets the active clipplane 5
  115481. */
  115482. clipPlane5: Nullable<Plane>;
  115483. /**
  115484. * Gets or sets the active clipplane 6
  115485. */
  115486. clipPlane6: Nullable<Plane>;
  115487. /**
  115488. * Gets or sets a boolean indicating if animations are enabled
  115489. */
  115490. animationsEnabled: boolean;
  115491. private _animationPropertiesOverride;
  115492. /**
  115493. * Gets or sets the animation properties override
  115494. */
  115495. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115496. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115497. /**
  115498. * Gets or sets a boolean indicating if a constant deltatime has to be used
  115499. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  115500. */
  115501. useConstantAnimationDeltaTime: boolean;
  115502. /**
  115503. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  115504. * Please note that it requires to run a ray cast through the scene on every frame
  115505. */
  115506. constantlyUpdateMeshUnderPointer: boolean;
  115507. /**
  115508. * Defines the HTML cursor to use when hovering over interactive elements
  115509. */
  115510. hoverCursor: string;
  115511. /**
  115512. * Defines the HTML default cursor to use (empty by default)
  115513. */
  115514. defaultCursor: string;
  115515. /**
  115516. * Defines whether cursors are handled by the scene.
  115517. */
  115518. doNotHandleCursors: boolean;
  115519. /**
  115520. * This is used to call preventDefault() on pointer down
  115521. * in order to block unwanted artifacts like system double clicks
  115522. */
  115523. preventDefaultOnPointerDown: boolean;
  115524. /**
  115525. * This is used to call preventDefault() on pointer up
  115526. * in order to block unwanted artifacts like system double clicks
  115527. */
  115528. preventDefaultOnPointerUp: boolean;
  115529. /**
  115530. * Gets or sets user defined metadata
  115531. */
  115532. metadata: any;
  115533. /**
  115534. * For internal use only. Please do not use.
  115535. */
  115536. reservedDataStore: any;
  115537. /**
  115538. * Gets the name of the plugin used to load this scene (null by default)
  115539. */
  115540. loadingPluginName: string;
  115541. /**
  115542. * Use this array to add regular expressions used to disable offline support for specific urls
  115543. */
  115544. disableOfflineSupportExceptionRules: RegExp[];
  115545. /**
  115546. * An event triggered when the scene is disposed.
  115547. */
  115548. onDisposeObservable: Observable<Scene>;
  115549. private _onDisposeObserver;
  115550. /** Sets a function to be executed when this scene is disposed. */
  115551. set onDispose(callback: () => void);
  115552. /**
  115553. * An event triggered before rendering the scene (right after animations and physics)
  115554. */
  115555. onBeforeRenderObservable: Observable<Scene>;
  115556. private _onBeforeRenderObserver;
  115557. /** Sets a function to be executed before rendering this scene */
  115558. set beforeRender(callback: Nullable<() => void>);
  115559. /**
  115560. * An event triggered after rendering the scene
  115561. */
  115562. onAfterRenderObservable: Observable<Scene>;
  115563. /**
  115564. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  115565. */
  115566. onAfterRenderCameraObservable: Observable<Camera>;
  115567. private _onAfterRenderObserver;
  115568. /** Sets a function to be executed after rendering this scene */
  115569. set afterRender(callback: Nullable<() => void>);
  115570. /**
  115571. * An event triggered before animating the scene
  115572. */
  115573. onBeforeAnimationsObservable: Observable<Scene>;
  115574. /**
  115575. * An event triggered after animations processing
  115576. */
  115577. onAfterAnimationsObservable: Observable<Scene>;
  115578. /**
  115579. * An event triggered before draw calls are ready to be sent
  115580. */
  115581. onBeforeDrawPhaseObservable: Observable<Scene>;
  115582. /**
  115583. * An event triggered after draw calls have been sent
  115584. */
  115585. onAfterDrawPhaseObservable: Observable<Scene>;
  115586. /**
  115587. * An event triggered when the scene is ready
  115588. */
  115589. onReadyObservable: Observable<Scene>;
  115590. /**
  115591. * An event triggered before rendering a camera
  115592. */
  115593. onBeforeCameraRenderObservable: Observable<Camera>;
  115594. private _onBeforeCameraRenderObserver;
  115595. /** Sets a function to be executed before rendering a camera*/
  115596. set beforeCameraRender(callback: () => void);
  115597. /**
  115598. * An event triggered after rendering a camera
  115599. */
  115600. onAfterCameraRenderObservable: Observable<Camera>;
  115601. private _onAfterCameraRenderObserver;
  115602. /** Sets a function to be executed after rendering a camera*/
  115603. set afterCameraRender(callback: () => void);
  115604. /**
  115605. * An event triggered when active meshes evaluation is about to start
  115606. */
  115607. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  115608. /**
  115609. * An event triggered when active meshes evaluation is done
  115610. */
  115611. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  115612. /**
  115613. * An event triggered when particles rendering is about to start
  115614. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115615. */
  115616. onBeforeParticlesRenderingObservable: Observable<Scene>;
  115617. /**
  115618. * An event triggered when particles rendering is done
  115619. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115620. */
  115621. onAfterParticlesRenderingObservable: Observable<Scene>;
  115622. /**
  115623. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  115624. */
  115625. onDataLoadedObservable: Observable<Scene>;
  115626. /**
  115627. * An event triggered when a camera is created
  115628. */
  115629. onNewCameraAddedObservable: Observable<Camera>;
  115630. /**
  115631. * An event triggered when a camera is removed
  115632. */
  115633. onCameraRemovedObservable: Observable<Camera>;
  115634. /**
  115635. * An event triggered when a light is created
  115636. */
  115637. onNewLightAddedObservable: Observable<Light>;
  115638. /**
  115639. * An event triggered when a light is removed
  115640. */
  115641. onLightRemovedObservable: Observable<Light>;
  115642. /**
  115643. * An event triggered when a geometry is created
  115644. */
  115645. onNewGeometryAddedObservable: Observable<Geometry>;
  115646. /**
  115647. * An event triggered when a geometry is removed
  115648. */
  115649. onGeometryRemovedObservable: Observable<Geometry>;
  115650. /**
  115651. * An event triggered when a transform node is created
  115652. */
  115653. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  115654. /**
  115655. * An event triggered when a transform node is removed
  115656. */
  115657. onTransformNodeRemovedObservable: Observable<TransformNode>;
  115658. /**
  115659. * An event triggered when a mesh is created
  115660. */
  115661. onNewMeshAddedObservable: Observable<AbstractMesh>;
  115662. /**
  115663. * An event triggered when a mesh is removed
  115664. */
  115665. onMeshRemovedObservable: Observable<AbstractMesh>;
  115666. /**
  115667. * An event triggered when a skeleton is created
  115668. */
  115669. onNewSkeletonAddedObservable: Observable<Skeleton>;
  115670. /**
  115671. * An event triggered when a skeleton is removed
  115672. */
  115673. onSkeletonRemovedObservable: Observable<Skeleton>;
  115674. /**
  115675. * An event triggered when a material is created
  115676. */
  115677. onNewMaterialAddedObservable: Observable<Material>;
  115678. /**
  115679. * An event triggered when a material is removed
  115680. */
  115681. onMaterialRemovedObservable: Observable<Material>;
  115682. /**
  115683. * An event triggered when a texture is created
  115684. */
  115685. onNewTextureAddedObservable: Observable<BaseTexture>;
  115686. /**
  115687. * An event triggered when a texture is removed
  115688. */
  115689. onTextureRemovedObservable: Observable<BaseTexture>;
  115690. /**
  115691. * An event triggered when render targets are about to be rendered
  115692. * Can happen multiple times per frame.
  115693. */
  115694. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  115695. /**
  115696. * An event triggered when render targets were rendered.
  115697. * Can happen multiple times per frame.
  115698. */
  115699. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  115700. /**
  115701. * An event triggered before calculating deterministic simulation step
  115702. */
  115703. onBeforeStepObservable: Observable<Scene>;
  115704. /**
  115705. * An event triggered after calculating deterministic simulation step
  115706. */
  115707. onAfterStepObservable: Observable<Scene>;
  115708. /**
  115709. * An event triggered when the activeCamera property is updated
  115710. */
  115711. onActiveCameraChanged: Observable<Scene>;
  115712. /**
  115713. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  115714. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115715. * 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)
  115716. */
  115717. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115718. /**
  115719. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  115720. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115721. * 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)
  115722. */
  115723. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115724. /**
  115725. * This Observable will when a mesh has been imported into the scene.
  115726. */
  115727. onMeshImportedObservable: Observable<AbstractMesh>;
  115728. /**
  115729. * This Observable will when an animation file has been imported into the scene.
  115730. */
  115731. onAnimationFileImportedObservable: Observable<Scene>;
  115732. /**
  115733. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  115734. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  115735. */
  115736. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  115737. /** @hidden */
  115738. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  115739. /**
  115740. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  115741. */
  115742. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  115743. /**
  115744. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  115745. */
  115746. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  115747. /**
  115748. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  115749. */
  115750. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  115751. /** Callback called when a pointer move is detected */
  115752. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115753. /** Callback called when a pointer down is detected */
  115754. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115755. /** Callback called when a pointer up is detected */
  115756. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  115757. /** Callback called when a pointer pick is detected */
  115758. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  115759. /**
  115760. * 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).
  115761. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  115762. */
  115763. onPrePointerObservable: Observable<PointerInfoPre>;
  115764. /**
  115765. * Observable event triggered each time an input event is received from the rendering canvas
  115766. */
  115767. onPointerObservable: Observable<PointerInfo>;
  115768. /**
  115769. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  115770. */
  115771. get unTranslatedPointer(): Vector2;
  115772. /**
  115773. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  115774. */
  115775. static get DragMovementThreshold(): number;
  115776. static set DragMovementThreshold(value: number);
  115777. /**
  115778. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  115779. */
  115780. static get LongPressDelay(): number;
  115781. static set LongPressDelay(value: number);
  115782. /**
  115783. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  115784. */
  115785. static get DoubleClickDelay(): number;
  115786. static set DoubleClickDelay(value: number);
  115787. /** If you need to check double click without raising a single click at first click, enable this flag */
  115788. static get ExclusiveDoubleClickMode(): boolean;
  115789. static set ExclusiveDoubleClickMode(value: boolean);
  115790. /** @hidden */
  115791. _mirroredCameraPosition: Nullable<Vector3>;
  115792. /**
  115793. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  115794. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  115795. */
  115796. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  115797. /**
  115798. * Observable event triggered each time an keyboard event is received from the hosting window
  115799. */
  115800. onKeyboardObservable: Observable<KeyboardInfo>;
  115801. private _useRightHandedSystem;
  115802. /**
  115803. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  115804. */
  115805. set useRightHandedSystem(value: boolean);
  115806. get useRightHandedSystem(): boolean;
  115807. private _timeAccumulator;
  115808. private _currentStepId;
  115809. private _currentInternalStep;
  115810. /**
  115811. * Sets the step Id used by deterministic lock step
  115812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115813. * @param newStepId defines the step Id
  115814. */
  115815. setStepId(newStepId: number): void;
  115816. /**
  115817. * Gets the step Id used by deterministic lock step
  115818. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115819. * @returns the step Id
  115820. */
  115821. getStepId(): number;
  115822. /**
  115823. * Gets the internal step used by deterministic lock step
  115824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115825. * @returns the internal step
  115826. */
  115827. getInternalStep(): number;
  115828. private _fogEnabled;
  115829. /**
  115830. * Gets or sets a boolean indicating if fog is enabled on this scene
  115831. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115832. * (Default is true)
  115833. */
  115834. set fogEnabled(value: boolean);
  115835. get fogEnabled(): boolean;
  115836. private _fogMode;
  115837. /**
  115838. * Gets or sets the fog mode to use
  115839. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115840. * | mode | value |
  115841. * | --- | --- |
  115842. * | FOGMODE_NONE | 0 |
  115843. * | FOGMODE_EXP | 1 |
  115844. * | FOGMODE_EXP2 | 2 |
  115845. * | FOGMODE_LINEAR | 3 |
  115846. */
  115847. set fogMode(value: number);
  115848. get fogMode(): number;
  115849. /**
  115850. * Gets or sets the fog color to use
  115851. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115852. * (Default is Color3(0.2, 0.2, 0.3))
  115853. */
  115854. fogColor: Color3;
  115855. /**
  115856. * Gets or sets the fog density to use
  115857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115858. * (Default is 0.1)
  115859. */
  115860. fogDensity: number;
  115861. /**
  115862. * Gets or sets the fog start distance to use
  115863. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115864. * (Default is 0)
  115865. */
  115866. fogStart: number;
  115867. /**
  115868. * Gets or sets the fog end distance to use
  115869. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115870. * (Default is 1000)
  115871. */
  115872. fogEnd: number;
  115873. private _shadowsEnabled;
  115874. /**
  115875. * Gets or sets a boolean indicating if shadows are enabled on this scene
  115876. */
  115877. set shadowsEnabled(value: boolean);
  115878. get shadowsEnabled(): boolean;
  115879. private _lightsEnabled;
  115880. /**
  115881. * Gets or sets a boolean indicating if lights are enabled on this scene
  115882. */
  115883. set lightsEnabled(value: boolean);
  115884. get lightsEnabled(): boolean;
  115885. /** All of the active cameras added to this scene. */
  115886. activeCameras: Camera[];
  115887. /** @hidden */
  115888. _activeCamera: Nullable<Camera>;
  115889. /** Gets or sets the current active camera */
  115890. get activeCamera(): Nullable<Camera>;
  115891. set activeCamera(value: Nullable<Camera>);
  115892. private _defaultMaterial;
  115893. /** The default material used on meshes when no material is affected */
  115894. get defaultMaterial(): Material;
  115895. /** The default material used on meshes when no material is affected */
  115896. set defaultMaterial(value: Material);
  115897. private _texturesEnabled;
  115898. /**
  115899. * Gets or sets a boolean indicating if textures are enabled on this scene
  115900. */
  115901. set texturesEnabled(value: boolean);
  115902. get texturesEnabled(): boolean;
  115903. /**
  115904. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  115905. */
  115906. physicsEnabled: boolean;
  115907. /**
  115908. * Gets or sets a boolean indicating if particles are enabled on this scene
  115909. */
  115910. particlesEnabled: boolean;
  115911. /**
  115912. * Gets or sets a boolean indicating if sprites are enabled on this scene
  115913. */
  115914. spritesEnabled: boolean;
  115915. private _skeletonsEnabled;
  115916. /**
  115917. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  115918. */
  115919. set skeletonsEnabled(value: boolean);
  115920. get skeletonsEnabled(): boolean;
  115921. /**
  115922. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  115923. */
  115924. lensFlaresEnabled: boolean;
  115925. /**
  115926. * Gets or sets a boolean indicating if collisions are enabled on this scene
  115927. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115928. */
  115929. collisionsEnabled: boolean;
  115930. private _collisionCoordinator;
  115931. /** @hidden */
  115932. get collisionCoordinator(): ICollisionCoordinator;
  115933. /**
  115934. * Defines the gravity applied to this scene (used only for collisions)
  115935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115936. */
  115937. gravity: Vector3;
  115938. /**
  115939. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  115940. */
  115941. postProcessesEnabled: boolean;
  115942. /**
  115943. * The list of postprocesses added to the scene
  115944. */
  115945. postProcesses: PostProcess[];
  115946. /**
  115947. * Gets the current postprocess manager
  115948. */
  115949. postProcessManager: PostProcessManager;
  115950. /**
  115951. * Gets or sets a boolean indicating if render targets are enabled on this scene
  115952. */
  115953. renderTargetsEnabled: boolean;
  115954. /**
  115955. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  115956. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  115957. */
  115958. dumpNextRenderTargets: boolean;
  115959. /**
  115960. * The list of user defined render targets added to the scene
  115961. */
  115962. customRenderTargets: RenderTargetTexture[];
  115963. /**
  115964. * Defines if texture loading must be delayed
  115965. * If true, textures will only be loaded when they need to be rendered
  115966. */
  115967. useDelayedTextureLoading: boolean;
  115968. /**
  115969. * Gets the list of meshes imported to the scene through SceneLoader
  115970. */
  115971. importedMeshesFiles: String[];
  115972. /**
  115973. * Gets or sets a boolean indicating if probes are enabled on this scene
  115974. */
  115975. probesEnabled: boolean;
  115976. /**
  115977. * Gets or sets the current offline provider to use to store scene data
  115978. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115979. */
  115980. offlineProvider: IOfflineProvider;
  115981. /**
  115982. * Gets or sets the action manager associated with the scene
  115983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  115984. */
  115985. actionManager: AbstractActionManager;
  115986. private _meshesForIntersections;
  115987. /**
  115988. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  115989. */
  115990. proceduralTexturesEnabled: boolean;
  115991. private _engine;
  115992. private _totalVertices;
  115993. /** @hidden */
  115994. _activeIndices: PerfCounter;
  115995. /** @hidden */
  115996. _activeParticles: PerfCounter;
  115997. /** @hidden */
  115998. _activeBones: PerfCounter;
  115999. private _animationRatio;
  116000. /** @hidden */
  116001. _animationTimeLast: number;
  116002. /** @hidden */
  116003. _animationTime: number;
  116004. /**
  116005. * Gets or sets a general scale for animation speed
  116006. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116007. */
  116008. animationTimeScale: number;
  116009. /** @hidden */
  116010. _cachedMaterial: Nullable<Material>;
  116011. /** @hidden */
  116012. _cachedEffect: Nullable<Effect>;
  116013. /** @hidden */
  116014. _cachedVisibility: Nullable<number>;
  116015. private _renderId;
  116016. private _frameId;
  116017. private _executeWhenReadyTimeoutId;
  116018. private _intermediateRendering;
  116019. private _viewUpdateFlag;
  116020. private _projectionUpdateFlag;
  116021. /** @hidden */
  116022. _toBeDisposed: Nullable<IDisposable>[];
  116023. private _activeRequests;
  116024. /** @hidden */
  116025. _pendingData: any[];
  116026. private _isDisposed;
  116027. /**
  116028. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116029. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116030. */
  116031. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116032. private _activeMeshes;
  116033. private _processedMaterials;
  116034. private _renderTargets;
  116035. /** @hidden */
  116036. _activeParticleSystems: SmartArray<IParticleSystem>;
  116037. private _activeSkeletons;
  116038. private _softwareSkinnedMeshes;
  116039. private _renderingManager;
  116040. /** @hidden */
  116041. _activeAnimatables: Animatable[];
  116042. private _transformMatrix;
  116043. private _sceneUbo;
  116044. /** @hidden */
  116045. _viewMatrix: Matrix;
  116046. private _projectionMatrix;
  116047. /** @hidden */
  116048. _forcedViewPosition: Nullable<Vector3>;
  116049. /** @hidden */
  116050. _frustumPlanes: Plane[];
  116051. /**
  116052. * Gets the list of frustum planes (built from the active camera)
  116053. */
  116054. get frustumPlanes(): Plane[];
  116055. /**
  116056. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116057. * This is useful if there are more lights that the maximum simulteanous authorized
  116058. */
  116059. requireLightSorting: boolean;
  116060. /** @hidden */
  116061. readonly useMaterialMeshMap: boolean;
  116062. /** @hidden */
  116063. readonly useClonedMeshMap: boolean;
  116064. private _externalData;
  116065. private _uid;
  116066. /**
  116067. * @hidden
  116068. * Backing store of defined scene components.
  116069. */
  116070. _components: ISceneComponent[];
  116071. /**
  116072. * @hidden
  116073. * Backing store of defined scene components.
  116074. */
  116075. _serializableComponents: ISceneSerializableComponent[];
  116076. /**
  116077. * List of components to register on the next registration step.
  116078. */
  116079. private _transientComponents;
  116080. /**
  116081. * Registers the transient components if needed.
  116082. */
  116083. private _registerTransientComponents;
  116084. /**
  116085. * @hidden
  116086. * Add a component to the scene.
  116087. * Note that the ccomponent could be registered on th next frame if this is called after
  116088. * the register component stage.
  116089. * @param component Defines the component to add to the scene
  116090. */
  116091. _addComponent(component: ISceneComponent): void;
  116092. /**
  116093. * @hidden
  116094. * Gets a component from the scene.
  116095. * @param name defines the name of the component to retrieve
  116096. * @returns the component or null if not present
  116097. */
  116098. _getComponent(name: string): Nullable<ISceneComponent>;
  116099. /**
  116100. * @hidden
  116101. * Defines the actions happening before camera updates.
  116102. */
  116103. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116104. /**
  116105. * @hidden
  116106. * Defines the actions happening before clear the canvas.
  116107. */
  116108. _beforeClearStage: Stage<SimpleStageAction>;
  116109. /**
  116110. * @hidden
  116111. * Defines the actions when collecting render targets for the frame.
  116112. */
  116113. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116114. /**
  116115. * @hidden
  116116. * Defines the actions happening for one camera in the frame.
  116117. */
  116118. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116119. /**
  116120. * @hidden
  116121. * Defines the actions happening during the per mesh ready checks.
  116122. */
  116123. _isReadyForMeshStage: Stage<MeshStageAction>;
  116124. /**
  116125. * @hidden
  116126. * Defines the actions happening before evaluate active mesh checks.
  116127. */
  116128. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116129. /**
  116130. * @hidden
  116131. * Defines the actions happening during the evaluate sub mesh checks.
  116132. */
  116133. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116134. /**
  116135. * @hidden
  116136. * Defines the actions happening during the active mesh stage.
  116137. */
  116138. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116139. /**
  116140. * @hidden
  116141. * Defines the actions happening during the per camera render target step.
  116142. */
  116143. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116144. /**
  116145. * @hidden
  116146. * Defines the actions happening just before the active camera is drawing.
  116147. */
  116148. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116149. /**
  116150. * @hidden
  116151. * Defines the actions happening just before a render target is drawing.
  116152. */
  116153. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116154. /**
  116155. * @hidden
  116156. * Defines the actions happening just before a rendering group is drawing.
  116157. */
  116158. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116159. /**
  116160. * @hidden
  116161. * Defines the actions happening just before a mesh is drawing.
  116162. */
  116163. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116164. /**
  116165. * @hidden
  116166. * Defines the actions happening just after a mesh has been drawn.
  116167. */
  116168. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116169. /**
  116170. * @hidden
  116171. * Defines the actions happening just after a rendering group has been drawn.
  116172. */
  116173. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116174. /**
  116175. * @hidden
  116176. * Defines the actions happening just after the active camera has been drawn.
  116177. */
  116178. _afterCameraDrawStage: Stage<CameraStageAction>;
  116179. /**
  116180. * @hidden
  116181. * Defines the actions happening just after a render target has been drawn.
  116182. */
  116183. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116184. /**
  116185. * @hidden
  116186. * Defines the actions happening just after rendering all cameras and computing intersections.
  116187. */
  116188. _afterRenderStage: Stage<SimpleStageAction>;
  116189. /**
  116190. * @hidden
  116191. * Defines the actions happening when a pointer move event happens.
  116192. */
  116193. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116194. /**
  116195. * @hidden
  116196. * Defines the actions happening when a pointer down event happens.
  116197. */
  116198. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116199. /**
  116200. * @hidden
  116201. * Defines the actions happening when a pointer up event happens.
  116202. */
  116203. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116204. /**
  116205. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116206. */
  116207. private geometriesByUniqueId;
  116208. /**
  116209. * Creates a new Scene
  116210. * @param engine defines the engine to use to render this scene
  116211. * @param options defines the scene options
  116212. */
  116213. constructor(engine: Engine, options?: SceneOptions);
  116214. /**
  116215. * Gets a string idenfifying the name of the class
  116216. * @returns "Scene" string
  116217. */
  116218. getClassName(): string;
  116219. private _defaultMeshCandidates;
  116220. /**
  116221. * @hidden
  116222. */
  116223. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116224. private _defaultSubMeshCandidates;
  116225. /**
  116226. * @hidden
  116227. */
  116228. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116229. /**
  116230. * Sets the default candidate providers for the scene.
  116231. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  116232. * and getCollidingSubMeshCandidates to their default function
  116233. */
  116234. setDefaultCandidateProviders(): void;
  116235. /**
  116236. * Gets the mesh that is currently under the pointer
  116237. */
  116238. get meshUnderPointer(): Nullable<AbstractMesh>;
  116239. /**
  116240. * Gets or sets the current on-screen X position of the pointer
  116241. */
  116242. get pointerX(): number;
  116243. set pointerX(value: number);
  116244. /**
  116245. * Gets or sets the current on-screen Y position of the pointer
  116246. */
  116247. get pointerY(): number;
  116248. set pointerY(value: number);
  116249. /**
  116250. * Gets the cached material (ie. the latest rendered one)
  116251. * @returns the cached material
  116252. */
  116253. getCachedMaterial(): Nullable<Material>;
  116254. /**
  116255. * Gets the cached effect (ie. the latest rendered one)
  116256. * @returns the cached effect
  116257. */
  116258. getCachedEffect(): Nullable<Effect>;
  116259. /**
  116260. * Gets the cached visibility state (ie. the latest rendered one)
  116261. * @returns the cached visibility state
  116262. */
  116263. getCachedVisibility(): Nullable<number>;
  116264. /**
  116265. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  116266. * @param material defines the current material
  116267. * @param effect defines the current effect
  116268. * @param visibility defines the current visibility state
  116269. * @returns true if one parameter is not cached
  116270. */
  116271. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  116272. /**
  116273. * Gets the engine associated with the scene
  116274. * @returns an Engine
  116275. */
  116276. getEngine(): Engine;
  116277. /**
  116278. * Gets the total number of vertices rendered per frame
  116279. * @returns the total number of vertices rendered per frame
  116280. */
  116281. getTotalVertices(): number;
  116282. /**
  116283. * Gets the performance counter for total vertices
  116284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116285. */
  116286. get totalVerticesPerfCounter(): PerfCounter;
  116287. /**
  116288. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  116289. * @returns the total number of active indices rendered per frame
  116290. */
  116291. getActiveIndices(): number;
  116292. /**
  116293. * Gets the performance counter for active indices
  116294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116295. */
  116296. get totalActiveIndicesPerfCounter(): PerfCounter;
  116297. /**
  116298. * Gets the total number of active particles rendered per frame
  116299. * @returns the total number of active particles rendered per frame
  116300. */
  116301. getActiveParticles(): number;
  116302. /**
  116303. * Gets the performance counter for active particles
  116304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116305. */
  116306. get activeParticlesPerfCounter(): PerfCounter;
  116307. /**
  116308. * Gets the total number of active bones rendered per frame
  116309. * @returns the total number of active bones rendered per frame
  116310. */
  116311. getActiveBones(): number;
  116312. /**
  116313. * Gets the performance counter for active bones
  116314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116315. */
  116316. get activeBonesPerfCounter(): PerfCounter;
  116317. /**
  116318. * Gets the array of active meshes
  116319. * @returns an array of AbstractMesh
  116320. */
  116321. getActiveMeshes(): SmartArray<AbstractMesh>;
  116322. /**
  116323. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  116324. * @returns a number
  116325. */
  116326. getAnimationRatio(): number;
  116327. /**
  116328. * Gets an unique Id for the current render phase
  116329. * @returns a number
  116330. */
  116331. getRenderId(): number;
  116332. /**
  116333. * Gets an unique Id for the current frame
  116334. * @returns a number
  116335. */
  116336. getFrameId(): number;
  116337. /** Call this function if you want to manually increment the render Id*/
  116338. incrementRenderId(): void;
  116339. private _createUbo;
  116340. /**
  116341. * Use this method to simulate a pointer move on a mesh
  116342. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116343. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116344. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116345. * @returns the current scene
  116346. */
  116347. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116348. /**
  116349. * Use this method to simulate a pointer down on a mesh
  116350. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116351. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116352. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116353. * @returns the current scene
  116354. */
  116355. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116356. /**
  116357. * Use this method to simulate a pointer up on a mesh
  116358. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116359. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116360. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116361. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116362. * @returns the current scene
  116363. */
  116364. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  116365. /**
  116366. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116367. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116368. * @returns true if the pointer was captured
  116369. */
  116370. isPointerCaptured(pointerId?: number): boolean;
  116371. /**
  116372. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116373. * @param attachUp defines if you want to attach events to pointerup
  116374. * @param attachDown defines if you want to attach events to pointerdown
  116375. * @param attachMove defines if you want to attach events to pointermove
  116376. */
  116377. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  116378. /** Detaches all event handlers*/
  116379. detachControl(): void;
  116380. /**
  116381. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  116382. * Delay loaded resources are not taking in account
  116383. * @return true if all required resources are ready
  116384. */
  116385. isReady(): boolean;
  116386. /** Resets all cached information relative to material (including effect and visibility) */
  116387. resetCachedMaterial(): void;
  116388. /**
  116389. * Registers a function to be called before every frame render
  116390. * @param func defines the function to register
  116391. */
  116392. registerBeforeRender(func: () => void): void;
  116393. /**
  116394. * Unregisters a function called before every frame render
  116395. * @param func defines the function to unregister
  116396. */
  116397. unregisterBeforeRender(func: () => void): void;
  116398. /**
  116399. * Registers a function to be called after every frame render
  116400. * @param func defines the function to register
  116401. */
  116402. registerAfterRender(func: () => void): void;
  116403. /**
  116404. * Unregisters a function called after every frame render
  116405. * @param func defines the function to unregister
  116406. */
  116407. unregisterAfterRender(func: () => void): void;
  116408. private _executeOnceBeforeRender;
  116409. /**
  116410. * The provided function will run before render once and will be disposed afterwards.
  116411. * A timeout delay can be provided so that the function will be executed in N ms.
  116412. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  116413. * @param func The function to be executed.
  116414. * @param timeout optional delay in ms
  116415. */
  116416. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  116417. /** @hidden */
  116418. _addPendingData(data: any): void;
  116419. /** @hidden */
  116420. _removePendingData(data: any): void;
  116421. /**
  116422. * Returns the number of items waiting to be loaded
  116423. * @returns the number of items waiting to be loaded
  116424. */
  116425. getWaitingItemsCount(): number;
  116426. /**
  116427. * Returns a boolean indicating if the scene is still loading data
  116428. */
  116429. get isLoading(): boolean;
  116430. /**
  116431. * Registers a function to be executed when the scene is ready
  116432. * @param {Function} func - the function to be executed
  116433. */
  116434. executeWhenReady(func: () => void): void;
  116435. /**
  116436. * Returns a promise that resolves when the scene is ready
  116437. * @returns A promise that resolves when the scene is ready
  116438. */
  116439. whenReadyAsync(): Promise<void>;
  116440. /** @hidden */
  116441. _checkIsReady(): void;
  116442. /**
  116443. * Gets all animatable attached to the scene
  116444. */
  116445. get animatables(): Animatable[];
  116446. /**
  116447. * Resets the last animation time frame.
  116448. * Useful to override when animations start running when loading a scene for the first time.
  116449. */
  116450. resetLastAnimationTimeFrame(): void;
  116451. /**
  116452. * Gets the current view matrix
  116453. * @returns a Matrix
  116454. */
  116455. getViewMatrix(): Matrix;
  116456. /**
  116457. * Gets the current projection matrix
  116458. * @returns a Matrix
  116459. */
  116460. getProjectionMatrix(): Matrix;
  116461. /**
  116462. * Gets the current transform matrix
  116463. * @returns a Matrix made of View * Projection
  116464. */
  116465. getTransformMatrix(): Matrix;
  116466. /**
  116467. * Sets the current transform matrix
  116468. * @param viewL defines the View matrix to use
  116469. * @param projectionL defines the Projection matrix to use
  116470. * @param viewR defines the right View matrix to use (if provided)
  116471. * @param projectionR defines the right Projection matrix to use (if provided)
  116472. */
  116473. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  116474. /**
  116475. * Gets the uniform buffer used to store scene data
  116476. * @returns a UniformBuffer
  116477. */
  116478. getSceneUniformBuffer(): UniformBuffer;
  116479. /**
  116480. * Gets an unique (relatively to the current scene) Id
  116481. * @returns an unique number for the scene
  116482. */
  116483. getUniqueId(): number;
  116484. /**
  116485. * Add a mesh to the list of scene's meshes
  116486. * @param newMesh defines the mesh to add
  116487. * @param recursive if all child meshes should also be added to the scene
  116488. */
  116489. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  116490. /**
  116491. * Remove a mesh for the list of scene's meshes
  116492. * @param toRemove defines the mesh to remove
  116493. * @param recursive if all child meshes should also be removed from the scene
  116494. * @returns the index where the mesh was in the mesh list
  116495. */
  116496. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  116497. /**
  116498. * Add a transform node to the list of scene's transform nodes
  116499. * @param newTransformNode defines the transform node to add
  116500. */
  116501. addTransformNode(newTransformNode: TransformNode): void;
  116502. /**
  116503. * Remove a transform node for the list of scene's transform nodes
  116504. * @param toRemove defines the transform node to remove
  116505. * @returns the index where the transform node was in the transform node list
  116506. */
  116507. removeTransformNode(toRemove: TransformNode): number;
  116508. /**
  116509. * Remove a skeleton for the list of scene's skeletons
  116510. * @param toRemove defines the skeleton to remove
  116511. * @returns the index where the skeleton was in the skeleton list
  116512. */
  116513. removeSkeleton(toRemove: Skeleton): number;
  116514. /**
  116515. * Remove a morph target for the list of scene's morph targets
  116516. * @param toRemove defines the morph target to remove
  116517. * @returns the index where the morph target was in the morph target list
  116518. */
  116519. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  116520. /**
  116521. * Remove a light for the list of scene's lights
  116522. * @param toRemove defines the light to remove
  116523. * @returns the index where the light was in the light list
  116524. */
  116525. removeLight(toRemove: Light): number;
  116526. /**
  116527. * Remove a camera for the list of scene's cameras
  116528. * @param toRemove defines the camera to remove
  116529. * @returns the index where the camera was in the camera list
  116530. */
  116531. removeCamera(toRemove: Camera): number;
  116532. /**
  116533. * Remove a particle system for the list of scene's particle systems
  116534. * @param toRemove defines the particle system to remove
  116535. * @returns the index where the particle system was in the particle system list
  116536. */
  116537. removeParticleSystem(toRemove: IParticleSystem): number;
  116538. /**
  116539. * Remove a animation for the list of scene's animations
  116540. * @param toRemove defines the animation to remove
  116541. * @returns the index where the animation was in the animation list
  116542. */
  116543. removeAnimation(toRemove: Animation): number;
  116544. /**
  116545. * Will stop the animation of the given target
  116546. * @param target - the target
  116547. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  116548. * @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)
  116549. */
  116550. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  116551. /**
  116552. * Removes the given animation group from this scene.
  116553. * @param toRemove The animation group to remove
  116554. * @returns The index of the removed animation group
  116555. */
  116556. removeAnimationGroup(toRemove: AnimationGroup): number;
  116557. /**
  116558. * Removes the given multi-material from this scene.
  116559. * @param toRemove The multi-material to remove
  116560. * @returns The index of the removed multi-material
  116561. */
  116562. removeMultiMaterial(toRemove: MultiMaterial): number;
  116563. /**
  116564. * Removes the given material from this scene.
  116565. * @param toRemove The material to remove
  116566. * @returns The index of the removed material
  116567. */
  116568. removeMaterial(toRemove: Material): number;
  116569. /**
  116570. * Removes the given action manager from this scene.
  116571. * @param toRemove The action manager to remove
  116572. * @returns The index of the removed action manager
  116573. */
  116574. removeActionManager(toRemove: AbstractActionManager): number;
  116575. /**
  116576. * Removes the given texture from this scene.
  116577. * @param toRemove The texture to remove
  116578. * @returns The index of the removed texture
  116579. */
  116580. removeTexture(toRemove: BaseTexture): number;
  116581. /**
  116582. * Adds the given light to this scene
  116583. * @param newLight The light to add
  116584. */
  116585. addLight(newLight: Light): void;
  116586. /**
  116587. * Sorts the list list based on light priorities
  116588. */
  116589. sortLightsByPriority(): void;
  116590. /**
  116591. * Adds the given camera to this scene
  116592. * @param newCamera The camera to add
  116593. */
  116594. addCamera(newCamera: Camera): void;
  116595. /**
  116596. * Adds the given skeleton to this scene
  116597. * @param newSkeleton The skeleton to add
  116598. */
  116599. addSkeleton(newSkeleton: Skeleton): void;
  116600. /**
  116601. * Adds the given particle system to this scene
  116602. * @param newParticleSystem The particle system to add
  116603. */
  116604. addParticleSystem(newParticleSystem: IParticleSystem): void;
  116605. /**
  116606. * Adds the given animation to this scene
  116607. * @param newAnimation The animation to add
  116608. */
  116609. addAnimation(newAnimation: Animation): void;
  116610. /**
  116611. * Adds the given animation group to this scene.
  116612. * @param newAnimationGroup The animation group to add
  116613. */
  116614. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  116615. /**
  116616. * Adds the given multi-material to this scene
  116617. * @param newMultiMaterial The multi-material to add
  116618. */
  116619. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  116620. /**
  116621. * Adds the given material to this scene
  116622. * @param newMaterial The material to add
  116623. */
  116624. addMaterial(newMaterial: Material): void;
  116625. /**
  116626. * Adds the given morph target to this scene
  116627. * @param newMorphTargetManager The morph target to add
  116628. */
  116629. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  116630. /**
  116631. * Adds the given geometry to this scene
  116632. * @param newGeometry The geometry to add
  116633. */
  116634. addGeometry(newGeometry: Geometry): void;
  116635. /**
  116636. * Adds the given action manager to this scene
  116637. * @param newActionManager The action manager to add
  116638. */
  116639. addActionManager(newActionManager: AbstractActionManager): void;
  116640. /**
  116641. * Adds the given texture to this scene.
  116642. * @param newTexture The texture to add
  116643. */
  116644. addTexture(newTexture: BaseTexture): void;
  116645. /**
  116646. * Switch active camera
  116647. * @param newCamera defines the new active camera
  116648. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  116649. */
  116650. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  116651. /**
  116652. * sets the active camera of the scene using its ID
  116653. * @param id defines the camera's ID
  116654. * @return the new active camera or null if none found.
  116655. */
  116656. setActiveCameraByID(id: string): Nullable<Camera>;
  116657. /**
  116658. * sets the active camera of the scene using its name
  116659. * @param name defines the camera's name
  116660. * @returns the new active camera or null if none found.
  116661. */
  116662. setActiveCameraByName(name: string): Nullable<Camera>;
  116663. /**
  116664. * get an animation group using its name
  116665. * @param name defines the material's name
  116666. * @return the animation group or null if none found.
  116667. */
  116668. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  116669. /**
  116670. * Get a material using its unique id
  116671. * @param uniqueId defines the material's unique id
  116672. * @return the material or null if none found.
  116673. */
  116674. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  116675. /**
  116676. * get a material using its id
  116677. * @param id defines the material's ID
  116678. * @return the material or null if none found.
  116679. */
  116680. getMaterialByID(id: string): Nullable<Material>;
  116681. /**
  116682. * Gets a the last added material using a given id
  116683. * @param id defines the material's ID
  116684. * @return the last material with the given id or null if none found.
  116685. */
  116686. getLastMaterialByID(id: string): Nullable<Material>;
  116687. /**
  116688. * Gets a material using its name
  116689. * @param name defines the material's name
  116690. * @return the material or null if none found.
  116691. */
  116692. getMaterialByName(name: string): Nullable<Material>;
  116693. /**
  116694. * Get a texture using its unique id
  116695. * @param uniqueId defines the texture's unique id
  116696. * @return the texture or null if none found.
  116697. */
  116698. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  116699. /**
  116700. * Gets a camera using its id
  116701. * @param id defines the id to look for
  116702. * @returns the camera or null if not found
  116703. */
  116704. getCameraByID(id: string): Nullable<Camera>;
  116705. /**
  116706. * Gets a camera using its unique id
  116707. * @param uniqueId defines the unique id to look for
  116708. * @returns the camera or null if not found
  116709. */
  116710. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  116711. /**
  116712. * Gets a camera using its name
  116713. * @param name defines the camera's name
  116714. * @return the camera or null if none found.
  116715. */
  116716. getCameraByName(name: string): Nullable<Camera>;
  116717. /**
  116718. * Gets a bone using its id
  116719. * @param id defines the bone's id
  116720. * @return the bone or null if not found
  116721. */
  116722. getBoneByID(id: string): Nullable<Bone>;
  116723. /**
  116724. * Gets a bone using its id
  116725. * @param name defines the bone's name
  116726. * @return the bone or null if not found
  116727. */
  116728. getBoneByName(name: string): Nullable<Bone>;
  116729. /**
  116730. * Gets a light node using its name
  116731. * @param name defines the the light's name
  116732. * @return the light or null if none found.
  116733. */
  116734. getLightByName(name: string): Nullable<Light>;
  116735. /**
  116736. * Gets a light node using its id
  116737. * @param id defines the light's id
  116738. * @return the light or null if none found.
  116739. */
  116740. getLightByID(id: string): Nullable<Light>;
  116741. /**
  116742. * Gets a light node using its scene-generated unique ID
  116743. * @param uniqueId defines the light's unique id
  116744. * @return the light or null if none found.
  116745. */
  116746. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  116747. /**
  116748. * Gets a particle system by id
  116749. * @param id defines the particle system id
  116750. * @return the corresponding system or null if none found
  116751. */
  116752. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  116753. /**
  116754. * Gets a geometry using its ID
  116755. * @param id defines the geometry's id
  116756. * @return the geometry or null if none found.
  116757. */
  116758. getGeometryByID(id: string): Nullable<Geometry>;
  116759. private _getGeometryByUniqueID;
  116760. /**
  116761. * Add a new geometry to this scene
  116762. * @param geometry defines the geometry to be added to the scene.
  116763. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  116764. * @return a boolean defining if the geometry was added or not
  116765. */
  116766. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  116767. /**
  116768. * Removes an existing geometry
  116769. * @param geometry defines the geometry to be removed from the scene
  116770. * @return a boolean defining if the geometry was removed or not
  116771. */
  116772. removeGeometry(geometry: Geometry): boolean;
  116773. /**
  116774. * Gets the list of geometries attached to the scene
  116775. * @returns an array of Geometry
  116776. */
  116777. getGeometries(): Geometry[];
  116778. /**
  116779. * Gets the first added mesh found of a given ID
  116780. * @param id defines the id to search for
  116781. * @return the mesh found or null if not found at all
  116782. */
  116783. getMeshByID(id: string): Nullable<AbstractMesh>;
  116784. /**
  116785. * Gets a list of meshes using their id
  116786. * @param id defines the id to search for
  116787. * @returns a list of meshes
  116788. */
  116789. getMeshesByID(id: string): Array<AbstractMesh>;
  116790. /**
  116791. * Gets the first added transform node found of a given ID
  116792. * @param id defines the id to search for
  116793. * @return the found transform node or null if not found at all.
  116794. */
  116795. getTransformNodeByID(id: string): Nullable<TransformNode>;
  116796. /**
  116797. * Gets a transform node with its auto-generated unique id
  116798. * @param uniqueId efines the unique id to search for
  116799. * @return the found transform node or null if not found at all.
  116800. */
  116801. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  116802. /**
  116803. * Gets a list of transform nodes using their id
  116804. * @param id defines the id to search for
  116805. * @returns a list of transform nodes
  116806. */
  116807. getTransformNodesByID(id: string): Array<TransformNode>;
  116808. /**
  116809. * Gets a mesh with its auto-generated unique id
  116810. * @param uniqueId defines the unique id to search for
  116811. * @return the found mesh or null if not found at all.
  116812. */
  116813. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  116814. /**
  116815. * Gets a the last added mesh using a given id
  116816. * @param id defines the id to search for
  116817. * @return the found mesh or null if not found at all.
  116818. */
  116819. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  116820. /**
  116821. * Gets a the last added node (Mesh, Camera, Light) using a given id
  116822. * @param id defines the id to search for
  116823. * @return the found node or null if not found at all
  116824. */
  116825. getLastEntryByID(id: string): Nullable<Node>;
  116826. /**
  116827. * Gets a node (Mesh, Camera, Light) using a given id
  116828. * @param id defines the id to search for
  116829. * @return the found node or null if not found at all
  116830. */
  116831. getNodeByID(id: string): Nullable<Node>;
  116832. /**
  116833. * Gets a node (Mesh, Camera, Light) using a given name
  116834. * @param name defines the name to search for
  116835. * @return the found node or null if not found at all.
  116836. */
  116837. getNodeByName(name: string): Nullable<Node>;
  116838. /**
  116839. * Gets a mesh using a given name
  116840. * @param name defines the name to search for
  116841. * @return the found mesh or null if not found at all.
  116842. */
  116843. getMeshByName(name: string): Nullable<AbstractMesh>;
  116844. /**
  116845. * Gets a transform node using a given name
  116846. * @param name defines the name to search for
  116847. * @return the found transform node or null if not found at all.
  116848. */
  116849. getTransformNodeByName(name: string): Nullable<TransformNode>;
  116850. /**
  116851. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  116852. * @param id defines the id to search for
  116853. * @return the found skeleton or null if not found at all.
  116854. */
  116855. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  116856. /**
  116857. * Gets a skeleton using a given auto generated unique id
  116858. * @param uniqueId defines the unique id to search for
  116859. * @return the found skeleton or null if not found at all.
  116860. */
  116861. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  116862. /**
  116863. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  116864. * @param id defines the id to search for
  116865. * @return the found skeleton or null if not found at all.
  116866. */
  116867. getSkeletonById(id: string): Nullable<Skeleton>;
  116868. /**
  116869. * Gets a skeleton using a given name
  116870. * @param name defines the name to search for
  116871. * @return the found skeleton or null if not found at all.
  116872. */
  116873. getSkeletonByName(name: string): Nullable<Skeleton>;
  116874. /**
  116875. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  116876. * @param id defines the id to search for
  116877. * @return the found morph target manager or null if not found at all.
  116878. */
  116879. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  116880. /**
  116881. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  116882. * @param id defines the id to search for
  116883. * @return the found morph target or null if not found at all.
  116884. */
  116885. getMorphTargetById(id: string): Nullable<MorphTarget>;
  116886. /**
  116887. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  116888. * @param name defines the name to search for
  116889. * @return the found morph target or null if not found at all.
  116890. */
  116891. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  116892. /**
  116893. * Gets a boolean indicating if the given mesh is active
  116894. * @param mesh defines the mesh to look for
  116895. * @returns true if the mesh is in the active list
  116896. */
  116897. isActiveMesh(mesh: AbstractMesh): boolean;
  116898. /**
  116899. * Return a unique id as a string which can serve as an identifier for the scene
  116900. */
  116901. get uid(): string;
  116902. /**
  116903. * Add an externaly attached data from its key.
  116904. * This method call will fail and return false, if such key already exists.
  116905. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  116906. * @param key the unique key that identifies the data
  116907. * @param data the data object to associate to the key for this Engine instance
  116908. * @return true if no such key were already present and the data was added successfully, false otherwise
  116909. */
  116910. addExternalData<T>(key: string, data: T): boolean;
  116911. /**
  116912. * Get an externaly attached data from its key
  116913. * @param key the unique key that identifies the data
  116914. * @return the associated data, if present (can be null), or undefined if not present
  116915. */
  116916. getExternalData<T>(key: string): Nullable<T>;
  116917. /**
  116918. * Get an externaly attached data from its key, create it using a factory if it's not already present
  116919. * @param key the unique key that identifies the data
  116920. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  116921. * @return the associated data, can be null if the factory returned null.
  116922. */
  116923. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  116924. /**
  116925. * Remove an externaly attached data from the Engine instance
  116926. * @param key the unique key that identifies the data
  116927. * @return true if the data was successfully removed, false if it doesn't exist
  116928. */
  116929. removeExternalData(key: string): boolean;
  116930. private _evaluateSubMesh;
  116931. /**
  116932. * Clear the processed materials smart array preventing retention point in material dispose.
  116933. */
  116934. freeProcessedMaterials(): void;
  116935. private _preventFreeActiveMeshesAndRenderingGroups;
  116936. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  116937. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  116938. * when disposing several meshes in a row or a hierarchy of meshes.
  116939. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  116940. */
  116941. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  116942. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  116943. /**
  116944. * Clear the active meshes smart array preventing retention point in mesh dispose.
  116945. */
  116946. freeActiveMeshes(): void;
  116947. /**
  116948. * Clear the info related to rendering groups preventing retention points during dispose.
  116949. */
  116950. freeRenderingGroups(): void;
  116951. /** @hidden */
  116952. _isInIntermediateRendering(): boolean;
  116953. /**
  116954. * Lambda returning the list of potentially active meshes.
  116955. */
  116956. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  116957. /**
  116958. * Lambda returning the list of potentially active sub meshes.
  116959. */
  116960. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  116961. /**
  116962. * Lambda returning the list of potentially intersecting sub meshes.
  116963. */
  116964. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  116965. /**
  116966. * Lambda returning the list of potentially colliding sub meshes.
  116967. */
  116968. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  116969. private _activeMeshesFrozen;
  116970. private _skipEvaluateActiveMeshesCompletely;
  116971. /**
  116972. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  116973. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  116974. * @returns the current scene
  116975. */
  116976. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  116977. /**
  116978. * Use this function to restart evaluating active meshes on every frame
  116979. * @returns the current scene
  116980. */
  116981. unfreezeActiveMeshes(): Scene;
  116982. private _evaluateActiveMeshes;
  116983. private _activeMesh;
  116984. /**
  116985. * Update the transform matrix to update from the current active camera
  116986. * @param force defines a boolean used to force the update even if cache is up to date
  116987. */
  116988. updateTransformMatrix(force?: boolean): void;
  116989. private _bindFrameBuffer;
  116990. /** @hidden */
  116991. _allowPostProcessClearColor: boolean;
  116992. /** @hidden */
  116993. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  116994. private _processSubCameras;
  116995. private _checkIntersections;
  116996. /** @hidden */
  116997. _advancePhysicsEngineStep(step: number): void;
  116998. /**
  116999. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117000. */
  117001. getDeterministicFrameTime: () => number;
  117002. /** @hidden */
  117003. _animate(): void;
  117004. /** Execute all animations (for a frame) */
  117005. animate(): void;
  117006. /**
  117007. * Render the scene
  117008. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117009. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117010. */
  117011. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117012. /**
  117013. * Freeze all materials
  117014. * A frozen material will not be updatable but should be faster to render
  117015. */
  117016. freezeMaterials(): void;
  117017. /**
  117018. * Unfreeze all materials
  117019. * A frozen material will not be updatable but should be faster to render
  117020. */
  117021. unfreezeMaterials(): void;
  117022. /**
  117023. * Releases all held ressources
  117024. */
  117025. dispose(): void;
  117026. /**
  117027. * Gets if the scene is already disposed
  117028. */
  117029. get isDisposed(): boolean;
  117030. /**
  117031. * Call this function to reduce memory footprint of the scene.
  117032. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117033. */
  117034. clearCachedVertexData(): void;
  117035. /**
  117036. * This function will remove the local cached buffer data from texture.
  117037. * It will save memory but will prevent the texture from being rebuilt
  117038. */
  117039. cleanCachedTextureBuffer(): void;
  117040. /**
  117041. * Get the world extend vectors with an optional filter
  117042. *
  117043. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117044. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117045. */
  117046. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117047. min: Vector3;
  117048. max: Vector3;
  117049. };
  117050. /**
  117051. * Creates a ray that can be used to pick in the scene
  117052. * @param x defines the x coordinate of the origin (on-screen)
  117053. * @param y defines the y coordinate of the origin (on-screen)
  117054. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117055. * @param camera defines the camera to use for the picking
  117056. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117057. * @returns a Ray
  117058. */
  117059. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117060. /**
  117061. * Creates a ray that can be used to pick in the scene
  117062. * @param x defines the x coordinate of the origin (on-screen)
  117063. * @param y defines the y coordinate of the origin (on-screen)
  117064. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117065. * @param result defines the ray where to store the picking ray
  117066. * @param camera defines the camera to use for the picking
  117067. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117068. * @returns the current scene
  117069. */
  117070. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117071. /**
  117072. * Creates a ray that can be used to pick in the scene
  117073. * @param x defines the x coordinate of the origin (on-screen)
  117074. * @param y defines the y coordinate of the origin (on-screen)
  117075. * @param camera defines the camera to use for the picking
  117076. * @returns a Ray
  117077. */
  117078. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117079. /**
  117080. * Creates a ray that can be used to pick in the scene
  117081. * @param x defines the x coordinate of the origin (on-screen)
  117082. * @param y defines the y coordinate of the origin (on-screen)
  117083. * @param result defines the ray where to store the picking ray
  117084. * @param camera defines the camera to use for the picking
  117085. * @returns the current scene
  117086. */
  117087. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117088. /** Launch a ray to try to pick a mesh in the scene
  117089. * @param x position on screen
  117090. * @param y position on screen
  117091. * @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
  117092. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117093. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117095. * @returns a PickingInfo
  117096. */
  117097. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117098. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117099. * @param x position on screen
  117100. * @param y position on screen
  117101. * @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
  117102. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117103. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117104. * @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)
  117105. */
  117106. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117107. /** Use the given ray to pick a mesh in the scene
  117108. * @param ray The ray to use to pick meshes
  117109. * @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
  117110. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117111. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117112. * @returns a PickingInfo
  117113. */
  117114. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117115. /**
  117116. * Launch a ray to try to pick a mesh in the scene
  117117. * @param x X position on screen
  117118. * @param y Y position on screen
  117119. * @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
  117120. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117121. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117122. * @returns an array of PickingInfo
  117123. */
  117124. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117125. /**
  117126. * Launch a ray to try to pick a mesh in the scene
  117127. * @param ray Ray to use
  117128. * @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
  117129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117130. * @returns an array of PickingInfo
  117131. */
  117132. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117133. /**
  117134. * Force the value of meshUnderPointer
  117135. * @param mesh defines the mesh to use
  117136. */
  117137. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117138. /**
  117139. * Gets the mesh under the pointer
  117140. * @returns a Mesh or null if no mesh is under the pointer
  117141. */
  117142. getPointerOverMesh(): Nullable<AbstractMesh>;
  117143. /** @hidden */
  117144. _rebuildGeometries(): void;
  117145. /** @hidden */
  117146. _rebuildTextures(): void;
  117147. private _getByTags;
  117148. /**
  117149. * Get a list of meshes by tags
  117150. * @param tagsQuery defines the tags query to use
  117151. * @param forEach defines a predicate used to filter results
  117152. * @returns an array of Mesh
  117153. */
  117154. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117155. /**
  117156. * Get a list of cameras by tags
  117157. * @param tagsQuery defines the tags query to use
  117158. * @param forEach defines a predicate used to filter results
  117159. * @returns an array of Camera
  117160. */
  117161. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117162. /**
  117163. * Get a list of lights by tags
  117164. * @param tagsQuery defines the tags query to use
  117165. * @param forEach defines a predicate used to filter results
  117166. * @returns an array of Light
  117167. */
  117168. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117169. /**
  117170. * Get a list of materials by tags
  117171. * @param tagsQuery defines the tags query to use
  117172. * @param forEach defines a predicate used to filter results
  117173. * @returns an array of Material
  117174. */
  117175. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117176. /**
  117177. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117178. * This allowed control for front to back rendering or reversly depending of the special needs.
  117179. *
  117180. * @param renderingGroupId The rendering group id corresponding to its index
  117181. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117182. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117183. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117184. */
  117185. 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;
  117186. /**
  117187. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117188. *
  117189. * @param renderingGroupId The rendering group id corresponding to its index
  117190. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117191. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117192. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117193. */
  117194. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117195. /**
  117196. * Gets the current auto clear configuration for one rendering group of the rendering
  117197. * manager.
  117198. * @param index the rendering group index to get the information for
  117199. * @returns The auto clear setup for the requested rendering group
  117200. */
  117201. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117202. private _blockMaterialDirtyMechanism;
  117203. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117204. get blockMaterialDirtyMechanism(): boolean;
  117205. set blockMaterialDirtyMechanism(value: boolean);
  117206. /**
  117207. * Will flag all materials as dirty to trigger new shader compilation
  117208. * @param flag defines the flag used to specify which material part must be marked as dirty
  117209. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117210. */
  117211. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117212. /** @hidden */
  117213. _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;
  117214. /** @hidden */
  117215. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117216. /** @hidden */
  117217. _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;
  117218. /** @hidden */
  117219. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117220. /** @hidden */
  117221. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117222. /** @hidden */
  117223. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117224. }
  117225. }
  117226. declare module BABYLON {
  117227. /**
  117228. * Set of assets to keep when moving a scene into an asset container.
  117229. */
  117230. export class KeepAssets extends AbstractScene {
  117231. }
  117232. /**
  117233. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  117234. */
  117235. export class InstantiatedEntries {
  117236. /**
  117237. * List of new root nodes (eg. nodes with no parent)
  117238. */
  117239. rootNodes: TransformNode[];
  117240. /**
  117241. * List of new skeletons
  117242. */
  117243. skeletons: Skeleton[];
  117244. /**
  117245. * List of new animation groups
  117246. */
  117247. animationGroups: AnimationGroup[];
  117248. }
  117249. /**
  117250. * Container with a set of assets that can be added or removed from a scene.
  117251. */
  117252. export class AssetContainer extends AbstractScene {
  117253. private _wasAddedToScene;
  117254. /**
  117255. * The scene the AssetContainer belongs to.
  117256. */
  117257. scene: Scene;
  117258. /**
  117259. * Instantiates an AssetContainer.
  117260. * @param scene The scene the AssetContainer belongs to.
  117261. */
  117262. constructor(scene: Scene);
  117263. /**
  117264. * Instantiate or clone all meshes and add the new ones to the scene.
  117265. * Skeletons and animation groups will all be cloned
  117266. * @param nameFunction defines an optional function used to get new names for clones
  117267. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  117268. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  117269. */
  117270. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  117271. /**
  117272. * Adds all the assets from the container to the scene.
  117273. */
  117274. addAllToScene(): void;
  117275. /**
  117276. * Removes all the assets in the container from the scene
  117277. */
  117278. removeAllFromScene(): void;
  117279. /**
  117280. * Disposes all the assets in the container
  117281. */
  117282. dispose(): void;
  117283. private _moveAssets;
  117284. /**
  117285. * Removes all the assets contained in the scene and adds them to the container.
  117286. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  117287. */
  117288. moveAllFromScene(keepAssets?: KeepAssets): void;
  117289. /**
  117290. * 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.
  117291. * @returns the root mesh
  117292. */
  117293. createRootMesh(): Mesh;
  117294. /**
  117295. * Merge animations (direct and animation groups) from this asset container into a scene
  117296. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117297. * @param animatables set of animatables to retarget to a node from the scene
  117298. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  117299. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  117300. */
  117301. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  117302. }
  117303. }
  117304. declare module BABYLON {
  117305. /**
  117306. * Defines how the parser contract is defined.
  117307. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  117308. */
  117309. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  117310. /**
  117311. * Defines how the individual parser contract is defined.
  117312. * These parser can parse an individual asset
  117313. */
  117314. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  117315. /**
  117316. * Base class of the scene acting as a container for the different elements composing a scene.
  117317. * This class is dynamically extended by the different components of the scene increasing
  117318. * flexibility and reducing coupling
  117319. */
  117320. export abstract class AbstractScene {
  117321. /**
  117322. * Stores the list of available parsers in the application.
  117323. */
  117324. private static _BabylonFileParsers;
  117325. /**
  117326. * Stores the list of available individual parsers in the application.
  117327. */
  117328. private static _IndividualBabylonFileParsers;
  117329. /**
  117330. * Adds a parser in the list of available ones
  117331. * @param name Defines the name of the parser
  117332. * @param parser Defines the parser to add
  117333. */
  117334. static AddParser(name: string, parser: BabylonFileParser): void;
  117335. /**
  117336. * Gets a general parser from the list of avaialble ones
  117337. * @param name Defines the name of the parser
  117338. * @returns the requested parser or null
  117339. */
  117340. static GetParser(name: string): Nullable<BabylonFileParser>;
  117341. /**
  117342. * Adds n individual parser in the list of available ones
  117343. * @param name Defines the name of the parser
  117344. * @param parser Defines the parser to add
  117345. */
  117346. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  117347. /**
  117348. * Gets an individual parser from the list of avaialble ones
  117349. * @param name Defines the name of the parser
  117350. * @returns the requested parser or null
  117351. */
  117352. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  117353. /**
  117354. * Parser json data and populate both a scene and its associated container object
  117355. * @param jsonData Defines the data to parse
  117356. * @param scene Defines the scene to parse the data for
  117357. * @param container Defines the container attached to the parsing sequence
  117358. * @param rootUrl Defines the root url of the data
  117359. */
  117360. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  117361. /**
  117362. * Gets the list of root nodes (ie. nodes with no parent)
  117363. */
  117364. rootNodes: Node[];
  117365. /** All of the cameras added to this scene
  117366. * @see http://doc.babylonjs.com/babylon101/cameras
  117367. */
  117368. cameras: Camera[];
  117369. /**
  117370. * All of the lights added to this scene
  117371. * @see http://doc.babylonjs.com/babylon101/lights
  117372. */
  117373. lights: Light[];
  117374. /**
  117375. * All of the (abstract) meshes added to this scene
  117376. */
  117377. meshes: AbstractMesh[];
  117378. /**
  117379. * The list of skeletons added to the scene
  117380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117381. */
  117382. skeletons: Skeleton[];
  117383. /**
  117384. * All of the particle systems added to this scene
  117385. * @see http://doc.babylonjs.com/babylon101/particles
  117386. */
  117387. particleSystems: IParticleSystem[];
  117388. /**
  117389. * Gets a list of Animations associated with the scene
  117390. */
  117391. animations: Animation[];
  117392. /**
  117393. * All of the animation groups added to this scene
  117394. * @see http://doc.babylonjs.com/how_to/group
  117395. */
  117396. animationGroups: AnimationGroup[];
  117397. /**
  117398. * All of the multi-materials added to this scene
  117399. * @see http://doc.babylonjs.com/how_to/multi_materials
  117400. */
  117401. multiMaterials: MultiMaterial[];
  117402. /**
  117403. * All of the materials added to this scene
  117404. * In the context of a Scene, it is not supposed to be modified manually.
  117405. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  117406. * Note also that the order of the Material within the array is not significant and might change.
  117407. * @see http://doc.babylonjs.com/babylon101/materials
  117408. */
  117409. materials: Material[];
  117410. /**
  117411. * The list of morph target managers added to the scene
  117412. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  117413. */
  117414. morphTargetManagers: MorphTargetManager[];
  117415. /**
  117416. * The list of geometries used in the scene.
  117417. */
  117418. geometries: Geometry[];
  117419. /**
  117420. * All of the tranform nodes added to this scene
  117421. * In the context of a Scene, it is not supposed to be modified manually.
  117422. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  117423. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  117424. * @see http://doc.babylonjs.com/how_to/transformnode
  117425. */
  117426. transformNodes: TransformNode[];
  117427. /**
  117428. * ActionManagers available on the scene.
  117429. */
  117430. actionManagers: AbstractActionManager[];
  117431. /**
  117432. * Textures to keep.
  117433. */
  117434. textures: BaseTexture[];
  117435. /**
  117436. * Environment texture for the scene
  117437. */
  117438. environmentTexture: Nullable<BaseTexture>;
  117439. /**
  117440. * @returns all meshes, lights, cameras, transformNodes and bones
  117441. */
  117442. getNodes(): Array<Node>;
  117443. }
  117444. }
  117445. declare module BABYLON {
  117446. /**
  117447. * Interface used to define options for Sound class
  117448. */
  117449. export interface ISoundOptions {
  117450. /**
  117451. * Does the sound autoplay once loaded.
  117452. */
  117453. autoplay?: boolean;
  117454. /**
  117455. * Does the sound loop after it finishes playing once.
  117456. */
  117457. loop?: boolean;
  117458. /**
  117459. * Sound's volume
  117460. */
  117461. volume?: number;
  117462. /**
  117463. * Is it a spatial sound?
  117464. */
  117465. spatialSound?: boolean;
  117466. /**
  117467. * Maximum distance to hear that sound
  117468. */
  117469. maxDistance?: number;
  117470. /**
  117471. * Uses user defined attenuation function
  117472. */
  117473. useCustomAttenuation?: boolean;
  117474. /**
  117475. * Define the roll off factor of spatial sounds.
  117476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117477. */
  117478. rolloffFactor?: number;
  117479. /**
  117480. * Define the reference distance the sound should be heard perfectly.
  117481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117482. */
  117483. refDistance?: number;
  117484. /**
  117485. * Define the distance attenuation model the sound will follow.
  117486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117487. */
  117488. distanceModel?: string;
  117489. /**
  117490. * Defines the playback speed (1 by default)
  117491. */
  117492. playbackRate?: number;
  117493. /**
  117494. * Defines if the sound is from a streaming source
  117495. */
  117496. streaming?: boolean;
  117497. /**
  117498. * Defines an optional length (in seconds) inside the sound file
  117499. */
  117500. length?: number;
  117501. /**
  117502. * Defines an optional offset (in seconds) inside the sound file
  117503. */
  117504. offset?: number;
  117505. /**
  117506. * If true, URLs will not be required to state the audio file codec to use.
  117507. */
  117508. skipCodecCheck?: boolean;
  117509. }
  117510. /**
  117511. * Defines a sound that can be played in the application.
  117512. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  117513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117514. */
  117515. export class Sound {
  117516. /**
  117517. * The name of the sound in the scene.
  117518. */
  117519. name: string;
  117520. /**
  117521. * Does the sound autoplay once loaded.
  117522. */
  117523. autoplay: boolean;
  117524. /**
  117525. * Does the sound loop after it finishes playing once.
  117526. */
  117527. loop: boolean;
  117528. /**
  117529. * Does the sound use a custom attenuation curve to simulate the falloff
  117530. * happening when the source gets further away from the camera.
  117531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117532. */
  117533. useCustomAttenuation: boolean;
  117534. /**
  117535. * The sound track id this sound belongs to.
  117536. */
  117537. soundTrackId: number;
  117538. /**
  117539. * Is this sound currently played.
  117540. */
  117541. isPlaying: boolean;
  117542. /**
  117543. * Is this sound currently paused.
  117544. */
  117545. isPaused: boolean;
  117546. /**
  117547. * Does this sound enables spatial sound.
  117548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117549. */
  117550. spatialSound: boolean;
  117551. /**
  117552. * Define the reference distance the sound should be heard perfectly.
  117553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117554. */
  117555. refDistance: number;
  117556. /**
  117557. * Define the roll off factor of spatial sounds.
  117558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117559. */
  117560. rolloffFactor: number;
  117561. /**
  117562. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  117563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117564. */
  117565. maxDistance: number;
  117566. /**
  117567. * Define the distance attenuation model the sound will follow.
  117568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117569. */
  117570. distanceModel: string;
  117571. /**
  117572. * @hidden
  117573. * Back Compat
  117574. **/
  117575. onended: () => any;
  117576. /**
  117577. * Gets or sets an object used to store user defined information for the sound.
  117578. */
  117579. metadata: any;
  117580. /**
  117581. * Observable event when the current playing sound finishes.
  117582. */
  117583. onEndedObservable: Observable<Sound>;
  117584. private _panningModel;
  117585. private _playbackRate;
  117586. private _streaming;
  117587. private _startTime;
  117588. private _startOffset;
  117589. private _position;
  117590. /** @hidden */
  117591. _positionInEmitterSpace: boolean;
  117592. private _localDirection;
  117593. private _volume;
  117594. private _isReadyToPlay;
  117595. private _isDirectional;
  117596. private _readyToPlayCallback;
  117597. private _audioBuffer;
  117598. private _soundSource;
  117599. private _streamingSource;
  117600. private _soundPanner;
  117601. private _soundGain;
  117602. private _inputAudioNode;
  117603. private _outputAudioNode;
  117604. private _coneInnerAngle;
  117605. private _coneOuterAngle;
  117606. private _coneOuterGain;
  117607. private _scene;
  117608. private _connectedTransformNode;
  117609. private _customAttenuationFunction;
  117610. private _registerFunc;
  117611. private _isOutputConnected;
  117612. private _htmlAudioElement;
  117613. private _urlType;
  117614. private _length?;
  117615. private _offset?;
  117616. /** @hidden */
  117617. static _SceneComponentInitialization: (scene: Scene) => void;
  117618. /**
  117619. * Create a sound and attach it to a scene
  117620. * @param name Name of your sound
  117621. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  117622. * @param scene defines the scene the sound belongs to
  117623. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  117624. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  117625. */
  117626. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  117627. /**
  117628. * Release the sound and its associated resources
  117629. */
  117630. dispose(): void;
  117631. /**
  117632. * Gets if the sounds is ready to be played or not.
  117633. * @returns true if ready, otherwise false
  117634. */
  117635. isReady(): boolean;
  117636. private _soundLoaded;
  117637. /**
  117638. * Sets the data of the sound from an audiobuffer
  117639. * @param audioBuffer The audioBuffer containing the data
  117640. */
  117641. setAudioBuffer(audioBuffer: AudioBuffer): void;
  117642. /**
  117643. * Updates the current sounds options such as maxdistance, loop...
  117644. * @param options A JSON object containing values named as the object properties
  117645. */
  117646. updateOptions(options: ISoundOptions): void;
  117647. private _createSpatialParameters;
  117648. private _updateSpatialParameters;
  117649. /**
  117650. * Switch the panning model to HRTF:
  117651. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117653. */
  117654. switchPanningModelToHRTF(): void;
  117655. /**
  117656. * Switch the panning model to Equal Power:
  117657. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117659. */
  117660. switchPanningModelToEqualPower(): void;
  117661. private _switchPanningModel;
  117662. /**
  117663. * Connect this sound to a sound track audio node like gain...
  117664. * @param soundTrackAudioNode the sound track audio node to connect to
  117665. */
  117666. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  117667. /**
  117668. * Transform this sound into a directional source
  117669. * @param coneInnerAngle Size of the inner cone in degree
  117670. * @param coneOuterAngle Size of the outer cone in degree
  117671. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  117672. */
  117673. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  117674. /**
  117675. * Gets or sets the inner angle for the directional cone.
  117676. */
  117677. get directionalConeInnerAngle(): number;
  117678. /**
  117679. * Gets or sets the inner angle for the directional cone.
  117680. */
  117681. set directionalConeInnerAngle(value: number);
  117682. /**
  117683. * Gets or sets the outer angle for the directional cone.
  117684. */
  117685. get directionalConeOuterAngle(): number;
  117686. /**
  117687. * Gets or sets the outer angle for the directional cone.
  117688. */
  117689. set directionalConeOuterAngle(value: number);
  117690. /**
  117691. * Sets the position of the emitter if spatial sound is enabled
  117692. * @param newPosition Defines the new posisiton
  117693. */
  117694. setPosition(newPosition: Vector3): void;
  117695. /**
  117696. * Sets the local direction of the emitter if spatial sound is enabled
  117697. * @param newLocalDirection Defines the new local direction
  117698. */
  117699. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  117700. private _updateDirection;
  117701. /** @hidden */
  117702. updateDistanceFromListener(): void;
  117703. /**
  117704. * Sets a new custom attenuation function for the sound.
  117705. * @param callback Defines the function used for the attenuation
  117706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117707. */
  117708. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  117709. /**
  117710. * Play the sound
  117711. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  117712. * @param offset (optional) Start the sound at a specific time in seconds
  117713. * @param length (optional) Sound duration (in seconds)
  117714. */
  117715. play(time?: number, offset?: number, length?: number): void;
  117716. private _onended;
  117717. /**
  117718. * Stop the sound
  117719. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  117720. */
  117721. stop(time?: number): void;
  117722. /**
  117723. * Put the sound in pause
  117724. */
  117725. pause(): void;
  117726. /**
  117727. * Sets a dedicated volume for this sounds
  117728. * @param newVolume Define the new volume of the sound
  117729. * @param time Define time for gradual change to new volume
  117730. */
  117731. setVolume(newVolume: number, time?: number): void;
  117732. /**
  117733. * Set the sound play back rate
  117734. * @param newPlaybackRate Define the playback rate the sound should be played at
  117735. */
  117736. setPlaybackRate(newPlaybackRate: number): void;
  117737. /**
  117738. * Gets the volume of the sound.
  117739. * @returns the volume of the sound
  117740. */
  117741. getVolume(): number;
  117742. /**
  117743. * Attach the sound to a dedicated mesh
  117744. * @param transformNode The transform node to connect the sound with
  117745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117746. */
  117747. attachToMesh(transformNode: TransformNode): void;
  117748. /**
  117749. * Detach the sound from the previously attached mesh
  117750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117751. */
  117752. detachFromMesh(): void;
  117753. private _onRegisterAfterWorldMatrixUpdate;
  117754. /**
  117755. * Clone the current sound in the scene.
  117756. * @returns the new sound clone
  117757. */
  117758. clone(): Nullable<Sound>;
  117759. /**
  117760. * Gets the current underlying audio buffer containing the data
  117761. * @returns the audio buffer
  117762. */
  117763. getAudioBuffer(): Nullable<AudioBuffer>;
  117764. /**
  117765. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  117766. * @returns the source node
  117767. */
  117768. getSoundSource(): Nullable<AudioBufferSourceNode>;
  117769. /**
  117770. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  117771. * @returns the gain node
  117772. */
  117773. getSoundGain(): Nullable<GainNode>;
  117774. /**
  117775. * Serializes the Sound in a JSON representation
  117776. * @returns the JSON representation of the sound
  117777. */
  117778. serialize(): any;
  117779. /**
  117780. * Parse a JSON representation of a sound to innstantiate in a given scene
  117781. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  117782. * @param scene Define the scene the new parsed sound should be created in
  117783. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  117784. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  117785. * @returns the newly parsed sound
  117786. */
  117787. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  117788. }
  117789. }
  117790. declare module BABYLON {
  117791. /**
  117792. * This defines an action helpful to play a defined sound on a triggered action.
  117793. */
  117794. export class PlaySoundAction extends Action {
  117795. private _sound;
  117796. /**
  117797. * Instantiate the action
  117798. * @param triggerOptions defines the trigger options
  117799. * @param sound defines the sound to play
  117800. * @param condition defines the trigger related conditions
  117801. */
  117802. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117803. /** @hidden */
  117804. _prepare(): void;
  117805. /**
  117806. * Execute the action and play the sound.
  117807. */
  117808. execute(): void;
  117809. /**
  117810. * Serializes the actions and its related information.
  117811. * @param parent defines the object to serialize in
  117812. * @returns the serialized object
  117813. */
  117814. serialize(parent: any): any;
  117815. }
  117816. /**
  117817. * This defines an action helpful to stop a defined sound on a triggered action.
  117818. */
  117819. export class StopSoundAction extends Action {
  117820. private _sound;
  117821. /**
  117822. * Instantiate the action
  117823. * @param triggerOptions defines the trigger options
  117824. * @param sound defines the sound to stop
  117825. * @param condition defines the trigger related conditions
  117826. */
  117827. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117828. /** @hidden */
  117829. _prepare(): void;
  117830. /**
  117831. * Execute the action and stop the sound.
  117832. */
  117833. execute(): void;
  117834. /**
  117835. * Serializes the actions and its related information.
  117836. * @param parent defines the object to serialize in
  117837. * @returns the serialized object
  117838. */
  117839. serialize(parent: any): any;
  117840. }
  117841. }
  117842. declare module BABYLON {
  117843. /**
  117844. * This defines an action responsible to change the value of a property
  117845. * by interpolating between its current value and the newly set one once triggered.
  117846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  117847. */
  117848. export class InterpolateValueAction extends Action {
  117849. /**
  117850. * Defines the path of the property where the value should be interpolated
  117851. */
  117852. propertyPath: string;
  117853. /**
  117854. * Defines the target value at the end of the interpolation.
  117855. */
  117856. value: any;
  117857. /**
  117858. * Defines the time it will take for the property to interpolate to the value.
  117859. */
  117860. duration: number;
  117861. /**
  117862. * Defines if the other scene animations should be stopped when the action has been triggered
  117863. */
  117864. stopOtherAnimations?: boolean;
  117865. /**
  117866. * Defines a callback raised once the interpolation animation has been done.
  117867. */
  117868. onInterpolationDone?: () => void;
  117869. /**
  117870. * Observable triggered once the interpolation animation has been done.
  117871. */
  117872. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  117873. private _target;
  117874. private _effectiveTarget;
  117875. private _property;
  117876. /**
  117877. * Instantiate the action
  117878. * @param triggerOptions defines the trigger options
  117879. * @param target defines the object containing the value to interpolate
  117880. * @param propertyPath defines the path to the property in the target object
  117881. * @param value defines the target value at the end of the interpolation
  117882. * @param duration deines the time it will take for the property to interpolate to the value.
  117883. * @param condition defines the trigger related conditions
  117884. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  117885. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  117886. */
  117887. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  117888. /** @hidden */
  117889. _prepare(): void;
  117890. /**
  117891. * Execute the action starts the value interpolation.
  117892. */
  117893. execute(): void;
  117894. /**
  117895. * Serializes the actions and its related information.
  117896. * @param parent defines the object to serialize in
  117897. * @returns the serialized object
  117898. */
  117899. serialize(parent: any): any;
  117900. }
  117901. }
  117902. declare module BABYLON {
  117903. /**
  117904. * Options allowed during the creation of a sound track.
  117905. */
  117906. export interface ISoundTrackOptions {
  117907. /**
  117908. * The volume the sound track should take during creation
  117909. */
  117910. volume?: number;
  117911. /**
  117912. * Define if the sound track is the main sound track of the scene
  117913. */
  117914. mainTrack?: boolean;
  117915. }
  117916. /**
  117917. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  117918. * It will be also used in a future release to apply effects on a specific track.
  117919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117920. */
  117921. export class SoundTrack {
  117922. /**
  117923. * The unique identifier of the sound track in the scene.
  117924. */
  117925. id: number;
  117926. /**
  117927. * The list of sounds included in the sound track.
  117928. */
  117929. soundCollection: Array<Sound>;
  117930. private _outputAudioNode;
  117931. private _scene;
  117932. private _connectedAnalyser;
  117933. private _options;
  117934. private _isInitialized;
  117935. /**
  117936. * Creates a new sound track.
  117937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117938. * @param scene Define the scene the sound track belongs to
  117939. * @param options
  117940. */
  117941. constructor(scene: Scene, options?: ISoundTrackOptions);
  117942. private _initializeSoundTrackAudioGraph;
  117943. /**
  117944. * Release the sound track and its associated resources
  117945. */
  117946. dispose(): void;
  117947. /**
  117948. * Adds a sound to this sound track
  117949. * @param sound define the cound to add
  117950. * @ignoreNaming
  117951. */
  117952. AddSound(sound: Sound): void;
  117953. /**
  117954. * Removes a sound to this sound track
  117955. * @param sound define the cound to remove
  117956. * @ignoreNaming
  117957. */
  117958. RemoveSound(sound: Sound): void;
  117959. /**
  117960. * Set a global volume for the full sound track.
  117961. * @param newVolume Define the new volume of the sound track
  117962. */
  117963. setVolume(newVolume: number): void;
  117964. /**
  117965. * Switch the panning model to HRTF:
  117966. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117968. */
  117969. switchPanningModelToHRTF(): void;
  117970. /**
  117971. * Switch the panning model to Equal Power:
  117972. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117974. */
  117975. switchPanningModelToEqualPower(): void;
  117976. /**
  117977. * Connect the sound track to an audio analyser allowing some amazing
  117978. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117980. * @param analyser The analyser to connect to the engine
  117981. */
  117982. connectToAnalyser(analyser: Analyser): void;
  117983. }
  117984. }
  117985. declare module BABYLON {
  117986. interface AbstractScene {
  117987. /**
  117988. * The list of sounds used in the scene.
  117989. */
  117990. sounds: Nullable<Array<Sound>>;
  117991. }
  117992. interface Scene {
  117993. /**
  117994. * @hidden
  117995. * Backing field
  117996. */
  117997. _mainSoundTrack: SoundTrack;
  117998. /**
  117999. * The main sound track played by the scene.
  118000. * It cotains your primary collection of sounds.
  118001. */
  118002. mainSoundTrack: SoundTrack;
  118003. /**
  118004. * The list of sound tracks added to the scene
  118005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118006. */
  118007. soundTracks: Nullable<Array<SoundTrack>>;
  118008. /**
  118009. * Gets a sound using a given name
  118010. * @param name defines the name to search for
  118011. * @return the found sound or null if not found at all.
  118012. */
  118013. getSoundByName(name: string): Nullable<Sound>;
  118014. /**
  118015. * Gets or sets if audio support is enabled
  118016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118017. */
  118018. audioEnabled: boolean;
  118019. /**
  118020. * Gets or sets if audio will be output to headphones
  118021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118022. */
  118023. headphone: boolean;
  118024. /**
  118025. * Gets or sets custom audio listener position provider
  118026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118027. */
  118028. audioListenerPositionProvider: Nullable<() => Vector3>;
  118029. /**
  118030. * Gets or sets a refresh rate when using 3D audio positioning
  118031. */
  118032. audioPositioningRefreshRate: number;
  118033. }
  118034. /**
  118035. * Defines the sound scene component responsible to manage any sounds
  118036. * in a given scene.
  118037. */
  118038. export class AudioSceneComponent implements ISceneSerializableComponent {
  118039. /**
  118040. * The component name helpfull to identify the component in the list of scene components.
  118041. */
  118042. readonly name: string;
  118043. /**
  118044. * The scene the component belongs to.
  118045. */
  118046. scene: Scene;
  118047. private _audioEnabled;
  118048. /**
  118049. * Gets whether audio is enabled or not.
  118050. * Please use related enable/disable method to switch state.
  118051. */
  118052. get audioEnabled(): boolean;
  118053. private _headphone;
  118054. /**
  118055. * Gets whether audio is outputing to headphone or not.
  118056. * Please use the according Switch methods to change output.
  118057. */
  118058. get headphone(): boolean;
  118059. /**
  118060. * Gets or sets a refresh rate when using 3D audio positioning
  118061. */
  118062. audioPositioningRefreshRate: number;
  118063. private _audioListenerPositionProvider;
  118064. /**
  118065. * Gets the current audio listener position provider
  118066. */
  118067. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118068. /**
  118069. * Sets a custom listener position for all sounds in the scene
  118070. * By default, this is the position of the first active camera
  118071. */
  118072. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118073. /**
  118074. * Creates a new instance of the component for the given scene
  118075. * @param scene Defines the scene to register the component in
  118076. */
  118077. constructor(scene: Scene);
  118078. /**
  118079. * Registers the component in a given scene
  118080. */
  118081. register(): void;
  118082. /**
  118083. * Rebuilds the elements related to this component in case of
  118084. * context lost for instance.
  118085. */
  118086. rebuild(): void;
  118087. /**
  118088. * Serializes the component data to the specified json object
  118089. * @param serializationObject The object to serialize to
  118090. */
  118091. serialize(serializationObject: any): void;
  118092. /**
  118093. * Adds all the elements from the container to the scene
  118094. * @param container the container holding the elements
  118095. */
  118096. addFromContainer(container: AbstractScene): void;
  118097. /**
  118098. * Removes all the elements in the container from the scene
  118099. * @param container contains the elements to remove
  118100. * @param dispose if the removed element should be disposed (default: false)
  118101. */
  118102. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118103. /**
  118104. * Disposes the component and the associated ressources.
  118105. */
  118106. dispose(): void;
  118107. /**
  118108. * Disables audio in the associated scene.
  118109. */
  118110. disableAudio(): void;
  118111. /**
  118112. * Enables audio in the associated scene.
  118113. */
  118114. enableAudio(): void;
  118115. /**
  118116. * Switch audio to headphone output.
  118117. */
  118118. switchAudioModeForHeadphones(): void;
  118119. /**
  118120. * Switch audio to normal speakers.
  118121. */
  118122. switchAudioModeForNormalSpeakers(): void;
  118123. private _cachedCameraDirection;
  118124. private _cachedCameraPosition;
  118125. private _lastCheck;
  118126. private _afterRender;
  118127. }
  118128. }
  118129. declare module BABYLON {
  118130. /**
  118131. * Wraps one or more Sound objects and selects one with random weight for playback.
  118132. */
  118133. export class WeightedSound {
  118134. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118135. loop: boolean;
  118136. private _coneInnerAngle;
  118137. private _coneOuterAngle;
  118138. private _volume;
  118139. /** A Sound is currently playing. */
  118140. isPlaying: boolean;
  118141. /** A Sound is currently paused. */
  118142. isPaused: boolean;
  118143. private _sounds;
  118144. private _weights;
  118145. private _currentIndex?;
  118146. /**
  118147. * Creates a new WeightedSound from the list of sounds given.
  118148. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118149. * @param sounds Array of Sounds that will be selected from.
  118150. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118151. */
  118152. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118153. /**
  118154. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118155. */
  118156. get directionalConeInnerAngle(): number;
  118157. /**
  118158. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118159. */
  118160. set directionalConeInnerAngle(value: number);
  118161. /**
  118162. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118163. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118164. */
  118165. get directionalConeOuterAngle(): number;
  118166. /**
  118167. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118168. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118169. */
  118170. set directionalConeOuterAngle(value: number);
  118171. /**
  118172. * Playback volume.
  118173. */
  118174. get volume(): number;
  118175. /**
  118176. * Playback volume.
  118177. */
  118178. set volume(value: number);
  118179. private _onended;
  118180. /**
  118181. * Suspend playback
  118182. */
  118183. pause(): void;
  118184. /**
  118185. * Stop playback
  118186. */
  118187. stop(): void;
  118188. /**
  118189. * Start playback.
  118190. * @param startOffset Position the clip head at a specific time in seconds.
  118191. */
  118192. play(startOffset?: number): void;
  118193. }
  118194. }
  118195. declare module BABYLON {
  118196. /**
  118197. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118198. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118199. */
  118200. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118201. /**
  118202. * Gets the name of the behavior.
  118203. */
  118204. get name(): string;
  118205. /**
  118206. * The easing function used by animations
  118207. */
  118208. static EasingFunction: BackEase;
  118209. /**
  118210. * The easing mode used by animations
  118211. */
  118212. static EasingMode: number;
  118213. /**
  118214. * The duration of the animation, in milliseconds
  118215. */
  118216. transitionDuration: number;
  118217. /**
  118218. * Length of the distance animated by the transition when lower radius is reached
  118219. */
  118220. lowerRadiusTransitionRange: number;
  118221. /**
  118222. * Length of the distance animated by the transition when upper radius is reached
  118223. */
  118224. upperRadiusTransitionRange: number;
  118225. private _autoTransitionRange;
  118226. /**
  118227. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118228. */
  118229. get autoTransitionRange(): boolean;
  118230. /**
  118231. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118232. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  118233. */
  118234. set autoTransitionRange(value: boolean);
  118235. private _attachedCamera;
  118236. private _onAfterCheckInputsObserver;
  118237. private _onMeshTargetChangedObserver;
  118238. /**
  118239. * Initializes the behavior.
  118240. */
  118241. init(): void;
  118242. /**
  118243. * Attaches the behavior to its arc rotate camera.
  118244. * @param camera Defines the camera to attach the behavior to
  118245. */
  118246. attach(camera: ArcRotateCamera): void;
  118247. /**
  118248. * Detaches the behavior from its current arc rotate camera.
  118249. */
  118250. detach(): void;
  118251. private _radiusIsAnimating;
  118252. private _radiusBounceTransition;
  118253. private _animatables;
  118254. private _cachedWheelPrecision;
  118255. /**
  118256. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  118257. * @param radiusLimit The limit to check against.
  118258. * @return Bool to indicate if at limit.
  118259. */
  118260. private _isRadiusAtLimit;
  118261. /**
  118262. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  118263. * @param radiusDelta The delta by which to animate to. Can be negative.
  118264. */
  118265. private _applyBoundRadiusAnimation;
  118266. /**
  118267. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  118268. */
  118269. protected _clearAnimationLocks(): void;
  118270. /**
  118271. * Stops and removes all animations that have been applied to the camera
  118272. */
  118273. stopAllAnimations(): void;
  118274. }
  118275. }
  118276. declare module BABYLON {
  118277. /**
  118278. * 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.
  118279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118280. */
  118281. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  118282. /**
  118283. * Gets the name of the behavior.
  118284. */
  118285. get name(): string;
  118286. private _mode;
  118287. private _radiusScale;
  118288. private _positionScale;
  118289. private _defaultElevation;
  118290. private _elevationReturnTime;
  118291. private _elevationReturnWaitTime;
  118292. private _zoomStopsAnimation;
  118293. private _framingTime;
  118294. /**
  118295. * The easing function used by animations
  118296. */
  118297. static EasingFunction: ExponentialEase;
  118298. /**
  118299. * The easing mode used by animations
  118300. */
  118301. static EasingMode: number;
  118302. /**
  118303. * Sets the current mode used by the behavior
  118304. */
  118305. set mode(mode: number);
  118306. /**
  118307. * Gets current mode used by the behavior.
  118308. */
  118309. get mode(): number;
  118310. /**
  118311. * Sets the scale applied to the radius (1 by default)
  118312. */
  118313. set radiusScale(radius: number);
  118314. /**
  118315. * Gets the scale applied to the radius
  118316. */
  118317. get radiusScale(): number;
  118318. /**
  118319. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118320. */
  118321. set positionScale(scale: number);
  118322. /**
  118323. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118324. */
  118325. get positionScale(): number;
  118326. /**
  118327. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118328. * behaviour is triggered, in radians.
  118329. */
  118330. set defaultElevation(elevation: number);
  118331. /**
  118332. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118333. * behaviour is triggered, in radians.
  118334. */
  118335. get defaultElevation(): number;
  118336. /**
  118337. * Sets the time (in milliseconds) taken to return to the default beta position.
  118338. * Negative value indicates camera should not return to default.
  118339. */
  118340. set elevationReturnTime(speed: number);
  118341. /**
  118342. * Gets the time (in milliseconds) taken to return to the default beta position.
  118343. * Negative value indicates camera should not return to default.
  118344. */
  118345. get elevationReturnTime(): number;
  118346. /**
  118347. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118348. */
  118349. set elevationReturnWaitTime(time: number);
  118350. /**
  118351. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118352. */
  118353. get elevationReturnWaitTime(): number;
  118354. /**
  118355. * Sets the flag that indicates if user zooming should stop animation.
  118356. */
  118357. set zoomStopsAnimation(flag: boolean);
  118358. /**
  118359. * Gets the flag that indicates if user zooming should stop animation.
  118360. */
  118361. get zoomStopsAnimation(): boolean;
  118362. /**
  118363. * Sets the transition time when framing the mesh, in milliseconds
  118364. */
  118365. set framingTime(time: number);
  118366. /**
  118367. * Gets the transition time when framing the mesh, in milliseconds
  118368. */
  118369. get framingTime(): number;
  118370. /**
  118371. * Define if the behavior should automatically change the configured
  118372. * camera limits and sensibilities.
  118373. */
  118374. autoCorrectCameraLimitsAndSensibility: boolean;
  118375. private _onPrePointerObservableObserver;
  118376. private _onAfterCheckInputsObserver;
  118377. private _onMeshTargetChangedObserver;
  118378. private _attachedCamera;
  118379. private _isPointerDown;
  118380. private _lastInteractionTime;
  118381. /**
  118382. * Initializes the behavior.
  118383. */
  118384. init(): void;
  118385. /**
  118386. * Attaches the behavior to its arc rotate camera.
  118387. * @param camera Defines the camera to attach the behavior to
  118388. */
  118389. attach(camera: ArcRotateCamera): void;
  118390. /**
  118391. * Detaches the behavior from its current arc rotate camera.
  118392. */
  118393. detach(): void;
  118394. private _animatables;
  118395. private _betaIsAnimating;
  118396. private _betaTransition;
  118397. private _radiusTransition;
  118398. private _vectorTransition;
  118399. /**
  118400. * Targets the given mesh and updates zoom level accordingly.
  118401. * @param mesh The mesh to target.
  118402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118404. */
  118405. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118406. /**
  118407. * Targets the given mesh with its children and updates zoom level accordingly.
  118408. * @param mesh The mesh to target.
  118409. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118410. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118411. */
  118412. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118413. /**
  118414. * Targets the given meshes with their children and updates zoom level accordingly.
  118415. * @param meshes The mesh to target.
  118416. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118417. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118418. */
  118419. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118420. /**
  118421. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  118422. * @param minimumWorld Determines the smaller position of the bounding box extend
  118423. * @param maximumWorld Determines the bigger position of the bounding box extend
  118424. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118425. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118426. */
  118427. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118428. /**
  118429. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  118430. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  118431. * frustum width.
  118432. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  118433. * to fully enclose the mesh in the viewing frustum.
  118434. */
  118435. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  118436. /**
  118437. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  118438. * is automatically returned to its default position (expected to be above ground plane).
  118439. */
  118440. private _maintainCameraAboveGround;
  118441. /**
  118442. * Returns the frustum slope based on the canvas ratio and camera FOV
  118443. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  118444. */
  118445. private _getFrustumSlope;
  118446. /**
  118447. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  118448. */
  118449. private _clearAnimationLocks;
  118450. /**
  118451. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118452. */
  118453. private _applyUserInteraction;
  118454. /**
  118455. * Stops and removes all animations that have been applied to the camera
  118456. */
  118457. stopAllAnimations(): void;
  118458. /**
  118459. * Gets a value indicating if the user is moving the camera
  118460. */
  118461. get isUserIsMoving(): boolean;
  118462. /**
  118463. * The camera can move all the way towards the mesh.
  118464. */
  118465. static IgnoreBoundsSizeMode: number;
  118466. /**
  118467. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  118468. */
  118469. static FitFrustumSidesMode: number;
  118470. }
  118471. }
  118472. declare module BABYLON {
  118473. /**
  118474. * Base class for Camera Pointer Inputs.
  118475. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  118476. * for example usage.
  118477. */
  118478. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  118479. /**
  118480. * Defines the camera the input is attached to.
  118481. */
  118482. abstract camera: Camera;
  118483. /**
  118484. * Whether keyboard modifier keys are pressed at time of last mouse event.
  118485. */
  118486. protected _altKey: boolean;
  118487. protected _ctrlKey: boolean;
  118488. protected _metaKey: boolean;
  118489. protected _shiftKey: boolean;
  118490. /**
  118491. * Which mouse buttons were pressed at time of last mouse event.
  118492. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  118493. */
  118494. protected _buttonsPressed: number;
  118495. /**
  118496. * Defines the buttons associated with the input to handle camera move.
  118497. */
  118498. buttons: number[];
  118499. /**
  118500. * Attach the input controls to a specific dom element to get the input from.
  118501. * @param element Defines the element the controls should be listened from
  118502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118503. */
  118504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118505. /**
  118506. * Detach the current controls from the specified dom element.
  118507. * @param element Defines the element to stop listening the inputs from
  118508. */
  118509. detachControl(element: Nullable<HTMLElement>): void;
  118510. /**
  118511. * Gets the class name of the current input.
  118512. * @returns the class name
  118513. */
  118514. getClassName(): string;
  118515. /**
  118516. * Get the friendly name associated with the input class.
  118517. * @returns the input friendly name
  118518. */
  118519. getSimpleName(): string;
  118520. /**
  118521. * Called on pointer POINTERDOUBLETAP event.
  118522. * Override this method to provide functionality on POINTERDOUBLETAP event.
  118523. */
  118524. protected onDoubleTap(type: string): void;
  118525. /**
  118526. * Called on pointer POINTERMOVE event if only a single touch is active.
  118527. * Override this method to provide functionality.
  118528. */
  118529. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118530. /**
  118531. * Called on pointer POINTERMOVE event if multiple touches are active.
  118532. * Override this method to provide functionality.
  118533. */
  118534. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118535. /**
  118536. * Called on JS contextmenu event.
  118537. * Override this method to provide functionality.
  118538. */
  118539. protected onContextMenu(evt: PointerEvent): void;
  118540. /**
  118541. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118542. * press.
  118543. * Override this method to provide functionality.
  118544. */
  118545. protected onButtonDown(evt: PointerEvent): void;
  118546. /**
  118547. * Called each time a new POINTERUP event occurs. Ie, for each button
  118548. * release.
  118549. * Override this method to provide functionality.
  118550. */
  118551. protected onButtonUp(evt: PointerEvent): void;
  118552. /**
  118553. * Called when window becomes inactive.
  118554. * Override this method to provide functionality.
  118555. */
  118556. protected onLostFocus(): void;
  118557. private _pointerInput;
  118558. private _observer;
  118559. private _onLostFocus;
  118560. private pointA;
  118561. private pointB;
  118562. }
  118563. }
  118564. declare module BABYLON {
  118565. /**
  118566. * Manage the pointers inputs to control an arc rotate camera.
  118567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118568. */
  118569. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  118570. /**
  118571. * Defines the camera the input is attached to.
  118572. */
  118573. camera: ArcRotateCamera;
  118574. /**
  118575. * Gets the class name of the current input.
  118576. * @returns the class name
  118577. */
  118578. getClassName(): string;
  118579. /**
  118580. * Defines the buttons associated with the input to handle camera move.
  118581. */
  118582. buttons: number[];
  118583. /**
  118584. * Defines the pointer angular sensibility along the X axis or how fast is
  118585. * the camera rotating.
  118586. */
  118587. angularSensibilityX: number;
  118588. /**
  118589. * Defines the pointer angular sensibility along the Y axis or how fast is
  118590. * the camera rotating.
  118591. */
  118592. angularSensibilityY: number;
  118593. /**
  118594. * Defines the pointer pinch precision or how fast is the camera zooming.
  118595. */
  118596. pinchPrecision: number;
  118597. /**
  118598. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  118599. * from 0.
  118600. * It defines the percentage of current camera.radius to use as delta when
  118601. * pinch zoom is used.
  118602. */
  118603. pinchDeltaPercentage: number;
  118604. /**
  118605. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118606. * that any object in the plane at the camera's target point will scale
  118607. * perfectly with finger motion.
  118608. * Overrides pinchDeltaPercentage and pinchPrecision.
  118609. */
  118610. useNaturalPinchZoom: boolean;
  118611. /**
  118612. * Defines the pointer panning sensibility or how fast is the camera moving.
  118613. */
  118614. panningSensibility: number;
  118615. /**
  118616. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  118617. */
  118618. multiTouchPanning: boolean;
  118619. /**
  118620. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  118621. * zoom (pinch) through multitouch.
  118622. */
  118623. multiTouchPanAndZoom: boolean;
  118624. /**
  118625. * Revers pinch action direction.
  118626. */
  118627. pinchInwards: boolean;
  118628. private _isPanClick;
  118629. private _twoFingerActivityCount;
  118630. private _isPinching;
  118631. /**
  118632. * Called on pointer POINTERMOVE event if only a single touch is active.
  118633. */
  118634. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118635. /**
  118636. * Called on pointer POINTERDOUBLETAP event.
  118637. */
  118638. protected onDoubleTap(type: string): void;
  118639. /**
  118640. * Called on pointer POINTERMOVE event if multiple touches are active.
  118641. */
  118642. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118643. /**
  118644. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118645. * press.
  118646. */
  118647. protected onButtonDown(evt: PointerEvent): void;
  118648. /**
  118649. * Called each time a new POINTERUP event occurs. Ie, for each button
  118650. * release.
  118651. */
  118652. protected onButtonUp(evt: PointerEvent): void;
  118653. /**
  118654. * Called when window becomes inactive.
  118655. */
  118656. protected onLostFocus(): void;
  118657. }
  118658. }
  118659. declare module BABYLON {
  118660. /**
  118661. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  118662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118663. */
  118664. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  118665. /**
  118666. * Defines the camera the input is attached to.
  118667. */
  118668. camera: ArcRotateCamera;
  118669. /**
  118670. * Defines the list of key codes associated with the up action (increase alpha)
  118671. */
  118672. keysUp: number[];
  118673. /**
  118674. * Defines the list of key codes associated with the down action (decrease alpha)
  118675. */
  118676. keysDown: number[];
  118677. /**
  118678. * Defines the list of key codes associated with the left action (increase beta)
  118679. */
  118680. keysLeft: number[];
  118681. /**
  118682. * Defines the list of key codes associated with the right action (decrease beta)
  118683. */
  118684. keysRight: number[];
  118685. /**
  118686. * Defines the list of key codes associated with the reset action.
  118687. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  118688. */
  118689. keysReset: number[];
  118690. /**
  118691. * Defines the panning sensibility of the inputs.
  118692. * (How fast is the camera panning)
  118693. */
  118694. panningSensibility: number;
  118695. /**
  118696. * Defines the zooming sensibility of the inputs.
  118697. * (How fast is the camera zooming)
  118698. */
  118699. zoomingSensibility: number;
  118700. /**
  118701. * Defines whether maintaining the alt key down switch the movement mode from
  118702. * orientation to zoom.
  118703. */
  118704. useAltToZoom: boolean;
  118705. /**
  118706. * Rotation speed of the camera
  118707. */
  118708. angularSpeed: number;
  118709. private _keys;
  118710. private _ctrlPressed;
  118711. private _altPressed;
  118712. private _onCanvasBlurObserver;
  118713. private _onKeyboardObserver;
  118714. private _engine;
  118715. private _scene;
  118716. /**
  118717. * Attach the input controls to a specific dom element to get the input from.
  118718. * @param element Defines the element the controls should be listened from
  118719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118720. */
  118721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118722. /**
  118723. * Detach the current controls from the specified dom element.
  118724. * @param element Defines the element to stop listening the inputs from
  118725. */
  118726. detachControl(element: Nullable<HTMLElement>): void;
  118727. /**
  118728. * Update the current camera state depending on the inputs that have been used this frame.
  118729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  118730. */
  118731. checkInputs(): void;
  118732. /**
  118733. * Gets the class name of the current intput.
  118734. * @returns the class name
  118735. */
  118736. getClassName(): string;
  118737. /**
  118738. * Get the friendly name associated with the input class.
  118739. * @returns the input friendly name
  118740. */
  118741. getSimpleName(): string;
  118742. }
  118743. }
  118744. declare module BABYLON {
  118745. /**
  118746. * Manage the mouse wheel inputs to control an arc rotate camera.
  118747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118748. */
  118749. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  118750. /**
  118751. * Defines the camera the input is attached to.
  118752. */
  118753. camera: ArcRotateCamera;
  118754. /**
  118755. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118756. */
  118757. wheelPrecision: number;
  118758. /**
  118759. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  118760. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  118761. */
  118762. wheelDeltaPercentage: number;
  118763. private _wheel;
  118764. private _observer;
  118765. private computeDeltaFromMouseWheelLegacyEvent;
  118766. /**
  118767. * Attach the input controls to a specific dom element to get the input from.
  118768. * @param element Defines the element the controls should be listened from
  118769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118770. */
  118771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118772. /**
  118773. * Detach the current controls from the specified dom element.
  118774. * @param element Defines the element to stop listening the inputs from
  118775. */
  118776. detachControl(element: Nullable<HTMLElement>): void;
  118777. /**
  118778. * Gets the class name of the current intput.
  118779. * @returns the class name
  118780. */
  118781. getClassName(): string;
  118782. /**
  118783. * Get the friendly name associated with the input class.
  118784. * @returns the input friendly name
  118785. */
  118786. getSimpleName(): string;
  118787. }
  118788. }
  118789. declare module BABYLON {
  118790. /**
  118791. * Default Inputs manager for the ArcRotateCamera.
  118792. * It groups all the default supported inputs for ease of use.
  118793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118794. */
  118795. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  118796. /**
  118797. * Instantiates a new ArcRotateCameraInputsManager.
  118798. * @param camera Defines the camera the inputs belong to
  118799. */
  118800. constructor(camera: ArcRotateCamera);
  118801. /**
  118802. * Add mouse wheel input support to the input manager.
  118803. * @returns the current input manager
  118804. */
  118805. addMouseWheel(): ArcRotateCameraInputsManager;
  118806. /**
  118807. * Add pointers input support to the input manager.
  118808. * @returns the current input manager
  118809. */
  118810. addPointers(): ArcRotateCameraInputsManager;
  118811. /**
  118812. * Add keyboard input support to the input manager.
  118813. * @returns the current input manager
  118814. */
  118815. addKeyboard(): ArcRotateCameraInputsManager;
  118816. }
  118817. }
  118818. declare module BABYLON {
  118819. /**
  118820. * This represents an orbital type of camera.
  118821. *
  118822. * 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.
  118823. * 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.
  118824. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  118825. */
  118826. export class ArcRotateCamera extends TargetCamera {
  118827. /**
  118828. * Defines the rotation angle of the camera along the longitudinal axis.
  118829. */
  118830. alpha: number;
  118831. /**
  118832. * Defines the rotation angle of the camera along the latitudinal axis.
  118833. */
  118834. beta: number;
  118835. /**
  118836. * Defines the radius of the camera from it s target point.
  118837. */
  118838. radius: number;
  118839. protected _target: Vector3;
  118840. protected _targetHost: Nullable<AbstractMesh>;
  118841. /**
  118842. * Defines the target point of the camera.
  118843. * The camera looks towards it form the radius distance.
  118844. */
  118845. get target(): Vector3;
  118846. set target(value: Vector3);
  118847. /**
  118848. * Define the current local position of the camera in the scene
  118849. */
  118850. get position(): Vector3;
  118851. set position(newPosition: Vector3);
  118852. protected _upVector: Vector3;
  118853. protected _upToYMatrix: Matrix;
  118854. protected _YToUpMatrix: Matrix;
  118855. /**
  118856. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  118857. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  118858. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  118859. */
  118860. set upVector(vec: Vector3);
  118861. get upVector(): Vector3;
  118862. /**
  118863. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  118864. */
  118865. setMatUp(): void;
  118866. /**
  118867. * Current inertia value on the longitudinal axis.
  118868. * The bigger this number the longer it will take for the camera to stop.
  118869. */
  118870. inertialAlphaOffset: number;
  118871. /**
  118872. * Current inertia value on the latitudinal axis.
  118873. * The bigger this number the longer it will take for the camera to stop.
  118874. */
  118875. inertialBetaOffset: number;
  118876. /**
  118877. * Current inertia value on the radius axis.
  118878. * The bigger this number the longer it will take for the camera to stop.
  118879. */
  118880. inertialRadiusOffset: number;
  118881. /**
  118882. * Minimum allowed angle on the longitudinal axis.
  118883. * This can help limiting how the Camera is able to move in the scene.
  118884. */
  118885. lowerAlphaLimit: Nullable<number>;
  118886. /**
  118887. * Maximum allowed angle on the longitudinal axis.
  118888. * This can help limiting how the Camera is able to move in the scene.
  118889. */
  118890. upperAlphaLimit: Nullable<number>;
  118891. /**
  118892. * Minimum allowed angle on the latitudinal axis.
  118893. * This can help limiting how the Camera is able to move in the scene.
  118894. */
  118895. lowerBetaLimit: number;
  118896. /**
  118897. * Maximum allowed angle on the latitudinal axis.
  118898. * This can help limiting how the Camera is able to move in the scene.
  118899. */
  118900. upperBetaLimit: number;
  118901. /**
  118902. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  118903. * This can help limiting how the Camera is able to move in the scene.
  118904. */
  118905. lowerRadiusLimit: Nullable<number>;
  118906. /**
  118907. * Maximum allowed distance of the camera to the target (The camera can not get further).
  118908. * This can help limiting how the Camera is able to move in the scene.
  118909. */
  118910. upperRadiusLimit: Nullable<number>;
  118911. /**
  118912. * Defines the current inertia value used during panning of the camera along the X axis.
  118913. */
  118914. inertialPanningX: number;
  118915. /**
  118916. * Defines the current inertia value used during panning of the camera along the Y axis.
  118917. */
  118918. inertialPanningY: number;
  118919. /**
  118920. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  118921. * Basically if your fingers moves away from more than this distance you will be considered
  118922. * in pinch mode.
  118923. */
  118924. pinchToPanMaxDistance: number;
  118925. /**
  118926. * Defines the maximum distance the camera can pan.
  118927. * This could help keeping the cammera always in your scene.
  118928. */
  118929. panningDistanceLimit: Nullable<number>;
  118930. /**
  118931. * Defines the target of the camera before paning.
  118932. */
  118933. panningOriginTarget: Vector3;
  118934. /**
  118935. * Defines the value of the inertia used during panning.
  118936. * 0 would mean stop inertia and one would mean no decelleration at all.
  118937. */
  118938. panningInertia: number;
  118939. /**
  118940. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  118941. */
  118942. get angularSensibilityX(): number;
  118943. set angularSensibilityX(value: number);
  118944. /**
  118945. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  118946. */
  118947. get angularSensibilityY(): number;
  118948. set angularSensibilityY(value: number);
  118949. /**
  118950. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  118951. */
  118952. get pinchPrecision(): number;
  118953. set pinchPrecision(value: number);
  118954. /**
  118955. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  118956. * It will be used instead of pinchDeltaPrecision if different from 0.
  118957. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118958. */
  118959. get pinchDeltaPercentage(): number;
  118960. set pinchDeltaPercentage(value: number);
  118961. /**
  118962. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  118963. * and pinch delta percentage.
  118964. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118965. * that any object in the plane at the camera's target point will scale
  118966. * perfectly with finger motion.
  118967. */
  118968. get useNaturalPinchZoom(): boolean;
  118969. set useNaturalPinchZoom(value: boolean);
  118970. /**
  118971. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  118972. */
  118973. get panningSensibility(): number;
  118974. set panningSensibility(value: number);
  118975. /**
  118976. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  118977. */
  118978. get keysUp(): number[];
  118979. set keysUp(value: number[]);
  118980. /**
  118981. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  118982. */
  118983. get keysDown(): number[];
  118984. set keysDown(value: number[]);
  118985. /**
  118986. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  118987. */
  118988. get keysLeft(): number[];
  118989. set keysLeft(value: number[]);
  118990. /**
  118991. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  118992. */
  118993. get keysRight(): number[];
  118994. set keysRight(value: number[]);
  118995. /**
  118996. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118997. */
  118998. get wheelPrecision(): number;
  118999. set wheelPrecision(value: number);
  119000. /**
  119001. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119002. * It will be used instead of pinchDeltaPrecision if different from 0.
  119003. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119004. */
  119005. get wheelDeltaPercentage(): number;
  119006. set wheelDeltaPercentage(value: number);
  119007. /**
  119008. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119009. */
  119010. zoomOnFactor: number;
  119011. /**
  119012. * Defines a screen offset for the camera position.
  119013. */
  119014. targetScreenOffset: Vector2;
  119015. /**
  119016. * Allows the camera to be completely reversed.
  119017. * If false the camera can not arrive upside down.
  119018. */
  119019. allowUpsideDown: boolean;
  119020. /**
  119021. * Define if double tap/click is used to restore the previously saved state of the camera.
  119022. */
  119023. useInputToRestoreState: boolean;
  119024. /** @hidden */
  119025. _viewMatrix: Matrix;
  119026. /** @hidden */
  119027. _useCtrlForPanning: boolean;
  119028. /** @hidden */
  119029. _panningMouseButton: number;
  119030. /**
  119031. * Defines the input associated to the camera.
  119032. */
  119033. inputs: ArcRotateCameraInputsManager;
  119034. /** @hidden */
  119035. _reset: () => void;
  119036. /**
  119037. * Defines the allowed panning axis.
  119038. */
  119039. panningAxis: Vector3;
  119040. protected _localDirection: Vector3;
  119041. protected _transformedDirection: Vector3;
  119042. private _bouncingBehavior;
  119043. /**
  119044. * Gets the bouncing behavior of the camera if it has been enabled.
  119045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119046. */
  119047. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119048. /**
  119049. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119051. */
  119052. get useBouncingBehavior(): boolean;
  119053. set useBouncingBehavior(value: boolean);
  119054. private _framingBehavior;
  119055. /**
  119056. * Gets the framing behavior of the camera if it has been enabled.
  119057. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119058. */
  119059. get framingBehavior(): Nullable<FramingBehavior>;
  119060. /**
  119061. * Defines if the framing behavior of the camera is enabled on the camera.
  119062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119063. */
  119064. get useFramingBehavior(): boolean;
  119065. set useFramingBehavior(value: boolean);
  119066. private _autoRotationBehavior;
  119067. /**
  119068. * Gets the auto rotation behavior of the camera if it has been enabled.
  119069. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119070. */
  119071. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119072. /**
  119073. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119074. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119075. */
  119076. get useAutoRotationBehavior(): boolean;
  119077. set useAutoRotationBehavior(value: boolean);
  119078. /**
  119079. * Observable triggered when the mesh target has been changed on the camera.
  119080. */
  119081. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119082. /**
  119083. * Event raised when the camera is colliding with a mesh.
  119084. */
  119085. onCollide: (collidedMesh: AbstractMesh) => void;
  119086. /**
  119087. * Defines whether the camera should check collision with the objects oh the scene.
  119088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119089. */
  119090. checkCollisions: boolean;
  119091. /**
  119092. * Defines the collision radius of the camera.
  119093. * This simulates a sphere around the camera.
  119094. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119095. */
  119096. collisionRadius: Vector3;
  119097. protected _collider: Collider;
  119098. protected _previousPosition: Vector3;
  119099. protected _collisionVelocity: Vector3;
  119100. protected _newPosition: Vector3;
  119101. protected _previousAlpha: number;
  119102. protected _previousBeta: number;
  119103. protected _previousRadius: number;
  119104. protected _collisionTriggered: boolean;
  119105. protected _targetBoundingCenter: Nullable<Vector3>;
  119106. private _computationVector;
  119107. /**
  119108. * Instantiates a new ArcRotateCamera in a given scene
  119109. * @param name Defines the name of the camera
  119110. * @param alpha Defines the camera rotation along the logitudinal axis
  119111. * @param beta Defines the camera rotation along the latitudinal axis
  119112. * @param radius Defines the camera distance from its target
  119113. * @param target Defines the camera target
  119114. * @param scene Defines the scene the camera belongs to
  119115. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119116. */
  119117. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119118. /** @hidden */
  119119. _initCache(): void;
  119120. /** @hidden */
  119121. _updateCache(ignoreParentClass?: boolean): void;
  119122. protected _getTargetPosition(): Vector3;
  119123. private _storedAlpha;
  119124. private _storedBeta;
  119125. private _storedRadius;
  119126. private _storedTarget;
  119127. private _storedTargetScreenOffset;
  119128. /**
  119129. * Stores the current state of the camera (alpha, beta, radius and target)
  119130. * @returns the camera itself
  119131. */
  119132. storeState(): Camera;
  119133. /**
  119134. * @hidden
  119135. * Restored camera state. You must call storeState() first
  119136. */
  119137. _restoreStateValues(): boolean;
  119138. /** @hidden */
  119139. _isSynchronizedViewMatrix(): boolean;
  119140. /**
  119141. * Attached controls to the current camera.
  119142. * @param element Defines the element the controls should be listened from
  119143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119144. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119145. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119146. */
  119147. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119148. /**
  119149. * Detach the current controls from the camera.
  119150. * The camera will stop reacting to inputs.
  119151. * @param element Defines the element to stop listening the inputs from
  119152. */
  119153. detachControl(element: HTMLElement): void;
  119154. /** @hidden */
  119155. _checkInputs(): void;
  119156. protected _checkLimits(): void;
  119157. /**
  119158. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119159. */
  119160. rebuildAnglesAndRadius(): void;
  119161. /**
  119162. * Use a position to define the current camera related information like alpha, beta and radius
  119163. * @param position Defines the position to set the camera at
  119164. */
  119165. setPosition(position: Vector3): void;
  119166. /**
  119167. * Defines the target the camera should look at.
  119168. * This will automatically adapt alpha beta and radius to fit within the new target.
  119169. * @param target Defines the new target as a Vector or a mesh
  119170. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119171. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119172. */
  119173. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119174. /** @hidden */
  119175. _getViewMatrix(): Matrix;
  119176. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119177. /**
  119178. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119179. * @param meshes Defines the mesh to zoom on
  119180. * @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)
  119181. */
  119182. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119183. /**
  119184. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119185. * The target will be changed but the radius
  119186. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119187. * @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)
  119188. */
  119189. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119190. min: Vector3;
  119191. max: Vector3;
  119192. distance: number;
  119193. }, doNotUpdateMaxZ?: boolean): void;
  119194. /**
  119195. * @override
  119196. * Override Camera.createRigCamera
  119197. */
  119198. createRigCamera(name: string, cameraIndex: number): Camera;
  119199. /**
  119200. * @hidden
  119201. * @override
  119202. * Override Camera._updateRigCameras
  119203. */
  119204. _updateRigCameras(): void;
  119205. /**
  119206. * Destroy the camera and release the current resources hold by it.
  119207. */
  119208. dispose(): void;
  119209. /**
  119210. * Gets the current object class name.
  119211. * @return the class name
  119212. */
  119213. getClassName(): string;
  119214. }
  119215. }
  119216. declare module BABYLON {
  119217. /**
  119218. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119219. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119220. */
  119221. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119222. /**
  119223. * Gets the name of the behavior.
  119224. */
  119225. get name(): string;
  119226. private _zoomStopsAnimation;
  119227. private _idleRotationSpeed;
  119228. private _idleRotationWaitTime;
  119229. private _idleRotationSpinupTime;
  119230. /**
  119231. * Sets the flag that indicates if user zooming should stop animation.
  119232. */
  119233. set zoomStopsAnimation(flag: boolean);
  119234. /**
  119235. * Gets the flag that indicates if user zooming should stop animation.
  119236. */
  119237. get zoomStopsAnimation(): boolean;
  119238. /**
  119239. * Sets the default speed at which the camera rotates around the model.
  119240. */
  119241. set idleRotationSpeed(speed: number);
  119242. /**
  119243. * Gets the default speed at which the camera rotates around the model.
  119244. */
  119245. get idleRotationSpeed(): number;
  119246. /**
  119247. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  119248. */
  119249. set idleRotationWaitTime(time: number);
  119250. /**
  119251. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  119252. */
  119253. get idleRotationWaitTime(): number;
  119254. /**
  119255. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119256. */
  119257. set idleRotationSpinupTime(time: number);
  119258. /**
  119259. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119260. */
  119261. get idleRotationSpinupTime(): number;
  119262. /**
  119263. * Gets a value indicating if the camera is currently rotating because of this behavior
  119264. */
  119265. get rotationInProgress(): boolean;
  119266. private _onPrePointerObservableObserver;
  119267. private _onAfterCheckInputsObserver;
  119268. private _attachedCamera;
  119269. private _isPointerDown;
  119270. private _lastFrameTime;
  119271. private _lastInteractionTime;
  119272. private _cameraRotationSpeed;
  119273. /**
  119274. * Initializes the behavior.
  119275. */
  119276. init(): void;
  119277. /**
  119278. * Attaches the behavior to its arc rotate camera.
  119279. * @param camera Defines the camera to attach the behavior to
  119280. */
  119281. attach(camera: ArcRotateCamera): void;
  119282. /**
  119283. * Detaches the behavior from its current arc rotate camera.
  119284. */
  119285. detach(): void;
  119286. /**
  119287. * Returns true if user is scrolling.
  119288. * @return true if user is scrolling.
  119289. */
  119290. private _userIsZooming;
  119291. private _lastFrameRadius;
  119292. private _shouldAnimationStopForInteraction;
  119293. /**
  119294. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119295. */
  119296. private _applyUserInteraction;
  119297. private _userIsMoving;
  119298. }
  119299. }
  119300. declare module BABYLON {
  119301. /**
  119302. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  119303. */
  119304. export class AttachToBoxBehavior implements Behavior<Mesh> {
  119305. private ui;
  119306. /**
  119307. * The name of the behavior
  119308. */
  119309. name: string;
  119310. /**
  119311. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  119312. */
  119313. distanceAwayFromFace: number;
  119314. /**
  119315. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  119316. */
  119317. distanceAwayFromBottomOfFace: number;
  119318. private _faceVectors;
  119319. private _target;
  119320. private _scene;
  119321. private _onRenderObserver;
  119322. private _tmpMatrix;
  119323. private _tmpVector;
  119324. /**
  119325. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  119326. * @param ui The transform node that should be attched to the mesh
  119327. */
  119328. constructor(ui: TransformNode);
  119329. /**
  119330. * Initializes the behavior
  119331. */
  119332. init(): void;
  119333. private _closestFace;
  119334. private _zeroVector;
  119335. private _lookAtTmpMatrix;
  119336. private _lookAtToRef;
  119337. /**
  119338. * Attaches the AttachToBoxBehavior to the passed in mesh
  119339. * @param target The mesh that the specified node will be attached to
  119340. */
  119341. attach(target: Mesh): void;
  119342. /**
  119343. * Detaches the behavior from the mesh
  119344. */
  119345. detach(): void;
  119346. }
  119347. }
  119348. declare module BABYLON {
  119349. /**
  119350. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  119351. */
  119352. export class FadeInOutBehavior implements Behavior<Mesh> {
  119353. /**
  119354. * Time in milliseconds to delay before fading in (Default: 0)
  119355. */
  119356. delay: number;
  119357. /**
  119358. * Time in milliseconds for the mesh to fade in (Default: 300)
  119359. */
  119360. fadeInTime: number;
  119361. private _millisecondsPerFrame;
  119362. private _hovered;
  119363. private _hoverValue;
  119364. private _ownerNode;
  119365. /**
  119366. * Instatiates the FadeInOutBehavior
  119367. */
  119368. constructor();
  119369. /**
  119370. * The name of the behavior
  119371. */
  119372. get name(): string;
  119373. /**
  119374. * Initializes the behavior
  119375. */
  119376. init(): void;
  119377. /**
  119378. * Attaches the fade behavior on the passed in mesh
  119379. * @param ownerNode The mesh that will be faded in/out once attached
  119380. */
  119381. attach(ownerNode: Mesh): void;
  119382. /**
  119383. * Detaches the behavior from the mesh
  119384. */
  119385. detach(): void;
  119386. /**
  119387. * Triggers the mesh to begin fading in or out
  119388. * @param value if the object should fade in or out (true to fade in)
  119389. */
  119390. fadeIn(value: boolean): void;
  119391. private _update;
  119392. private _setAllVisibility;
  119393. }
  119394. }
  119395. declare module BABYLON {
  119396. /**
  119397. * Class containing a set of static utilities functions for managing Pivots
  119398. * @hidden
  119399. */
  119400. export class PivotTools {
  119401. private static _PivotCached;
  119402. private static _OldPivotPoint;
  119403. private static _PivotTranslation;
  119404. private static _PivotTmpVector;
  119405. /** @hidden */
  119406. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  119407. /** @hidden */
  119408. static _RestorePivotPoint(mesh: AbstractMesh): void;
  119409. }
  119410. }
  119411. declare module BABYLON {
  119412. /**
  119413. * Class containing static functions to help procedurally build meshes
  119414. */
  119415. export class PlaneBuilder {
  119416. /**
  119417. * Creates a plane mesh
  119418. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119419. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119420. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119424. * @param name defines the name of the mesh
  119425. * @param options defines the options used to create the mesh
  119426. * @param scene defines the hosting scene
  119427. * @returns the plane mesh
  119428. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119429. */
  119430. static CreatePlane(name: string, options: {
  119431. size?: number;
  119432. width?: number;
  119433. height?: number;
  119434. sideOrientation?: number;
  119435. frontUVs?: Vector4;
  119436. backUVs?: Vector4;
  119437. updatable?: boolean;
  119438. sourcePlane?: Plane;
  119439. }, scene?: Nullable<Scene>): Mesh;
  119440. }
  119441. }
  119442. declare module BABYLON {
  119443. /**
  119444. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  119445. */
  119446. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  119447. private static _AnyMouseID;
  119448. /**
  119449. * Abstract mesh the behavior is set on
  119450. */
  119451. attachedNode: AbstractMesh;
  119452. private _dragPlane;
  119453. private _scene;
  119454. private _pointerObserver;
  119455. private _beforeRenderObserver;
  119456. private static _planeScene;
  119457. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  119458. /**
  119459. * 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)
  119460. */
  119461. maxDragAngle: number;
  119462. /**
  119463. * @hidden
  119464. */
  119465. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  119466. /**
  119467. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119468. */
  119469. currentDraggingPointerID: number;
  119470. /**
  119471. * The last position where the pointer hit the drag plane in world space
  119472. */
  119473. lastDragPosition: Vector3;
  119474. /**
  119475. * If the behavior is currently in a dragging state
  119476. */
  119477. dragging: boolean;
  119478. /**
  119479. * 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)
  119480. */
  119481. dragDeltaRatio: number;
  119482. /**
  119483. * If the drag plane orientation should be updated during the dragging (Default: true)
  119484. */
  119485. updateDragPlane: boolean;
  119486. private _debugMode;
  119487. private _moving;
  119488. /**
  119489. * Fires each time the attached mesh is dragged with the pointer
  119490. * * delta between last drag position and current drag position in world space
  119491. * * dragDistance along the drag axis
  119492. * * dragPlaneNormal normal of the current drag plane used during the drag
  119493. * * dragPlanePoint in world space where the drag intersects the drag plane
  119494. */
  119495. onDragObservable: Observable<{
  119496. delta: Vector3;
  119497. dragPlanePoint: Vector3;
  119498. dragPlaneNormal: Vector3;
  119499. dragDistance: number;
  119500. pointerId: number;
  119501. }>;
  119502. /**
  119503. * Fires each time a drag begins (eg. mouse down on mesh)
  119504. */
  119505. onDragStartObservable: Observable<{
  119506. dragPlanePoint: Vector3;
  119507. pointerId: number;
  119508. }>;
  119509. /**
  119510. * Fires each time a drag ends (eg. mouse release after drag)
  119511. */
  119512. onDragEndObservable: Observable<{
  119513. dragPlanePoint: Vector3;
  119514. pointerId: number;
  119515. }>;
  119516. /**
  119517. * If the attached mesh should be moved when dragged
  119518. */
  119519. moveAttached: boolean;
  119520. /**
  119521. * If the drag behavior will react to drag events (Default: true)
  119522. */
  119523. enabled: boolean;
  119524. /**
  119525. * If pointer events should start and release the drag (Default: true)
  119526. */
  119527. startAndReleaseDragOnPointerEvents: boolean;
  119528. /**
  119529. * If camera controls should be detached during the drag
  119530. */
  119531. detachCameraControls: boolean;
  119532. /**
  119533. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  119534. */
  119535. useObjectOrientationForDragging: boolean;
  119536. private _options;
  119537. /**
  119538. * Gets the options used by the behavior
  119539. */
  119540. get options(): {
  119541. dragAxis?: Vector3;
  119542. dragPlaneNormal?: Vector3;
  119543. };
  119544. /**
  119545. * Sets the options used by the behavior
  119546. */
  119547. set options(options: {
  119548. dragAxis?: Vector3;
  119549. dragPlaneNormal?: Vector3;
  119550. });
  119551. /**
  119552. * Creates a pointer drag behavior that can be attached to a mesh
  119553. * @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)
  119554. */
  119555. constructor(options?: {
  119556. dragAxis?: Vector3;
  119557. dragPlaneNormal?: Vector3;
  119558. });
  119559. /**
  119560. * Predicate to determine if it is valid to move the object to a new position when it is moved
  119561. */
  119562. validateDrag: (targetPosition: Vector3) => boolean;
  119563. /**
  119564. * The name of the behavior
  119565. */
  119566. get name(): string;
  119567. /**
  119568. * Initializes the behavior
  119569. */
  119570. init(): void;
  119571. private _tmpVector;
  119572. private _alternatePickedPoint;
  119573. private _worldDragAxis;
  119574. private _targetPosition;
  119575. private _attachedElement;
  119576. /**
  119577. * Attaches the drag behavior the passed in mesh
  119578. * @param ownerNode The mesh that will be dragged around once attached
  119579. * @param predicate Predicate to use for pick filtering
  119580. */
  119581. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  119582. /**
  119583. * Force relase the drag action by code.
  119584. */
  119585. releaseDrag(): void;
  119586. private _startDragRay;
  119587. private _lastPointerRay;
  119588. /**
  119589. * Simulates the start of a pointer drag event on the behavior
  119590. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  119591. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  119592. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  119593. */
  119594. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  119595. private _startDrag;
  119596. private _dragDelta;
  119597. private _moveDrag;
  119598. private _pickWithRayOnDragPlane;
  119599. private _pointA;
  119600. private _pointB;
  119601. private _pointC;
  119602. private _lineA;
  119603. private _lineB;
  119604. private _localAxis;
  119605. private _lookAt;
  119606. private _updateDragPlanePosition;
  119607. /**
  119608. * Detaches the behavior from the mesh
  119609. */
  119610. detach(): void;
  119611. }
  119612. }
  119613. declare module BABYLON {
  119614. /**
  119615. * A behavior that when attached to a mesh will allow the mesh to be scaled
  119616. */
  119617. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  119618. private _dragBehaviorA;
  119619. private _dragBehaviorB;
  119620. private _startDistance;
  119621. private _initialScale;
  119622. private _targetScale;
  119623. private _ownerNode;
  119624. private _sceneRenderObserver;
  119625. /**
  119626. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  119627. */
  119628. constructor();
  119629. /**
  119630. * The name of the behavior
  119631. */
  119632. get name(): string;
  119633. /**
  119634. * Initializes the behavior
  119635. */
  119636. init(): void;
  119637. private _getCurrentDistance;
  119638. /**
  119639. * Attaches the scale behavior the passed in mesh
  119640. * @param ownerNode The mesh that will be scaled around once attached
  119641. */
  119642. attach(ownerNode: Mesh): void;
  119643. /**
  119644. * Detaches the behavior from the mesh
  119645. */
  119646. detach(): void;
  119647. }
  119648. }
  119649. declare module BABYLON {
  119650. /**
  119651. * 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
  119652. */
  119653. export class SixDofDragBehavior implements Behavior<Mesh> {
  119654. private static _virtualScene;
  119655. private _ownerNode;
  119656. private _sceneRenderObserver;
  119657. private _scene;
  119658. private _targetPosition;
  119659. private _virtualOriginMesh;
  119660. private _virtualDragMesh;
  119661. private _pointerObserver;
  119662. private _moving;
  119663. private _startingOrientation;
  119664. private _attachedElement;
  119665. /**
  119666. * 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)
  119667. */
  119668. private zDragFactor;
  119669. /**
  119670. * If the object should rotate to face the drag origin
  119671. */
  119672. rotateDraggedObject: boolean;
  119673. /**
  119674. * If the behavior is currently in a dragging state
  119675. */
  119676. dragging: boolean;
  119677. /**
  119678. * 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)
  119679. */
  119680. dragDeltaRatio: number;
  119681. /**
  119682. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119683. */
  119684. currentDraggingPointerID: number;
  119685. /**
  119686. * If camera controls should be detached during the drag
  119687. */
  119688. detachCameraControls: boolean;
  119689. /**
  119690. * Fires each time a drag starts
  119691. */
  119692. onDragStartObservable: Observable<{}>;
  119693. /**
  119694. * Fires each time a drag ends (eg. mouse release after drag)
  119695. */
  119696. onDragEndObservable: Observable<{}>;
  119697. /**
  119698. * 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
  119699. */
  119700. constructor();
  119701. /**
  119702. * The name of the behavior
  119703. */
  119704. get name(): string;
  119705. /**
  119706. * Initializes the behavior
  119707. */
  119708. init(): void;
  119709. /**
  119710. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  119711. */
  119712. private get _pointerCamera();
  119713. /**
  119714. * Attaches the scale behavior the passed in mesh
  119715. * @param ownerNode The mesh that will be scaled around once attached
  119716. */
  119717. attach(ownerNode: Mesh): void;
  119718. /**
  119719. * Detaches the behavior from the mesh
  119720. */
  119721. detach(): void;
  119722. }
  119723. }
  119724. declare module BABYLON {
  119725. /**
  119726. * Class used to apply inverse kinematics to bones
  119727. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  119728. */
  119729. export class BoneIKController {
  119730. private static _tmpVecs;
  119731. private static _tmpQuat;
  119732. private static _tmpMats;
  119733. /**
  119734. * Gets or sets the target mesh
  119735. */
  119736. targetMesh: AbstractMesh;
  119737. /** Gets or sets the mesh used as pole */
  119738. poleTargetMesh: AbstractMesh;
  119739. /**
  119740. * Gets or sets the bone used as pole
  119741. */
  119742. poleTargetBone: Nullable<Bone>;
  119743. /**
  119744. * Gets or sets the target position
  119745. */
  119746. targetPosition: Vector3;
  119747. /**
  119748. * Gets or sets the pole target position
  119749. */
  119750. poleTargetPosition: Vector3;
  119751. /**
  119752. * Gets or sets the pole target local offset
  119753. */
  119754. poleTargetLocalOffset: Vector3;
  119755. /**
  119756. * Gets or sets the pole angle
  119757. */
  119758. poleAngle: number;
  119759. /**
  119760. * Gets or sets the mesh associated with the controller
  119761. */
  119762. mesh: AbstractMesh;
  119763. /**
  119764. * 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)
  119765. */
  119766. slerpAmount: number;
  119767. private _bone1Quat;
  119768. private _bone1Mat;
  119769. private _bone2Ang;
  119770. private _bone1;
  119771. private _bone2;
  119772. private _bone1Length;
  119773. private _bone2Length;
  119774. private _maxAngle;
  119775. private _maxReach;
  119776. private _rightHandedSystem;
  119777. private _bendAxis;
  119778. private _slerping;
  119779. private _adjustRoll;
  119780. /**
  119781. * Gets or sets maximum allowed angle
  119782. */
  119783. get maxAngle(): number;
  119784. set maxAngle(value: number);
  119785. /**
  119786. * Creates a new BoneIKController
  119787. * @param mesh defines the mesh to control
  119788. * @param bone defines the bone to control
  119789. * @param options defines options to set up the controller
  119790. */
  119791. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  119792. targetMesh?: AbstractMesh;
  119793. poleTargetMesh?: AbstractMesh;
  119794. poleTargetBone?: Bone;
  119795. poleTargetLocalOffset?: Vector3;
  119796. poleAngle?: number;
  119797. bendAxis?: Vector3;
  119798. maxAngle?: number;
  119799. slerpAmount?: number;
  119800. });
  119801. private _setMaxAngle;
  119802. /**
  119803. * Force the controller to update the bones
  119804. */
  119805. update(): void;
  119806. }
  119807. }
  119808. declare module BABYLON {
  119809. /**
  119810. * Class used to make a bone look toward a point in space
  119811. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  119812. */
  119813. export class BoneLookController {
  119814. private static _tmpVecs;
  119815. private static _tmpQuat;
  119816. private static _tmpMats;
  119817. /**
  119818. * The target Vector3 that the bone will look at
  119819. */
  119820. target: Vector3;
  119821. /**
  119822. * The mesh that the bone is attached to
  119823. */
  119824. mesh: AbstractMesh;
  119825. /**
  119826. * The bone that will be looking to the target
  119827. */
  119828. bone: Bone;
  119829. /**
  119830. * The up axis of the coordinate system that is used when the bone is rotated
  119831. */
  119832. upAxis: Vector3;
  119833. /**
  119834. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  119835. */
  119836. upAxisSpace: Space;
  119837. /**
  119838. * Used to make an adjustment to the yaw of the bone
  119839. */
  119840. adjustYaw: number;
  119841. /**
  119842. * Used to make an adjustment to the pitch of the bone
  119843. */
  119844. adjustPitch: number;
  119845. /**
  119846. * Used to make an adjustment to the roll of the bone
  119847. */
  119848. adjustRoll: number;
  119849. /**
  119850. * 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)
  119851. */
  119852. slerpAmount: number;
  119853. private _minYaw;
  119854. private _maxYaw;
  119855. private _minPitch;
  119856. private _maxPitch;
  119857. private _minYawSin;
  119858. private _minYawCos;
  119859. private _maxYawSin;
  119860. private _maxYawCos;
  119861. private _midYawConstraint;
  119862. private _minPitchTan;
  119863. private _maxPitchTan;
  119864. private _boneQuat;
  119865. private _slerping;
  119866. private _transformYawPitch;
  119867. private _transformYawPitchInv;
  119868. private _firstFrameSkipped;
  119869. private _yawRange;
  119870. private _fowardAxis;
  119871. /**
  119872. * Gets or sets the minimum yaw angle that the bone can look to
  119873. */
  119874. get minYaw(): number;
  119875. set minYaw(value: number);
  119876. /**
  119877. * Gets or sets the maximum yaw angle that the bone can look to
  119878. */
  119879. get maxYaw(): number;
  119880. set maxYaw(value: number);
  119881. /**
  119882. * Gets or sets the minimum pitch angle that the bone can look to
  119883. */
  119884. get minPitch(): number;
  119885. set minPitch(value: number);
  119886. /**
  119887. * Gets or sets the maximum pitch angle that the bone can look to
  119888. */
  119889. get maxPitch(): number;
  119890. set maxPitch(value: number);
  119891. /**
  119892. * Create a BoneLookController
  119893. * @param mesh the mesh that the bone belongs to
  119894. * @param bone the bone that will be looking to the target
  119895. * @param target the target Vector3 to look at
  119896. * @param options optional settings:
  119897. * * maxYaw: the maximum angle the bone will yaw to
  119898. * * minYaw: the minimum angle the bone will yaw to
  119899. * * maxPitch: the maximum angle the bone will pitch to
  119900. * * minPitch: the minimum angle the bone will yaw to
  119901. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  119902. * * upAxis: the up axis of the coordinate system
  119903. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  119904. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  119905. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  119906. * * adjustYaw: used to make an adjustment to the yaw of the bone
  119907. * * adjustPitch: used to make an adjustment to the pitch of the bone
  119908. * * adjustRoll: used to make an adjustment to the roll of the bone
  119909. **/
  119910. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  119911. maxYaw?: number;
  119912. minYaw?: number;
  119913. maxPitch?: number;
  119914. minPitch?: number;
  119915. slerpAmount?: number;
  119916. upAxis?: Vector3;
  119917. upAxisSpace?: Space;
  119918. yawAxis?: Vector3;
  119919. pitchAxis?: Vector3;
  119920. adjustYaw?: number;
  119921. adjustPitch?: number;
  119922. adjustRoll?: number;
  119923. });
  119924. /**
  119925. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  119926. */
  119927. update(): void;
  119928. private _getAngleDiff;
  119929. private _getAngleBetween;
  119930. private _isAngleBetween;
  119931. }
  119932. }
  119933. declare module BABYLON {
  119934. /**
  119935. * Manage the gamepad inputs to control an arc rotate camera.
  119936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119937. */
  119938. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  119939. /**
  119940. * Defines the camera the input is attached to.
  119941. */
  119942. camera: ArcRotateCamera;
  119943. /**
  119944. * Defines the gamepad the input is gathering event from.
  119945. */
  119946. gamepad: Nullable<Gamepad>;
  119947. /**
  119948. * Defines the gamepad rotation sensiblity.
  119949. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  119950. */
  119951. gamepadRotationSensibility: number;
  119952. /**
  119953. * Defines the gamepad move sensiblity.
  119954. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  119955. */
  119956. gamepadMoveSensibility: number;
  119957. private _yAxisScale;
  119958. /**
  119959. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  119960. */
  119961. get invertYAxis(): boolean;
  119962. set invertYAxis(value: boolean);
  119963. private _onGamepadConnectedObserver;
  119964. private _onGamepadDisconnectedObserver;
  119965. /**
  119966. * Attach the input controls to a specific dom element to get the input from.
  119967. * @param element Defines the element the controls should be listened from
  119968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119969. */
  119970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119971. /**
  119972. * Detach the current controls from the specified dom element.
  119973. * @param element Defines the element to stop listening the inputs from
  119974. */
  119975. detachControl(element: Nullable<HTMLElement>): void;
  119976. /**
  119977. * Update the current camera state depending on the inputs that have been used this frame.
  119978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119979. */
  119980. checkInputs(): void;
  119981. /**
  119982. * Gets the class name of the current intput.
  119983. * @returns the class name
  119984. */
  119985. getClassName(): string;
  119986. /**
  119987. * Get the friendly name associated with the input class.
  119988. * @returns the input friendly name
  119989. */
  119990. getSimpleName(): string;
  119991. }
  119992. }
  119993. declare module BABYLON {
  119994. interface ArcRotateCameraInputsManager {
  119995. /**
  119996. * Add orientation input support to the input manager.
  119997. * @returns the current input manager
  119998. */
  119999. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120000. }
  120001. /**
  120002. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120004. */
  120005. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120006. /**
  120007. * Defines the camera the input is attached to.
  120008. */
  120009. camera: ArcRotateCamera;
  120010. /**
  120011. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120012. */
  120013. alphaCorrection: number;
  120014. /**
  120015. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120016. */
  120017. gammaCorrection: number;
  120018. private _alpha;
  120019. private _gamma;
  120020. private _dirty;
  120021. private _deviceOrientationHandler;
  120022. /**
  120023. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120024. */
  120025. constructor();
  120026. /**
  120027. * Attach the input controls to a specific dom element to get the input from.
  120028. * @param element Defines the element the controls should be listened from
  120029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120030. */
  120031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120032. /** @hidden */
  120033. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120034. /**
  120035. * Update the current camera state depending on the inputs that have been used this frame.
  120036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120037. */
  120038. checkInputs(): void;
  120039. /**
  120040. * Detach the current controls from the specified dom element.
  120041. * @param element Defines the element to stop listening the inputs from
  120042. */
  120043. detachControl(element: Nullable<HTMLElement>): void;
  120044. /**
  120045. * Gets the class name of the current intput.
  120046. * @returns the class name
  120047. */
  120048. getClassName(): string;
  120049. /**
  120050. * Get the friendly name associated with the input class.
  120051. * @returns the input friendly name
  120052. */
  120053. getSimpleName(): string;
  120054. }
  120055. }
  120056. declare module BABYLON {
  120057. /**
  120058. * Listen to mouse events to control the camera.
  120059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120060. */
  120061. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120062. /**
  120063. * Defines the camera the input is attached to.
  120064. */
  120065. camera: FlyCamera;
  120066. /**
  120067. * Defines if touch is enabled. (Default is true.)
  120068. */
  120069. touchEnabled: boolean;
  120070. /**
  120071. * Defines the buttons associated with the input to handle camera rotation.
  120072. */
  120073. buttons: number[];
  120074. /**
  120075. * Assign buttons for Yaw control.
  120076. */
  120077. buttonsYaw: number[];
  120078. /**
  120079. * Assign buttons for Pitch control.
  120080. */
  120081. buttonsPitch: number[];
  120082. /**
  120083. * Assign buttons for Roll control.
  120084. */
  120085. buttonsRoll: number[];
  120086. /**
  120087. * Detect if any button is being pressed while mouse is moved.
  120088. * -1 = Mouse locked.
  120089. * 0 = Left button.
  120090. * 1 = Middle Button.
  120091. * 2 = Right Button.
  120092. */
  120093. activeButton: number;
  120094. /**
  120095. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120096. * Higher values reduce its sensitivity.
  120097. */
  120098. angularSensibility: number;
  120099. private _mousemoveCallback;
  120100. private _observer;
  120101. private _rollObserver;
  120102. private previousPosition;
  120103. private noPreventDefault;
  120104. private element;
  120105. /**
  120106. * Listen to mouse events to control the camera.
  120107. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120109. */
  120110. constructor(touchEnabled?: boolean);
  120111. /**
  120112. * Attach the mouse control to the HTML DOM element.
  120113. * @param element Defines the element that listens to the input events.
  120114. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120115. */
  120116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120117. /**
  120118. * Detach the current controls from the specified dom element.
  120119. * @param element Defines the element to stop listening the inputs from
  120120. */
  120121. detachControl(element: Nullable<HTMLElement>): void;
  120122. /**
  120123. * Gets the class name of the current input.
  120124. * @returns the class name.
  120125. */
  120126. getClassName(): string;
  120127. /**
  120128. * Get the friendly name associated with the input class.
  120129. * @returns the input's friendly name.
  120130. */
  120131. getSimpleName(): string;
  120132. private _pointerInput;
  120133. private _onMouseMove;
  120134. /**
  120135. * Rotate camera by mouse offset.
  120136. */
  120137. private rotateCamera;
  120138. }
  120139. }
  120140. declare module BABYLON {
  120141. /**
  120142. * Default Inputs manager for the FlyCamera.
  120143. * It groups all the default supported inputs for ease of use.
  120144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120145. */
  120146. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120147. /**
  120148. * Instantiates a new FlyCameraInputsManager.
  120149. * @param camera Defines the camera the inputs belong to.
  120150. */
  120151. constructor(camera: FlyCamera);
  120152. /**
  120153. * Add keyboard input support to the input manager.
  120154. * @returns the new FlyCameraKeyboardMoveInput().
  120155. */
  120156. addKeyboard(): FlyCameraInputsManager;
  120157. /**
  120158. * Add mouse input support to the input manager.
  120159. * @param touchEnabled Enable touch screen support.
  120160. * @returns the new FlyCameraMouseInput().
  120161. */
  120162. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120163. }
  120164. }
  120165. declare module BABYLON {
  120166. /**
  120167. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120168. * such as in a 3D Space Shooter or a Flight Simulator.
  120169. */
  120170. export class FlyCamera extends TargetCamera {
  120171. /**
  120172. * Define the collision ellipsoid of the camera.
  120173. * This is helpful for simulating a camera body, like a player's body.
  120174. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120175. */
  120176. ellipsoid: Vector3;
  120177. /**
  120178. * Define an offset for the position of the ellipsoid around the camera.
  120179. * This can be helpful if the camera is attached away from the player's body center,
  120180. * such as at its head.
  120181. */
  120182. ellipsoidOffset: Vector3;
  120183. /**
  120184. * Enable or disable collisions of the camera with the rest of the scene objects.
  120185. */
  120186. checkCollisions: boolean;
  120187. /**
  120188. * Enable or disable gravity on the camera.
  120189. */
  120190. applyGravity: boolean;
  120191. /**
  120192. * Define the current direction the camera is moving to.
  120193. */
  120194. cameraDirection: Vector3;
  120195. /**
  120196. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120197. * This overrides and empties cameraRotation.
  120198. */
  120199. rotationQuaternion: Quaternion;
  120200. /**
  120201. * Track Roll to maintain the wanted Rolling when looking around.
  120202. */
  120203. _trackRoll: number;
  120204. /**
  120205. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120206. */
  120207. rollCorrect: number;
  120208. /**
  120209. * Mimic a banked turn, Rolling the camera when Yawing.
  120210. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120211. */
  120212. bankedTurn: boolean;
  120213. /**
  120214. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120215. */
  120216. bankedTurnLimit: number;
  120217. /**
  120218. * Value of 0 disables the banked Roll.
  120219. * Value of 1 is equal to the Yaw angle in radians.
  120220. */
  120221. bankedTurnMultiplier: number;
  120222. /**
  120223. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120224. */
  120225. inputs: FlyCameraInputsManager;
  120226. /**
  120227. * Gets the input sensibility for mouse input.
  120228. * Higher values reduce sensitivity.
  120229. */
  120230. get angularSensibility(): number;
  120231. /**
  120232. * Sets the input sensibility for a mouse input.
  120233. * Higher values reduce sensitivity.
  120234. */
  120235. set angularSensibility(value: number);
  120236. /**
  120237. * Get the keys for camera movement forward.
  120238. */
  120239. get keysForward(): number[];
  120240. /**
  120241. * Set the keys for camera movement forward.
  120242. */
  120243. set keysForward(value: number[]);
  120244. /**
  120245. * Get the keys for camera movement backward.
  120246. */
  120247. get keysBackward(): number[];
  120248. set keysBackward(value: number[]);
  120249. /**
  120250. * Get the keys for camera movement up.
  120251. */
  120252. get keysUp(): number[];
  120253. /**
  120254. * Set the keys for camera movement up.
  120255. */
  120256. set keysUp(value: number[]);
  120257. /**
  120258. * Get the keys for camera movement down.
  120259. */
  120260. get keysDown(): number[];
  120261. /**
  120262. * Set the keys for camera movement down.
  120263. */
  120264. set keysDown(value: number[]);
  120265. /**
  120266. * Get the keys for camera movement left.
  120267. */
  120268. get keysLeft(): number[];
  120269. /**
  120270. * Set the keys for camera movement left.
  120271. */
  120272. set keysLeft(value: number[]);
  120273. /**
  120274. * Set the keys for camera movement right.
  120275. */
  120276. get keysRight(): number[];
  120277. /**
  120278. * Set the keys for camera movement right.
  120279. */
  120280. set keysRight(value: number[]);
  120281. /**
  120282. * Event raised when the camera collides with a mesh in the scene.
  120283. */
  120284. onCollide: (collidedMesh: AbstractMesh) => void;
  120285. private _collider;
  120286. private _needMoveForGravity;
  120287. private _oldPosition;
  120288. private _diffPosition;
  120289. private _newPosition;
  120290. /** @hidden */
  120291. _localDirection: Vector3;
  120292. /** @hidden */
  120293. _transformedDirection: Vector3;
  120294. /**
  120295. * Instantiates a FlyCamera.
  120296. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120297. * such as in a 3D Space Shooter or a Flight Simulator.
  120298. * @param name Define the name of the camera in the scene.
  120299. * @param position Define the starting position of the camera in the scene.
  120300. * @param scene Define the scene the camera belongs to.
  120301. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  120302. */
  120303. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120304. /**
  120305. * Attach a control to the HTML DOM element.
  120306. * @param element Defines the element that listens to the input events.
  120307. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  120308. */
  120309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120310. /**
  120311. * Detach a control from the HTML DOM element.
  120312. * The camera will stop reacting to that input.
  120313. * @param element Defines the element that listens to the input events.
  120314. */
  120315. detachControl(element: HTMLElement): void;
  120316. private _collisionMask;
  120317. /**
  120318. * Get the mask that the camera ignores in collision events.
  120319. */
  120320. get collisionMask(): number;
  120321. /**
  120322. * Set the mask that the camera ignores in collision events.
  120323. */
  120324. set collisionMask(mask: number);
  120325. /** @hidden */
  120326. _collideWithWorld(displacement: Vector3): void;
  120327. /** @hidden */
  120328. private _onCollisionPositionChange;
  120329. /** @hidden */
  120330. _checkInputs(): void;
  120331. /** @hidden */
  120332. _decideIfNeedsToMove(): boolean;
  120333. /** @hidden */
  120334. _updatePosition(): void;
  120335. /**
  120336. * Restore the Roll to its target value at the rate specified.
  120337. * @param rate - Higher means slower restoring.
  120338. * @hidden
  120339. */
  120340. restoreRoll(rate: number): void;
  120341. /**
  120342. * Destroy the camera and release the current resources held by it.
  120343. */
  120344. dispose(): void;
  120345. /**
  120346. * Get the current object class name.
  120347. * @returns the class name.
  120348. */
  120349. getClassName(): string;
  120350. }
  120351. }
  120352. declare module BABYLON {
  120353. /**
  120354. * Listen to keyboard events to control the camera.
  120355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120356. */
  120357. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  120358. /**
  120359. * Defines the camera the input is attached to.
  120360. */
  120361. camera: FlyCamera;
  120362. /**
  120363. * The list of keyboard keys used to control the forward move of the camera.
  120364. */
  120365. keysForward: number[];
  120366. /**
  120367. * The list of keyboard keys used to control the backward move of the camera.
  120368. */
  120369. keysBackward: number[];
  120370. /**
  120371. * The list of keyboard keys used to control the forward move of the camera.
  120372. */
  120373. keysUp: number[];
  120374. /**
  120375. * The list of keyboard keys used to control the backward move of the camera.
  120376. */
  120377. keysDown: number[];
  120378. /**
  120379. * The list of keyboard keys used to control the right strafe move of the camera.
  120380. */
  120381. keysRight: number[];
  120382. /**
  120383. * The list of keyboard keys used to control the left strafe move of the camera.
  120384. */
  120385. keysLeft: number[];
  120386. private _keys;
  120387. private _onCanvasBlurObserver;
  120388. private _onKeyboardObserver;
  120389. private _engine;
  120390. private _scene;
  120391. /**
  120392. * Attach the input controls to a specific dom element to get the input from.
  120393. * @param element Defines the element the controls should be listened from
  120394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120395. */
  120396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120397. /**
  120398. * Detach the current controls from the specified dom element.
  120399. * @param element Defines the element to stop listening the inputs from
  120400. */
  120401. detachControl(element: Nullable<HTMLElement>): void;
  120402. /**
  120403. * Gets the class name of the current intput.
  120404. * @returns the class name
  120405. */
  120406. getClassName(): string;
  120407. /** @hidden */
  120408. _onLostFocus(e: FocusEvent): void;
  120409. /**
  120410. * Get the friendly name associated with the input class.
  120411. * @returns the input friendly name
  120412. */
  120413. getSimpleName(): string;
  120414. /**
  120415. * Update the current camera state depending on the inputs that have been used this frame.
  120416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120417. */
  120418. checkInputs(): void;
  120419. }
  120420. }
  120421. declare module BABYLON {
  120422. /**
  120423. * Manage the mouse wheel inputs to control a follow camera.
  120424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120425. */
  120426. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  120427. /**
  120428. * Defines the camera the input is attached to.
  120429. */
  120430. camera: FollowCamera;
  120431. /**
  120432. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  120433. */
  120434. axisControlRadius: boolean;
  120435. /**
  120436. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  120437. */
  120438. axisControlHeight: boolean;
  120439. /**
  120440. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  120441. */
  120442. axisControlRotation: boolean;
  120443. /**
  120444. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  120445. * relation to mouseWheel events.
  120446. */
  120447. wheelPrecision: number;
  120448. /**
  120449. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120450. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120451. */
  120452. wheelDeltaPercentage: number;
  120453. private _wheel;
  120454. private _observer;
  120455. /**
  120456. * Attach the input controls to a specific dom element to get the input from.
  120457. * @param element Defines the element the controls should be listened from
  120458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120459. */
  120460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120461. /**
  120462. * Detach the current controls from the specified dom element.
  120463. * @param element Defines the element to stop listening the inputs from
  120464. */
  120465. detachControl(element: Nullable<HTMLElement>): void;
  120466. /**
  120467. * Gets the class name of the current intput.
  120468. * @returns the class name
  120469. */
  120470. getClassName(): string;
  120471. /**
  120472. * Get the friendly name associated with the input class.
  120473. * @returns the input friendly name
  120474. */
  120475. getSimpleName(): string;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. /**
  120480. * Manage the pointers inputs to control an follow camera.
  120481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120482. */
  120483. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  120484. /**
  120485. * Defines the camera the input is attached to.
  120486. */
  120487. camera: FollowCamera;
  120488. /**
  120489. * Gets the class name of the current input.
  120490. * @returns the class name
  120491. */
  120492. getClassName(): string;
  120493. /**
  120494. * Defines the pointer angular sensibility along the X axis or how fast is
  120495. * the camera rotating.
  120496. * A negative number will reverse the axis direction.
  120497. */
  120498. angularSensibilityX: number;
  120499. /**
  120500. * Defines the pointer angular sensibility along the Y axis or how fast is
  120501. * the camera rotating.
  120502. * A negative number will reverse the axis direction.
  120503. */
  120504. angularSensibilityY: number;
  120505. /**
  120506. * Defines the pointer pinch precision or how fast is the camera zooming.
  120507. * A negative number will reverse the axis direction.
  120508. */
  120509. pinchPrecision: number;
  120510. /**
  120511. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120512. * from 0.
  120513. * It defines the percentage of current camera.radius to use as delta when
  120514. * pinch zoom is used.
  120515. */
  120516. pinchDeltaPercentage: number;
  120517. /**
  120518. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  120519. */
  120520. axisXControlRadius: boolean;
  120521. /**
  120522. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  120523. */
  120524. axisXControlHeight: boolean;
  120525. /**
  120526. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  120527. */
  120528. axisXControlRotation: boolean;
  120529. /**
  120530. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  120531. */
  120532. axisYControlRadius: boolean;
  120533. /**
  120534. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  120535. */
  120536. axisYControlHeight: boolean;
  120537. /**
  120538. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  120539. */
  120540. axisYControlRotation: boolean;
  120541. /**
  120542. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  120543. */
  120544. axisPinchControlRadius: boolean;
  120545. /**
  120546. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  120547. */
  120548. axisPinchControlHeight: boolean;
  120549. /**
  120550. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  120551. */
  120552. axisPinchControlRotation: boolean;
  120553. /**
  120554. * Log error messages if basic misconfiguration has occurred.
  120555. */
  120556. warningEnable: boolean;
  120557. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120558. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120559. private _warningCounter;
  120560. private _warning;
  120561. }
  120562. }
  120563. declare module BABYLON {
  120564. /**
  120565. * Default Inputs manager for the FollowCamera.
  120566. * It groups all the default supported inputs for ease of use.
  120567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120568. */
  120569. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  120570. /**
  120571. * Instantiates a new FollowCameraInputsManager.
  120572. * @param camera Defines the camera the inputs belong to
  120573. */
  120574. constructor(camera: FollowCamera);
  120575. /**
  120576. * Add keyboard input support to the input manager.
  120577. * @returns the current input manager
  120578. */
  120579. addKeyboard(): FollowCameraInputsManager;
  120580. /**
  120581. * Add mouse wheel input support to the input manager.
  120582. * @returns the current input manager
  120583. */
  120584. addMouseWheel(): FollowCameraInputsManager;
  120585. /**
  120586. * Add pointers input support to the input manager.
  120587. * @returns the current input manager
  120588. */
  120589. addPointers(): FollowCameraInputsManager;
  120590. /**
  120591. * Add orientation input support to the input manager.
  120592. * @returns the current input manager
  120593. */
  120594. addVRDeviceOrientation(): FollowCameraInputsManager;
  120595. }
  120596. }
  120597. declare module BABYLON {
  120598. /**
  120599. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  120600. * an arc rotate version arcFollowCamera are available.
  120601. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120602. */
  120603. export class FollowCamera extends TargetCamera {
  120604. /**
  120605. * Distance the follow camera should follow an object at
  120606. */
  120607. radius: number;
  120608. /**
  120609. * Minimum allowed distance of the camera to the axis of rotation
  120610. * (The camera can not get closer).
  120611. * This can help limiting how the Camera is able to move in the scene.
  120612. */
  120613. lowerRadiusLimit: Nullable<number>;
  120614. /**
  120615. * Maximum allowed distance of the camera to the axis of rotation
  120616. * (The camera can not get further).
  120617. * This can help limiting how the Camera is able to move in the scene.
  120618. */
  120619. upperRadiusLimit: Nullable<number>;
  120620. /**
  120621. * Define a rotation offset between the camera and the object it follows
  120622. */
  120623. rotationOffset: number;
  120624. /**
  120625. * Minimum allowed angle to camera position relative to target object.
  120626. * This can help limiting how the Camera is able to move in the scene.
  120627. */
  120628. lowerRotationOffsetLimit: Nullable<number>;
  120629. /**
  120630. * Maximum allowed angle to camera position relative to target object.
  120631. * This can help limiting how the Camera is able to move in the scene.
  120632. */
  120633. upperRotationOffsetLimit: Nullable<number>;
  120634. /**
  120635. * Define a height offset between the camera and the object it follows.
  120636. * It can help following an object from the top (like a car chaing a plane)
  120637. */
  120638. heightOffset: number;
  120639. /**
  120640. * Minimum allowed height of camera position relative to target object.
  120641. * This can help limiting how the Camera is able to move in the scene.
  120642. */
  120643. lowerHeightOffsetLimit: Nullable<number>;
  120644. /**
  120645. * Maximum allowed height of camera position relative to target object.
  120646. * This can help limiting how the Camera is able to move in the scene.
  120647. */
  120648. upperHeightOffsetLimit: Nullable<number>;
  120649. /**
  120650. * Define how fast the camera can accelerate to follow it s target.
  120651. */
  120652. cameraAcceleration: number;
  120653. /**
  120654. * Define the speed limit of the camera following an object.
  120655. */
  120656. maxCameraSpeed: number;
  120657. /**
  120658. * Define the target of the camera.
  120659. */
  120660. lockedTarget: Nullable<AbstractMesh>;
  120661. /**
  120662. * Defines the input associated with the camera.
  120663. */
  120664. inputs: FollowCameraInputsManager;
  120665. /**
  120666. * Instantiates the follow camera.
  120667. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120668. * @param name Define the name of the camera in the scene
  120669. * @param position Define the position of the camera
  120670. * @param scene Define the scene the camera belong to
  120671. * @param lockedTarget Define the target of the camera
  120672. */
  120673. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  120674. private _follow;
  120675. /**
  120676. * Attached controls to the current camera.
  120677. * @param element Defines the element the controls should be listened from
  120678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120679. */
  120680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120681. /**
  120682. * Detach the current controls from the camera.
  120683. * The camera will stop reacting to inputs.
  120684. * @param element Defines the element to stop listening the inputs from
  120685. */
  120686. detachControl(element: HTMLElement): void;
  120687. /** @hidden */
  120688. _checkInputs(): void;
  120689. private _checkLimits;
  120690. /**
  120691. * Gets the camera class name.
  120692. * @returns the class name
  120693. */
  120694. getClassName(): string;
  120695. }
  120696. /**
  120697. * Arc Rotate version of the follow camera.
  120698. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  120699. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120700. */
  120701. export class ArcFollowCamera extends TargetCamera {
  120702. /** The longitudinal angle of the camera */
  120703. alpha: number;
  120704. /** The latitudinal angle of the camera */
  120705. beta: number;
  120706. /** The radius of the camera from its target */
  120707. radius: number;
  120708. /** Define the camera target (the messh it should follow) */
  120709. target: Nullable<AbstractMesh>;
  120710. private _cartesianCoordinates;
  120711. /**
  120712. * Instantiates a new ArcFollowCamera
  120713. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120714. * @param name Define the name of the camera
  120715. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  120716. * @param beta Define the rotation angle of the camera around the elevation axis
  120717. * @param radius Define the radius of the camera from its target point
  120718. * @param target Define the target of the camera
  120719. * @param scene Define the scene the camera belongs to
  120720. */
  120721. constructor(name: string,
  120722. /** The longitudinal angle of the camera */
  120723. alpha: number,
  120724. /** The latitudinal angle of the camera */
  120725. beta: number,
  120726. /** The radius of the camera from its target */
  120727. radius: number,
  120728. /** Define the camera target (the messh it should follow) */
  120729. target: Nullable<AbstractMesh>, scene: Scene);
  120730. private _follow;
  120731. /** @hidden */
  120732. _checkInputs(): void;
  120733. /**
  120734. * Returns the class name of the object.
  120735. * It is mostly used internally for serialization purposes.
  120736. */
  120737. getClassName(): string;
  120738. }
  120739. }
  120740. declare module BABYLON {
  120741. /**
  120742. * Manage the keyboard inputs to control the movement of a follow camera.
  120743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120744. */
  120745. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  120746. /**
  120747. * Defines the camera the input is attached to.
  120748. */
  120749. camera: FollowCamera;
  120750. /**
  120751. * Defines the list of key codes associated with the up action (increase heightOffset)
  120752. */
  120753. keysHeightOffsetIncr: number[];
  120754. /**
  120755. * Defines the list of key codes associated with the down action (decrease heightOffset)
  120756. */
  120757. keysHeightOffsetDecr: number[];
  120758. /**
  120759. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  120760. */
  120761. keysHeightOffsetModifierAlt: boolean;
  120762. /**
  120763. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  120764. */
  120765. keysHeightOffsetModifierCtrl: boolean;
  120766. /**
  120767. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  120768. */
  120769. keysHeightOffsetModifierShift: boolean;
  120770. /**
  120771. * Defines the list of key codes associated with the left action (increase rotationOffset)
  120772. */
  120773. keysRotationOffsetIncr: number[];
  120774. /**
  120775. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  120776. */
  120777. keysRotationOffsetDecr: number[];
  120778. /**
  120779. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  120780. */
  120781. keysRotationOffsetModifierAlt: boolean;
  120782. /**
  120783. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  120784. */
  120785. keysRotationOffsetModifierCtrl: boolean;
  120786. /**
  120787. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  120788. */
  120789. keysRotationOffsetModifierShift: boolean;
  120790. /**
  120791. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  120792. */
  120793. keysRadiusIncr: number[];
  120794. /**
  120795. * Defines the list of key codes associated with the zoom-out action (increase radius)
  120796. */
  120797. keysRadiusDecr: number[];
  120798. /**
  120799. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  120800. */
  120801. keysRadiusModifierAlt: boolean;
  120802. /**
  120803. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  120804. */
  120805. keysRadiusModifierCtrl: boolean;
  120806. /**
  120807. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  120808. */
  120809. keysRadiusModifierShift: boolean;
  120810. /**
  120811. * Defines the rate of change of heightOffset.
  120812. */
  120813. heightSensibility: number;
  120814. /**
  120815. * Defines the rate of change of rotationOffset.
  120816. */
  120817. rotationSensibility: number;
  120818. /**
  120819. * Defines the rate of change of radius.
  120820. */
  120821. radiusSensibility: number;
  120822. private _keys;
  120823. private _ctrlPressed;
  120824. private _altPressed;
  120825. private _shiftPressed;
  120826. private _onCanvasBlurObserver;
  120827. private _onKeyboardObserver;
  120828. private _engine;
  120829. private _scene;
  120830. /**
  120831. * Attach the input controls to a specific dom element to get the input from.
  120832. * @param element Defines the element the controls should be listened from
  120833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120834. */
  120835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120836. /**
  120837. * Detach the current controls from the specified dom element.
  120838. * @param element Defines the element to stop listening the inputs from
  120839. */
  120840. detachControl(element: Nullable<HTMLElement>): void;
  120841. /**
  120842. * Update the current camera state depending on the inputs that have been used this frame.
  120843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120844. */
  120845. checkInputs(): void;
  120846. /**
  120847. * Gets the class name of the current input.
  120848. * @returns the class name
  120849. */
  120850. getClassName(): string;
  120851. /**
  120852. * Get the friendly name associated with the input class.
  120853. * @returns the input friendly name
  120854. */
  120855. getSimpleName(): string;
  120856. /**
  120857. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120858. * allow modification of the heightOffset value.
  120859. */
  120860. private _modifierHeightOffset;
  120861. /**
  120862. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120863. * allow modification of the rotationOffset value.
  120864. */
  120865. private _modifierRotationOffset;
  120866. /**
  120867. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120868. * allow modification of the radius value.
  120869. */
  120870. private _modifierRadius;
  120871. }
  120872. }
  120873. declare module BABYLON {
  120874. interface FreeCameraInputsManager {
  120875. /**
  120876. * @hidden
  120877. */
  120878. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  120879. /**
  120880. * Add orientation input support to the input manager.
  120881. * @returns the current input manager
  120882. */
  120883. addDeviceOrientation(): FreeCameraInputsManager;
  120884. }
  120885. /**
  120886. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  120887. * Screen rotation is taken into account.
  120888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120889. */
  120890. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  120891. private _camera;
  120892. private _screenOrientationAngle;
  120893. private _constantTranform;
  120894. private _screenQuaternion;
  120895. private _alpha;
  120896. private _beta;
  120897. private _gamma;
  120898. /**
  120899. * Can be used to detect if a device orientation sensor is available on a device
  120900. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  120901. * @returns a promise that will resolve on orientation change
  120902. */
  120903. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  120904. /**
  120905. * @hidden
  120906. */
  120907. _onDeviceOrientationChangedObservable: Observable<void>;
  120908. /**
  120909. * Instantiates a new input
  120910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120911. */
  120912. constructor();
  120913. /**
  120914. * Define the camera controlled by the input.
  120915. */
  120916. get camera(): FreeCamera;
  120917. set camera(camera: FreeCamera);
  120918. /**
  120919. * Attach the input controls to a specific dom element to get the input from.
  120920. * @param element Defines the element the controls should be listened from
  120921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120922. */
  120923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120924. private _orientationChanged;
  120925. private _deviceOrientation;
  120926. /**
  120927. * Detach the current controls from the specified dom element.
  120928. * @param element Defines the element to stop listening the inputs from
  120929. */
  120930. detachControl(element: Nullable<HTMLElement>): void;
  120931. /**
  120932. * Update the current camera state depending on the inputs that have been used this frame.
  120933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120934. */
  120935. checkInputs(): void;
  120936. /**
  120937. * Gets the class name of the current intput.
  120938. * @returns the class name
  120939. */
  120940. getClassName(): string;
  120941. /**
  120942. * Get the friendly name associated with the input class.
  120943. * @returns the input friendly name
  120944. */
  120945. getSimpleName(): string;
  120946. }
  120947. }
  120948. declare module BABYLON {
  120949. /**
  120950. * Manage the gamepad inputs to control a free camera.
  120951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120952. */
  120953. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  120954. /**
  120955. * Define the camera the input is attached to.
  120956. */
  120957. camera: FreeCamera;
  120958. /**
  120959. * Define the Gamepad controlling the input
  120960. */
  120961. gamepad: Nullable<Gamepad>;
  120962. /**
  120963. * Defines the gamepad rotation sensiblity.
  120964. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120965. */
  120966. gamepadAngularSensibility: number;
  120967. /**
  120968. * Defines the gamepad move sensiblity.
  120969. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120970. */
  120971. gamepadMoveSensibility: number;
  120972. private _yAxisScale;
  120973. /**
  120974. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120975. */
  120976. get invertYAxis(): boolean;
  120977. set invertYAxis(value: boolean);
  120978. private _onGamepadConnectedObserver;
  120979. private _onGamepadDisconnectedObserver;
  120980. private _cameraTransform;
  120981. private _deltaTransform;
  120982. private _vector3;
  120983. private _vector2;
  120984. /**
  120985. * Attach the input controls to a specific dom element to get the input from.
  120986. * @param element Defines the element the controls should be listened from
  120987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120988. */
  120989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120990. /**
  120991. * Detach the current controls from the specified dom element.
  120992. * @param element Defines the element to stop listening the inputs from
  120993. */
  120994. detachControl(element: Nullable<HTMLElement>): void;
  120995. /**
  120996. * Update the current camera state depending on the inputs that have been used this frame.
  120997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120998. */
  120999. checkInputs(): void;
  121000. /**
  121001. * Gets the class name of the current intput.
  121002. * @returns the class name
  121003. */
  121004. getClassName(): string;
  121005. /**
  121006. * Get the friendly name associated with the input class.
  121007. * @returns the input friendly name
  121008. */
  121009. getSimpleName(): string;
  121010. }
  121011. }
  121012. declare module BABYLON {
  121013. /**
  121014. * Defines the potential axis of a Joystick
  121015. */
  121016. export enum JoystickAxis {
  121017. /** X axis */
  121018. X = 0,
  121019. /** Y axis */
  121020. Y = 1,
  121021. /** Z axis */
  121022. Z = 2
  121023. }
  121024. /**
  121025. * Class used to define virtual joystick (used in touch mode)
  121026. */
  121027. export class VirtualJoystick {
  121028. /**
  121029. * Gets or sets a boolean indicating that left and right values must be inverted
  121030. */
  121031. reverseLeftRight: boolean;
  121032. /**
  121033. * Gets or sets a boolean indicating that up and down values must be inverted
  121034. */
  121035. reverseUpDown: boolean;
  121036. /**
  121037. * Gets the offset value for the position (ie. the change of the position value)
  121038. */
  121039. deltaPosition: Vector3;
  121040. /**
  121041. * Gets a boolean indicating if the virtual joystick was pressed
  121042. */
  121043. pressed: boolean;
  121044. /**
  121045. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121046. */
  121047. static Canvas: Nullable<HTMLCanvasElement>;
  121048. private static _globalJoystickIndex;
  121049. private static vjCanvasContext;
  121050. private static vjCanvasWidth;
  121051. private static vjCanvasHeight;
  121052. private static halfWidth;
  121053. private _action;
  121054. private _axisTargetedByLeftAndRight;
  121055. private _axisTargetedByUpAndDown;
  121056. private _joystickSensibility;
  121057. private _inversedSensibility;
  121058. private _joystickPointerID;
  121059. private _joystickColor;
  121060. private _joystickPointerPos;
  121061. private _joystickPreviousPointerPos;
  121062. private _joystickPointerStartPos;
  121063. private _deltaJoystickVector;
  121064. private _leftJoystick;
  121065. private _touches;
  121066. private _onPointerDownHandlerRef;
  121067. private _onPointerMoveHandlerRef;
  121068. private _onPointerUpHandlerRef;
  121069. private _onResize;
  121070. /**
  121071. * Creates a new virtual joystick
  121072. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121073. */
  121074. constructor(leftJoystick?: boolean);
  121075. /**
  121076. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121077. * @param newJoystickSensibility defines the new sensibility
  121078. */
  121079. setJoystickSensibility(newJoystickSensibility: number): void;
  121080. private _onPointerDown;
  121081. private _onPointerMove;
  121082. private _onPointerUp;
  121083. /**
  121084. * Change the color of the virtual joystick
  121085. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121086. */
  121087. setJoystickColor(newColor: string): void;
  121088. /**
  121089. * Defines a callback to call when the joystick is touched
  121090. * @param action defines the callback
  121091. */
  121092. setActionOnTouch(action: () => any): void;
  121093. /**
  121094. * Defines which axis you'd like to control for left & right
  121095. * @param axis defines the axis to use
  121096. */
  121097. setAxisForLeftRight(axis: JoystickAxis): void;
  121098. /**
  121099. * Defines which axis you'd like to control for up & down
  121100. * @param axis defines the axis to use
  121101. */
  121102. setAxisForUpDown(axis: JoystickAxis): void;
  121103. private _drawVirtualJoystick;
  121104. /**
  121105. * Release internal HTML canvas
  121106. */
  121107. releaseCanvas(): void;
  121108. }
  121109. }
  121110. declare module BABYLON {
  121111. interface FreeCameraInputsManager {
  121112. /**
  121113. * Add virtual joystick input support to the input manager.
  121114. * @returns the current input manager
  121115. */
  121116. addVirtualJoystick(): FreeCameraInputsManager;
  121117. }
  121118. /**
  121119. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121121. */
  121122. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121123. /**
  121124. * Defines the camera the input is attached to.
  121125. */
  121126. camera: FreeCamera;
  121127. private _leftjoystick;
  121128. private _rightjoystick;
  121129. /**
  121130. * Gets the left stick of the virtual joystick.
  121131. * @returns The virtual Joystick
  121132. */
  121133. getLeftJoystick(): VirtualJoystick;
  121134. /**
  121135. * Gets the right stick of the virtual joystick.
  121136. * @returns The virtual Joystick
  121137. */
  121138. getRightJoystick(): VirtualJoystick;
  121139. /**
  121140. * Update the current camera state depending on the inputs that have been used this frame.
  121141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121142. */
  121143. checkInputs(): void;
  121144. /**
  121145. * Attach the input controls to a specific dom element to get the input from.
  121146. * @param element Defines the element the controls should be listened from
  121147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121148. */
  121149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121150. /**
  121151. * Detach the current controls from the specified dom element.
  121152. * @param element Defines the element to stop listening the inputs from
  121153. */
  121154. detachControl(element: Nullable<HTMLElement>): void;
  121155. /**
  121156. * Gets the class name of the current intput.
  121157. * @returns the class name
  121158. */
  121159. getClassName(): string;
  121160. /**
  121161. * Get the friendly name associated with the input class.
  121162. * @returns the input friendly name
  121163. */
  121164. getSimpleName(): string;
  121165. }
  121166. }
  121167. declare module BABYLON {
  121168. /**
  121169. * This represents a FPS type of camera controlled by touch.
  121170. * This is like a universal camera minus the Gamepad controls.
  121171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121172. */
  121173. export class TouchCamera extends FreeCamera {
  121174. /**
  121175. * Defines the touch sensibility for rotation.
  121176. * The higher the faster.
  121177. */
  121178. get touchAngularSensibility(): number;
  121179. set touchAngularSensibility(value: number);
  121180. /**
  121181. * Defines the touch sensibility for move.
  121182. * The higher the faster.
  121183. */
  121184. get touchMoveSensibility(): number;
  121185. set touchMoveSensibility(value: number);
  121186. /**
  121187. * Instantiates a new touch camera.
  121188. * This represents a FPS type of camera controlled by touch.
  121189. * This is like a universal camera minus the Gamepad controls.
  121190. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121191. * @param name Define the name of the camera in the scene
  121192. * @param position Define the start position of the camera in the scene
  121193. * @param scene Define the scene the camera belongs to
  121194. */
  121195. constructor(name: string, position: Vector3, scene: Scene);
  121196. /**
  121197. * Gets the current object class name.
  121198. * @return the class name
  121199. */
  121200. getClassName(): string;
  121201. /** @hidden */
  121202. _setupInputs(): void;
  121203. }
  121204. }
  121205. declare module BABYLON {
  121206. /**
  121207. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121208. * being tilted forward or back and left or right.
  121209. */
  121210. export class DeviceOrientationCamera extends FreeCamera {
  121211. private _initialQuaternion;
  121212. private _quaternionCache;
  121213. private _tmpDragQuaternion;
  121214. private _disablePointerInputWhenUsingDeviceOrientation;
  121215. /**
  121216. * Creates a new device orientation camera
  121217. * @param name The name of the camera
  121218. * @param position The start position camera
  121219. * @param scene The scene the camera belongs to
  121220. */
  121221. constructor(name: string, position: Vector3, scene: Scene);
  121222. /**
  121223. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121224. */
  121225. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121226. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121227. private _dragFactor;
  121228. /**
  121229. * Enabled turning on the y axis when the orientation sensor is active
  121230. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121231. */
  121232. enableHorizontalDragging(dragFactor?: number): void;
  121233. /**
  121234. * Gets the current instance class name ("DeviceOrientationCamera").
  121235. * This helps avoiding instanceof at run time.
  121236. * @returns the class name
  121237. */
  121238. getClassName(): string;
  121239. /**
  121240. * @hidden
  121241. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  121242. */
  121243. _checkInputs(): void;
  121244. /**
  121245. * Reset the camera to its default orientation on the specified axis only.
  121246. * @param axis The axis to reset
  121247. */
  121248. resetToCurrentRotation(axis?: Axis): void;
  121249. }
  121250. }
  121251. declare module BABYLON {
  121252. /**
  121253. * Defines supported buttons for XBox360 compatible gamepads
  121254. */
  121255. export enum Xbox360Button {
  121256. /** A */
  121257. A = 0,
  121258. /** B */
  121259. B = 1,
  121260. /** X */
  121261. X = 2,
  121262. /** Y */
  121263. Y = 3,
  121264. /** Left button */
  121265. LB = 4,
  121266. /** Right button */
  121267. RB = 5,
  121268. /** Back */
  121269. Back = 8,
  121270. /** Start */
  121271. Start = 9,
  121272. /** Left stick */
  121273. LeftStick = 10,
  121274. /** Right stick */
  121275. RightStick = 11
  121276. }
  121277. /** Defines values for XBox360 DPad */
  121278. export enum Xbox360Dpad {
  121279. /** Up */
  121280. Up = 12,
  121281. /** Down */
  121282. Down = 13,
  121283. /** Left */
  121284. Left = 14,
  121285. /** Right */
  121286. Right = 15
  121287. }
  121288. /**
  121289. * Defines a XBox360 gamepad
  121290. */
  121291. export class Xbox360Pad extends Gamepad {
  121292. private _leftTrigger;
  121293. private _rightTrigger;
  121294. private _onlefttriggerchanged;
  121295. private _onrighttriggerchanged;
  121296. private _onbuttondown;
  121297. private _onbuttonup;
  121298. private _ondpaddown;
  121299. private _ondpadup;
  121300. /** Observable raised when a button is pressed */
  121301. onButtonDownObservable: Observable<Xbox360Button>;
  121302. /** Observable raised when a button is released */
  121303. onButtonUpObservable: Observable<Xbox360Button>;
  121304. /** Observable raised when a pad is pressed */
  121305. onPadDownObservable: Observable<Xbox360Dpad>;
  121306. /** Observable raised when a pad is released */
  121307. onPadUpObservable: Observable<Xbox360Dpad>;
  121308. private _buttonA;
  121309. private _buttonB;
  121310. private _buttonX;
  121311. private _buttonY;
  121312. private _buttonBack;
  121313. private _buttonStart;
  121314. private _buttonLB;
  121315. private _buttonRB;
  121316. private _buttonLeftStick;
  121317. private _buttonRightStick;
  121318. private _dPadUp;
  121319. private _dPadDown;
  121320. private _dPadLeft;
  121321. private _dPadRight;
  121322. private _isXboxOnePad;
  121323. /**
  121324. * Creates a new XBox360 gamepad object
  121325. * @param id defines the id of this gamepad
  121326. * @param index defines its index
  121327. * @param gamepad defines the internal HTML gamepad object
  121328. * @param xboxOne defines if it is a XBox One gamepad
  121329. */
  121330. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  121331. /**
  121332. * Defines the callback to call when left trigger is pressed
  121333. * @param callback defines the callback to use
  121334. */
  121335. onlefttriggerchanged(callback: (value: number) => void): void;
  121336. /**
  121337. * Defines the callback to call when right trigger is pressed
  121338. * @param callback defines the callback to use
  121339. */
  121340. onrighttriggerchanged(callback: (value: number) => void): void;
  121341. /**
  121342. * Gets the left trigger value
  121343. */
  121344. get leftTrigger(): number;
  121345. /**
  121346. * Sets the left trigger value
  121347. */
  121348. set leftTrigger(newValue: number);
  121349. /**
  121350. * Gets the right trigger value
  121351. */
  121352. get rightTrigger(): number;
  121353. /**
  121354. * Sets the right trigger value
  121355. */
  121356. set rightTrigger(newValue: number);
  121357. /**
  121358. * Defines the callback to call when a button is pressed
  121359. * @param callback defines the callback to use
  121360. */
  121361. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  121362. /**
  121363. * Defines the callback to call when a button is released
  121364. * @param callback defines the callback to use
  121365. */
  121366. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  121367. /**
  121368. * Defines the callback to call when a pad is pressed
  121369. * @param callback defines the callback to use
  121370. */
  121371. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  121372. /**
  121373. * Defines the callback to call when a pad is released
  121374. * @param callback defines the callback to use
  121375. */
  121376. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  121377. private _setButtonValue;
  121378. private _setDPadValue;
  121379. /**
  121380. * Gets the value of the `A` button
  121381. */
  121382. get buttonA(): number;
  121383. /**
  121384. * Sets the value of the `A` button
  121385. */
  121386. set buttonA(value: number);
  121387. /**
  121388. * Gets the value of the `B` button
  121389. */
  121390. get buttonB(): number;
  121391. /**
  121392. * Sets the value of the `B` button
  121393. */
  121394. set buttonB(value: number);
  121395. /**
  121396. * Gets the value of the `X` button
  121397. */
  121398. get buttonX(): number;
  121399. /**
  121400. * Sets the value of the `X` button
  121401. */
  121402. set buttonX(value: number);
  121403. /**
  121404. * Gets the value of the `Y` button
  121405. */
  121406. get buttonY(): number;
  121407. /**
  121408. * Sets the value of the `Y` button
  121409. */
  121410. set buttonY(value: number);
  121411. /**
  121412. * Gets the value of the `Start` button
  121413. */
  121414. get buttonStart(): number;
  121415. /**
  121416. * Sets the value of the `Start` button
  121417. */
  121418. set buttonStart(value: number);
  121419. /**
  121420. * Gets the value of the `Back` button
  121421. */
  121422. get buttonBack(): number;
  121423. /**
  121424. * Sets the value of the `Back` button
  121425. */
  121426. set buttonBack(value: number);
  121427. /**
  121428. * Gets the value of the `Left` button
  121429. */
  121430. get buttonLB(): number;
  121431. /**
  121432. * Sets the value of the `Left` button
  121433. */
  121434. set buttonLB(value: number);
  121435. /**
  121436. * Gets the value of the `Right` button
  121437. */
  121438. get buttonRB(): number;
  121439. /**
  121440. * Sets the value of the `Right` button
  121441. */
  121442. set buttonRB(value: number);
  121443. /**
  121444. * Gets the value of the Left joystick
  121445. */
  121446. get buttonLeftStick(): number;
  121447. /**
  121448. * Sets the value of the Left joystick
  121449. */
  121450. set buttonLeftStick(value: number);
  121451. /**
  121452. * Gets the value of the Right joystick
  121453. */
  121454. get buttonRightStick(): number;
  121455. /**
  121456. * Sets the value of the Right joystick
  121457. */
  121458. set buttonRightStick(value: number);
  121459. /**
  121460. * Gets the value of D-pad up
  121461. */
  121462. get dPadUp(): number;
  121463. /**
  121464. * Sets the value of D-pad up
  121465. */
  121466. set dPadUp(value: number);
  121467. /**
  121468. * Gets the value of D-pad down
  121469. */
  121470. get dPadDown(): number;
  121471. /**
  121472. * Sets the value of D-pad down
  121473. */
  121474. set dPadDown(value: number);
  121475. /**
  121476. * Gets the value of D-pad left
  121477. */
  121478. get dPadLeft(): number;
  121479. /**
  121480. * Sets the value of D-pad left
  121481. */
  121482. set dPadLeft(value: number);
  121483. /**
  121484. * Gets the value of D-pad right
  121485. */
  121486. get dPadRight(): number;
  121487. /**
  121488. * Sets the value of D-pad right
  121489. */
  121490. set dPadRight(value: number);
  121491. /**
  121492. * Force the gamepad to synchronize with device values
  121493. */
  121494. update(): void;
  121495. /**
  121496. * Disposes the gamepad
  121497. */
  121498. dispose(): void;
  121499. }
  121500. }
  121501. declare module BABYLON {
  121502. /**
  121503. * Defines supported buttons for DualShock compatible gamepads
  121504. */
  121505. export enum DualShockButton {
  121506. /** Cross */
  121507. Cross = 0,
  121508. /** Circle */
  121509. Circle = 1,
  121510. /** Square */
  121511. Square = 2,
  121512. /** Triangle */
  121513. Triangle = 3,
  121514. /** L1 */
  121515. L1 = 4,
  121516. /** R1 */
  121517. R1 = 5,
  121518. /** Share */
  121519. Share = 8,
  121520. /** Options */
  121521. Options = 9,
  121522. /** Left stick */
  121523. LeftStick = 10,
  121524. /** Right stick */
  121525. RightStick = 11
  121526. }
  121527. /** Defines values for DualShock DPad */
  121528. export enum DualShockDpad {
  121529. /** Up */
  121530. Up = 12,
  121531. /** Down */
  121532. Down = 13,
  121533. /** Left */
  121534. Left = 14,
  121535. /** Right */
  121536. Right = 15
  121537. }
  121538. /**
  121539. * Defines a DualShock gamepad
  121540. */
  121541. export class DualShockPad extends Gamepad {
  121542. private _leftTrigger;
  121543. private _rightTrigger;
  121544. private _onlefttriggerchanged;
  121545. private _onrighttriggerchanged;
  121546. private _onbuttondown;
  121547. private _onbuttonup;
  121548. private _ondpaddown;
  121549. private _ondpadup;
  121550. /** Observable raised when a button is pressed */
  121551. onButtonDownObservable: Observable<DualShockButton>;
  121552. /** Observable raised when a button is released */
  121553. onButtonUpObservable: Observable<DualShockButton>;
  121554. /** Observable raised when a pad is pressed */
  121555. onPadDownObservable: Observable<DualShockDpad>;
  121556. /** Observable raised when a pad is released */
  121557. onPadUpObservable: Observable<DualShockDpad>;
  121558. private _buttonCross;
  121559. private _buttonCircle;
  121560. private _buttonSquare;
  121561. private _buttonTriangle;
  121562. private _buttonShare;
  121563. private _buttonOptions;
  121564. private _buttonL1;
  121565. private _buttonR1;
  121566. private _buttonLeftStick;
  121567. private _buttonRightStick;
  121568. private _dPadUp;
  121569. private _dPadDown;
  121570. private _dPadLeft;
  121571. private _dPadRight;
  121572. /**
  121573. * Creates a new DualShock gamepad object
  121574. * @param id defines the id of this gamepad
  121575. * @param index defines its index
  121576. * @param gamepad defines the internal HTML gamepad object
  121577. */
  121578. constructor(id: string, index: number, gamepad: any);
  121579. /**
  121580. * Defines the callback to call when left trigger is pressed
  121581. * @param callback defines the callback to use
  121582. */
  121583. onlefttriggerchanged(callback: (value: number) => void): void;
  121584. /**
  121585. * Defines the callback to call when right trigger is pressed
  121586. * @param callback defines the callback to use
  121587. */
  121588. onrighttriggerchanged(callback: (value: number) => void): void;
  121589. /**
  121590. * Gets the left trigger value
  121591. */
  121592. get leftTrigger(): number;
  121593. /**
  121594. * Sets the left trigger value
  121595. */
  121596. set leftTrigger(newValue: number);
  121597. /**
  121598. * Gets the right trigger value
  121599. */
  121600. get rightTrigger(): number;
  121601. /**
  121602. * Sets the right trigger value
  121603. */
  121604. set rightTrigger(newValue: number);
  121605. /**
  121606. * Defines the callback to call when a button is pressed
  121607. * @param callback defines the callback to use
  121608. */
  121609. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  121610. /**
  121611. * Defines the callback to call when a button is released
  121612. * @param callback defines the callback to use
  121613. */
  121614. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  121615. /**
  121616. * Defines the callback to call when a pad is pressed
  121617. * @param callback defines the callback to use
  121618. */
  121619. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  121620. /**
  121621. * Defines the callback to call when a pad is released
  121622. * @param callback defines the callback to use
  121623. */
  121624. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  121625. private _setButtonValue;
  121626. private _setDPadValue;
  121627. /**
  121628. * Gets the value of the `Cross` button
  121629. */
  121630. get buttonCross(): number;
  121631. /**
  121632. * Sets the value of the `Cross` button
  121633. */
  121634. set buttonCross(value: number);
  121635. /**
  121636. * Gets the value of the `Circle` button
  121637. */
  121638. get buttonCircle(): number;
  121639. /**
  121640. * Sets the value of the `Circle` button
  121641. */
  121642. set buttonCircle(value: number);
  121643. /**
  121644. * Gets the value of the `Square` button
  121645. */
  121646. get buttonSquare(): number;
  121647. /**
  121648. * Sets the value of the `Square` button
  121649. */
  121650. set buttonSquare(value: number);
  121651. /**
  121652. * Gets the value of the `Triangle` button
  121653. */
  121654. get buttonTriangle(): number;
  121655. /**
  121656. * Sets the value of the `Triangle` button
  121657. */
  121658. set buttonTriangle(value: number);
  121659. /**
  121660. * Gets the value of the `Options` button
  121661. */
  121662. get buttonOptions(): number;
  121663. /**
  121664. * Sets the value of the `Options` button
  121665. */
  121666. set buttonOptions(value: number);
  121667. /**
  121668. * Gets the value of the `Share` button
  121669. */
  121670. get buttonShare(): number;
  121671. /**
  121672. * Sets the value of the `Share` button
  121673. */
  121674. set buttonShare(value: number);
  121675. /**
  121676. * Gets the value of the `L1` button
  121677. */
  121678. get buttonL1(): number;
  121679. /**
  121680. * Sets the value of the `L1` button
  121681. */
  121682. set buttonL1(value: number);
  121683. /**
  121684. * Gets the value of the `R1` button
  121685. */
  121686. get buttonR1(): number;
  121687. /**
  121688. * Sets the value of the `R1` button
  121689. */
  121690. set buttonR1(value: number);
  121691. /**
  121692. * Gets the value of the Left joystick
  121693. */
  121694. get buttonLeftStick(): number;
  121695. /**
  121696. * Sets the value of the Left joystick
  121697. */
  121698. set buttonLeftStick(value: number);
  121699. /**
  121700. * Gets the value of the Right joystick
  121701. */
  121702. get buttonRightStick(): number;
  121703. /**
  121704. * Sets the value of the Right joystick
  121705. */
  121706. set buttonRightStick(value: number);
  121707. /**
  121708. * Gets the value of D-pad up
  121709. */
  121710. get dPadUp(): number;
  121711. /**
  121712. * Sets the value of D-pad up
  121713. */
  121714. set dPadUp(value: number);
  121715. /**
  121716. * Gets the value of D-pad down
  121717. */
  121718. get dPadDown(): number;
  121719. /**
  121720. * Sets the value of D-pad down
  121721. */
  121722. set dPadDown(value: number);
  121723. /**
  121724. * Gets the value of D-pad left
  121725. */
  121726. get dPadLeft(): number;
  121727. /**
  121728. * Sets the value of D-pad left
  121729. */
  121730. set dPadLeft(value: number);
  121731. /**
  121732. * Gets the value of D-pad right
  121733. */
  121734. get dPadRight(): number;
  121735. /**
  121736. * Sets the value of D-pad right
  121737. */
  121738. set dPadRight(value: number);
  121739. /**
  121740. * Force the gamepad to synchronize with device values
  121741. */
  121742. update(): void;
  121743. /**
  121744. * Disposes the gamepad
  121745. */
  121746. dispose(): void;
  121747. }
  121748. }
  121749. declare module BABYLON {
  121750. /**
  121751. * Manager for handling gamepads
  121752. */
  121753. export class GamepadManager {
  121754. private _scene?;
  121755. private _babylonGamepads;
  121756. private _oneGamepadConnected;
  121757. /** @hidden */
  121758. _isMonitoring: boolean;
  121759. private _gamepadEventSupported;
  121760. private _gamepadSupport?;
  121761. /**
  121762. * observable to be triggered when the gamepad controller has been connected
  121763. */
  121764. onGamepadConnectedObservable: Observable<Gamepad>;
  121765. /**
  121766. * observable to be triggered when the gamepad controller has been disconnected
  121767. */
  121768. onGamepadDisconnectedObservable: Observable<Gamepad>;
  121769. private _onGamepadConnectedEvent;
  121770. private _onGamepadDisconnectedEvent;
  121771. /**
  121772. * Initializes the gamepad manager
  121773. * @param _scene BabylonJS scene
  121774. */
  121775. constructor(_scene?: Scene | undefined);
  121776. /**
  121777. * The gamepads in the game pad manager
  121778. */
  121779. get gamepads(): Gamepad[];
  121780. /**
  121781. * Get the gamepad controllers based on type
  121782. * @param type The type of gamepad controller
  121783. * @returns Nullable gamepad
  121784. */
  121785. getGamepadByType(type?: number): Nullable<Gamepad>;
  121786. /**
  121787. * Disposes the gamepad manager
  121788. */
  121789. dispose(): void;
  121790. private _addNewGamepad;
  121791. private _startMonitoringGamepads;
  121792. private _stopMonitoringGamepads;
  121793. /** @hidden */
  121794. _checkGamepadsStatus(): void;
  121795. private _updateGamepadObjects;
  121796. }
  121797. }
  121798. declare module BABYLON {
  121799. interface Scene {
  121800. /** @hidden */
  121801. _gamepadManager: Nullable<GamepadManager>;
  121802. /**
  121803. * Gets the gamepad manager associated with the scene
  121804. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  121805. */
  121806. gamepadManager: GamepadManager;
  121807. }
  121808. /**
  121809. * Interface representing a free camera inputs manager
  121810. */
  121811. interface FreeCameraInputsManager {
  121812. /**
  121813. * Adds gamepad input support to the FreeCameraInputsManager.
  121814. * @returns the FreeCameraInputsManager
  121815. */
  121816. addGamepad(): FreeCameraInputsManager;
  121817. }
  121818. /**
  121819. * Interface representing an arc rotate camera inputs manager
  121820. */
  121821. interface ArcRotateCameraInputsManager {
  121822. /**
  121823. * Adds gamepad input support to the ArcRotateCamera InputManager.
  121824. * @returns the camera inputs manager
  121825. */
  121826. addGamepad(): ArcRotateCameraInputsManager;
  121827. }
  121828. /**
  121829. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  121830. */
  121831. export class GamepadSystemSceneComponent implements ISceneComponent {
  121832. /**
  121833. * The component name helpfull to identify the component in the list of scene components.
  121834. */
  121835. readonly name: string;
  121836. /**
  121837. * The scene the component belongs to.
  121838. */
  121839. scene: Scene;
  121840. /**
  121841. * Creates a new instance of the component for the given scene
  121842. * @param scene Defines the scene to register the component in
  121843. */
  121844. constructor(scene: Scene);
  121845. /**
  121846. * Registers the component in a given scene
  121847. */
  121848. register(): void;
  121849. /**
  121850. * Rebuilds the elements related to this component in case of
  121851. * context lost for instance.
  121852. */
  121853. rebuild(): void;
  121854. /**
  121855. * Disposes the component and the associated ressources
  121856. */
  121857. dispose(): void;
  121858. private _beforeCameraUpdate;
  121859. }
  121860. }
  121861. declare module BABYLON {
  121862. /**
  121863. * 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,
  121864. * which still works and will still be found in many Playgrounds.
  121865. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121866. */
  121867. export class UniversalCamera extends TouchCamera {
  121868. /**
  121869. * Defines the gamepad rotation sensiblity.
  121870. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121871. */
  121872. get gamepadAngularSensibility(): number;
  121873. set gamepadAngularSensibility(value: number);
  121874. /**
  121875. * Defines the gamepad move sensiblity.
  121876. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121877. */
  121878. get gamepadMoveSensibility(): number;
  121879. set gamepadMoveSensibility(value: number);
  121880. /**
  121881. * 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,
  121882. * which still works and will still be found in many Playgrounds.
  121883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121884. * @param name Define the name of the camera in the scene
  121885. * @param position Define the start position of the camera in the scene
  121886. * @param scene Define the scene the camera belongs to
  121887. */
  121888. constructor(name: string, position: Vector3, scene: Scene);
  121889. /**
  121890. * Gets the current object class name.
  121891. * @return the class name
  121892. */
  121893. getClassName(): string;
  121894. }
  121895. }
  121896. declare module BABYLON {
  121897. /**
  121898. * This represents a FPS type of camera. This is only here for back compat purpose.
  121899. * Please use the UniversalCamera instead as both are identical.
  121900. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121901. */
  121902. export class GamepadCamera extends UniversalCamera {
  121903. /**
  121904. * Instantiates a new Gamepad Camera
  121905. * This represents a FPS type of camera. This is only here for back compat purpose.
  121906. * Please use the UniversalCamera instead as both are identical.
  121907. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121908. * @param name Define the name of the camera in the scene
  121909. * @param position Define the start position of the camera in the scene
  121910. * @param scene Define the scene the camera belongs to
  121911. */
  121912. constructor(name: string, position: Vector3, scene: Scene);
  121913. /**
  121914. * Gets the current object class name.
  121915. * @return the class name
  121916. */
  121917. getClassName(): string;
  121918. }
  121919. }
  121920. declare module BABYLON {
  121921. /** @hidden */
  121922. export var passPixelShader: {
  121923. name: string;
  121924. shader: string;
  121925. };
  121926. }
  121927. declare module BABYLON {
  121928. /** @hidden */
  121929. export var passCubePixelShader: {
  121930. name: string;
  121931. shader: string;
  121932. };
  121933. }
  121934. declare module BABYLON {
  121935. /**
  121936. * PassPostProcess which produces an output the same as it's input
  121937. */
  121938. export class PassPostProcess extends PostProcess {
  121939. /**
  121940. * Creates the PassPostProcess
  121941. * @param name The name of the effect.
  121942. * @param options The required width/height ratio to downsize to before computing the render pass.
  121943. * @param camera The camera to apply the render pass to.
  121944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121945. * @param engine The engine which the post process will be applied. (default: current engine)
  121946. * @param reusable If the post process can be reused on the same frame. (default: false)
  121947. * @param textureType The type of texture to be used when performing the post processing.
  121948. * @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)
  121949. */
  121950. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121951. }
  121952. /**
  121953. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  121954. */
  121955. export class PassCubePostProcess extends PostProcess {
  121956. private _face;
  121957. /**
  121958. * Gets or sets the cube face to display.
  121959. * * 0 is +X
  121960. * * 1 is -X
  121961. * * 2 is +Y
  121962. * * 3 is -Y
  121963. * * 4 is +Z
  121964. * * 5 is -Z
  121965. */
  121966. get face(): number;
  121967. set face(value: number);
  121968. /**
  121969. * Creates the PassCubePostProcess
  121970. * @param name The name of the effect.
  121971. * @param options The required width/height ratio to downsize to before computing the render pass.
  121972. * @param camera The camera to apply the render pass to.
  121973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121974. * @param engine The engine which the post process will be applied. (default: current engine)
  121975. * @param reusable If the post process can be reused on the same frame. (default: false)
  121976. * @param textureType The type of texture to be used when performing the post processing.
  121977. * @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)
  121978. */
  121979. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121980. }
  121981. }
  121982. declare module BABYLON {
  121983. /** @hidden */
  121984. export var anaglyphPixelShader: {
  121985. name: string;
  121986. shader: string;
  121987. };
  121988. }
  121989. declare module BABYLON {
  121990. /**
  121991. * Postprocess used to generate anaglyphic rendering
  121992. */
  121993. export class AnaglyphPostProcess extends PostProcess {
  121994. private _passedProcess;
  121995. /**
  121996. * Creates a new AnaglyphPostProcess
  121997. * @param name defines postprocess name
  121998. * @param options defines creation options or target ratio scale
  121999. * @param rigCameras defines cameras using this postprocess
  122000. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122001. * @param engine defines hosting engine
  122002. * @param reusable defines if the postprocess will be reused multiple times per frame
  122003. */
  122004. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122005. }
  122006. }
  122007. declare module BABYLON {
  122008. /**
  122009. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122010. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122011. */
  122012. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122013. /**
  122014. * Creates a new AnaglyphArcRotateCamera
  122015. * @param name defines camera name
  122016. * @param alpha defines alpha angle (in radians)
  122017. * @param beta defines beta angle (in radians)
  122018. * @param radius defines radius
  122019. * @param target defines camera target
  122020. * @param interaxialDistance defines distance between each color axis
  122021. * @param scene defines the hosting scene
  122022. */
  122023. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122024. /**
  122025. * Gets camera class name
  122026. * @returns AnaglyphArcRotateCamera
  122027. */
  122028. getClassName(): string;
  122029. }
  122030. }
  122031. declare module BABYLON {
  122032. /**
  122033. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122034. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122035. */
  122036. export class AnaglyphFreeCamera extends FreeCamera {
  122037. /**
  122038. * Creates a new AnaglyphFreeCamera
  122039. * @param name defines camera name
  122040. * @param position defines initial position
  122041. * @param interaxialDistance defines distance between each color axis
  122042. * @param scene defines the hosting scene
  122043. */
  122044. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122045. /**
  122046. * Gets camera class name
  122047. * @returns AnaglyphFreeCamera
  122048. */
  122049. getClassName(): string;
  122050. }
  122051. }
  122052. declare module BABYLON {
  122053. /**
  122054. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122055. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122056. */
  122057. export class AnaglyphGamepadCamera extends GamepadCamera {
  122058. /**
  122059. * Creates a new AnaglyphGamepadCamera
  122060. * @param name defines camera name
  122061. * @param position defines initial position
  122062. * @param interaxialDistance defines distance between each color axis
  122063. * @param scene defines the hosting scene
  122064. */
  122065. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122066. /**
  122067. * Gets camera class name
  122068. * @returns AnaglyphGamepadCamera
  122069. */
  122070. getClassName(): string;
  122071. }
  122072. }
  122073. declare module BABYLON {
  122074. /**
  122075. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122076. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122077. */
  122078. export class AnaglyphUniversalCamera extends UniversalCamera {
  122079. /**
  122080. * Creates a new AnaglyphUniversalCamera
  122081. * @param name defines camera name
  122082. * @param position defines initial position
  122083. * @param interaxialDistance defines distance between each color axis
  122084. * @param scene defines the hosting scene
  122085. */
  122086. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122087. /**
  122088. * Gets camera class name
  122089. * @returns AnaglyphUniversalCamera
  122090. */
  122091. getClassName(): string;
  122092. }
  122093. }
  122094. declare module BABYLON {
  122095. /**
  122096. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122097. * @see http://doc.babylonjs.com/features/cameras
  122098. */
  122099. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122100. /**
  122101. * Creates a new StereoscopicArcRotateCamera
  122102. * @param name defines camera name
  122103. * @param alpha defines alpha angle (in radians)
  122104. * @param beta defines beta angle (in radians)
  122105. * @param radius defines radius
  122106. * @param target defines camera target
  122107. * @param interaxialDistance defines distance between each color axis
  122108. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122109. * @param scene defines the hosting scene
  122110. */
  122111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122112. /**
  122113. * Gets camera class name
  122114. * @returns StereoscopicArcRotateCamera
  122115. */
  122116. getClassName(): string;
  122117. }
  122118. }
  122119. declare module BABYLON {
  122120. /**
  122121. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122122. * @see http://doc.babylonjs.com/features/cameras
  122123. */
  122124. export class StereoscopicFreeCamera extends FreeCamera {
  122125. /**
  122126. * Creates a new StereoscopicFreeCamera
  122127. * @param name defines camera name
  122128. * @param position defines initial position
  122129. * @param interaxialDistance defines distance between each color axis
  122130. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122131. * @param scene defines the hosting scene
  122132. */
  122133. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122134. /**
  122135. * Gets camera class name
  122136. * @returns StereoscopicFreeCamera
  122137. */
  122138. getClassName(): string;
  122139. }
  122140. }
  122141. declare module BABYLON {
  122142. /**
  122143. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122144. * @see http://doc.babylonjs.com/features/cameras
  122145. */
  122146. export class StereoscopicGamepadCamera extends GamepadCamera {
  122147. /**
  122148. * Creates a new StereoscopicGamepadCamera
  122149. * @param name defines camera name
  122150. * @param position defines initial position
  122151. * @param interaxialDistance defines distance between each color axis
  122152. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122153. * @param scene defines the hosting scene
  122154. */
  122155. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122156. /**
  122157. * Gets camera class name
  122158. * @returns StereoscopicGamepadCamera
  122159. */
  122160. getClassName(): string;
  122161. }
  122162. }
  122163. declare module BABYLON {
  122164. /**
  122165. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122166. * @see http://doc.babylonjs.com/features/cameras
  122167. */
  122168. export class StereoscopicUniversalCamera extends UniversalCamera {
  122169. /**
  122170. * Creates a new StereoscopicUniversalCamera
  122171. * @param name defines camera name
  122172. * @param position defines initial position
  122173. * @param interaxialDistance defines distance between each color axis
  122174. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122175. * @param scene defines the hosting scene
  122176. */
  122177. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122178. /**
  122179. * Gets camera class name
  122180. * @returns StereoscopicUniversalCamera
  122181. */
  122182. getClassName(): string;
  122183. }
  122184. }
  122185. declare module BABYLON {
  122186. /**
  122187. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122188. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122189. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122190. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122191. */
  122192. export class VirtualJoysticksCamera extends FreeCamera {
  122193. /**
  122194. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122195. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122196. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122197. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122198. * @param name Define the name of the camera in the scene
  122199. * @param position Define the start position of the camera in the scene
  122200. * @param scene Define the scene the camera belongs to
  122201. */
  122202. constructor(name: string, position: Vector3, scene: Scene);
  122203. /**
  122204. * Gets the current object class name.
  122205. * @return the class name
  122206. */
  122207. getClassName(): string;
  122208. }
  122209. }
  122210. declare module BABYLON {
  122211. /**
  122212. * This represents all the required metrics to create a VR camera.
  122213. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122214. */
  122215. export class VRCameraMetrics {
  122216. /**
  122217. * Define the horizontal resolution off the screen.
  122218. */
  122219. hResolution: number;
  122220. /**
  122221. * Define the vertical resolution off the screen.
  122222. */
  122223. vResolution: number;
  122224. /**
  122225. * Define the horizontal screen size.
  122226. */
  122227. hScreenSize: number;
  122228. /**
  122229. * Define the vertical screen size.
  122230. */
  122231. vScreenSize: number;
  122232. /**
  122233. * Define the vertical screen center position.
  122234. */
  122235. vScreenCenter: number;
  122236. /**
  122237. * Define the distance of the eyes to the screen.
  122238. */
  122239. eyeToScreenDistance: number;
  122240. /**
  122241. * Define the distance between both lenses
  122242. */
  122243. lensSeparationDistance: number;
  122244. /**
  122245. * Define the distance between both viewer's eyes.
  122246. */
  122247. interpupillaryDistance: number;
  122248. /**
  122249. * Define the distortion factor of the VR postprocess.
  122250. * Please, touch with care.
  122251. */
  122252. distortionK: number[];
  122253. /**
  122254. * Define the chromatic aberration correction factors for the VR post process.
  122255. */
  122256. chromaAbCorrection: number[];
  122257. /**
  122258. * Define the scale factor of the post process.
  122259. * The smaller the better but the slower.
  122260. */
  122261. postProcessScaleFactor: number;
  122262. /**
  122263. * Define an offset for the lens center.
  122264. */
  122265. lensCenterOffset: number;
  122266. /**
  122267. * Define if the current vr camera should compensate the distortion of the lense or not.
  122268. */
  122269. compensateDistortion: boolean;
  122270. /**
  122271. * Defines if multiview should be enabled when rendering (Default: false)
  122272. */
  122273. multiviewEnabled: boolean;
  122274. /**
  122275. * Gets the rendering aspect ratio based on the provided resolutions.
  122276. */
  122277. get aspectRatio(): number;
  122278. /**
  122279. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  122280. */
  122281. get aspectRatioFov(): number;
  122282. /**
  122283. * @hidden
  122284. */
  122285. get leftHMatrix(): Matrix;
  122286. /**
  122287. * @hidden
  122288. */
  122289. get rightHMatrix(): Matrix;
  122290. /**
  122291. * @hidden
  122292. */
  122293. get leftPreViewMatrix(): Matrix;
  122294. /**
  122295. * @hidden
  122296. */
  122297. get rightPreViewMatrix(): Matrix;
  122298. /**
  122299. * Get the default VRMetrics based on the most generic setup.
  122300. * @returns the default vr metrics
  122301. */
  122302. static GetDefault(): VRCameraMetrics;
  122303. }
  122304. }
  122305. declare module BABYLON {
  122306. /** @hidden */
  122307. export var vrDistortionCorrectionPixelShader: {
  122308. name: string;
  122309. shader: string;
  122310. };
  122311. }
  122312. declare module BABYLON {
  122313. /**
  122314. * VRDistortionCorrectionPostProcess used for mobile VR
  122315. */
  122316. export class VRDistortionCorrectionPostProcess extends PostProcess {
  122317. private _isRightEye;
  122318. private _distortionFactors;
  122319. private _postProcessScaleFactor;
  122320. private _lensCenterOffset;
  122321. private _scaleIn;
  122322. private _scaleFactor;
  122323. private _lensCenter;
  122324. /**
  122325. * Initializes the VRDistortionCorrectionPostProcess
  122326. * @param name The name of the effect.
  122327. * @param camera The camera to apply the render pass to.
  122328. * @param isRightEye If this is for the right eye distortion
  122329. * @param vrMetrics All the required metrics for the VR camera
  122330. */
  122331. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  122332. }
  122333. }
  122334. declare module BABYLON {
  122335. /**
  122336. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  122337. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122338. */
  122339. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  122340. /**
  122341. * Creates a new VRDeviceOrientationArcRotateCamera
  122342. * @param name defines camera name
  122343. * @param alpha defines the camera rotation along the logitudinal axis
  122344. * @param beta defines the camera rotation along the latitudinal axis
  122345. * @param radius defines the camera distance from its target
  122346. * @param target defines the camera target
  122347. * @param scene defines the scene the camera belongs to
  122348. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122349. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122350. */
  122351. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122352. /**
  122353. * Gets camera class name
  122354. * @returns VRDeviceOrientationArcRotateCamera
  122355. */
  122356. getClassName(): string;
  122357. }
  122358. }
  122359. declare module BABYLON {
  122360. /**
  122361. * Camera used to simulate VR rendering (based on FreeCamera)
  122362. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122363. */
  122364. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  122365. /**
  122366. * Creates a new VRDeviceOrientationFreeCamera
  122367. * @param name defines camera name
  122368. * @param position defines the start position of the camera
  122369. * @param scene defines the scene the camera belongs to
  122370. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122371. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122372. */
  122373. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122374. /**
  122375. * Gets camera class name
  122376. * @returns VRDeviceOrientationFreeCamera
  122377. */
  122378. getClassName(): string;
  122379. }
  122380. }
  122381. declare module BABYLON {
  122382. /**
  122383. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  122384. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122385. */
  122386. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  122387. /**
  122388. * Creates a new VRDeviceOrientationGamepadCamera
  122389. * @param name defines camera name
  122390. * @param position defines the start position of the camera
  122391. * @param scene defines the scene the camera belongs to
  122392. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122393. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122394. */
  122395. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122396. /**
  122397. * Gets camera class name
  122398. * @returns VRDeviceOrientationGamepadCamera
  122399. */
  122400. getClassName(): string;
  122401. }
  122402. }
  122403. declare module BABYLON {
  122404. /** @hidden */
  122405. export var imageProcessingPixelShader: {
  122406. name: string;
  122407. shader: string;
  122408. };
  122409. }
  122410. declare module BABYLON {
  122411. /**
  122412. * ImageProcessingPostProcess
  122413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122414. */
  122415. export class ImageProcessingPostProcess extends PostProcess {
  122416. /**
  122417. * Default configuration related to image processing available in the PBR Material.
  122418. */
  122419. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122420. /**
  122421. * Gets the image processing configuration used either in this material.
  122422. */
  122423. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122424. /**
  122425. * Sets the Default image processing configuration used either in the this material.
  122426. *
  122427. * If sets to null, the scene one is in use.
  122428. */
  122429. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122430. /**
  122431. * Keep track of the image processing observer to allow dispose and replace.
  122432. */
  122433. private _imageProcessingObserver;
  122434. /**
  122435. * Attaches a new image processing configuration to the PBR Material.
  122436. * @param configuration
  122437. */
  122438. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  122439. /**
  122440. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122441. */
  122442. get colorCurves(): Nullable<ColorCurves>;
  122443. /**
  122444. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122445. */
  122446. set colorCurves(value: Nullable<ColorCurves>);
  122447. /**
  122448. * Gets wether the color curves effect is enabled.
  122449. */
  122450. get colorCurvesEnabled(): boolean;
  122451. /**
  122452. * Sets wether the color curves effect is enabled.
  122453. */
  122454. set colorCurvesEnabled(value: boolean);
  122455. /**
  122456. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122457. */
  122458. get colorGradingTexture(): Nullable<BaseTexture>;
  122459. /**
  122460. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122461. */
  122462. set colorGradingTexture(value: Nullable<BaseTexture>);
  122463. /**
  122464. * Gets wether the color grading effect is enabled.
  122465. */
  122466. get colorGradingEnabled(): boolean;
  122467. /**
  122468. * Gets wether the color grading effect is enabled.
  122469. */
  122470. set colorGradingEnabled(value: boolean);
  122471. /**
  122472. * Gets exposure used in the effect.
  122473. */
  122474. get exposure(): number;
  122475. /**
  122476. * Sets exposure used in the effect.
  122477. */
  122478. set exposure(value: number);
  122479. /**
  122480. * Gets wether tonemapping is enabled or not.
  122481. */
  122482. get toneMappingEnabled(): boolean;
  122483. /**
  122484. * Sets wether tonemapping is enabled or not
  122485. */
  122486. set toneMappingEnabled(value: boolean);
  122487. /**
  122488. * Gets the type of tone mapping effect.
  122489. */
  122490. get toneMappingType(): number;
  122491. /**
  122492. * Sets the type of tone mapping effect.
  122493. */
  122494. set toneMappingType(value: number);
  122495. /**
  122496. * Gets contrast used in the effect.
  122497. */
  122498. get contrast(): number;
  122499. /**
  122500. * Sets contrast used in the effect.
  122501. */
  122502. set contrast(value: number);
  122503. /**
  122504. * Gets Vignette stretch size.
  122505. */
  122506. get vignetteStretch(): number;
  122507. /**
  122508. * Sets Vignette stretch size.
  122509. */
  122510. set vignetteStretch(value: number);
  122511. /**
  122512. * Gets Vignette centre X Offset.
  122513. */
  122514. get vignetteCentreX(): number;
  122515. /**
  122516. * Sets Vignette centre X Offset.
  122517. */
  122518. set vignetteCentreX(value: number);
  122519. /**
  122520. * Gets Vignette centre Y Offset.
  122521. */
  122522. get vignetteCentreY(): number;
  122523. /**
  122524. * Sets Vignette centre Y Offset.
  122525. */
  122526. set vignetteCentreY(value: number);
  122527. /**
  122528. * Gets Vignette weight or intensity of the vignette effect.
  122529. */
  122530. get vignetteWeight(): number;
  122531. /**
  122532. * Sets Vignette weight or intensity of the vignette effect.
  122533. */
  122534. set vignetteWeight(value: number);
  122535. /**
  122536. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122537. * if vignetteEnabled is set to true.
  122538. */
  122539. get vignetteColor(): Color4;
  122540. /**
  122541. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122542. * if vignetteEnabled is set to true.
  122543. */
  122544. set vignetteColor(value: Color4);
  122545. /**
  122546. * Gets Camera field of view used by the Vignette effect.
  122547. */
  122548. get vignetteCameraFov(): number;
  122549. /**
  122550. * Sets Camera field of view used by the Vignette effect.
  122551. */
  122552. set vignetteCameraFov(value: number);
  122553. /**
  122554. * Gets the vignette blend mode allowing different kind of effect.
  122555. */
  122556. get vignetteBlendMode(): number;
  122557. /**
  122558. * Sets the vignette blend mode allowing different kind of effect.
  122559. */
  122560. set vignetteBlendMode(value: number);
  122561. /**
  122562. * Gets wether the vignette effect is enabled.
  122563. */
  122564. get vignetteEnabled(): boolean;
  122565. /**
  122566. * Sets wether the vignette effect is enabled.
  122567. */
  122568. set vignetteEnabled(value: boolean);
  122569. private _fromLinearSpace;
  122570. /**
  122571. * Gets wether the input of the processing is in Gamma or Linear Space.
  122572. */
  122573. get fromLinearSpace(): boolean;
  122574. /**
  122575. * Sets wether the input of the processing is in Gamma or Linear Space.
  122576. */
  122577. set fromLinearSpace(value: boolean);
  122578. /**
  122579. * Defines cache preventing GC.
  122580. */
  122581. private _defines;
  122582. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  122583. /**
  122584. * "ImageProcessingPostProcess"
  122585. * @returns "ImageProcessingPostProcess"
  122586. */
  122587. getClassName(): string;
  122588. protected _updateParameters(): void;
  122589. dispose(camera?: Camera): void;
  122590. }
  122591. }
  122592. declare module BABYLON {
  122593. /**
  122594. * Class containing static functions to help procedurally build meshes
  122595. */
  122596. export class GroundBuilder {
  122597. /**
  122598. * Creates a ground mesh
  122599. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122600. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122602. * @param name defines the name of the mesh
  122603. * @param options defines the options used to create the mesh
  122604. * @param scene defines the hosting scene
  122605. * @returns the ground mesh
  122606. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122607. */
  122608. static CreateGround(name: string, options: {
  122609. width?: number;
  122610. height?: number;
  122611. subdivisions?: number;
  122612. subdivisionsX?: number;
  122613. subdivisionsY?: number;
  122614. updatable?: boolean;
  122615. }, scene: any): Mesh;
  122616. /**
  122617. * Creates a tiled ground mesh
  122618. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122619. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122620. * * 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
  122621. * * 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
  122622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122623. * @param name defines the name of the mesh
  122624. * @param options defines the options used to create the mesh
  122625. * @param scene defines the hosting scene
  122626. * @returns the tiled ground mesh
  122627. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122628. */
  122629. static CreateTiledGround(name: string, options: {
  122630. xmin: number;
  122631. zmin: number;
  122632. xmax: number;
  122633. zmax: number;
  122634. subdivisions?: {
  122635. w: number;
  122636. h: number;
  122637. };
  122638. precision?: {
  122639. w: number;
  122640. h: number;
  122641. };
  122642. updatable?: boolean;
  122643. }, scene?: Nullable<Scene>): Mesh;
  122644. /**
  122645. * Creates a ground mesh from a height map
  122646. * * The parameter `url` sets the URL of the height map image resource.
  122647. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122648. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122649. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122650. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122651. * * 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.
  122652. * * 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).
  122653. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122655. * @param name defines the name of the mesh
  122656. * @param url defines the url to the height map
  122657. * @param options defines the options used to create the mesh
  122658. * @param scene defines the hosting scene
  122659. * @returns the ground mesh
  122660. * @see https://doc.babylonjs.com/babylon101/height_map
  122661. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122662. */
  122663. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122664. width?: number;
  122665. height?: number;
  122666. subdivisions?: number;
  122667. minHeight?: number;
  122668. maxHeight?: number;
  122669. colorFilter?: Color3;
  122670. alphaFilter?: number;
  122671. updatable?: boolean;
  122672. onReady?: (mesh: GroundMesh) => void;
  122673. }, scene?: Nullable<Scene>): GroundMesh;
  122674. }
  122675. }
  122676. declare module BABYLON {
  122677. /**
  122678. * Class containing static functions to help procedurally build meshes
  122679. */
  122680. export class TorusBuilder {
  122681. /**
  122682. * Creates a torus mesh
  122683. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122684. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122685. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122689. * @param name defines the name of the mesh
  122690. * @param options defines the options used to create the mesh
  122691. * @param scene defines the hosting scene
  122692. * @returns the torus mesh
  122693. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122694. */
  122695. static CreateTorus(name: string, options: {
  122696. diameter?: number;
  122697. thickness?: number;
  122698. tessellation?: number;
  122699. updatable?: boolean;
  122700. sideOrientation?: number;
  122701. frontUVs?: Vector4;
  122702. backUVs?: Vector4;
  122703. }, scene: any): Mesh;
  122704. }
  122705. }
  122706. declare module BABYLON {
  122707. /**
  122708. * Class containing static functions to help procedurally build meshes
  122709. */
  122710. export class CylinderBuilder {
  122711. /**
  122712. * Creates a cylinder or a cone mesh
  122713. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122714. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122715. * * 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.
  122716. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122717. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122718. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122719. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122720. * * 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).
  122721. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122722. * * 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).
  122723. * * 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
  122724. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122725. * * 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
  122726. * * 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.
  122727. * * If `enclose` is false, a ring surface is one element.
  122728. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122729. * * 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
  122730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122733. * @param name defines the name of the mesh
  122734. * @param options defines the options used to create the mesh
  122735. * @param scene defines the hosting scene
  122736. * @returns the cylinder mesh
  122737. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122738. */
  122739. static CreateCylinder(name: string, options: {
  122740. height?: number;
  122741. diameterTop?: number;
  122742. diameterBottom?: number;
  122743. diameter?: number;
  122744. tessellation?: number;
  122745. subdivisions?: number;
  122746. arc?: number;
  122747. faceColors?: Color4[];
  122748. faceUV?: Vector4[];
  122749. updatable?: boolean;
  122750. hasRings?: boolean;
  122751. enclose?: boolean;
  122752. cap?: number;
  122753. sideOrientation?: number;
  122754. frontUVs?: Vector4;
  122755. backUVs?: Vector4;
  122756. }, scene: any): Mesh;
  122757. }
  122758. }
  122759. declare module BABYLON {
  122760. /**
  122761. * States of the webXR experience
  122762. */
  122763. export enum WebXRState {
  122764. /**
  122765. * Transitioning to being in XR mode
  122766. */
  122767. ENTERING_XR = 0,
  122768. /**
  122769. * Transitioning to non XR mode
  122770. */
  122771. EXITING_XR = 1,
  122772. /**
  122773. * In XR mode and presenting
  122774. */
  122775. IN_XR = 2,
  122776. /**
  122777. * Not entered XR mode
  122778. */
  122779. NOT_IN_XR = 3
  122780. }
  122781. /**
  122782. * Abstraction of the XR render target
  122783. */
  122784. export interface WebXRRenderTarget extends IDisposable {
  122785. /**
  122786. * xrpresent context of the canvas which can be used to display/mirror xr content
  122787. */
  122788. canvasContext: WebGLRenderingContext;
  122789. /**
  122790. * xr layer for the canvas
  122791. */
  122792. xrLayer: Nullable<XRWebGLLayer>;
  122793. /**
  122794. * Initializes the xr layer for the session
  122795. * @param xrSession xr session
  122796. * @returns a promise that will resolve once the XR Layer has been created
  122797. */
  122798. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122799. }
  122800. }
  122801. declare module BABYLON {
  122802. /**
  122803. * COnfiguration object for WebXR output canvas
  122804. */
  122805. export class WebXRManagedOutputCanvasOptions {
  122806. /**
  122807. * An optional canvas in case you wish to create it yourself and provide it here.
  122808. * If not provided, a new canvas will be created
  122809. */
  122810. canvasElement?: HTMLCanvasElement;
  122811. /**
  122812. * Options for this XR Layer output
  122813. */
  122814. canvasOptions?: XRWebGLLayerOptions;
  122815. /**
  122816. * CSS styling for a newly created canvas (if not provided)
  122817. */
  122818. newCanvasCssStyle?: string;
  122819. /**
  122820. * Get the default values of the configuration object
  122821. * @returns default values of this configuration object
  122822. */
  122823. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  122824. }
  122825. /**
  122826. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  122827. */
  122828. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  122829. private _options;
  122830. private _canvas;
  122831. private _engine;
  122832. /**
  122833. * Rendering context of the canvas which can be used to display/mirror xr content
  122834. */
  122835. canvasContext: WebGLRenderingContext;
  122836. /**
  122837. * xr layer for the canvas
  122838. */
  122839. xrLayer: Nullable<XRWebGLLayer>;
  122840. /**
  122841. * Initializes the canvas to be added/removed upon entering/exiting xr
  122842. * @param _xrSessionManager The XR Session manager
  122843. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  122844. */
  122845. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  122846. /**
  122847. * Disposes of the object
  122848. */
  122849. dispose(): void;
  122850. /**
  122851. * Initializes the xr layer for the session
  122852. * @param xrSession xr session
  122853. * @returns a promise that will resolve once the XR Layer has been created
  122854. */
  122855. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122856. private _addCanvas;
  122857. private _removeCanvas;
  122858. private _setManagedOutputCanvas;
  122859. }
  122860. }
  122861. declare module BABYLON {
  122862. /**
  122863. * Manages an XRSession to work with Babylon's engine
  122864. * @see https://doc.babylonjs.com/how_to/webxr
  122865. */
  122866. export class WebXRSessionManager implements IDisposable {
  122867. /** The scene which the session should be created for */
  122868. scene: Scene;
  122869. private _referenceSpace;
  122870. private _rttProvider;
  122871. private _sessionEnded;
  122872. private _xrNavigator;
  122873. private baseLayer;
  122874. /**
  122875. * The base reference space from which the session started. good if you want to reset your
  122876. * reference space
  122877. */
  122878. baseReferenceSpace: XRReferenceSpace;
  122879. /**
  122880. * Current XR frame
  122881. */
  122882. currentFrame: Nullable<XRFrame>;
  122883. /** WebXR timestamp updated every frame */
  122884. currentTimestamp: number;
  122885. /**
  122886. * Used just in case of a failure to initialize an immersive session.
  122887. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  122888. */
  122889. defaultHeightCompensation: number;
  122890. /**
  122891. * Fires every time a new xrFrame arrives which can be used to update the camera
  122892. */
  122893. onXRFrameObservable: Observable<XRFrame>;
  122894. /**
  122895. * Fires when the reference space changed
  122896. */
  122897. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  122898. /**
  122899. * Fires when the xr session is ended either by the device or manually done
  122900. */
  122901. onXRSessionEnded: Observable<any>;
  122902. /**
  122903. * Fires when the xr session is ended either by the device or manually done
  122904. */
  122905. onXRSessionInit: Observable<XRSession>;
  122906. /**
  122907. * Underlying xr session
  122908. */
  122909. session: XRSession;
  122910. /**
  122911. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  122912. * or get the offset the player is currently at.
  122913. */
  122914. viewerReferenceSpace: XRReferenceSpace;
  122915. /**
  122916. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  122917. * @param scene The scene which the session should be created for
  122918. */
  122919. constructor(
  122920. /** The scene which the session should be created for */
  122921. scene: Scene);
  122922. /**
  122923. * The current reference space used in this session. This reference space can constantly change!
  122924. * It is mainly used to offset the camera's position.
  122925. */
  122926. get referenceSpace(): XRReferenceSpace;
  122927. /**
  122928. * Set a new reference space and triggers the observable
  122929. */
  122930. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  122931. /**
  122932. * Disposes of the session manager
  122933. */
  122934. dispose(): void;
  122935. /**
  122936. * Stops the xrSession and restores the render loop
  122937. * @returns Promise which resolves after it exits XR
  122938. */
  122939. exitXRAsync(): Promise<void>;
  122940. /**
  122941. * Gets the correct render target texture to be rendered this frame for this eye
  122942. * @param eye the eye for which to get the render target
  122943. * @returns the render target for the specified eye
  122944. */
  122945. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  122946. /**
  122947. * Creates a WebXRRenderTarget object for the XR session
  122948. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  122949. * @param options optional options to provide when creating a new render target
  122950. * @returns a WebXR render target to which the session can render
  122951. */
  122952. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  122953. /**
  122954. * Initializes the manager
  122955. * After initialization enterXR can be called to start an XR session
  122956. * @returns Promise which resolves after it is initialized
  122957. */
  122958. initializeAsync(): Promise<void>;
  122959. /**
  122960. * Initializes an xr session
  122961. * @param xrSessionMode mode to initialize
  122962. * @param xrSessionInit defines optional and required values to pass to the session builder
  122963. * @returns a promise which will resolve once the session has been initialized
  122964. */
  122965. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  122966. /**
  122967. * Checks if a session would be supported for the creation options specified
  122968. * @param sessionMode session mode to check if supported eg. immersive-vr
  122969. * @returns A Promise that resolves to true if supported and false if not
  122970. */
  122971. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122972. /**
  122973. * Resets the reference space to the one started the session
  122974. */
  122975. resetReferenceSpace(): void;
  122976. /**
  122977. * Starts rendering to the xr layer
  122978. */
  122979. runXRRenderLoop(): void;
  122980. /**
  122981. * Sets the reference space on the xr session
  122982. * @param referenceSpaceType space to set
  122983. * @returns a promise that will resolve once the reference space has been set
  122984. */
  122985. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122986. /**
  122987. * Updates the render state of the session
  122988. * @param state state to set
  122989. * @returns a promise that resolves once the render state has been updated
  122990. */
  122991. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  122992. /**
  122993. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  122994. * @param sessionMode defines the session to test
  122995. * @returns a promise with boolean as final value
  122996. */
  122997. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122998. private _createRenderTargetTexture;
  122999. }
  123000. }
  123001. declare module BABYLON {
  123002. /**
  123003. * WebXR Camera which holds the views for the xrSession
  123004. * @see https://doc.babylonjs.com/how_to/webxr_camera
  123005. */
  123006. export class WebXRCamera extends FreeCamera {
  123007. private _xrSessionManager;
  123008. private _firstFrame;
  123009. private _referenceQuaternion;
  123010. private _referencedPosition;
  123011. private _xrInvPositionCache;
  123012. private _xrInvQuaternionCache;
  123013. /**
  123014. * Should position compensation execute on first frame.
  123015. * This is used when copying the position from a native (non XR) camera
  123016. */
  123017. compensateOnFirstFrame: boolean;
  123018. /**
  123019. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  123020. * @param name the name of the camera
  123021. * @param scene the scene to add the camera to
  123022. * @param _xrSessionManager a constructed xr session manager
  123023. */
  123024. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  123025. /**
  123026. * Return the user's height, unrelated to the current ground.
  123027. * This will be the y position of this camera, when ground level is 0.
  123028. */
  123029. get realWorldHeight(): number;
  123030. /** @hidden */
  123031. _updateForDualEyeDebugging(): void;
  123032. /**
  123033. * Sets this camera's transformation based on a non-vr camera
  123034. * @param otherCamera the non-vr camera to copy the transformation from
  123035. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123036. */
  123037. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123038. /**
  123039. * Gets the current instance class name ("WebXRCamera").
  123040. * @returns the class name
  123041. */
  123042. getClassName(): string;
  123043. /**
  123044. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123045. */
  123046. _getViewMatrix(): Matrix;
  123047. private _updateFromXRSession;
  123048. private _updateNumberOfRigCameras;
  123049. private _updateReferenceSpace;
  123050. private _updateReferenceSpaceOffset;
  123051. }
  123052. }
  123053. declare module BABYLON {
  123054. /**
  123055. * Defining the interface required for a (webxr) feature
  123056. */
  123057. export interface IWebXRFeature extends IDisposable {
  123058. /**
  123059. * Is this feature attached
  123060. */
  123061. attached: boolean;
  123062. /**
  123063. * Should auto-attach be disabled?
  123064. */
  123065. disableAutoAttach: boolean;
  123066. /**
  123067. * Attach the feature to the session
  123068. * Will usually be called by the features manager
  123069. *
  123070. * @param force should attachment be forced (even when already attached)
  123071. * @returns true if successful.
  123072. */
  123073. attach(force?: boolean): boolean;
  123074. /**
  123075. * Detach the feature from the session
  123076. * Will usually be called by the features manager
  123077. *
  123078. * @returns true if successful.
  123079. */
  123080. detach(): boolean;
  123081. }
  123082. /**
  123083. * A list of the currently available features without referencing them
  123084. */
  123085. export class WebXRFeatureName {
  123086. /**
  123087. * The name of the anchor system feature
  123088. */
  123089. static ANCHOR_SYSTEM: string;
  123090. /**
  123091. * The name of the background remover feature
  123092. */
  123093. static BACKGROUND_REMOVER: string;
  123094. /**
  123095. * The name of the hit test feature
  123096. */
  123097. static HIT_TEST: string;
  123098. /**
  123099. * physics impostors for xr controllers feature
  123100. */
  123101. static PHYSICS_CONTROLLERS: string;
  123102. /**
  123103. * The name of the plane detection feature
  123104. */
  123105. static PLANE_DETECTION: string;
  123106. /**
  123107. * The name of the pointer selection feature
  123108. */
  123109. static POINTER_SELECTION: string;
  123110. /**
  123111. * The name of the teleportation feature
  123112. */
  123113. static TELEPORTATION: string;
  123114. }
  123115. /**
  123116. * Defining the constructor of a feature. Used to register the modules.
  123117. */
  123118. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123119. /**
  123120. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123121. * It is mainly used in AR sessions.
  123122. *
  123123. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123124. */
  123125. export class WebXRFeaturesManager implements IDisposable {
  123126. private _xrSessionManager;
  123127. private static readonly _AvailableFeatures;
  123128. private _features;
  123129. /**
  123130. * constructs a new features manages.
  123131. *
  123132. * @param _xrSessionManager an instance of WebXRSessionManager
  123133. */
  123134. constructor(_xrSessionManager: WebXRSessionManager);
  123135. /**
  123136. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123137. * Mainly used internally.
  123138. *
  123139. * @param featureName the name of the feature to register
  123140. * @param constructorFunction the function used to construct the module
  123141. * @param version the (babylon) version of the module
  123142. * @param stable is that a stable version of this module
  123143. */
  123144. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123145. /**
  123146. * Returns a constructor of a specific feature.
  123147. *
  123148. * @param featureName the name of the feature to construct
  123149. * @param version the version of the feature to load
  123150. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123151. * @param options optional options provided to the module.
  123152. * @returns a function that, when called, will return a new instance of this feature
  123153. */
  123154. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123155. /**
  123156. * Can be used to return the list of features currently registered
  123157. *
  123158. * @returns an Array of available features
  123159. */
  123160. static GetAvailableFeatures(): string[];
  123161. /**
  123162. * Gets the versions available for a specific feature
  123163. * @param featureName the name of the feature
  123164. * @returns an array with the available versions
  123165. */
  123166. static GetAvailableVersions(featureName: string): string[];
  123167. /**
  123168. * Return the latest unstable version of this feature
  123169. * @param featureName the name of the feature to search
  123170. * @returns the version number. if not found will return -1
  123171. */
  123172. static GetLatestVersionOfFeature(featureName: string): number;
  123173. /**
  123174. * Return the latest stable version of this feature
  123175. * @param featureName the name of the feature to search
  123176. * @returns the version number. if not found will return -1
  123177. */
  123178. static GetStableVersionOfFeature(featureName: string): number;
  123179. /**
  123180. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123181. * Can be used during a session to start a feature
  123182. * @param featureName the name of feature to attach
  123183. */
  123184. attachFeature(featureName: string): void;
  123185. /**
  123186. * Can be used inside a session or when the session ends to detach a specific feature
  123187. * @param featureName the name of the feature to detach
  123188. */
  123189. detachFeature(featureName: string): void;
  123190. /**
  123191. * Used to disable an already-enabled feature
  123192. * The feature will be disposed and will be recreated once enabled.
  123193. * @param featureName the feature to disable
  123194. * @returns true if disable was successful
  123195. */
  123196. disableFeature(featureName: string | {
  123197. Name: string;
  123198. }): boolean;
  123199. /**
  123200. * dispose this features manager
  123201. */
  123202. dispose(): void;
  123203. /**
  123204. * 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.
  123205. * 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.
  123206. *
  123207. * @param featureName the name of the feature to load or the class of the feature
  123208. * @param version optional version to load. if not provided the latest version will be enabled
  123209. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123210. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123211. * @returns a new constructed feature or throws an error if feature not found.
  123212. */
  123213. enableFeature(featureName: string | {
  123214. Name: string;
  123215. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123216. /**
  123217. * get the implementation of an enabled feature.
  123218. * @param featureName the name of the feature to load
  123219. * @returns the feature class, if found
  123220. */
  123221. getEnabledFeature(featureName: string): IWebXRFeature;
  123222. /**
  123223. * Get the list of enabled features
  123224. * @returns an array of enabled features
  123225. */
  123226. getEnabledFeatures(): string[];
  123227. }
  123228. }
  123229. declare module BABYLON {
  123230. /**
  123231. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  123232. * @see https://doc.babylonjs.com/how_to/webxr
  123233. */
  123234. export class WebXRExperienceHelper implements IDisposable {
  123235. private scene;
  123236. private _nonVRCamera;
  123237. private _originalSceneAutoClear;
  123238. private _supported;
  123239. /**
  123240. * Camera used to render xr content
  123241. */
  123242. camera: WebXRCamera;
  123243. /** A features manager for this xr session */
  123244. featuresManager: WebXRFeaturesManager;
  123245. /**
  123246. * Observers registered here will be triggered after the camera's initial transformation is set
  123247. * This can be used to set a different ground level or an extra rotation.
  123248. *
  123249. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  123250. * to the position set after this observable is done executing.
  123251. */
  123252. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  123253. /**
  123254. * Fires when the state of the experience helper has changed
  123255. */
  123256. onStateChangedObservable: Observable<WebXRState>;
  123257. /** Session manager used to keep track of xr session */
  123258. sessionManager: WebXRSessionManager;
  123259. /**
  123260. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  123261. */
  123262. state: WebXRState;
  123263. /**
  123264. * Creates a WebXRExperienceHelper
  123265. * @param scene The scene the helper should be created in
  123266. */
  123267. private constructor();
  123268. /**
  123269. * Creates the experience helper
  123270. * @param scene the scene to attach the experience helper to
  123271. * @returns a promise for the experience helper
  123272. */
  123273. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  123274. /**
  123275. * Disposes of the experience helper
  123276. */
  123277. dispose(): void;
  123278. /**
  123279. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  123280. * @param sessionMode options for the XR session
  123281. * @param referenceSpaceType frame of reference of the XR session
  123282. * @param renderTarget the output canvas that will be used to enter XR mode
  123283. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  123284. * @returns promise that resolves after xr mode has entered
  123285. */
  123286. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  123287. /**
  123288. * Exits XR mode and returns the scene to its original state
  123289. * @returns promise that resolves after xr mode has exited
  123290. */
  123291. exitXRAsync(): Promise<void>;
  123292. private _nonXRToXRCamera;
  123293. private _setState;
  123294. }
  123295. }
  123296. declare module BABYLON {
  123297. /**
  123298. * X-Y values for axes in WebXR
  123299. */
  123300. export interface IWebXRMotionControllerAxesValue {
  123301. /**
  123302. * The value of the x axis
  123303. */
  123304. x: number;
  123305. /**
  123306. * The value of the y-axis
  123307. */
  123308. y: number;
  123309. }
  123310. /**
  123311. * changed / previous values for the values of this component
  123312. */
  123313. export interface IWebXRMotionControllerComponentChangesValues<T> {
  123314. /**
  123315. * current (this frame) value
  123316. */
  123317. current: T;
  123318. /**
  123319. * previous (last change) value
  123320. */
  123321. previous: T;
  123322. }
  123323. /**
  123324. * Represents changes in the component between current frame and last values recorded
  123325. */
  123326. export interface IWebXRMotionControllerComponentChanges {
  123327. /**
  123328. * will be populated with previous and current values if axes changed
  123329. */
  123330. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  123331. /**
  123332. * will be populated with previous and current values if pressed changed
  123333. */
  123334. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123335. /**
  123336. * will be populated with previous and current values if touched changed
  123337. */
  123338. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123339. /**
  123340. * will be populated with previous and current values if value changed
  123341. */
  123342. value?: IWebXRMotionControllerComponentChangesValues<number>;
  123343. }
  123344. /**
  123345. * This class represents a single component (for example button or thumbstick) of a motion controller
  123346. */
  123347. export class WebXRControllerComponent implements IDisposable {
  123348. /**
  123349. * the id of this component
  123350. */
  123351. id: string;
  123352. /**
  123353. * the type of the component
  123354. */
  123355. type: MotionControllerComponentType;
  123356. private _buttonIndex;
  123357. private _axesIndices;
  123358. private _axes;
  123359. private _changes;
  123360. private _currentValue;
  123361. private _hasChanges;
  123362. private _pressed;
  123363. private _touched;
  123364. /**
  123365. * button component type
  123366. */
  123367. static BUTTON_TYPE: MotionControllerComponentType;
  123368. /**
  123369. * squeeze component type
  123370. */
  123371. static SQUEEZE_TYPE: MotionControllerComponentType;
  123372. /**
  123373. * Thumbstick component type
  123374. */
  123375. static THUMBSTICK_TYPE: MotionControllerComponentType;
  123376. /**
  123377. * Touchpad component type
  123378. */
  123379. static TOUCHPAD_TYPE: MotionControllerComponentType;
  123380. /**
  123381. * trigger component type
  123382. */
  123383. static TRIGGER_TYPE: MotionControllerComponentType;
  123384. /**
  123385. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  123386. * the axes data changes
  123387. */
  123388. onAxisValueChangedObservable: Observable<{
  123389. x: number;
  123390. y: number;
  123391. }>;
  123392. /**
  123393. * Observers registered here will be triggered when the state of a button changes
  123394. * State change is either pressed / touched / value
  123395. */
  123396. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  123397. /**
  123398. * Creates a new component for a motion controller.
  123399. * It is created by the motion controller itself
  123400. *
  123401. * @param id the id of this component
  123402. * @param type the type of the component
  123403. * @param _buttonIndex index in the buttons array of the gamepad
  123404. * @param _axesIndices indices of the values in the axes array of the gamepad
  123405. */
  123406. constructor(
  123407. /**
  123408. * the id of this component
  123409. */
  123410. id: string,
  123411. /**
  123412. * the type of the component
  123413. */
  123414. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  123415. /**
  123416. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  123417. */
  123418. get axes(): IWebXRMotionControllerAxesValue;
  123419. /**
  123420. * Get the changes. Elements will be populated only if they changed with their previous and current value
  123421. */
  123422. get changes(): IWebXRMotionControllerComponentChanges;
  123423. /**
  123424. * Return whether or not the component changed the last frame
  123425. */
  123426. get hasChanges(): boolean;
  123427. /**
  123428. * is the button currently pressed
  123429. */
  123430. get pressed(): boolean;
  123431. /**
  123432. * is the button currently touched
  123433. */
  123434. get touched(): boolean;
  123435. /**
  123436. * Get the current value of this component
  123437. */
  123438. get value(): number;
  123439. /**
  123440. * Dispose this component
  123441. */
  123442. dispose(): void;
  123443. /**
  123444. * Are there axes correlating to this component
  123445. * @return true is axes data is available
  123446. */
  123447. isAxes(): boolean;
  123448. /**
  123449. * Is this component a button (hence - pressable)
  123450. * @returns true if can be pressed
  123451. */
  123452. isButton(): boolean;
  123453. /**
  123454. * update this component using the gamepad object it is in. Called on every frame
  123455. * @param nativeController the native gamepad controller object
  123456. */
  123457. update(nativeController: IMinimalMotionControllerObject): void;
  123458. }
  123459. }
  123460. declare module BABYLON {
  123461. /**
  123462. * Class used to represent data loading progression
  123463. */
  123464. export class SceneLoaderProgressEvent {
  123465. /** defines if data length to load can be evaluated */
  123466. readonly lengthComputable: boolean;
  123467. /** defines the loaded data length */
  123468. readonly loaded: number;
  123469. /** defines the data length to load */
  123470. readonly total: number;
  123471. /**
  123472. * Create a new progress event
  123473. * @param lengthComputable defines if data length to load can be evaluated
  123474. * @param loaded defines the loaded data length
  123475. * @param total defines the data length to load
  123476. */
  123477. constructor(
  123478. /** defines if data length to load can be evaluated */
  123479. lengthComputable: boolean,
  123480. /** defines the loaded data length */
  123481. loaded: number,
  123482. /** defines the data length to load */
  123483. total: number);
  123484. /**
  123485. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  123486. * @param event defines the source event
  123487. * @returns a new SceneLoaderProgressEvent
  123488. */
  123489. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  123490. }
  123491. /**
  123492. * Interface used by SceneLoader plugins to define supported file extensions
  123493. */
  123494. export interface ISceneLoaderPluginExtensions {
  123495. /**
  123496. * Defines the list of supported extensions
  123497. */
  123498. [extension: string]: {
  123499. isBinary: boolean;
  123500. };
  123501. }
  123502. /**
  123503. * Interface used by SceneLoader plugin factory
  123504. */
  123505. export interface ISceneLoaderPluginFactory {
  123506. /**
  123507. * Defines the name of the factory
  123508. */
  123509. name: string;
  123510. /**
  123511. * Function called to create a new plugin
  123512. * @return the new plugin
  123513. */
  123514. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  123515. /**
  123516. * The callback that returns true if the data can be directly loaded.
  123517. * @param data string containing the file data
  123518. * @returns if the data can be loaded directly
  123519. */
  123520. canDirectLoad?(data: string): boolean;
  123521. }
  123522. /**
  123523. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  123524. */
  123525. export interface ISceneLoaderPluginBase {
  123526. /**
  123527. * The friendly name of this plugin.
  123528. */
  123529. name: string;
  123530. /**
  123531. * The file extensions supported by this plugin.
  123532. */
  123533. extensions: string | ISceneLoaderPluginExtensions;
  123534. /**
  123535. * The callback called when loading from a url.
  123536. * @param scene scene loading this url
  123537. * @param url url to load
  123538. * @param onSuccess callback called when the file successfully loads
  123539. * @param onProgress callback called while file is loading (if the server supports this mode)
  123540. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123541. * @param onError callback called when the file fails to load
  123542. * @returns a file request object
  123543. */
  123544. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123545. /**
  123546. * The callback called when loading from a file object.
  123547. * @param scene scene loading this file
  123548. * @param file defines the file to load
  123549. * @param onSuccess defines the callback to call when data is loaded
  123550. * @param onProgress defines the callback to call during loading process
  123551. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123552. * @param onError defines the callback to call when an error occurs
  123553. * @returns a file request object
  123554. */
  123555. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123556. /**
  123557. * The callback that returns true if the data can be directly loaded.
  123558. * @param data string containing the file data
  123559. * @returns if the data can be loaded directly
  123560. */
  123561. canDirectLoad?(data: string): boolean;
  123562. /**
  123563. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  123564. * @param scene scene loading this data
  123565. * @param data string containing the data
  123566. * @returns data to pass to the plugin
  123567. */
  123568. directLoad?(scene: Scene, data: string): any;
  123569. /**
  123570. * The callback that allows custom handling of the root url based on the response url.
  123571. * @param rootUrl the original root url
  123572. * @param responseURL the response url if available
  123573. * @returns the new root url
  123574. */
  123575. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  123576. }
  123577. /**
  123578. * Interface used to define a SceneLoader plugin
  123579. */
  123580. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  123581. /**
  123582. * Import meshes into a scene.
  123583. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123584. * @param scene The scene to import into
  123585. * @param data The data to import
  123586. * @param rootUrl The root url for scene and resources
  123587. * @param meshes The meshes array to import into
  123588. * @param particleSystems The particle systems array to import into
  123589. * @param skeletons The skeletons array to import into
  123590. * @param onError The callback when import fails
  123591. * @returns True if successful or false otherwise
  123592. */
  123593. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  123594. /**
  123595. * Load into a scene.
  123596. * @param scene The scene to load into
  123597. * @param data The data to import
  123598. * @param rootUrl The root url for scene and resources
  123599. * @param onError The callback when import fails
  123600. * @returns True if successful or false otherwise
  123601. */
  123602. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  123603. /**
  123604. * Load into an asset container.
  123605. * @param scene The scene to load into
  123606. * @param data The data to import
  123607. * @param rootUrl The root url for scene and resources
  123608. * @param onError The callback when import fails
  123609. * @returns The loaded asset container
  123610. */
  123611. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  123612. }
  123613. /**
  123614. * Interface used to define an async SceneLoader plugin
  123615. */
  123616. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  123617. /**
  123618. * Import meshes into a scene.
  123619. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123620. * @param scene The scene to import into
  123621. * @param data The data to import
  123622. * @param rootUrl The root url for scene and resources
  123623. * @param onProgress The callback when the load progresses
  123624. * @param fileName Defines the name of the file to load
  123625. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  123626. */
  123627. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  123628. meshes: AbstractMesh[];
  123629. particleSystems: IParticleSystem[];
  123630. skeletons: Skeleton[];
  123631. animationGroups: AnimationGroup[];
  123632. }>;
  123633. /**
  123634. * Load into a scene.
  123635. * @param scene The scene to load into
  123636. * @param data The data to import
  123637. * @param rootUrl The root url for scene and resources
  123638. * @param onProgress The callback when the load progresses
  123639. * @param fileName Defines the name of the file to load
  123640. * @returns Nothing
  123641. */
  123642. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  123643. /**
  123644. * Load into an asset container.
  123645. * @param scene The scene to load into
  123646. * @param data The data to import
  123647. * @param rootUrl The root url for scene and resources
  123648. * @param onProgress The callback when the load progresses
  123649. * @param fileName Defines the name of the file to load
  123650. * @returns The loaded asset container
  123651. */
  123652. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  123653. }
  123654. /**
  123655. * Mode that determines how to handle old animation groups before loading new ones.
  123656. */
  123657. export enum SceneLoaderAnimationGroupLoadingMode {
  123658. /**
  123659. * Reset all old animations to initial state then dispose them.
  123660. */
  123661. Clean = 0,
  123662. /**
  123663. * Stop all old animations.
  123664. */
  123665. Stop = 1,
  123666. /**
  123667. * Restart old animations from first frame.
  123668. */
  123669. Sync = 2,
  123670. /**
  123671. * Old animations remains untouched.
  123672. */
  123673. NoSync = 3
  123674. }
  123675. /**
  123676. * Class used to load scene from various file formats using registered plugins
  123677. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  123678. */
  123679. export class SceneLoader {
  123680. /**
  123681. * No logging while loading
  123682. */
  123683. static readonly NO_LOGGING: number;
  123684. /**
  123685. * Minimal logging while loading
  123686. */
  123687. static readonly MINIMAL_LOGGING: number;
  123688. /**
  123689. * Summary logging while loading
  123690. */
  123691. static readonly SUMMARY_LOGGING: number;
  123692. /**
  123693. * Detailled logging while loading
  123694. */
  123695. static readonly DETAILED_LOGGING: number;
  123696. /**
  123697. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  123698. */
  123699. static get ForceFullSceneLoadingForIncremental(): boolean;
  123700. static set ForceFullSceneLoadingForIncremental(value: boolean);
  123701. /**
  123702. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  123703. */
  123704. static get ShowLoadingScreen(): boolean;
  123705. static set ShowLoadingScreen(value: boolean);
  123706. /**
  123707. * Defines the current logging level (while loading the scene)
  123708. * @ignorenaming
  123709. */
  123710. static get loggingLevel(): number;
  123711. static set loggingLevel(value: number);
  123712. /**
  123713. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  123714. */
  123715. static get CleanBoneMatrixWeights(): boolean;
  123716. static set CleanBoneMatrixWeights(value: boolean);
  123717. /**
  123718. * Event raised when a plugin is used to load a scene
  123719. */
  123720. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123721. private static _registeredPlugins;
  123722. private static _getDefaultPlugin;
  123723. private static _getPluginForExtension;
  123724. private static _getPluginForDirectLoad;
  123725. private static _getPluginForFilename;
  123726. private static _getDirectLoad;
  123727. private static _loadData;
  123728. private static _getFileInfo;
  123729. /**
  123730. * Gets a plugin that can load the given extension
  123731. * @param extension defines the extension to load
  123732. * @returns a plugin or null if none works
  123733. */
  123734. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  123735. /**
  123736. * Gets a boolean indicating that the given extension can be loaded
  123737. * @param extension defines the extension to load
  123738. * @returns true if the extension is supported
  123739. */
  123740. static IsPluginForExtensionAvailable(extension: string): boolean;
  123741. /**
  123742. * Adds a new plugin to the list of registered plugins
  123743. * @param plugin defines the plugin to add
  123744. */
  123745. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  123746. /**
  123747. * Import meshes into a scene
  123748. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123749. * @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)
  123750. * @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)
  123751. * @param scene the instance of BABYLON.Scene to append to
  123752. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  123753. * @param onProgress a callback with a progress event for each file being loaded
  123754. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123755. * @param pluginExtension the extension used to determine the plugin
  123756. * @returns The loaded plugin
  123757. */
  123758. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123759. /**
  123760. * Import meshes into a scene
  123761. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123762. * @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)
  123763. * @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)
  123764. * @param scene the instance of BABYLON.Scene to append to
  123765. * @param onProgress a callback with a progress event for each file being loaded
  123766. * @param pluginExtension the extension used to determine the plugin
  123767. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  123768. */
  123769. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  123770. meshes: AbstractMesh[];
  123771. particleSystems: IParticleSystem[];
  123772. skeletons: Skeleton[];
  123773. animationGroups: AnimationGroup[];
  123774. }>;
  123775. /**
  123776. * Load a scene
  123777. * @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)
  123778. * @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)
  123779. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123780. * @param onSuccess a callback with the scene when import succeeds
  123781. * @param onProgress a callback with a progress event for each file being loaded
  123782. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123783. * @param pluginExtension the extension used to determine the plugin
  123784. * @returns The loaded plugin
  123785. */
  123786. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123787. /**
  123788. * Load a scene
  123789. * @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)
  123790. * @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)
  123791. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123792. * @param onProgress a callback with a progress event for each file being loaded
  123793. * @param pluginExtension the extension used to determine the plugin
  123794. * @returns The loaded scene
  123795. */
  123796. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123797. /**
  123798. * Append a scene
  123799. * @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)
  123800. * @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)
  123801. * @param scene is the instance of BABYLON.Scene to append to
  123802. * @param onSuccess a callback with the scene when import succeeds
  123803. * @param onProgress a callback with a progress event for each file being loaded
  123804. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123805. * @param pluginExtension the extension used to determine the plugin
  123806. * @returns The loaded plugin
  123807. */
  123808. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123809. /**
  123810. * Append a scene
  123811. * @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)
  123812. * @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)
  123813. * @param scene is the instance of BABYLON.Scene to append to
  123814. * @param onProgress a callback with a progress event for each file being loaded
  123815. * @param pluginExtension the extension used to determine the plugin
  123816. * @returns The given scene
  123817. */
  123818. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123819. /**
  123820. * Load a scene into an asset container
  123821. * @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)
  123822. * @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)
  123823. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123824. * @param onSuccess a callback with the scene when import succeeds
  123825. * @param onProgress a callback with a progress event for each file being loaded
  123826. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123827. * @param pluginExtension the extension used to determine the plugin
  123828. * @returns The loaded plugin
  123829. */
  123830. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123831. /**
  123832. * Load a scene into an asset container
  123833. * @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)
  123834. * @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)
  123835. * @param scene is the instance of Scene to append to
  123836. * @param onProgress a callback with a progress event for each file being loaded
  123837. * @param pluginExtension the extension used to determine the plugin
  123838. * @returns The loaded asset container
  123839. */
  123840. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  123841. /**
  123842. * Import animations from a file into a scene
  123843. * @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)
  123844. * @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)
  123845. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123846. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123847. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123848. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123849. * @param onSuccess a callback with the scene when import succeeds
  123850. * @param onProgress a callback with a progress event for each file being loaded
  123851. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123852. */
  123853. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  123854. /**
  123855. * Import animations from a file into a scene
  123856. * @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)
  123857. * @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)
  123858. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123859. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123860. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123861. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123862. * @param onSuccess a callback with the scene when import succeeds
  123863. * @param onProgress a callback with a progress event for each file being loaded
  123864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123865. * @returns the updated scene with imported animations
  123866. */
  123867. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  123868. }
  123869. }
  123870. declare module BABYLON {
  123871. /**
  123872. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  123873. */
  123874. export type MotionControllerHandedness = "none" | "left" | "right";
  123875. /**
  123876. * The type of components available in motion controllers.
  123877. * This is not the name of the component.
  123878. */
  123879. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  123880. /**
  123881. * The state of a controller component
  123882. */
  123883. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  123884. /**
  123885. * The schema of motion controller layout.
  123886. * No object will be initialized using this interface
  123887. * This is used just to define the profile.
  123888. */
  123889. export interface IMotionControllerLayout {
  123890. /**
  123891. * Path to load the assets. Usually relative to the base path
  123892. */
  123893. assetPath: string;
  123894. /**
  123895. * Available components (unsorted)
  123896. */
  123897. components: {
  123898. /**
  123899. * A map of component Ids
  123900. */
  123901. [componentId: string]: {
  123902. /**
  123903. * The type of input the component outputs
  123904. */
  123905. type: MotionControllerComponentType;
  123906. /**
  123907. * The indices of this component in the gamepad object
  123908. */
  123909. gamepadIndices: {
  123910. /**
  123911. * Index of button
  123912. */
  123913. button?: number;
  123914. /**
  123915. * If available, index of x-axis
  123916. */
  123917. xAxis?: number;
  123918. /**
  123919. * If available, index of y-axis
  123920. */
  123921. yAxis?: number;
  123922. };
  123923. /**
  123924. * The mesh's root node name
  123925. */
  123926. rootNodeName: string;
  123927. /**
  123928. * Animation definitions for this model
  123929. */
  123930. visualResponses: {
  123931. [stateKey: string]: {
  123932. /**
  123933. * What property will be animated
  123934. */
  123935. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  123936. /**
  123937. * What states influence this visual response
  123938. */
  123939. states: MotionControllerComponentStateType[];
  123940. /**
  123941. * Type of animation - movement or visibility
  123942. */
  123943. valueNodeProperty: "transform" | "visibility";
  123944. /**
  123945. * Base node name to move. Its position will be calculated according to the min and max nodes
  123946. */
  123947. valueNodeName?: string;
  123948. /**
  123949. * Minimum movement node
  123950. */
  123951. minNodeName?: string;
  123952. /**
  123953. * Max movement node
  123954. */
  123955. maxNodeName?: string;
  123956. };
  123957. };
  123958. /**
  123959. * If touch enabled, what is the name of node to display user feedback
  123960. */
  123961. touchPointNodeName?: string;
  123962. };
  123963. };
  123964. /**
  123965. * Is it xr standard mapping or not
  123966. */
  123967. gamepadMapping: "" | "xr-standard";
  123968. /**
  123969. * Base root node of this entire model
  123970. */
  123971. rootNodeName: string;
  123972. /**
  123973. * Defines the main button component id
  123974. */
  123975. selectComponentId: string;
  123976. }
  123977. /**
  123978. * A definition for the layout map in the input profile
  123979. */
  123980. export interface IMotionControllerLayoutMap {
  123981. /**
  123982. * Layouts with handedness type as a key
  123983. */
  123984. [handedness: string]: IMotionControllerLayout;
  123985. }
  123986. /**
  123987. * The XR Input profile schema
  123988. * Profiles can be found here:
  123989. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  123990. */
  123991. export interface IMotionControllerProfile {
  123992. /**
  123993. * fallback profiles for this profileId
  123994. */
  123995. fallbackProfileIds: string[];
  123996. /**
  123997. * The layout map, with handedness as key
  123998. */
  123999. layouts: IMotionControllerLayoutMap;
  124000. /**
  124001. * The id of this profile
  124002. * correlates to the profile(s) in the xrInput.profiles array
  124003. */
  124004. profileId: string;
  124005. }
  124006. /**
  124007. * A helper-interface for the 3 meshes needed for controller button animation
  124008. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  124009. */
  124010. export interface IMotionControllerButtonMeshMap {
  124011. /**
  124012. * the mesh that defines the pressed value mesh position.
  124013. * This is used to find the max-position of this button
  124014. */
  124015. pressedMesh: AbstractMesh;
  124016. /**
  124017. * the mesh that defines the unpressed value mesh position.
  124018. * This is used to find the min (or initial) position of this button
  124019. */
  124020. unpressedMesh: AbstractMesh;
  124021. /**
  124022. * The mesh that will be changed when value changes
  124023. */
  124024. valueMesh: AbstractMesh;
  124025. }
  124026. /**
  124027. * A helper-interface for the 3 meshes needed for controller axis animation.
  124028. * This will be expanded when touchpad animations are fully supported
  124029. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  124030. */
  124031. export interface IMotionControllerMeshMap {
  124032. /**
  124033. * the mesh that defines the maximum value mesh position.
  124034. */
  124035. maxMesh?: AbstractMesh;
  124036. /**
  124037. * the mesh that defines the minimum value mesh position.
  124038. */
  124039. minMesh?: AbstractMesh;
  124040. /**
  124041. * The mesh that will be changed when axis value changes
  124042. */
  124043. valueMesh: AbstractMesh;
  124044. }
  124045. /**
  124046. * The elements needed for change-detection of the gamepad objects in motion controllers
  124047. */
  124048. export interface IMinimalMotionControllerObject {
  124049. /**
  124050. * Available axes of this controller
  124051. */
  124052. axes: number[];
  124053. /**
  124054. * An array of available buttons
  124055. */
  124056. buttons: Array<{
  124057. /**
  124058. * Value of the button/trigger
  124059. */
  124060. value: number;
  124061. /**
  124062. * If the button/trigger is currently touched
  124063. */
  124064. touched: boolean;
  124065. /**
  124066. * If the button/trigger is currently pressed
  124067. */
  124068. pressed: boolean;
  124069. }>;
  124070. /**
  124071. * EXPERIMENTAL haptic support.
  124072. */
  124073. hapticActuators?: Array<{
  124074. pulse: (value: number, duration: number) => Promise<boolean>;
  124075. }>;
  124076. }
  124077. /**
  124078. * An Abstract Motion controller
  124079. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124080. * Each component has an observable to check for changes in value and state
  124081. */
  124082. export abstract class WebXRAbstractMotionController implements IDisposable {
  124083. protected scene: Scene;
  124084. protected layout: IMotionControllerLayout;
  124085. /**
  124086. * The gamepad object correlating to this controller
  124087. */
  124088. gamepadObject: IMinimalMotionControllerObject;
  124089. /**
  124090. * handedness (left/right/none) of this controller
  124091. */
  124092. handedness: MotionControllerHandedness;
  124093. private _initComponent;
  124094. private _modelReady;
  124095. /**
  124096. * A map of components (WebXRControllerComponent) in this motion controller
  124097. * Components have a ComponentType and can also have both button and axis definitions
  124098. */
  124099. readonly components: {
  124100. [id: string]: WebXRControllerComponent;
  124101. };
  124102. /**
  124103. * Disable the model's animation. Can be set at any time.
  124104. */
  124105. disableAnimation: boolean;
  124106. /**
  124107. * Observers registered here will be triggered when the model of this controller is done loading
  124108. */
  124109. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124110. /**
  124111. * The profile id of this motion controller
  124112. */
  124113. abstract profileId: string;
  124114. /**
  124115. * The root mesh of the model. It is null if the model was not yet initialized
  124116. */
  124117. rootMesh: Nullable<AbstractMesh>;
  124118. /**
  124119. * constructs a new abstract motion controller
  124120. * @param scene the scene to which the model of the controller will be added
  124121. * @param layout The profile layout to load
  124122. * @param gamepadObject The gamepad object correlating to this controller
  124123. * @param handedness handedness (left/right/none) of this controller
  124124. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124125. */
  124126. constructor(scene: Scene, layout: IMotionControllerLayout,
  124127. /**
  124128. * The gamepad object correlating to this controller
  124129. */
  124130. gamepadObject: IMinimalMotionControllerObject,
  124131. /**
  124132. * handedness (left/right/none) of this controller
  124133. */
  124134. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124135. /**
  124136. * Dispose this controller, the model mesh and all its components
  124137. */
  124138. dispose(): void;
  124139. /**
  124140. * Returns all components of specific type
  124141. * @param type the type to search for
  124142. * @return an array of components with this type
  124143. */
  124144. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124145. /**
  124146. * get a component based an its component id as defined in layout.components
  124147. * @param id the id of the component
  124148. * @returns the component correlates to the id or undefined if not found
  124149. */
  124150. getComponent(id: string): WebXRControllerComponent;
  124151. /**
  124152. * Get the list of components available in this motion controller
  124153. * @returns an array of strings correlating to available components
  124154. */
  124155. getComponentIds(): string[];
  124156. /**
  124157. * Get the first component of specific type
  124158. * @param type type of component to find
  124159. * @return a controller component or null if not found
  124160. */
  124161. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124162. /**
  124163. * Get the main (Select) component of this controller as defined in the layout
  124164. * @returns the main component of this controller
  124165. */
  124166. getMainComponent(): WebXRControllerComponent;
  124167. /**
  124168. * Loads the model correlating to this controller
  124169. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124170. * @returns A promise fulfilled with the result of the model loading
  124171. */
  124172. loadModel(): Promise<boolean>;
  124173. /**
  124174. * Update this model using the current XRFrame
  124175. * @param xrFrame the current xr frame to use and update the model
  124176. */
  124177. updateFromXRFrame(xrFrame: XRFrame): void;
  124178. /**
  124179. * Backwards compatibility due to a deeply-integrated typo
  124180. */
  124181. get handness(): XREye;
  124182. /**
  124183. * Pulse (vibrate) this controller
  124184. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124185. * Consecutive calls to this function will cancel the last pulse call
  124186. *
  124187. * @param value the strength of the pulse in 0.0...1.0 range
  124188. * @param duration Duration of the pulse in milliseconds
  124189. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124190. * @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
  124191. */
  124192. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124193. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124194. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124195. /**
  124196. * Moves the axis on the controller mesh based on its current state
  124197. * @param axis the index of the axis
  124198. * @param axisValue the value of the axis which determines the meshes new position
  124199. * @hidden
  124200. */
  124201. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124202. /**
  124203. * Update the model itself with the current frame data
  124204. * @param xrFrame the frame to use for updating the model mesh
  124205. */
  124206. protected updateModel(xrFrame: XRFrame): void;
  124207. /**
  124208. * Get the filename and path for this controller's model
  124209. * @returns a map of filename and path
  124210. */
  124211. protected abstract _getFilenameAndPath(): {
  124212. filename: string;
  124213. path: string;
  124214. };
  124215. /**
  124216. * This function is called before the mesh is loaded. It checks for loading constraints.
  124217. * For example, this function can check if the GLB loader is available
  124218. * If this function returns false, the generic controller will be loaded instead
  124219. * @returns Is the client ready to load the mesh
  124220. */
  124221. protected abstract _getModelLoadingConstraints(): boolean;
  124222. /**
  124223. * This function will be called after the model was successfully loaded and can be used
  124224. * for mesh transformations before it is available for the user
  124225. * @param meshes the loaded meshes
  124226. */
  124227. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124228. /**
  124229. * Set the root mesh for this controller. Important for the WebXR controller class
  124230. * @param meshes the loaded meshes
  124231. */
  124232. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  124233. /**
  124234. * A function executed each frame that updates the mesh (if needed)
  124235. * @param xrFrame the current xrFrame
  124236. */
  124237. protected abstract _updateModel(xrFrame: XRFrame): void;
  124238. private _getGenericFilenameAndPath;
  124239. private _getGenericParentMesh;
  124240. }
  124241. }
  124242. declare module BABYLON {
  124243. /**
  124244. * A generic trigger-only motion controller for WebXR
  124245. */
  124246. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  124247. /**
  124248. * Static version of the profile id of this controller
  124249. */
  124250. static ProfileId: string;
  124251. profileId: string;
  124252. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  124253. protected _getFilenameAndPath(): {
  124254. filename: string;
  124255. path: string;
  124256. };
  124257. protected _getModelLoadingConstraints(): boolean;
  124258. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  124259. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124260. protected _updateModel(): void;
  124261. }
  124262. }
  124263. declare module BABYLON {
  124264. /**
  124265. * Class containing static functions to help procedurally build meshes
  124266. */
  124267. export class SphereBuilder {
  124268. /**
  124269. * Creates a sphere mesh
  124270. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124271. * * 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`)
  124272. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124273. * * 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
  124274. * * 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)
  124275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124278. * @param name defines the name of the mesh
  124279. * @param options defines the options used to create the mesh
  124280. * @param scene defines the hosting scene
  124281. * @returns the sphere mesh
  124282. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124283. */
  124284. static CreateSphere(name: string, options: {
  124285. segments?: number;
  124286. diameter?: number;
  124287. diameterX?: number;
  124288. diameterY?: number;
  124289. diameterZ?: number;
  124290. arc?: number;
  124291. slice?: number;
  124292. sideOrientation?: number;
  124293. frontUVs?: Vector4;
  124294. backUVs?: Vector4;
  124295. updatable?: boolean;
  124296. }, scene?: Nullable<Scene>): Mesh;
  124297. }
  124298. }
  124299. declare module BABYLON {
  124300. /**
  124301. * A profiled motion controller has its profile loaded from an online repository.
  124302. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  124303. */
  124304. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  124305. private _repositoryUrl;
  124306. private _buttonMeshMapping;
  124307. private _touchDots;
  124308. /**
  124309. * The profile ID of this controller. Will be populated when the controller initializes.
  124310. */
  124311. profileId: string;
  124312. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  124313. dispose(): void;
  124314. protected _getFilenameAndPath(): {
  124315. filename: string;
  124316. path: string;
  124317. };
  124318. protected _getModelLoadingConstraints(): boolean;
  124319. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  124320. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124321. protected _updateModel(_xrFrame: XRFrame): void;
  124322. }
  124323. }
  124324. declare module BABYLON {
  124325. /**
  124326. * A construction function type to create a new controller based on an xrInput object
  124327. */
  124328. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  124329. /**
  124330. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  124331. *
  124332. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  124333. * it should be replaced with auto-loaded controllers.
  124334. *
  124335. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  124336. */
  124337. export class WebXRMotionControllerManager {
  124338. private static _AvailableControllers;
  124339. private static _Fallbacks;
  124340. private static _ProfileLoadingPromises;
  124341. private static _ProfilesList;
  124342. /**
  124343. * The base URL of the online controller repository. Can be changed at any time.
  124344. */
  124345. static BaseRepositoryUrl: string;
  124346. /**
  124347. * Which repository gets priority - local or online
  124348. */
  124349. static PrioritizeOnlineRepository: boolean;
  124350. /**
  124351. * Use the online repository, or use only locally-defined controllers
  124352. */
  124353. static UseOnlineRepository: boolean;
  124354. /**
  124355. * Clear the cache used for profile loading and reload when requested again
  124356. */
  124357. static ClearProfilesCache(): void;
  124358. /**
  124359. * Register the default fallbacks.
  124360. * This function is called automatically when this file is imported.
  124361. */
  124362. static DefaultFallbacks(): void;
  124363. /**
  124364. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  124365. * @param profileId the profile to which a fallback needs to be found
  124366. * @return an array with corresponding fallback profiles
  124367. */
  124368. static FindFallbackWithProfileId(profileId: string): string[];
  124369. /**
  124370. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  124371. * The order of search:
  124372. *
  124373. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  124374. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  124375. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  124376. * 4) return the generic trigger controller if none were found
  124377. *
  124378. * @param xrInput the xrInput to which a new controller is initialized
  124379. * @param scene the scene to which the model will be added
  124380. * @param forceProfile force a certain profile for this controller
  124381. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  124382. */
  124383. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  124384. /**
  124385. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  124386. *
  124387. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  124388. *
  124389. * @param type the profile type to register
  124390. * @param constructFunction the function to be called when loading this profile
  124391. */
  124392. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  124393. /**
  124394. * Register a fallback to a specific profile.
  124395. * @param profileId the profileId that will receive the fallbacks
  124396. * @param fallbacks A list of fallback profiles
  124397. */
  124398. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  124399. /**
  124400. * Will update the list of profiles available in the repository
  124401. * @return a promise that resolves to a map of profiles available online
  124402. */
  124403. static UpdateProfilesList(): Promise<{
  124404. [profile: string]: string;
  124405. }>;
  124406. private static _LoadProfileFromRepository;
  124407. private static _LoadProfilesFromAvailableControllers;
  124408. }
  124409. }
  124410. declare module BABYLON {
  124411. /**
  124412. * Configuration options for the WebXR controller creation
  124413. */
  124414. export interface IWebXRControllerOptions {
  124415. /**
  124416. * Should the controller mesh be animated when a user interacts with it
  124417. * The pressed buttons / thumbstick and touchpad animations will be disabled
  124418. */
  124419. disableMotionControllerAnimation?: boolean;
  124420. /**
  124421. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  124422. */
  124423. doNotLoadControllerMesh?: boolean;
  124424. /**
  124425. * Force a specific controller type for this controller.
  124426. * This can be used when creating your own profile or when testing different controllers
  124427. */
  124428. forceControllerProfile?: string;
  124429. /**
  124430. * Defines a rendering group ID for meshes that will be loaded.
  124431. * This is for the default controllers only.
  124432. */
  124433. renderingGroupId?: number;
  124434. }
  124435. /**
  124436. * Represents an XR controller
  124437. */
  124438. export class WebXRInputSource {
  124439. private _scene;
  124440. /** The underlying input source for the controller */
  124441. inputSource: XRInputSource;
  124442. private _options;
  124443. private _tmpVector;
  124444. private _uniqueId;
  124445. /**
  124446. * 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
  124447. */
  124448. grip?: AbstractMesh;
  124449. /**
  124450. * If available, this is the gamepad object related to this controller.
  124451. * Using this object it is possible to get click events and trackpad changes of the
  124452. * webxr controller that is currently being used.
  124453. */
  124454. motionController?: WebXRAbstractMotionController;
  124455. /**
  124456. * Event that fires when the controller is removed/disposed.
  124457. * The object provided as event data is this controller, after associated assets were disposed.
  124458. * uniqueId is still available.
  124459. */
  124460. onDisposeObservable: Observable<WebXRInputSource>;
  124461. /**
  124462. * Will be triggered when the mesh associated with the motion controller is done loading.
  124463. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  124464. * A shortened version of controller -> motion controller -> on mesh loaded.
  124465. */
  124466. onMeshLoadedObservable: Observable<AbstractMesh>;
  124467. /**
  124468. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  124469. */
  124470. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  124471. /**
  124472. * Pointer which can be used to select objects or attach a visible laser to
  124473. */
  124474. pointer: AbstractMesh;
  124475. /**
  124476. * Creates the controller
  124477. * @see https://doc.babylonjs.com/how_to/webxr
  124478. * @param _scene the scene which the controller should be associated to
  124479. * @param inputSource the underlying input source for the controller
  124480. * @param _options options for this controller creation
  124481. */
  124482. constructor(_scene: Scene,
  124483. /** The underlying input source for the controller */
  124484. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  124485. /**
  124486. * Get this controllers unique id
  124487. */
  124488. get uniqueId(): string;
  124489. /**
  124490. * Disposes of the object
  124491. */
  124492. dispose(): void;
  124493. /**
  124494. * Gets a world space ray coming from the pointer or grip
  124495. * @param result the resulting ray
  124496. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  124497. */
  124498. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  124499. /**
  124500. * Updates the controller pose based on the given XRFrame
  124501. * @param xrFrame xr frame to update the pose with
  124502. * @param referenceSpace reference space to use
  124503. */
  124504. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  124505. }
  124506. }
  124507. declare module BABYLON {
  124508. /**
  124509. * The schema for initialization options of the XR Input class
  124510. */
  124511. export interface IWebXRInputOptions {
  124512. /**
  124513. * If set to true no model will be automatically loaded
  124514. */
  124515. doNotLoadControllerMeshes?: boolean;
  124516. /**
  124517. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  124518. * If not found, the xr input profile data will be used.
  124519. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  124520. */
  124521. forceInputProfile?: string;
  124522. /**
  124523. * Do not send a request to the controller repository to load the profile.
  124524. *
  124525. * Instead, use the controllers available in babylon itself.
  124526. */
  124527. disableOnlineControllerRepository?: boolean;
  124528. /**
  124529. * A custom URL for the controllers repository
  124530. */
  124531. customControllersRepositoryURL?: string;
  124532. /**
  124533. * Should the controller model's components not move according to the user input
  124534. */
  124535. disableControllerAnimation?: boolean;
  124536. /**
  124537. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  124538. */
  124539. controllerOptions?: IWebXRControllerOptions;
  124540. }
  124541. /**
  124542. * XR input used to track XR inputs such as controllers/rays
  124543. */
  124544. export class WebXRInput implements IDisposable {
  124545. /**
  124546. * the xr session manager for this session
  124547. */
  124548. xrSessionManager: WebXRSessionManager;
  124549. /**
  124550. * the WebXR camera for this session. Mainly used for teleportation
  124551. */
  124552. xrCamera: WebXRCamera;
  124553. private readonly options;
  124554. /**
  124555. * XR controllers being tracked
  124556. */
  124557. controllers: Array<WebXRInputSource>;
  124558. private _frameObserver;
  124559. private _sessionEndedObserver;
  124560. private _sessionInitObserver;
  124561. /**
  124562. * Event when a controller has been connected/added
  124563. */
  124564. onControllerAddedObservable: Observable<WebXRInputSource>;
  124565. /**
  124566. * Event when a controller has been removed/disconnected
  124567. */
  124568. onControllerRemovedObservable: Observable<WebXRInputSource>;
  124569. /**
  124570. * Initializes the WebXRInput
  124571. * @param xrSessionManager the xr session manager for this session
  124572. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  124573. * @param options = initialization options for this xr input
  124574. */
  124575. constructor(
  124576. /**
  124577. * the xr session manager for this session
  124578. */
  124579. xrSessionManager: WebXRSessionManager,
  124580. /**
  124581. * the WebXR camera for this session. Mainly used for teleportation
  124582. */
  124583. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  124584. private _onInputSourcesChange;
  124585. private _addAndRemoveControllers;
  124586. /**
  124587. * Disposes of the object
  124588. */
  124589. dispose(): void;
  124590. }
  124591. }
  124592. declare module BABYLON {
  124593. /**
  124594. * This is the base class for all WebXR features.
  124595. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  124596. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  124597. */
  124598. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  124599. protected _xrSessionManager: WebXRSessionManager;
  124600. private _attached;
  124601. private _removeOnDetach;
  124602. /**
  124603. * Should auto-attach be disabled?
  124604. */
  124605. disableAutoAttach: boolean;
  124606. /**
  124607. * Construct a new (abstract) WebXR feature
  124608. * @param _xrSessionManager the xr session manager for this feature
  124609. */
  124610. constructor(_xrSessionManager: WebXRSessionManager);
  124611. /**
  124612. * Is this feature attached
  124613. */
  124614. get attached(): boolean;
  124615. /**
  124616. * attach this feature
  124617. *
  124618. * @param force should attachment be forced (even when already attached)
  124619. * @returns true if successful, false is failed or already attached
  124620. */
  124621. attach(force?: boolean): boolean;
  124622. /**
  124623. * detach this feature.
  124624. *
  124625. * @returns true if successful, false if failed or already detached
  124626. */
  124627. detach(): boolean;
  124628. /**
  124629. * Dispose this feature and all of the resources attached
  124630. */
  124631. dispose(): void;
  124632. /**
  124633. * This is used to register callbacks that will automatically be removed when detach is called.
  124634. * @param observable the observable to which the observer will be attached
  124635. * @param callback the callback to register
  124636. */
  124637. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  124638. /**
  124639. * Code in this function will be executed on each xrFrame received from the browser.
  124640. * This function will not execute after the feature is detached.
  124641. * @param _xrFrame the current frame
  124642. */
  124643. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  124644. }
  124645. }
  124646. declare module BABYLON {
  124647. /**
  124648. * Renders a layer on top of an existing scene
  124649. */
  124650. export class UtilityLayerRenderer implements IDisposable {
  124651. /** the original scene that will be rendered on top of */
  124652. originalScene: Scene;
  124653. private _pointerCaptures;
  124654. private _lastPointerEvents;
  124655. private static _DefaultUtilityLayer;
  124656. private static _DefaultKeepDepthUtilityLayer;
  124657. private _sharedGizmoLight;
  124658. private _renderCamera;
  124659. /**
  124660. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  124661. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  124662. * @returns the camera that is used when rendering the utility layer
  124663. */
  124664. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  124665. /**
  124666. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  124667. * @param cam the camera that should be used when rendering the utility layer
  124668. */
  124669. setRenderCamera(cam: Nullable<Camera>): void;
  124670. /**
  124671. * @hidden
  124672. * Light which used by gizmos to get light shading
  124673. */
  124674. _getSharedGizmoLight(): HemisphericLight;
  124675. /**
  124676. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124677. */
  124678. pickUtilitySceneFirst: boolean;
  124679. /**
  124680. * 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)
  124681. */
  124682. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  124683. /**
  124684. * 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)
  124685. */
  124686. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  124687. /**
  124688. * The scene that is rendered on top of the original scene
  124689. */
  124690. utilityLayerScene: Scene;
  124691. /**
  124692. * If the utility layer should automatically be rendered on top of existing scene
  124693. */
  124694. shouldRender: boolean;
  124695. /**
  124696. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124697. */
  124698. onlyCheckPointerDownEvents: boolean;
  124699. /**
  124700. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124701. */
  124702. processAllEvents: boolean;
  124703. /**
  124704. * Observable raised when the pointer move from the utility layer scene to the main scene
  124705. */
  124706. onPointerOutObservable: Observable<number>;
  124707. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  124708. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  124709. private _afterRenderObserver;
  124710. private _sceneDisposeObserver;
  124711. private _originalPointerObserver;
  124712. /**
  124713. * Instantiates a UtilityLayerRenderer
  124714. * @param originalScene the original scene that will be rendered on top of
  124715. * @param handleEvents boolean indicating if the utility layer should handle events
  124716. */
  124717. constructor(
  124718. /** the original scene that will be rendered on top of */
  124719. originalScene: Scene, handleEvents?: boolean);
  124720. private _notifyObservers;
  124721. /**
  124722. * Renders the utility layers scene on top of the original scene
  124723. */
  124724. render(): void;
  124725. /**
  124726. * Disposes of the renderer
  124727. */
  124728. dispose(): void;
  124729. private _updateCamera;
  124730. }
  124731. }
  124732. declare module BABYLON {
  124733. /**
  124734. * Options interface for the pointer selection module
  124735. */
  124736. export interface IWebXRControllerPointerSelectionOptions {
  124737. /**
  124738. * if provided, this scene will be used to render meshes.
  124739. */
  124740. customUtilityLayerScene?: Scene;
  124741. /**
  124742. * 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)
  124743. * If not disabled, the last picked point will be used to execute a pointer up event
  124744. * If disabled, pointer up event will be triggered right after the pointer down event.
  124745. * Used in screen and gaze target ray mode only
  124746. */
  124747. disablePointerUpOnTouchOut: boolean;
  124748. /**
  124749. * For gaze mode (time to select instead of press)
  124750. */
  124751. forceGazeMode: boolean;
  124752. /**
  124753. * 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
  124754. * to start a new countdown to the pointer down event.
  124755. * Defaults to 1.
  124756. */
  124757. gazeModePointerMovedFactor?: number;
  124758. /**
  124759. * Different button type to use instead of the main component
  124760. */
  124761. overrideButtonId?: string;
  124762. /**
  124763. * use this rendering group id for the meshes (optional)
  124764. */
  124765. renderingGroupId?: number;
  124766. /**
  124767. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  124768. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  124769. * 3000 means 3 seconds between pointing at something and selecting it
  124770. */
  124771. timeToSelect?: number;
  124772. /**
  124773. * Should meshes created here be added to a utility layer or the main scene
  124774. */
  124775. useUtilityLayer?: boolean;
  124776. /**
  124777. * the xr input to use with this pointer selection
  124778. */
  124779. xrInput: WebXRInput;
  124780. }
  124781. /**
  124782. * A module that will enable pointer selection for motion controllers of XR Input Sources
  124783. */
  124784. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  124785. private readonly _options;
  124786. private static _idCounter;
  124787. private _attachController;
  124788. private _controllers;
  124789. private _scene;
  124790. private _tmpVectorForPickCompare;
  124791. /**
  124792. * The module's name
  124793. */
  124794. static readonly Name: string;
  124795. /**
  124796. * The (Babylon) version of this module.
  124797. * This is an integer representing the implementation version.
  124798. * This number does not correspond to the WebXR specs version
  124799. */
  124800. static readonly Version: number;
  124801. /**
  124802. * Disable lighting on the laser pointer (so it will always be visible)
  124803. */
  124804. disablePointerLighting: boolean;
  124805. /**
  124806. * Disable lighting on the selection mesh (so it will always be visible)
  124807. */
  124808. disableSelectionMeshLighting: boolean;
  124809. /**
  124810. * Should the laser pointer be displayed
  124811. */
  124812. displayLaserPointer: boolean;
  124813. /**
  124814. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  124815. */
  124816. displaySelectionMesh: boolean;
  124817. /**
  124818. * This color will be set to the laser pointer when selection is triggered
  124819. */
  124820. laserPointerPickedColor: Color3;
  124821. /**
  124822. * Default color of the laser pointer
  124823. */
  124824. lasterPointerDefaultColor: Color3;
  124825. /**
  124826. * default color of the selection ring
  124827. */
  124828. selectionMeshDefaultColor: Color3;
  124829. /**
  124830. * This color will be applied to the selection ring when selection is triggered
  124831. */
  124832. selectionMeshPickedColor: Color3;
  124833. /**
  124834. * Optional filter to be used for ray selection. This predicate shares behavior with
  124835. * scene.pointerMovePredicate which takes priority if it is also assigned.
  124836. */
  124837. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  124838. /**
  124839. * constructs a new background remover module
  124840. * @param _xrSessionManager the session manager for this module
  124841. * @param _options read-only options to be used in this module
  124842. */
  124843. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  124844. /**
  124845. * attach this feature
  124846. * Will usually be called by the features manager
  124847. *
  124848. * @returns true if successful.
  124849. */
  124850. attach(): boolean;
  124851. /**
  124852. * detach this feature.
  124853. * Will usually be called by the features manager
  124854. *
  124855. * @returns true if successful.
  124856. */
  124857. detach(): boolean;
  124858. /**
  124859. * Will get the mesh under a specific pointer.
  124860. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  124861. * @param controllerId the controllerId to check
  124862. * @returns The mesh under pointer or null if no mesh is under the pointer
  124863. */
  124864. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  124865. /**
  124866. * Get the xr controller that correlates to the pointer id in the pointer event
  124867. *
  124868. * @param id the pointer id to search for
  124869. * @returns the controller that correlates to this id or null if not found
  124870. */
  124871. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  124872. protected _onXRFrame(_xrFrame: XRFrame): void;
  124873. private _attachGazeMode;
  124874. private _attachScreenRayMode;
  124875. private _attachTrackedPointerRayMode;
  124876. private _convertNormalToDirectionOfRay;
  124877. private _detachController;
  124878. private _generateNewMeshPair;
  124879. private _pickingMoved;
  124880. private _updatePointerDistance;
  124881. }
  124882. }
  124883. declare module BABYLON {
  124884. /**
  124885. * Button which can be used to enter a different mode of XR
  124886. */
  124887. export class WebXREnterExitUIButton {
  124888. /** button element */
  124889. element: HTMLElement;
  124890. /** XR initialization options for the button */
  124891. sessionMode: XRSessionMode;
  124892. /** Reference space type */
  124893. referenceSpaceType: XRReferenceSpaceType;
  124894. /**
  124895. * Creates a WebXREnterExitUIButton
  124896. * @param element button element
  124897. * @param sessionMode XR initialization session mode
  124898. * @param referenceSpaceType the type of reference space to be used
  124899. */
  124900. constructor(
  124901. /** button element */
  124902. element: HTMLElement,
  124903. /** XR initialization options for the button */
  124904. sessionMode: XRSessionMode,
  124905. /** Reference space type */
  124906. referenceSpaceType: XRReferenceSpaceType);
  124907. /**
  124908. * Extendable function which can be used to update the button's visuals when the state changes
  124909. * @param activeButton the current active button in the UI
  124910. */
  124911. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  124912. }
  124913. /**
  124914. * Options to create the webXR UI
  124915. */
  124916. export class WebXREnterExitUIOptions {
  124917. /**
  124918. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  124919. */
  124920. customButtons?: Array<WebXREnterExitUIButton>;
  124921. /**
  124922. * A reference space type to use when creating the default button.
  124923. * Default is local-floor
  124924. */
  124925. referenceSpaceType?: XRReferenceSpaceType;
  124926. /**
  124927. * Context to enter xr with
  124928. */
  124929. renderTarget?: Nullable<WebXRRenderTarget>;
  124930. /**
  124931. * A session mode to use when creating the default button.
  124932. * Default is immersive-vr
  124933. */
  124934. sessionMode?: XRSessionMode;
  124935. /**
  124936. * A list of optional features to init the session with
  124937. */
  124938. optionalFeatures?: string[];
  124939. }
  124940. /**
  124941. * UI to allow the user to enter/exit XR mode
  124942. */
  124943. export class WebXREnterExitUI implements IDisposable {
  124944. private scene;
  124945. /** version of the options passed to this UI */
  124946. options: WebXREnterExitUIOptions;
  124947. private _activeButton;
  124948. private _buttons;
  124949. private _overlay;
  124950. /**
  124951. * Fired every time the active button is changed.
  124952. *
  124953. * When xr is entered via a button that launches xr that button will be the callback parameter
  124954. *
  124955. * When exiting xr the callback parameter will be null)
  124956. */
  124957. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  124958. /**
  124959. *
  124960. * @param scene babylon scene object to use
  124961. * @param options (read-only) version of the options passed to this UI
  124962. */
  124963. private constructor();
  124964. /**
  124965. * Creates UI to allow the user to enter/exit XR mode
  124966. * @param scene the scene to add the ui to
  124967. * @param helper the xr experience helper to enter/exit xr with
  124968. * @param options options to configure the UI
  124969. * @returns the created ui
  124970. */
  124971. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  124972. /**
  124973. * Disposes of the XR UI component
  124974. */
  124975. dispose(): void;
  124976. private _updateButtons;
  124977. }
  124978. }
  124979. declare module BABYLON {
  124980. /**
  124981. * Class containing static functions to help procedurally build meshes
  124982. */
  124983. export class LinesBuilder {
  124984. /**
  124985. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124986. * * 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
  124987. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124988. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124989. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124990. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124991. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124992. * * 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
  124993. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124996. * @param name defines the name of the new line system
  124997. * @param options defines the options used to create the line system
  124998. * @param scene defines the hosting scene
  124999. * @returns a new line system mesh
  125000. */
  125001. static CreateLineSystem(name: string, options: {
  125002. lines: Vector3[][];
  125003. updatable?: boolean;
  125004. instance?: Nullable<LinesMesh>;
  125005. colors?: Nullable<Color4[][]>;
  125006. useVertexAlpha?: boolean;
  125007. }, scene: Nullable<Scene>): LinesMesh;
  125008. /**
  125009. * Creates a line mesh
  125010. * 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
  125011. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125012. * * The parameter `points` is an array successive Vector3
  125013. * * 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
  125014. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125015. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125016. * * When updating an instance, remember that only point positions can change, not the number of points
  125017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125019. * @param name defines the name of the new line system
  125020. * @param options defines the options used to create the line system
  125021. * @param scene defines the hosting scene
  125022. * @returns a new line mesh
  125023. */
  125024. static CreateLines(name: string, options: {
  125025. points: Vector3[];
  125026. updatable?: boolean;
  125027. instance?: Nullable<LinesMesh>;
  125028. colors?: Color4[];
  125029. useVertexAlpha?: boolean;
  125030. }, scene?: Nullable<Scene>): LinesMesh;
  125031. /**
  125032. * Creates a dashed line mesh
  125033. * * 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
  125034. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125035. * * The parameter `points` is an array successive Vector3
  125036. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125037. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125038. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125039. * * 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
  125040. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125041. * * When updating an instance, remember that only point positions can change, not the number of points
  125042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125043. * @param name defines the name of the mesh
  125044. * @param options defines the options used to create the mesh
  125045. * @param scene defines the hosting scene
  125046. * @returns the dashed line mesh
  125047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125048. */
  125049. static CreateDashedLines(name: string, options: {
  125050. points: Vector3[];
  125051. dashSize?: number;
  125052. gapSize?: number;
  125053. dashNb?: number;
  125054. updatable?: boolean;
  125055. instance?: LinesMesh;
  125056. useVertexAlpha?: boolean;
  125057. }, scene?: Nullable<Scene>): LinesMesh;
  125058. }
  125059. }
  125060. declare module BABYLON {
  125061. /**
  125062. * The options container for the teleportation module
  125063. */
  125064. export interface IWebXRTeleportationOptions {
  125065. /**
  125066. * if provided, this scene will be used to render meshes.
  125067. */
  125068. customUtilityLayerScene?: Scene;
  125069. /**
  125070. * Values to configure the default target mesh
  125071. */
  125072. defaultTargetMeshOptions?: {
  125073. /**
  125074. * Fill color of the teleportation area
  125075. */
  125076. teleportationFillColor?: string;
  125077. /**
  125078. * Border color for the teleportation area
  125079. */
  125080. teleportationBorderColor?: string;
  125081. /**
  125082. * Disable the mesh's animation sequence
  125083. */
  125084. disableAnimation?: boolean;
  125085. /**
  125086. * Disable lighting on the material or the ring and arrow
  125087. */
  125088. disableLighting?: boolean;
  125089. /**
  125090. * Override the default material of the torus and arrow
  125091. */
  125092. torusArrowMaterial?: Material;
  125093. };
  125094. /**
  125095. * A list of meshes to use as floor meshes.
  125096. * Meshes can be added and removed after initializing the feature using the
  125097. * addFloorMesh and removeFloorMesh functions
  125098. * If empty, rotation will still work
  125099. */
  125100. floorMeshes?: AbstractMesh[];
  125101. /**
  125102. * use this rendering group id for the meshes (optional)
  125103. */
  125104. renderingGroupId?: number;
  125105. /**
  125106. * Should teleportation move only to snap points
  125107. */
  125108. snapPointsOnly?: boolean;
  125109. /**
  125110. * An array of points to which the teleportation will snap to.
  125111. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  125112. */
  125113. snapPositions?: Vector3[];
  125114. /**
  125115. * How close should the teleportation ray be in order to snap to position.
  125116. * Default to 0.8 units (meters)
  125117. */
  125118. snapToPositionRadius?: number;
  125119. /**
  125120. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  125121. * If you want to support rotation, make sure your mesh has a direction indicator.
  125122. *
  125123. * When left untouched, the default mesh will be initialized.
  125124. */
  125125. teleportationTargetMesh?: AbstractMesh;
  125126. /**
  125127. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  125128. */
  125129. timeToTeleport?: number;
  125130. /**
  125131. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  125132. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  125133. */
  125134. useMainComponentOnly?: boolean;
  125135. /**
  125136. * Should meshes created here be added to a utility layer or the main scene
  125137. */
  125138. useUtilityLayer?: boolean;
  125139. /**
  125140. * Babylon XR Input class for controller
  125141. */
  125142. xrInput: WebXRInput;
  125143. }
  125144. /**
  125145. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  125146. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  125147. * the input of the attached controllers.
  125148. */
  125149. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  125150. private _options;
  125151. private _controllers;
  125152. private _currentTeleportationControllerId;
  125153. private _floorMeshes;
  125154. private _quadraticBezierCurve;
  125155. private _selectionFeature;
  125156. private _snapToPositions;
  125157. private _snappedToPoint;
  125158. private _teleportationRingMaterial?;
  125159. private _tmpRay;
  125160. private _tmpVector;
  125161. /**
  125162. * The module's name
  125163. */
  125164. static readonly Name: string;
  125165. /**
  125166. * The (Babylon) version of this module.
  125167. * This is an integer representing the implementation version.
  125168. * This number does not correspond to the webxr specs version
  125169. */
  125170. static readonly Version: number;
  125171. /**
  125172. * Is movement backwards enabled
  125173. */
  125174. backwardsMovementEnabled: boolean;
  125175. /**
  125176. * Distance to travel when moving backwards
  125177. */
  125178. backwardsTeleportationDistance: number;
  125179. /**
  125180. * The distance from the user to the inspection point in the direction of the controller
  125181. * A higher number will allow the user to move further
  125182. * defaults to 5 (meters, in xr units)
  125183. */
  125184. parabolicCheckRadius: number;
  125185. /**
  125186. * Should the module support parabolic ray on top of direct ray
  125187. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  125188. * Very helpful when moving between floors / different heights
  125189. */
  125190. parabolicRayEnabled: boolean;
  125191. /**
  125192. * How much rotation should be applied when rotating right and left
  125193. */
  125194. rotationAngle: number;
  125195. /**
  125196. * Is rotation enabled when moving forward?
  125197. * Disabling this feature will prevent the user from deciding the direction when teleporting
  125198. */
  125199. rotationEnabled: boolean;
  125200. /**
  125201. * constructs a new anchor system
  125202. * @param _xrSessionManager an instance of WebXRSessionManager
  125203. * @param _options configuration object for this feature
  125204. */
  125205. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  125206. /**
  125207. * Get the snapPointsOnly flag
  125208. */
  125209. get snapPointsOnly(): boolean;
  125210. /**
  125211. * Sets the snapPointsOnly flag
  125212. * @param snapToPoints should teleportation be exclusively to snap points
  125213. */
  125214. set snapPointsOnly(snapToPoints: boolean);
  125215. /**
  125216. * Add a new mesh to the floor meshes array
  125217. * @param mesh the mesh to use as floor mesh
  125218. */
  125219. addFloorMesh(mesh: AbstractMesh): void;
  125220. /**
  125221. * Add a new snap-to point to fix teleportation to this position
  125222. * @param newSnapPoint The new Snap-To point
  125223. */
  125224. addSnapPoint(newSnapPoint: Vector3): void;
  125225. attach(): boolean;
  125226. detach(): boolean;
  125227. dispose(): void;
  125228. /**
  125229. * Remove a mesh from the floor meshes array
  125230. * @param mesh the mesh to remove
  125231. */
  125232. removeFloorMesh(mesh: AbstractMesh): void;
  125233. /**
  125234. * Remove a mesh from the floor meshes array using its name
  125235. * @param name the mesh name to remove
  125236. */
  125237. removeFloorMeshByName(name: string): void;
  125238. /**
  125239. * 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
  125240. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  125241. * @returns was the point found and removed or not
  125242. */
  125243. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  125244. /**
  125245. * This function sets a selection feature that will be disabled when
  125246. * the forward ray is shown and will be reattached when hidden.
  125247. * This is used to remove the selection rays when moving.
  125248. * @param selectionFeature the feature to disable when forward movement is enabled
  125249. */
  125250. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  125251. protected _onXRFrame(_xrFrame: XRFrame): void;
  125252. private _attachController;
  125253. private _createDefaultTargetMesh;
  125254. private _detachController;
  125255. private _findClosestSnapPointWithRadius;
  125256. private _setTargetMeshPosition;
  125257. private _setTargetMeshVisibility;
  125258. private _showParabolicPath;
  125259. private _teleportForward;
  125260. }
  125261. }
  125262. declare module BABYLON {
  125263. /**
  125264. * Options for the default xr helper
  125265. */
  125266. export class WebXRDefaultExperienceOptions {
  125267. /**
  125268. * Enable or disable default UI to enter XR
  125269. */
  125270. disableDefaultUI?: boolean;
  125271. /**
  125272. * Should teleportation not initialize. defaults to false.
  125273. */
  125274. disableTeleportation?: boolean;
  125275. /**
  125276. * Floor meshes that will be used for teleport
  125277. */
  125278. floorMeshes?: Array<AbstractMesh>;
  125279. /**
  125280. * If set to true, the first frame will not be used to reset position
  125281. * The first frame is mainly used when copying transformation from the old camera
  125282. * Mainly used in AR
  125283. */
  125284. ignoreNativeCameraTransformation?: boolean;
  125285. /**
  125286. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  125287. */
  125288. inputOptions?: IWebXRInputOptions;
  125289. /**
  125290. * optional configuration for the output canvas
  125291. */
  125292. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  125293. /**
  125294. * optional UI options. This can be used among other to change session mode and reference space type
  125295. */
  125296. uiOptions?: WebXREnterExitUIOptions;
  125297. /**
  125298. * When loading teleportation and pointer select, use stable versions instead of latest.
  125299. */
  125300. useStablePlugins?: boolean;
  125301. /**
  125302. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  125303. */
  125304. renderingGroupId?: number;
  125305. /**
  125306. * A list of optional features to init the session with
  125307. * If set to true, all features we support will be added
  125308. */
  125309. optionalFeatures?: boolean | string[];
  125310. }
  125311. /**
  125312. * Default experience which provides a similar setup to the previous webVRExperience
  125313. */
  125314. export class WebXRDefaultExperience {
  125315. /**
  125316. * Base experience
  125317. */
  125318. baseExperience: WebXRExperienceHelper;
  125319. /**
  125320. * Enables ui for entering/exiting xr
  125321. */
  125322. enterExitUI: WebXREnterExitUI;
  125323. /**
  125324. * Input experience extension
  125325. */
  125326. input: WebXRInput;
  125327. /**
  125328. * Enables laser pointer and selection
  125329. */
  125330. pointerSelection: WebXRControllerPointerSelection;
  125331. /**
  125332. * Default target xr should render to
  125333. */
  125334. renderTarget: WebXRRenderTarget;
  125335. /**
  125336. * Enables teleportation
  125337. */
  125338. teleportation: WebXRMotionControllerTeleportation;
  125339. private constructor();
  125340. /**
  125341. * Creates the default xr experience
  125342. * @param scene scene
  125343. * @param options options for basic configuration
  125344. * @returns resulting WebXRDefaultExperience
  125345. */
  125346. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125347. /**
  125348. * DIsposes of the experience helper
  125349. */
  125350. dispose(): void;
  125351. }
  125352. }
  125353. declare module BABYLON {
  125354. /**
  125355. * Options to modify the vr teleportation behavior.
  125356. */
  125357. export interface VRTeleportationOptions {
  125358. /**
  125359. * The name of the mesh which should be used as the teleportation floor. (default: null)
  125360. */
  125361. floorMeshName?: string;
  125362. /**
  125363. * A list of meshes to be used as the teleportation floor. (default: empty)
  125364. */
  125365. floorMeshes?: Mesh[];
  125366. /**
  125367. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  125368. */
  125369. teleportationMode?: number;
  125370. /**
  125371. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  125372. */
  125373. teleportationTime?: number;
  125374. /**
  125375. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  125376. */
  125377. teleportationSpeed?: number;
  125378. /**
  125379. * The easing function used in the animation or null for Linear. (default CircleEase)
  125380. */
  125381. easingFunction?: EasingFunction;
  125382. }
  125383. /**
  125384. * Options to modify the vr experience helper's behavior.
  125385. */
  125386. export interface VRExperienceHelperOptions extends WebVROptions {
  125387. /**
  125388. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  125389. */
  125390. createDeviceOrientationCamera?: boolean;
  125391. /**
  125392. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  125393. */
  125394. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  125395. /**
  125396. * Uses the main button on the controller to toggle the laser casted. (default: true)
  125397. */
  125398. laserToggle?: boolean;
  125399. /**
  125400. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  125401. */
  125402. floorMeshes?: Mesh[];
  125403. /**
  125404. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  125405. */
  125406. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  125407. /**
  125408. * Defines if WebXR should be used instead of WebVR (if available)
  125409. */
  125410. useXR?: boolean;
  125411. }
  125412. /**
  125413. * Event containing information after VR has been entered
  125414. */
  125415. export class OnAfterEnteringVRObservableEvent {
  125416. /**
  125417. * If entering vr was successful
  125418. */
  125419. success: boolean;
  125420. }
  125421. /**
  125422. * Helps to quickly add VR support to an existing scene.
  125423. * See http://doc.babylonjs.com/how_to/webvr_helper
  125424. */
  125425. export class VRExperienceHelper {
  125426. /** Options to modify the vr experience helper's behavior. */
  125427. webVROptions: VRExperienceHelperOptions;
  125428. private _scene;
  125429. private _position;
  125430. private _btnVR;
  125431. private _btnVRDisplayed;
  125432. private _webVRsupported;
  125433. private _webVRready;
  125434. private _webVRrequesting;
  125435. private _webVRpresenting;
  125436. private _hasEnteredVR;
  125437. private _fullscreenVRpresenting;
  125438. private _inputElement;
  125439. private _webVRCamera;
  125440. private _vrDeviceOrientationCamera;
  125441. private _deviceOrientationCamera;
  125442. private _existingCamera;
  125443. private _onKeyDown;
  125444. private _onVrDisplayPresentChange;
  125445. private _onVRDisplayChanged;
  125446. private _onVRRequestPresentStart;
  125447. private _onVRRequestPresentComplete;
  125448. /**
  125449. * 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)
  125450. */
  125451. enableGazeEvenWhenNoPointerLock: boolean;
  125452. /**
  125453. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  125454. */
  125455. exitVROnDoubleTap: boolean;
  125456. /**
  125457. * Observable raised right before entering VR.
  125458. */
  125459. onEnteringVRObservable: Observable<VRExperienceHelper>;
  125460. /**
  125461. * Observable raised when entering VR has completed.
  125462. */
  125463. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  125464. /**
  125465. * Observable raised when exiting VR.
  125466. */
  125467. onExitingVRObservable: Observable<VRExperienceHelper>;
  125468. /**
  125469. * Observable raised when controller mesh is loaded.
  125470. */
  125471. onControllerMeshLoadedObservable: Observable<WebVRController>;
  125472. /** Return this.onEnteringVRObservable
  125473. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  125474. */
  125475. get onEnteringVR(): Observable<VRExperienceHelper>;
  125476. /** Return this.onExitingVRObservable
  125477. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  125478. */
  125479. get onExitingVR(): Observable<VRExperienceHelper>;
  125480. /** Return this.onControllerMeshLoadedObservable
  125481. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  125482. */
  125483. get onControllerMeshLoaded(): Observable<WebVRController>;
  125484. private _rayLength;
  125485. private _useCustomVRButton;
  125486. private _teleportationRequested;
  125487. private _teleportActive;
  125488. private _floorMeshName;
  125489. private _floorMeshesCollection;
  125490. private _teleportationMode;
  125491. private _teleportationTime;
  125492. private _teleportationSpeed;
  125493. private _teleportationEasing;
  125494. private _rotationAllowed;
  125495. private _teleportBackwardsVector;
  125496. private _teleportationTarget;
  125497. private _isDefaultTeleportationTarget;
  125498. private _postProcessMove;
  125499. private _teleportationFillColor;
  125500. private _teleportationBorderColor;
  125501. private _rotationAngle;
  125502. private _haloCenter;
  125503. private _cameraGazer;
  125504. private _padSensibilityUp;
  125505. private _padSensibilityDown;
  125506. private _leftController;
  125507. private _rightController;
  125508. private _gazeColor;
  125509. private _laserColor;
  125510. private _pickedLaserColor;
  125511. private _pickedGazeColor;
  125512. /**
  125513. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  125514. */
  125515. onNewMeshSelected: Observable<AbstractMesh>;
  125516. /**
  125517. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  125518. * This observable will provide the mesh and the controller used to select the mesh
  125519. */
  125520. onMeshSelectedWithController: Observable<{
  125521. mesh: AbstractMesh;
  125522. controller: WebVRController;
  125523. }>;
  125524. /**
  125525. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  125526. */
  125527. onNewMeshPicked: Observable<PickingInfo>;
  125528. private _circleEase;
  125529. /**
  125530. * Observable raised before camera teleportation
  125531. */
  125532. onBeforeCameraTeleport: Observable<Vector3>;
  125533. /**
  125534. * Observable raised after camera teleportation
  125535. */
  125536. onAfterCameraTeleport: Observable<Vector3>;
  125537. /**
  125538. * Observable raised when current selected mesh gets unselected
  125539. */
  125540. onSelectedMeshUnselected: Observable<AbstractMesh>;
  125541. private _raySelectionPredicate;
  125542. /**
  125543. * To be optionaly changed by user to define custom ray selection
  125544. */
  125545. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125546. /**
  125547. * To be optionaly changed by user to define custom selection logic (after ray selection)
  125548. */
  125549. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  125550. /**
  125551. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  125552. */
  125553. teleportationEnabled: boolean;
  125554. private _defaultHeight;
  125555. private _teleportationInitialized;
  125556. private _interactionsEnabled;
  125557. private _interactionsRequested;
  125558. private _displayGaze;
  125559. private _displayLaserPointer;
  125560. /**
  125561. * The mesh used to display where the user is going to teleport.
  125562. */
  125563. get teleportationTarget(): Mesh;
  125564. /**
  125565. * Sets the mesh to be used to display where the user is going to teleport.
  125566. */
  125567. set teleportationTarget(value: Mesh);
  125568. /**
  125569. * 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
  125570. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  125571. * See http://doc.babylonjs.com/resources/baking_transformations
  125572. */
  125573. get gazeTrackerMesh(): Mesh;
  125574. set gazeTrackerMesh(value: Mesh);
  125575. /**
  125576. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  125577. */
  125578. updateGazeTrackerScale: boolean;
  125579. /**
  125580. * If the gaze trackers color should be updated when selecting meshes
  125581. */
  125582. updateGazeTrackerColor: boolean;
  125583. /**
  125584. * If the controller laser color should be updated when selecting meshes
  125585. */
  125586. updateControllerLaserColor: boolean;
  125587. /**
  125588. * The gaze tracking mesh corresponding to the left controller
  125589. */
  125590. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  125591. /**
  125592. * The gaze tracking mesh corresponding to the right controller
  125593. */
  125594. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  125595. /**
  125596. * If the ray of the gaze should be displayed.
  125597. */
  125598. get displayGaze(): boolean;
  125599. /**
  125600. * Sets if the ray of the gaze should be displayed.
  125601. */
  125602. set displayGaze(value: boolean);
  125603. /**
  125604. * If the ray of the LaserPointer should be displayed.
  125605. */
  125606. get displayLaserPointer(): boolean;
  125607. /**
  125608. * Sets if the ray of the LaserPointer should be displayed.
  125609. */
  125610. set displayLaserPointer(value: boolean);
  125611. /**
  125612. * The deviceOrientationCamera used as the camera when not in VR.
  125613. */
  125614. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  125615. /**
  125616. * Based on the current WebVR support, returns the current VR camera used.
  125617. */
  125618. get currentVRCamera(): Nullable<Camera>;
  125619. /**
  125620. * The webVRCamera which is used when in VR.
  125621. */
  125622. get webVRCamera(): WebVRFreeCamera;
  125623. /**
  125624. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  125625. */
  125626. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  125627. /**
  125628. * The html button that is used to trigger entering into VR.
  125629. */
  125630. get vrButton(): Nullable<HTMLButtonElement>;
  125631. private get _teleportationRequestInitiated();
  125632. /**
  125633. * Defines whether or not Pointer lock should be requested when switching to
  125634. * full screen.
  125635. */
  125636. requestPointerLockOnFullScreen: boolean;
  125637. /**
  125638. * If asking to force XR, this will be populated with the default xr experience
  125639. */
  125640. xr: WebXRDefaultExperience;
  125641. /**
  125642. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  125643. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  125644. */
  125645. xrTestDone: boolean;
  125646. /**
  125647. * Instantiates a VRExperienceHelper.
  125648. * Helps to quickly add VR support to an existing scene.
  125649. * @param scene The scene the VRExperienceHelper belongs to.
  125650. * @param webVROptions Options to modify the vr experience helper's behavior.
  125651. */
  125652. constructor(scene: Scene,
  125653. /** Options to modify the vr experience helper's behavior. */
  125654. webVROptions?: VRExperienceHelperOptions);
  125655. private completeVRInit;
  125656. private _onDefaultMeshLoaded;
  125657. private _onResize;
  125658. private _onFullscreenChange;
  125659. /**
  125660. * Gets a value indicating if we are currently in VR mode.
  125661. */
  125662. get isInVRMode(): boolean;
  125663. private onVrDisplayPresentChange;
  125664. private onVRDisplayChanged;
  125665. private moveButtonToBottomRight;
  125666. private displayVRButton;
  125667. private updateButtonVisibility;
  125668. private _cachedAngularSensibility;
  125669. /**
  125670. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  125671. * Otherwise, will use the fullscreen API.
  125672. */
  125673. enterVR(): void;
  125674. /**
  125675. * Attempt to exit VR, or fullscreen.
  125676. */
  125677. exitVR(): void;
  125678. /**
  125679. * The position of the vr experience helper.
  125680. */
  125681. get position(): Vector3;
  125682. /**
  125683. * Sets the position of the vr experience helper.
  125684. */
  125685. set position(value: Vector3);
  125686. /**
  125687. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  125688. */
  125689. enableInteractions(): void;
  125690. private get _noControllerIsActive();
  125691. private beforeRender;
  125692. private _isTeleportationFloor;
  125693. /**
  125694. * Adds a floor mesh to be used for teleportation.
  125695. * @param floorMesh the mesh to be used for teleportation.
  125696. */
  125697. addFloorMesh(floorMesh: Mesh): void;
  125698. /**
  125699. * Removes a floor mesh from being used for teleportation.
  125700. * @param floorMesh the mesh to be removed.
  125701. */
  125702. removeFloorMesh(floorMesh: Mesh): void;
  125703. /**
  125704. * Enables interactions and teleportation using the VR controllers and gaze.
  125705. * @param vrTeleportationOptions options to modify teleportation behavior.
  125706. */
  125707. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  125708. private _onNewGamepadConnected;
  125709. private _tryEnableInteractionOnController;
  125710. private _onNewGamepadDisconnected;
  125711. private _enableInteractionOnController;
  125712. private _checkTeleportWithRay;
  125713. private _checkRotate;
  125714. private _checkTeleportBackwards;
  125715. private _enableTeleportationOnController;
  125716. private _createTeleportationCircles;
  125717. private _displayTeleportationTarget;
  125718. private _hideTeleportationTarget;
  125719. private _rotateCamera;
  125720. private _moveTeleportationSelectorTo;
  125721. private _workingVector;
  125722. private _workingQuaternion;
  125723. private _workingMatrix;
  125724. /**
  125725. * Time Constant Teleportation Mode
  125726. */
  125727. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  125728. /**
  125729. * Speed Constant Teleportation Mode
  125730. */
  125731. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  125732. /**
  125733. * Teleports the users feet to the desired location
  125734. * @param location The location where the user's feet should be placed
  125735. */
  125736. teleportCamera(location: Vector3): void;
  125737. private _convertNormalToDirectionOfRay;
  125738. private _castRayAndSelectObject;
  125739. private _notifySelectedMeshUnselected;
  125740. /**
  125741. * Permanently set new colors for the laser pointer
  125742. * @param color the new laser color
  125743. * @param pickedColor the new laser color when picked mesh detected
  125744. */
  125745. setLaserColor(color: Color3, pickedColor?: Color3): void;
  125746. /**
  125747. * Set lighting enabled / disabled on the laser pointer of both controllers
  125748. * @param enabled should the lighting be enabled on the laser pointer
  125749. */
  125750. setLaserLightingState(enabled?: boolean): void;
  125751. /**
  125752. * Permanently set new colors for the gaze pointer
  125753. * @param color the new gaze color
  125754. * @param pickedColor the new gaze color when picked mesh detected
  125755. */
  125756. setGazeColor(color: Color3, pickedColor?: Color3): void;
  125757. /**
  125758. * Sets the color of the laser ray from the vr controllers.
  125759. * @param color new color for the ray.
  125760. */
  125761. changeLaserColor(color: Color3): void;
  125762. /**
  125763. * Sets the color of the ray from the vr headsets gaze.
  125764. * @param color new color for the ray.
  125765. */
  125766. changeGazeColor(color: Color3): void;
  125767. /**
  125768. * Exits VR and disposes of the vr experience helper
  125769. */
  125770. dispose(): void;
  125771. /**
  125772. * Gets the name of the VRExperienceHelper class
  125773. * @returns "VRExperienceHelper"
  125774. */
  125775. getClassName(): string;
  125776. }
  125777. }
  125778. declare module BABYLON {
  125779. /**
  125780. * Contains an array of blocks representing the octree
  125781. */
  125782. export interface IOctreeContainer<T> {
  125783. /**
  125784. * Blocks within the octree
  125785. */
  125786. blocks: Array<OctreeBlock<T>>;
  125787. }
  125788. /**
  125789. * Class used to store a cell in an octree
  125790. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125791. */
  125792. export class OctreeBlock<T> {
  125793. /**
  125794. * Gets the content of the current block
  125795. */
  125796. entries: T[];
  125797. /**
  125798. * Gets the list of block children
  125799. */
  125800. blocks: Array<OctreeBlock<T>>;
  125801. private _depth;
  125802. private _maxDepth;
  125803. private _capacity;
  125804. private _minPoint;
  125805. private _maxPoint;
  125806. private _boundingVectors;
  125807. private _creationFunc;
  125808. /**
  125809. * Creates a new block
  125810. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  125811. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  125812. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125813. * @param depth defines the current depth of this block in the octree
  125814. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  125815. * @param creationFunc defines a callback to call when an element is added to the block
  125816. */
  125817. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  125818. /**
  125819. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125820. */
  125821. get capacity(): number;
  125822. /**
  125823. * Gets the minimum vector (in world space) of the block's bounding box
  125824. */
  125825. get minPoint(): Vector3;
  125826. /**
  125827. * Gets the maximum vector (in world space) of the block's bounding box
  125828. */
  125829. get maxPoint(): Vector3;
  125830. /**
  125831. * Add a new element to this block
  125832. * @param entry defines the element to add
  125833. */
  125834. addEntry(entry: T): void;
  125835. /**
  125836. * Remove an element from this block
  125837. * @param entry defines the element to remove
  125838. */
  125839. removeEntry(entry: T): void;
  125840. /**
  125841. * Add an array of elements to this block
  125842. * @param entries defines the array of elements to add
  125843. */
  125844. addEntries(entries: T[]): void;
  125845. /**
  125846. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  125847. * @param frustumPlanes defines the frustum planes to test
  125848. * @param selection defines the array to store current content if selection is positive
  125849. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125850. */
  125851. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125852. /**
  125853. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  125854. * @param sphereCenter defines the bounding sphere center
  125855. * @param sphereRadius defines the bounding sphere radius
  125856. * @param selection defines the array to store current content if selection is positive
  125857. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125858. */
  125859. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125860. /**
  125861. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  125862. * @param ray defines the ray to test with
  125863. * @param selection defines the array to store current content if selection is positive
  125864. */
  125865. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  125866. /**
  125867. * Subdivide the content into child blocks (this block will then be empty)
  125868. */
  125869. createInnerBlocks(): void;
  125870. /**
  125871. * @hidden
  125872. */
  125873. 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;
  125874. }
  125875. }
  125876. declare module BABYLON {
  125877. /**
  125878. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  125879. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125880. */
  125881. export class Octree<T> {
  125882. /** 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.) */
  125883. maxDepth: number;
  125884. /**
  125885. * Blocks within the octree containing objects
  125886. */
  125887. blocks: Array<OctreeBlock<T>>;
  125888. /**
  125889. * Content stored in the octree
  125890. */
  125891. dynamicContent: T[];
  125892. private _maxBlockCapacity;
  125893. private _selectionContent;
  125894. private _creationFunc;
  125895. /**
  125896. * Creates a octree
  125897. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125898. * @param creationFunc function to be used to instatiate the octree
  125899. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  125900. * @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.)
  125901. */
  125902. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  125903. /** 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.) */
  125904. maxDepth?: number);
  125905. /**
  125906. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  125907. * @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);
  125908. * @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);
  125909. * @param entries meshes to be added to the octree blocks
  125910. */
  125911. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  125912. /**
  125913. * Adds a mesh to the octree
  125914. * @param entry Mesh to add to the octree
  125915. */
  125916. addMesh(entry: T): void;
  125917. /**
  125918. * Remove an element from the octree
  125919. * @param entry defines the element to remove
  125920. */
  125921. removeMesh(entry: T): void;
  125922. /**
  125923. * Selects an array of meshes within the frustum
  125924. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  125925. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  125926. * @returns array of meshes within the frustum
  125927. */
  125928. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  125929. /**
  125930. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  125931. * @param sphereCenter defines the bounding sphere center
  125932. * @param sphereRadius defines the bounding sphere radius
  125933. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125934. * @returns an array of objects that intersect the sphere
  125935. */
  125936. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  125937. /**
  125938. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  125939. * @param ray defines the ray to test with
  125940. * @returns array of intersected objects
  125941. */
  125942. intersectsRay(ray: Ray): SmartArray<T>;
  125943. /**
  125944. * Adds a mesh into the octree block if it intersects the block
  125945. */
  125946. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  125947. /**
  125948. * Adds a submesh into the octree block if it intersects the block
  125949. */
  125950. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  125951. }
  125952. }
  125953. declare module BABYLON {
  125954. interface Scene {
  125955. /**
  125956. * @hidden
  125957. * Backing Filed
  125958. */
  125959. _selectionOctree: Octree<AbstractMesh>;
  125960. /**
  125961. * Gets the octree used to boost mesh selection (picking)
  125962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125963. */
  125964. selectionOctree: Octree<AbstractMesh>;
  125965. /**
  125966. * Creates or updates the octree used to boost selection (picking)
  125967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125968. * @param maxCapacity defines the maximum capacity per leaf
  125969. * @param maxDepth defines the maximum depth of the octree
  125970. * @returns an octree of AbstractMesh
  125971. */
  125972. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  125973. }
  125974. interface AbstractMesh {
  125975. /**
  125976. * @hidden
  125977. * Backing Field
  125978. */
  125979. _submeshesOctree: Octree<SubMesh>;
  125980. /**
  125981. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  125982. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  125983. * @param maxCapacity defines the maximum size of each block (64 by default)
  125984. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  125985. * @returns the new octree
  125986. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  125987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125988. */
  125989. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  125990. }
  125991. /**
  125992. * Defines the octree scene component responsible to manage any octrees
  125993. * in a given scene.
  125994. */
  125995. export class OctreeSceneComponent {
  125996. /**
  125997. * The component name help to identify the component in the list of scene components.
  125998. */
  125999. readonly name: string;
  126000. /**
  126001. * The scene the component belongs to.
  126002. */
  126003. scene: Scene;
  126004. /**
  126005. * Indicates if the meshes have been checked to make sure they are isEnabled()
  126006. */
  126007. readonly checksIsEnabled: boolean;
  126008. /**
  126009. * Creates a new instance of the component for the given scene
  126010. * @param scene Defines the scene to register the component in
  126011. */
  126012. constructor(scene: Scene);
  126013. /**
  126014. * Registers the component in a given scene
  126015. */
  126016. register(): void;
  126017. /**
  126018. * Return the list of active meshes
  126019. * @returns the list of active meshes
  126020. */
  126021. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  126022. /**
  126023. * Return the list of active sub meshes
  126024. * @param mesh The mesh to get the candidates sub meshes from
  126025. * @returns the list of active sub meshes
  126026. */
  126027. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  126028. private _tempRay;
  126029. /**
  126030. * Return the list of sub meshes intersecting with a given local ray
  126031. * @param mesh defines the mesh to find the submesh for
  126032. * @param localRay defines the ray in local space
  126033. * @returns the list of intersecting sub meshes
  126034. */
  126035. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126036. /**
  126037. * Return the list of sub meshes colliding with a collider
  126038. * @param mesh defines the mesh to find the submesh for
  126039. * @param collider defines the collider to evaluate the collision against
  126040. * @returns the list of colliding sub meshes
  126041. */
  126042. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126043. /**
  126044. * Rebuilds the elements related to this component in case of
  126045. * context lost for instance.
  126046. */
  126047. rebuild(): void;
  126048. /**
  126049. * Disposes the component and the associated ressources.
  126050. */
  126051. dispose(): void;
  126052. }
  126053. }
  126054. declare module BABYLON {
  126055. /**
  126056. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126057. */
  126058. export class Gizmo implements IDisposable {
  126059. /** The utility layer the gizmo will be added to */
  126060. gizmoLayer: UtilityLayerRenderer;
  126061. /**
  126062. * The root mesh of the gizmo
  126063. */
  126064. _rootMesh: Mesh;
  126065. private _attachedMesh;
  126066. /**
  126067. * Ratio for the scale of the gizmo (Default: 1)
  126068. */
  126069. scaleRatio: number;
  126070. /**
  126071. * If a custom mesh has been set (Default: false)
  126072. */
  126073. protected _customMeshSet: boolean;
  126074. /**
  126075. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126076. * * When set, interactions will be enabled
  126077. */
  126078. get attachedMesh(): Nullable<AbstractMesh>;
  126079. set attachedMesh(value: Nullable<AbstractMesh>);
  126080. /**
  126081. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  126082. * @param mesh The mesh to replace the default mesh of the gizmo
  126083. */
  126084. setCustomMesh(mesh: Mesh): void;
  126085. /**
  126086. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  126087. */
  126088. updateGizmoRotationToMatchAttachedMesh: boolean;
  126089. /**
  126090. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  126091. */
  126092. updateGizmoPositionToMatchAttachedMesh: boolean;
  126093. /**
  126094. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  126095. */
  126096. updateScale: boolean;
  126097. protected _interactionsEnabled: boolean;
  126098. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126099. private _beforeRenderObserver;
  126100. private _tempVector;
  126101. /**
  126102. * Creates a gizmo
  126103. * @param gizmoLayer The utility layer the gizmo will be added to
  126104. */
  126105. constructor(
  126106. /** The utility layer the gizmo will be added to */
  126107. gizmoLayer?: UtilityLayerRenderer);
  126108. /**
  126109. * Updates the gizmo to match the attached mesh's position/rotation
  126110. */
  126111. protected _update(): void;
  126112. /**
  126113. * Disposes of the gizmo
  126114. */
  126115. dispose(): void;
  126116. }
  126117. }
  126118. declare module BABYLON {
  126119. /**
  126120. * Single plane drag gizmo
  126121. */
  126122. export class PlaneDragGizmo extends Gizmo {
  126123. /**
  126124. * Drag behavior responsible for the gizmos dragging interactions
  126125. */
  126126. dragBehavior: PointerDragBehavior;
  126127. private _pointerObserver;
  126128. /**
  126129. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126130. */
  126131. snapDistance: number;
  126132. /**
  126133. * Event that fires each time the gizmo snaps to a new location.
  126134. * * snapDistance is the the change in distance
  126135. */
  126136. onSnapObservable: Observable<{
  126137. snapDistance: number;
  126138. }>;
  126139. private _plane;
  126140. private _coloredMaterial;
  126141. private _hoverMaterial;
  126142. private _isEnabled;
  126143. private _parent;
  126144. /** @hidden */
  126145. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  126146. /** @hidden */
  126147. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126148. /**
  126149. * Creates a PlaneDragGizmo
  126150. * @param gizmoLayer The utility layer the gizmo will be added to
  126151. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  126152. * @param color The color of the gizmo
  126153. */
  126154. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126155. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126156. /**
  126157. * If the gizmo is enabled
  126158. */
  126159. set isEnabled(value: boolean);
  126160. get isEnabled(): boolean;
  126161. /**
  126162. * Disposes of the gizmo
  126163. */
  126164. dispose(): void;
  126165. }
  126166. }
  126167. declare module BABYLON {
  126168. /**
  126169. * Gizmo that enables dragging a mesh along 3 axis
  126170. */
  126171. export class PositionGizmo extends Gizmo {
  126172. /**
  126173. * Internal gizmo used for interactions on the x axis
  126174. */
  126175. xGizmo: AxisDragGizmo;
  126176. /**
  126177. * Internal gizmo used for interactions on the y axis
  126178. */
  126179. yGizmo: AxisDragGizmo;
  126180. /**
  126181. * Internal gizmo used for interactions on the z axis
  126182. */
  126183. zGizmo: AxisDragGizmo;
  126184. /**
  126185. * Internal gizmo used for interactions on the yz plane
  126186. */
  126187. xPlaneGizmo: PlaneDragGizmo;
  126188. /**
  126189. * Internal gizmo used for interactions on the xz plane
  126190. */
  126191. yPlaneGizmo: PlaneDragGizmo;
  126192. /**
  126193. * Internal gizmo used for interactions on the xy plane
  126194. */
  126195. zPlaneGizmo: PlaneDragGizmo;
  126196. /**
  126197. * private variables
  126198. */
  126199. private _meshAttached;
  126200. private _updateGizmoRotationToMatchAttachedMesh;
  126201. private _snapDistance;
  126202. private _scaleRatio;
  126203. /** Fires an event when any of it's sub gizmos are dragged */
  126204. onDragStartObservable: Observable<unknown>;
  126205. /** Fires an event when any of it's sub gizmos are released from dragging */
  126206. onDragEndObservable: Observable<unknown>;
  126207. /**
  126208. * If set to true, planar drag is enabled
  126209. */
  126210. private _planarGizmoEnabled;
  126211. get attachedMesh(): Nullable<AbstractMesh>;
  126212. set attachedMesh(mesh: Nullable<AbstractMesh>);
  126213. /**
  126214. * Creates a PositionGizmo
  126215. * @param gizmoLayer The utility layer the gizmo will be added to
  126216. */
  126217. constructor(gizmoLayer?: UtilityLayerRenderer);
  126218. /**
  126219. * If the planar drag gizmo is enabled
  126220. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  126221. */
  126222. set planarGizmoEnabled(value: boolean);
  126223. get planarGizmoEnabled(): boolean;
  126224. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  126225. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  126226. /**
  126227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126228. */
  126229. set snapDistance(value: number);
  126230. get snapDistance(): number;
  126231. /**
  126232. * Ratio for the scale of the gizmo (Default: 1)
  126233. */
  126234. set scaleRatio(value: number);
  126235. get scaleRatio(): number;
  126236. /**
  126237. * Disposes of the gizmo
  126238. */
  126239. dispose(): void;
  126240. /**
  126241. * CustomMeshes are not supported by this gizmo
  126242. * @param mesh The mesh to replace the default mesh of the gizmo
  126243. */
  126244. setCustomMesh(mesh: Mesh): void;
  126245. }
  126246. }
  126247. declare module BABYLON {
  126248. /**
  126249. * Single axis drag gizmo
  126250. */
  126251. export class AxisDragGizmo extends Gizmo {
  126252. /**
  126253. * Drag behavior responsible for the gizmos dragging interactions
  126254. */
  126255. dragBehavior: PointerDragBehavior;
  126256. private _pointerObserver;
  126257. /**
  126258. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126259. */
  126260. snapDistance: number;
  126261. /**
  126262. * Event that fires each time the gizmo snaps to a new location.
  126263. * * snapDistance is the the change in distance
  126264. */
  126265. onSnapObservable: Observable<{
  126266. snapDistance: number;
  126267. }>;
  126268. private _isEnabled;
  126269. private _parent;
  126270. private _arrow;
  126271. private _coloredMaterial;
  126272. private _hoverMaterial;
  126273. /** @hidden */
  126274. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  126275. /** @hidden */
  126276. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126277. /**
  126278. * Creates an AxisDragGizmo
  126279. * @param gizmoLayer The utility layer the gizmo will be added to
  126280. * @param dragAxis The axis which the gizmo will be able to drag on
  126281. * @param color The color of the gizmo
  126282. */
  126283. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126284. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126285. /**
  126286. * If the gizmo is enabled
  126287. */
  126288. set isEnabled(value: boolean);
  126289. get isEnabled(): boolean;
  126290. /**
  126291. * Disposes of the gizmo
  126292. */
  126293. dispose(): void;
  126294. }
  126295. }
  126296. declare module BABYLON.Debug {
  126297. /**
  126298. * The Axes viewer will show 3 axes in a specific point in space
  126299. */
  126300. export class AxesViewer {
  126301. private _xAxis;
  126302. private _yAxis;
  126303. private _zAxis;
  126304. private _scaleLinesFactor;
  126305. private _instanced;
  126306. /**
  126307. * Gets the hosting scene
  126308. */
  126309. scene: Scene;
  126310. /**
  126311. * Gets or sets a number used to scale line length
  126312. */
  126313. scaleLines: number;
  126314. /** Gets the node hierarchy used to render x-axis */
  126315. get xAxis(): TransformNode;
  126316. /** Gets the node hierarchy used to render y-axis */
  126317. get yAxis(): TransformNode;
  126318. /** Gets the node hierarchy used to render z-axis */
  126319. get zAxis(): TransformNode;
  126320. /**
  126321. * Creates a new AxesViewer
  126322. * @param scene defines the hosting scene
  126323. * @param scaleLines defines a number used to scale line length (1 by default)
  126324. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  126325. * @param xAxis defines the node hierarchy used to render the x-axis
  126326. * @param yAxis defines the node hierarchy used to render the y-axis
  126327. * @param zAxis defines the node hierarchy used to render the z-axis
  126328. */
  126329. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  126330. /**
  126331. * Force the viewer to update
  126332. * @param position defines the position of the viewer
  126333. * @param xaxis defines the x axis of the viewer
  126334. * @param yaxis defines the y axis of the viewer
  126335. * @param zaxis defines the z axis of the viewer
  126336. */
  126337. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  126338. /**
  126339. * Creates an instance of this axes viewer.
  126340. * @returns a new axes viewer with instanced meshes
  126341. */
  126342. createInstance(): AxesViewer;
  126343. /** Releases resources */
  126344. dispose(): void;
  126345. private static _SetRenderingGroupId;
  126346. }
  126347. }
  126348. declare module BABYLON.Debug {
  126349. /**
  126350. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  126351. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  126352. */
  126353. export class BoneAxesViewer extends AxesViewer {
  126354. /**
  126355. * Gets or sets the target mesh where to display the axes viewer
  126356. */
  126357. mesh: Nullable<Mesh>;
  126358. /**
  126359. * Gets or sets the target bone where to display the axes viewer
  126360. */
  126361. bone: Nullable<Bone>;
  126362. /** Gets current position */
  126363. pos: Vector3;
  126364. /** Gets direction of X axis */
  126365. xaxis: Vector3;
  126366. /** Gets direction of Y axis */
  126367. yaxis: Vector3;
  126368. /** Gets direction of Z axis */
  126369. zaxis: Vector3;
  126370. /**
  126371. * Creates a new BoneAxesViewer
  126372. * @param scene defines the hosting scene
  126373. * @param bone defines the target bone
  126374. * @param mesh defines the target mesh
  126375. * @param scaleLines defines a scaling factor for line length (1 by default)
  126376. */
  126377. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  126378. /**
  126379. * Force the viewer to update
  126380. */
  126381. update(): void;
  126382. /** Releases resources */
  126383. dispose(): void;
  126384. }
  126385. }
  126386. declare module BABYLON {
  126387. /**
  126388. * Interface used to define scene explorer extensibility option
  126389. */
  126390. export interface IExplorerExtensibilityOption {
  126391. /**
  126392. * Define the option label
  126393. */
  126394. label: string;
  126395. /**
  126396. * Defines the action to execute on click
  126397. */
  126398. action: (entity: any) => void;
  126399. }
  126400. /**
  126401. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  126402. */
  126403. export interface IExplorerExtensibilityGroup {
  126404. /**
  126405. * Defines a predicate to test if a given type mut be extended
  126406. */
  126407. predicate: (entity: any) => boolean;
  126408. /**
  126409. * Gets the list of options added to a type
  126410. */
  126411. entries: IExplorerExtensibilityOption[];
  126412. }
  126413. /**
  126414. * Interface used to define the options to use to create the Inspector
  126415. */
  126416. export interface IInspectorOptions {
  126417. /**
  126418. * Display in overlay mode (default: false)
  126419. */
  126420. overlay?: boolean;
  126421. /**
  126422. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  126423. */
  126424. globalRoot?: HTMLElement;
  126425. /**
  126426. * Display the Scene explorer
  126427. */
  126428. showExplorer?: boolean;
  126429. /**
  126430. * Display the property inspector
  126431. */
  126432. showInspector?: boolean;
  126433. /**
  126434. * Display in embed mode (both panes on the right)
  126435. */
  126436. embedMode?: boolean;
  126437. /**
  126438. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  126439. */
  126440. handleResize?: boolean;
  126441. /**
  126442. * Allow the panes to popup (default: true)
  126443. */
  126444. enablePopup?: boolean;
  126445. /**
  126446. * Allow the panes to be closed by users (default: true)
  126447. */
  126448. enableClose?: boolean;
  126449. /**
  126450. * Optional list of extensibility entries
  126451. */
  126452. explorerExtensibility?: IExplorerExtensibilityGroup[];
  126453. /**
  126454. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  126455. */
  126456. inspectorURL?: string;
  126457. /**
  126458. * Optional initial tab (default to DebugLayerTab.Properties)
  126459. */
  126460. initialTab?: DebugLayerTab;
  126461. }
  126462. interface Scene {
  126463. /**
  126464. * @hidden
  126465. * Backing field
  126466. */
  126467. _debugLayer: DebugLayer;
  126468. /**
  126469. * Gets the debug layer (aka Inspector) associated with the scene
  126470. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126471. */
  126472. debugLayer: DebugLayer;
  126473. }
  126474. /**
  126475. * Enum of inspector action tab
  126476. */
  126477. export enum DebugLayerTab {
  126478. /**
  126479. * Properties tag (default)
  126480. */
  126481. Properties = 0,
  126482. /**
  126483. * Debug tab
  126484. */
  126485. Debug = 1,
  126486. /**
  126487. * Statistics tab
  126488. */
  126489. Statistics = 2,
  126490. /**
  126491. * Tools tab
  126492. */
  126493. Tools = 3,
  126494. /**
  126495. * Settings tab
  126496. */
  126497. Settings = 4
  126498. }
  126499. /**
  126500. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126501. * what is happening in your scene
  126502. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126503. */
  126504. export class DebugLayer {
  126505. /**
  126506. * Define the url to get the inspector script from.
  126507. * By default it uses the babylonjs CDN.
  126508. * @ignoreNaming
  126509. */
  126510. static InspectorURL: string;
  126511. private _scene;
  126512. private BJSINSPECTOR;
  126513. private _onPropertyChangedObservable?;
  126514. /**
  126515. * Observable triggered when a property is changed through the inspector.
  126516. */
  126517. get onPropertyChangedObservable(): any;
  126518. /**
  126519. * Instantiates a new debug layer.
  126520. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126521. * what is happening in your scene
  126522. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126523. * @param scene Defines the scene to inspect
  126524. */
  126525. constructor(scene: Scene);
  126526. /** Creates the inspector window. */
  126527. private _createInspector;
  126528. /**
  126529. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  126530. * @param entity defines the entity to select
  126531. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  126532. */
  126533. select(entity: any, lineContainerTitles?: string | string[]): void;
  126534. /** Get the inspector from bundle or global */
  126535. private _getGlobalInspector;
  126536. /**
  126537. * Get if the inspector is visible or not.
  126538. * @returns true if visible otherwise, false
  126539. */
  126540. isVisible(): boolean;
  126541. /**
  126542. * Hide the inspector and close its window.
  126543. */
  126544. hide(): void;
  126545. /**
  126546. * Update the scene in the inspector
  126547. */
  126548. setAsActiveScene(): void;
  126549. /**
  126550. * Launch the debugLayer.
  126551. * @param config Define the configuration of the inspector
  126552. * @return a promise fulfilled when the debug layer is visible
  126553. */
  126554. show(config?: IInspectorOptions): Promise<DebugLayer>;
  126555. }
  126556. }
  126557. declare module BABYLON {
  126558. /**
  126559. * Class containing static functions to help procedurally build meshes
  126560. */
  126561. export class BoxBuilder {
  126562. /**
  126563. * Creates a box mesh
  126564. * * The parameter `size` sets the size (float) of each box side (default 1)
  126565. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126566. * * 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)
  126567. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126571. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126572. * @param name defines the name of the mesh
  126573. * @param options defines the options used to create the mesh
  126574. * @param scene defines the hosting scene
  126575. * @returns the box mesh
  126576. */
  126577. static CreateBox(name: string, options: {
  126578. size?: number;
  126579. width?: number;
  126580. height?: number;
  126581. depth?: number;
  126582. faceUV?: Vector4[];
  126583. faceColors?: Color4[];
  126584. sideOrientation?: number;
  126585. frontUVs?: Vector4;
  126586. backUVs?: Vector4;
  126587. wrap?: boolean;
  126588. topBaseAt?: number;
  126589. bottomBaseAt?: number;
  126590. updatable?: boolean;
  126591. }, scene?: Nullable<Scene>): Mesh;
  126592. }
  126593. }
  126594. declare module BABYLON.Debug {
  126595. /**
  126596. * Used to show the physics impostor around the specific mesh
  126597. */
  126598. export class PhysicsViewer {
  126599. /** @hidden */
  126600. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  126601. /** @hidden */
  126602. protected _meshes: Array<Nullable<AbstractMesh>>;
  126603. /** @hidden */
  126604. protected _scene: Nullable<Scene>;
  126605. /** @hidden */
  126606. protected _numMeshes: number;
  126607. /** @hidden */
  126608. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  126609. private _renderFunction;
  126610. private _utilityLayer;
  126611. private _debugBoxMesh;
  126612. private _debugSphereMesh;
  126613. private _debugCylinderMesh;
  126614. private _debugMaterial;
  126615. private _debugMeshMeshes;
  126616. /**
  126617. * Creates a new PhysicsViewer
  126618. * @param scene defines the hosting scene
  126619. */
  126620. constructor(scene: Scene);
  126621. /** @hidden */
  126622. protected _updateDebugMeshes(): void;
  126623. /**
  126624. * Renders a specified physic impostor
  126625. * @param impostor defines the impostor to render
  126626. * @param targetMesh defines the mesh represented by the impostor
  126627. * @returns the new debug mesh used to render the impostor
  126628. */
  126629. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  126630. /**
  126631. * Hides a specified physic impostor
  126632. * @param impostor defines the impostor to hide
  126633. */
  126634. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  126635. private _getDebugMaterial;
  126636. private _getDebugBoxMesh;
  126637. private _getDebugSphereMesh;
  126638. private _getDebugCylinderMesh;
  126639. private _getDebugMeshMesh;
  126640. private _getDebugMesh;
  126641. /** Releases all resources */
  126642. dispose(): void;
  126643. }
  126644. }
  126645. declare module BABYLON {
  126646. /**
  126647. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126648. * in order to better appreciate the issue one might have.
  126649. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126650. */
  126651. export class RayHelper {
  126652. /**
  126653. * Defines the ray we are currently tryin to visualize.
  126654. */
  126655. ray: Nullable<Ray>;
  126656. private _renderPoints;
  126657. private _renderLine;
  126658. private _renderFunction;
  126659. private _scene;
  126660. private _updateToMeshFunction;
  126661. private _attachedToMesh;
  126662. private _meshSpaceDirection;
  126663. private _meshSpaceOrigin;
  126664. /**
  126665. * Helper function to create a colored helper in a scene in one line.
  126666. * @param ray Defines the ray we are currently tryin to visualize
  126667. * @param scene Defines the scene the ray is used in
  126668. * @param color Defines the color we want to see the ray in
  126669. * @returns The newly created ray helper.
  126670. */
  126671. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  126672. /**
  126673. * Instantiate a new ray helper.
  126674. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126675. * in order to better appreciate the issue one might have.
  126676. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126677. * @param ray Defines the ray we are currently tryin to visualize
  126678. */
  126679. constructor(ray: Ray);
  126680. /**
  126681. * Shows the ray we are willing to debug.
  126682. * @param scene Defines the scene the ray needs to be rendered in
  126683. * @param color Defines the color the ray needs to be rendered in
  126684. */
  126685. show(scene: Scene, color?: Color3): void;
  126686. /**
  126687. * Hides the ray we are debugging.
  126688. */
  126689. hide(): void;
  126690. private _render;
  126691. /**
  126692. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  126693. * @param mesh Defines the mesh we want the helper attached to
  126694. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  126695. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  126696. * @param length Defines the length of the ray
  126697. */
  126698. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  126699. /**
  126700. * Detach the ray helper from the mesh it has previously been attached to.
  126701. */
  126702. detachFromMesh(): void;
  126703. private _updateToMesh;
  126704. /**
  126705. * Dispose the helper and release its associated resources.
  126706. */
  126707. dispose(): void;
  126708. }
  126709. }
  126710. declare module BABYLON.Debug {
  126711. /**
  126712. * Class used to render a debug view of a given skeleton
  126713. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  126714. */
  126715. export class SkeletonViewer {
  126716. /** defines the skeleton to render */
  126717. skeleton: Skeleton;
  126718. /** defines the mesh attached to the skeleton */
  126719. mesh: AbstractMesh;
  126720. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126721. autoUpdateBonesMatrices: boolean;
  126722. /** defines the rendering group id to use with the viewer */
  126723. renderingGroupId: number;
  126724. /** Gets or sets the color used to render the skeleton */
  126725. color: Color3;
  126726. private _scene;
  126727. private _debugLines;
  126728. private _debugMesh;
  126729. private _isEnabled;
  126730. private _renderFunction;
  126731. private _utilityLayer;
  126732. /**
  126733. * Returns the mesh used to render the bones
  126734. */
  126735. get debugMesh(): Nullable<LinesMesh>;
  126736. /**
  126737. * Creates a new SkeletonViewer
  126738. * @param skeleton defines the skeleton to render
  126739. * @param mesh defines the mesh attached to the skeleton
  126740. * @param scene defines the hosting scene
  126741. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  126742. * @param renderingGroupId defines the rendering group id to use with the viewer
  126743. */
  126744. constructor(
  126745. /** defines the skeleton to render */
  126746. skeleton: Skeleton,
  126747. /** defines the mesh attached to the skeleton */
  126748. mesh: AbstractMesh, scene: Scene,
  126749. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126750. autoUpdateBonesMatrices?: boolean,
  126751. /** defines the rendering group id to use with the viewer */
  126752. renderingGroupId?: number);
  126753. /** Gets or sets a boolean indicating if the viewer is enabled */
  126754. set isEnabled(value: boolean);
  126755. get isEnabled(): boolean;
  126756. private _getBonePosition;
  126757. private _getLinesForBonesWithLength;
  126758. private _getLinesForBonesNoLength;
  126759. /** Update the viewer to sync with current skeleton state */
  126760. update(): void;
  126761. /** Release associated resources */
  126762. dispose(): void;
  126763. }
  126764. }
  126765. declare module BABYLON {
  126766. /**
  126767. * Enum for Device Types
  126768. */
  126769. export enum DeviceType {
  126770. /** Generic */
  126771. Generic = 0,
  126772. /** Keyboard */
  126773. Keyboard = 1,
  126774. /** Mouse */
  126775. Mouse = 2,
  126776. /** Touch Pointers */
  126777. Touch = 3,
  126778. /** PS4 Dual Shock */
  126779. DualShock = 4,
  126780. /** Xbox */
  126781. Xbox = 5,
  126782. /** Switch Controller */
  126783. Switch = 6
  126784. }
  126785. /**
  126786. * Enum for All Pointers (Touch/Mouse)
  126787. */
  126788. export enum PointerInput {
  126789. /** Horizontal Axis */
  126790. Horizontal = 0,
  126791. /** Vertical Axis */
  126792. Vertical = 1,
  126793. /** Left Click or Touch */
  126794. LeftClick = 2,
  126795. /** Middle Click */
  126796. MiddleClick = 3,
  126797. /** Right Click */
  126798. RightClick = 4,
  126799. /** Browser Back */
  126800. BrowserBack = 5,
  126801. /** Browser Forward */
  126802. BrowserForward = 6
  126803. }
  126804. /**
  126805. * Enum for Dual Shock Gamepad
  126806. */
  126807. export enum DualShockInput {
  126808. /** Cross */
  126809. Cross = 0,
  126810. /** Circle */
  126811. Circle = 1,
  126812. /** Square */
  126813. Square = 2,
  126814. /** Triangle */
  126815. Triangle = 3,
  126816. /** L1 */
  126817. L1 = 4,
  126818. /** R1 */
  126819. R1 = 5,
  126820. /** L2 */
  126821. L2 = 6,
  126822. /** R2 */
  126823. R2 = 7,
  126824. /** Share */
  126825. Share = 8,
  126826. /** Options */
  126827. Options = 9,
  126828. /** L3 */
  126829. L3 = 10,
  126830. /** R3 */
  126831. R3 = 11,
  126832. /** DPadUp */
  126833. DPadUp = 12,
  126834. /** DPadDown */
  126835. DPadDown = 13,
  126836. /** DPadLeft */
  126837. DPadLeft = 14,
  126838. /** DRight */
  126839. DPadRight = 15,
  126840. /** Home */
  126841. Home = 16,
  126842. /** TouchPad */
  126843. TouchPad = 17,
  126844. /** LStickXAxis */
  126845. LStickXAxis = 18,
  126846. /** LStickYAxis */
  126847. LStickYAxis = 19,
  126848. /** RStickXAxis */
  126849. RStickXAxis = 20,
  126850. /** RStickYAxis */
  126851. RStickYAxis = 21
  126852. }
  126853. /**
  126854. * Enum for Xbox Gamepad
  126855. */
  126856. export enum XboxInput {
  126857. /** A */
  126858. A = 0,
  126859. /** B */
  126860. B = 1,
  126861. /** X */
  126862. X = 2,
  126863. /** Y */
  126864. Y = 3,
  126865. /** LB */
  126866. LB = 4,
  126867. /** RB */
  126868. RB = 5,
  126869. /** LT */
  126870. LT = 6,
  126871. /** RT */
  126872. RT = 7,
  126873. /** Back */
  126874. Back = 8,
  126875. /** Start */
  126876. Start = 9,
  126877. /** LS */
  126878. LS = 10,
  126879. /** RS */
  126880. RS = 11,
  126881. /** DPadUp */
  126882. DPadUp = 12,
  126883. /** DPadDown */
  126884. DPadDown = 13,
  126885. /** DPadLeft */
  126886. DPadLeft = 14,
  126887. /** DRight */
  126888. DPadRight = 15,
  126889. /** Home */
  126890. Home = 16,
  126891. /** LStickXAxis */
  126892. LStickXAxis = 17,
  126893. /** LStickYAxis */
  126894. LStickYAxis = 18,
  126895. /** RStickXAxis */
  126896. RStickXAxis = 19,
  126897. /** RStickYAxis */
  126898. RStickYAxis = 20
  126899. }
  126900. /**
  126901. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  126902. */
  126903. export enum SwitchInput {
  126904. /** B */
  126905. B = 0,
  126906. /** A */
  126907. A = 1,
  126908. /** Y */
  126909. Y = 2,
  126910. /** X */
  126911. X = 3,
  126912. /** L */
  126913. L = 4,
  126914. /** R */
  126915. R = 5,
  126916. /** ZL */
  126917. ZL = 6,
  126918. /** ZR */
  126919. ZR = 7,
  126920. /** Minus */
  126921. Minus = 8,
  126922. /** Plus */
  126923. Plus = 9,
  126924. /** LS */
  126925. LS = 10,
  126926. /** RS */
  126927. RS = 11,
  126928. /** DPadUp */
  126929. DPadUp = 12,
  126930. /** DPadDown */
  126931. DPadDown = 13,
  126932. /** DPadLeft */
  126933. DPadLeft = 14,
  126934. /** DRight */
  126935. DPadRight = 15,
  126936. /** Home */
  126937. Home = 16,
  126938. /** Capture */
  126939. Capture = 17,
  126940. /** LStickXAxis */
  126941. LStickXAxis = 18,
  126942. /** LStickYAxis */
  126943. LStickYAxis = 19,
  126944. /** RStickXAxis */
  126945. RStickXAxis = 20,
  126946. /** RStickYAxis */
  126947. RStickYAxis = 21
  126948. }
  126949. }
  126950. declare module BABYLON {
  126951. /**
  126952. * This class will take all inputs from Keyboard, Pointer, and
  126953. * any Gamepads and provide a polling system that all devices
  126954. * will use. This class assumes that there will only be one
  126955. * pointer device and one keyboard.
  126956. */
  126957. export class DeviceInputSystem implements IDisposable {
  126958. /**
  126959. * Callback to be triggered when a device is connected
  126960. */
  126961. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126962. /**
  126963. * Callback to be triggered when a device is disconnected
  126964. */
  126965. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126966. /**
  126967. * Callback to be triggered when event driven input is updated
  126968. */
  126969. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  126970. private _inputs;
  126971. private _gamepads;
  126972. private _keyboardActive;
  126973. private _pointerActive;
  126974. private _elementToAttachTo;
  126975. private _keyboardDownEvent;
  126976. private _keyboardUpEvent;
  126977. private _pointerMoveEvent;
  126978. private _pointerDownEvent;
  126979. private _pointerUpEvent;
  126980. private _gamepadConnectedEvent;
  126981. private _gamepadDisconnectedEvent;
  126982. private static _MAX_KEYCODES;
  126983. private static _MAX_POINTER_INPUTS;
  126984. private constructor();
  126985. /**
  126986. * Creates a new DeviceInputSystem instance
  126987. * @param engine Engine to pull input element from
  126988. * @returns The new instance
  126989. */
  126990. static Create(engine: Engine): DeviceInputSystem;
  126991. /**
  126992. * Checks for current device input value, given an id and input index
  126993. * @param deviceName Id of connected device
  126994. * @param inputIndex Index of device input
  126995. * @returns Current value of input
  126996. */
  126997. /**
  126998. * Checks for current device input value, given an id and input index
  126999. * @param deviceType Enum specifiying device type
  127000. * @param deviceSlot "Slot" or index that device is referenced in
  127001. * @param inputIndex Id of input to be checked
  127002. * @returns Current value of input
  127003. */
  127004. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  127005. /**
  127006. * Dispose of all the eventlisteners
  127007. */
  127008. dispose(): void;
  127009. /**
  127010. * Add device and inputs to device array
  127011. * @param deviceType Enum specifiying device type
  127012. * @param deviceSlot "Slot" or index that device is referenced in
  127013. * @param numberOfInputs Number of input entries to create for given device
  127014. */
  127015. private _registerDevice;
  127016. /**
  127017. * Given a specific device name, remove that device from the device map
  127018. * @param deviceType Enum specifiying device type
  127019. * @param deviceSlot "Slot" or index that device is referenced in
  127020. */
  127021. private _unregisterDevice;
  127022. /**
  127023. * Handle all actions that come from keyboard interaction
  127024. */
  127025. private _handleKeyActions;
  127026. /**
  127027. * Handle all actions that come from pointer interaction
  127028. */
  127029. private _handlePointerActions;
  127030. /**
  127031. * Handle all actions that come from gamepad interaction
  127032. */
  127033. private _handleGamepadActions;
  127034. /**
  127035. * Update all non-event based devices with each frame
  127036. * @param deviceType Enum specifiying device type
  127037. * @param deviceSlot "Slot" or index that device is referenced in
  127038. * @param inputIndex Id of input to be checked
  127039. */
  127040. private _updateDevice;
  127041. /**
  127042. * Gets DeviceType from the device name
  127043. * @param deviceName Name of Device from DeviceInputSystem
  127044. * @returns DeviceType enum value
  127045. */
  127046. private _getGamepadDeviceType;
  127047. }
  127048. }
  127049. declare module BABYLON {
  127050. /**
  127051. * Type to handle enforcement of inputs
  127052. */
  127053. 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;
  127054. }
  127055. declare module BABYLON {
  127056. /**
  127057. * Class that handles all input for a specific device
  127058. */
  127059. export class DeviceSource<T extends DeviceType> {
  127060. /** Type of device */
  127061. readonly deviceType: DeviceType;
  127062. /** "Slot" or index that device is referenced in */
  127063. readonly deviceSlot: number;
  127064. /**
  127065. * Observable to handle device input changes per device
  127066. */
  127067. readonly onInputChangedObservable: Observable<{
  127068. inputIndex: DeviceInput<T>;
  127069. previousState: Nullable<number>;
  127070. currentState: Nullable<number>;
  127071. }>;
  127072. private readonly _deviceInputSystem;
  127073. /**
  127074. * Default Constructor
  127075. * @param deviceInputSystem Reference to DeviceInputSystem
  127076. * @param deviceType Type of device
  127077. * @param deviceSlot "Slot" or index that device is referenced in
  127078. */
  127079. constructor(deviceInputSystem: DeviceInputSystem,
  127080. /** Type of device */
  127081. deviceType: DeviceType,
  127082. /** "Slot" or index that device is referenced in */
  127083. deviceSlot?: number);
  127084. /**
  127085. * Get input for specific input
  127086. * @param inputIndex index of specific input on device
  127087. * @returns Input value from DeviceInputSystem
  127088. */
  127089. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  127090. }
  127091. /**
  127092. * Class to keep track of devices
  127093. */
  127094. export class DeviceSourceManager implements IDisposable {
  127095. /**
  127096. * Observable to be triggered when before a device is connected
  127097. */
  127098. readonly onBeforeDeviceConnectedObservable: Observable<{
  127099. deviceType: DeviceType;
  127100. deviceSlot: number;
  127101. }>;
  127102. /**
  127103. * Observable to be triggered when before a device is disconnected
  127104. */
  127105. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  127106. deviceType: DeviceType;
  127107. deviceSlot: number;
  127108. }>;
  127109. /**
  127110. * Observable to be triggered when after a device is connected
  127111. */
  127112. readonly onAfterDeviceConnectedObservable: Observable<{
  127113. deviceType: DeviceType;
  127114. deviceSlot: number;
  127115. }>;
  127116. /**
  127117. * Observable to be triggered when after a device is disconnected
  127118. */
  127119. readonly onAfterDeviceDisconnectedObservable: Observable<{
  127120. deviceType: DeviceType;
  127121. deviceSlot: number;
  127122. }>;
  127123. private readonly _devices;
  127124. private readonly _firstDevice;
  127125. private readonly _deviceInputSystem;
  127126. /**
  127127. * Default Constructor
  127128. * @param engine engine to pull input element from
  127129. */
  127130. constructor(engine: Engine);
  127131. /**
  127132. * Gets a DeviceSource, given a type and slot
  127133. * @param deviceType Enum specifying device type
  127134. * @param deviceSlot "Slot" or index that device is referenced in
  127135. * @returns DeviceSource object
  127136. */
  127137. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  127138. /**
  127139. * Gets an array of DeviceSource objects for a given device type
  127140. * @param deviceType Enum specifying device type
  127141. * @returns Array of DeviceSource objects
  127142. */
  127143. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  127144. /**
  127145. * Dispose of DeviceInputSystem and other parts
  127146. */
  127147. dispose(): void;
  127148. /**
  127149. * Function to add device name to device list
  127150. * @param deviceType Enum specifying device type
  127151. * @param deviceSlot "Slot" or index that device is referenced in
  127152. */
  127153. private _addDevice;
  127154. /**
  127155. * Function to remove device name to device list
  127156. * @param deviceType Enum specifying device type
  127157. * @param deviceSlot "Slot" or index that device is referenced in
  127158. */
  127159. private _removeDevice;
  127160. /**
  127161. * Updates array storing first connected device of each type
  127162. * @param type Type of Device
  127163. */
  127164. private _updateFirstDevices;
  127165. }
  127166. }
  127167. declare module BABYLON {
  127168. /**
  127169. * Options to create the null engine
  127170. */
  127171. export class NullEngineOptions {
  127172. /**
  127173. * Render width (Default: 512)
  127174. */
  127175. renderWidth: number;
  127176. /**
  127177. * Render height (Default: 256)
  127178. */
  127179. renderHeight: number;
  127180. /**
  127181. * Texture size (Default: 512)
  127182. */
  127183. textureSize: number;
  127184. /**
  127185. * If delta time between frames should be constant
  127186. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127187. */
  127188. deterministicLockstep: boolean;
  127189. /**
  127190. * Maximum about of steps between frames (Default: 4)
  127191. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127192. */
  127193. lockstepMaxSteps: number;
  127194. }
  127195. /**
  127196. * The null engine class provides support for headless version of babylon.js.
  127197. * This can be used in server side scenario or for testing purposes
  127198. */
  127199. export class NullEngine extends Engine {
  127200. private _options;
  127201. /**
  127202. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  127203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127204. * @returns true if engine is in deterministic lock step mode
  127205. */
  127206. isDeterministicLockStep(): boolean;
  127207. /**
  127208. * Gets the max steps when engine is running in deterministic lock step
  127209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127210. * @returns the max steps
  127211. */
  127212. getLockstepMaxSteps(): number;
  127213. /**
  127214. * Gets the current hardware scaling level.
  127215. * By default the hardware scaling level is computed from the window device ratio.
  127216. * 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.
  127217. * @returns a number indicating the current hardware scaling level
  127218. */
  127219. getHardwareScalingLevel(): number;
  127220. constructor(options?: NullEngineOptions);
  127221. /**
  127222. * Creates a vertex buffer
  127223. * @param vertices the data for the vertex buffer
  127224. * @returns the new WebGL static buffer
  127225. */
  127226. createVertexBuffer(vertices: FloatArray): DataBuffer;
  127227. /**
  127228. * Creates a new index buffer
  127229. * @param indices defines the content of the index buffer
  127230. * @param updatable defines if the index buffer must be updatable
  127231. * @returns a new webGL buffer
  127232. */
  127233. createIndexBuffer(indices: IndicesArray): DataBuffer;
  127234. /**
  127235. * Clear the current render buffer or the current render target (if any is set up)
  127236. * @param color defines the color to use
  127237. * @param backBuffer defines if the back buffer must be cleared
  127238. * @param depth defines if the depth buffer must be cleared
  127239. * @param stencil defines if the stencil buffer must be cleared
  127240. */
  127241. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  127242. /**
  127243. * Gets the current render width
  127244. * @param useScreen defines if screen size must be used (or the current render target if any)
  127245. * @returns a number defining the current render width
  127246. */
  127247. getRenderWidth(useScreen?: boolean): number;
  127248. /**
  127249. * Gets the current render height
  127250. * @param useScreen defines if screen size must be used (or the current render target if any)
  127251. * @returns a number defining the current render height
  127252. */
  127253. getRenderHeight(useScreen?: boolean): number;
  127254. /**
  127255. * Set the WebGL's viewport
  127256. * @param viewport defines the viewport element to be used
  127257. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  127258. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  127259. */
  127260. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  127261. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  127262. /**
  127263. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  127264. * @param pipelineContext defines the pipeline context to use
  127265. * @param uniformsNames defines the list of uniform names
  127266. * @returns an array of webGL uniform locations
  127267. */
  127268. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  127269. /**
  127270. * Gets the lsit of active attributes for a given webGL program
  127271. * @param pipelineContext defines the pipeline context to use
  127272. * @param attributesNames defines the list of attribute names to get
  127273. * @returns an array of indices indicating the offset of each attribute
  127274. */
  127275. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  127276. /**
  127277. * Binds an effect to the webGL context
  127278. * @param effect defines the effect to bind
  127279. */
  127280. bindSamplers(effect: Effect): void;
  127281. /**
  127282. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  127283. * @param effect defines the effect to activate
  127284. */
  127285. enableEffect(effect: Effect): void;
  127286. /**
  127287. * Set various states to the webGL context
  127288. * @param culling defines backface culling state
  127289. * @param zOffset defines the value to apply to zOffset (0 by default)
  127290. * @param force defines if states must be applied even if cache is up to date
  127291. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127292. */
  127293. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127294. /**
  127295. * Set the value of an uniform to an array of int32
  127296. * @param uniform defines the webGL uniform location where to store the value
  127297. * @param array defines the array of int32 to store
  127298. */
  127299. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  127300. /**
  127301. * Set the value of an uniform to an array of int32 (stored as vec2)
  127302. * @param uniform defines the webGL uniform location where to store the value
  127303. * @param array defines the array of int32 to store
  127304. */
  127305. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  127306. /**
  127307. * Set the value of an uniform to an array of int32 (stored as vec3)
  127308. * @param uniform defines the webGL uniform location where to store the value
  127309. * @param array defines the array of int32 to store
  127310. */
  127311. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  127312. /**
  127313. * Set the value of an uniform to an array of int32 (stored as vec4)
  127314. * @param uniform defines the webGL uniform location where to store the value
  127315. * @param array defines the array of int32 to store
  127316. */
  127317. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  127318. /**
  127319. * Set the value of an uniform to an array of float32
  127320. * @param uniform defines the webGL uniform location where to store the value
  127321. * @param array defines the array of float32 to store
  127322. */
  127323. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  127324. /**
  127325. * Set the value of an uniform to an array of float32 (stored as vec2)
  127326. * @param uniform defines the webGL uniform location where to store the value
  127327. * @param array defines the array of float32 to store
  127328. */
  127329. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  127330. /**
  127331. * Set the value of an uniform to an array of float32 (stored as vec3)
  127332. * @param uniform defines the webGL uniform location where to store the value
  127333. * @param array defines the array of float32 to store
  127334. */
  127335. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  127336. /**
  127337. * Set the value of an uniform to an array of float32 (stored as vec4)
  127338. * @param uniform defines the webGL uniform location where to store the value
  127339. * @param array defines the array of float32 to store
  127340. */
  127341. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  127342. /**
  127343. * Set the value of an uniform to an array of number
  127344. * @param uniform defines the webGL uniform location where to store the value
  127345. * @param array defines the array of number to store
  127346. */
  127347. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  127348. /**
  127349. * Set the value of an uniform to an array of number (stored as vec2)
  127350. * @param uniform defines the webGL uniform location where to store the value
  127351. * @param array defines the array of number to store
  127352. */
  127353. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  127354. /**
  127355. * Set the value of an uniform to an array of number (stored as vec3)
  127356. * @param uniform defines the webGL uniform location where to store the value
  127357. * @param array defines the array of number to store
  127358. */
  127359. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  127360. /**
  127361. * Set the value of an uniform to an array of number (stored as vec4)
  127362. * @param uniform defines the webGL uniform location where to store the value
  127363. * @param array defines the array of number to store
  127364. */
  127365. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  127366. /**
  127367. * Set the value of an uniform to an array of float32 (stored as matrices)
  127368. * @param uniform defines the webGL uniform location where to store the value
  127369. * @param matrices defines the array of float32 to store
  127370. */
  127371. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  127372. /**
  127373. * Set the value of an uniform to a matrix (3x3)
  127374. * @param uniform defines the webGL uniform location where to store the value
  127375. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  127376. */
  127377. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127378. /**
  127379. * Set the value of an uniform to a matrix (2x2)
  127380. * @param uniform defines the webGL uniform location where to store the value
  127381. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  127382. */
  127383. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127384. /**
  127385. * Set the value of an uniform to a number (float)
  127386. * @param uniform defines the webGL uniform location where to store the value
  127387. * @param value defines the float number to store
  127388. */
  127389. setFloat(uniform: WebGLUniformLocation, value: number): void;
  127390. /**
  127391. * Set the value of an uniform to a vec2
  127392. * @param uniform defines the webGL uniform location where to store the value
  127393. * @param x defines the 1st component of the value
  127394. * @param y defines the 2nd component of the value
  127395. */
  127396. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  127397. /**
  127398. * Set the value of an uniform to a vec3
  127399. * @param uniform defines the webGL uniform location where to store the value
  127400. * @param x defines the 1st component of the value
  127401. * @param y defines the 2nd component of the value
  127402. * @param z defines the 3rd component of the value
  127403. */
  127404. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  127405. /**
  127406. * Set the value of an uniform to a boolean
  127407. * @param uniform defines the webGL uniform location where to store the value
  127408. * @param bool defines the boolean to store
  127409. */
  127410. setBool(uniform: WebGLUniformLocation, bool: number): void;
  127411. /**
  127412. * Set the value of an uniform to a vec4
  127413. * @param uniform defines the webGL uniform location where to store the value
  127414. * @param x defines the 1st component of the value
  127415. * @param y defines the 2nd component of the value
  127416. * @param z defines the 3rd component of the value
  127417. * @param w defines the 4th component of the value
  127418. */
  127419. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  127420. /**
  127421. * Sets the current alpha mode
  127422. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  127423. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  127424. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  127425. */
  127426. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  127427. /**
  127428. * Bind webGl buffers directly to the webGL context
  127429. * @param vertexBuffers defines the vertex buffer to bind
  127430. * @param indexBuffer defines the index buffer to bind
  127431. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  127432. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  127433. * @param effect defines the effect associated with the vertex buffer
  127434. */
  127435. bindBuffers(vertexBuffers: {
  127436. [key: string]: VertexBuffer;
  127437. }, indexBuffer: DataBuffer, effect: Effect): void;
  127438. /**
  127439. * Force the entire cache to be cleared
  127440. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  127441. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  127442. */
  127443. wipeCaches(bruteForce?: boolean): void;
  127444. /**
  127445. * Send a draw order
  127446. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  127447. * @param indexStart defines the starting index
  127448. * @param indexCount defines the number of index to draw
  127449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127450. */
  127451. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  127452. /**
  127453. * Draw a list of indexed primitives
  127454. * @param fillMode defines the primitive to use
  127455. * @param indexStart defines the starting index
  127456. * @param indexCount defines the number of index to draw
  127457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127458. */
  127459. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  127460. /**
  127461. * Draw a list of unindexed primitives
  127462. * @param fillMode defines the primitive to use
  127463. * @param verticesStart defines the index of first vertex to draw
  127464. * @param verticesCount defines the count of vertices to draw
  127465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127466. */
  127467. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  127468. /** @hidden */
  127469. _createTexture(): WebGLTexture;
  127470. /** @hidden */
  127471. _releaseTexture(texture: InternalTexture): void;
  127472. /**
  127473. * Usually called from Texture.ts.
  127474. * Passed information to create a WebGLTexture
  127475. * @param urlArg defines a value which contains one of the following:
  127476. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  127477. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  127478. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  127479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  127480. * @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)
  127481. * @param scene needed for loading to the correct scene
  127482. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  127483. * @param onLoad optional callback to be called upon successful completion
  127484. * @param onError optional callback to be called upon failure
  127485. * @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
  127486. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  127487. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  127488. * @param forcedExtension defines the extension to use to pick the right loader
  127489. * @param mimeType defines an optional mime type
  127490. * @returns a InternalTexture for assignment back into BABYLON.Texture
  127491. */
  127492. 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;
  127493. /**
  127494. * Creates a new render target texture
  127495. * @param size defines the size of the texture
  127496. * @param options defines the options used to create the texture
  127497. * @returns a new render target texture stored in an InternalTexture
  127498. */
  127499. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  127500. /**
  127501. * Update the sampling mode of a given texture
  127502. * @param samplingMode defines the required sampling mode
  127503. * @param texture defines the texture to update
  127504. */
  127505. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  127506. /**
  127507. * Binds the frame buffer to the specified texture.
  127508. * @param texture The texture to render to or null for the default canvas
  127509. * @param faceIndex The face of the texture to render to in case of cube texture
  127510. * @param requiredWidth The width of the target to render to
  127511. * @param requiredHeight The height of the target to render to
  127512. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  127513. * @param lodLevel defines le lod level to bind to the frame buffer
  127514. */
  127515. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  127516. /**
  127517. * Unbind the current render target texture from the webGL context
  127518. * @param texture defines the render target texture to unbind
  127519. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127520. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127521. */
  127522. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  127523. /**
  127524. * Creates a dynamic vertex buffer
  127525. * @param vertices the data for the dynamic vertex buffer
  127526. * @returns the new WebGL dynamic buffer
  127527. */
  127528. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  127529. /**
  127530. * Update the content of a dynamic texture
  127531. * @param texture defines the texture to update
  127532. * @param canvas defines the canvas containing the source
  127533. * @param invertY defines if data must be stored with Y axis inverted
  127534. * @param premulAlpha defines if alpha is stored as premultiplied
  127535. * @param format defines the format of the data
  127536. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  127537. */
  127538. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  127539. /**
  127540. * Gets a boolean indicating if all created effects are ready
  127541. * @returns true if all effects are ready
  127542. */
  127543. areAllEffectsReady(): boolean;
  127544. /**
  127545. * @hidden
  127546. * Get the current error code of the webGL context
  127547. * @returns the error code
  127548. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  127549. */
  127550. getError(): number;
  127551. /** @hidden */
  127552. _getUnpackAlignement(): number;
  127553. /** @hidden */
  127554. _unpackFlipY(value: boolean): void;
  127555. /**
  127556. * Update a dynamic index buffer
  127557. * @param indexBuffer defines the target index buffer
  127558. * @param indices defines the data to update
  127559. * @param offset defines the offset in the target index buffer where update should start
  127560. */
  127561. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  127562. /**
  127563. * Updates a dynamic vertex buffer.
  127564. * @param vertexBuffer the vertex buffer to update
  127565. * @param vertices the data used to update the vertex buffer
  127566. * @param byteOffset the byte offset of the data (optional)
  127567. * @param byteLength the byte length of the data (optional)
  127568. */
  127569. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  127570. /** @hidden */
  127571. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  127572. /** @hidden */
  127573. _bindTexture(channel: number, texture: InternalTexture): void;
  127574. protected _deleteBuffer(buffer: WebGLBuffer): void;
  127575. /**
  127576. * 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
  127577. */
  127578. releaseEffects(): void;
  127579. displayLoadingUI(): void;
  127580. hideLoadingUI(): void;
  127581. /** @hidden */
  127582. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127583. /** @hidden */
  127584. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127585. /** @hidden */
  127586. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127587. /** @hidden */
  127588. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  127589. }
  127590. }
  127591. declare module BABYLON {
  127592. /**
  127593. * @hidden
  127594. **/
  127595. export class _TimeToken {
  127596. _startTimeQuery: Nullable<WebGLQuery>;
  127597. _endTimeQuery: Nullable<WebGLQuery>;
  127598. _timeElapsedQuery: Nullable<WebGLQuery>;
  127599. _timeElapsedQueryEnded: boolean;
  127600. }
  127601. }
  127602. declare module BABYLON {
  127603. /** @hidden */
  127604. export class _OcclusionDataStorage {
  127605. /** @hidden */
  127606. occlusionInternalRetryCounter: number;
  127607. /** @hidden */
  127608. isOcclusionQueryInProgress: boolean;
  127609. /** @hidden */
  127610. isOccluded: boolean;
  127611. /** @hidden */
  127612. occlusionRetryCount: number;
  127613. /** @hidden */
  127614. occlusionType: number;
  127615. /** @hidden */
  127616. occlusionQueryAlgorithmType: number;
  127617. }
  127618. interface Engine {
  127619. /**
  127620. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  127621. * @return the new query
  127622. */
  127623. createQuery(): WebGLQuery;
  127624. /**
  127625. * Delete and release a webGL query
  127626. * @param query defines the query to delete
  127627. * @return the current engine
  127628. */
  127629. deleteQuery(query: WebGLQuery): Engine;
  127630. /**
  127631. * Check if a given query has resolved and got its value
  127632. * @param query defines the query to check
  127633. * @returns true if the query got its value
  127634. */
  127635. isQueryResultAvailable(query: WebGLQuery): boolean;
  127636. /**
  127637. * Gets the value of a given query
  127638. * @param query defines the query to check
  127639. * @returns the value of the query
  127640. */
  127641. getQueryResult(query: WebGLQuery): number;
  127642. /**
  127643. * Initiates an occlusion query
  127644. * @param algorithmType defines the algorithm to use
  127645. * @param query defines the query to use
  127646. * @returns the current engine
  127647. * @see http://doc.babylonjs.com/features/occlusionquery
  127648. */
  127649. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  127650. /**
  127651. * Ends an occlusion query
  127652. * @see http://doc.babylonjs.com/features/occlusionquery
  127653. * @param algorithmType defines the algorithm to use
  127654. * @returns the current engine
  127655. */
  127656. endOcclusionQuery(algorithmType: number): Engine;
  127657. /**
  127658. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  127659. * Please note that only one query can be issued at a time
  127660. * @returns a time token used to track the time span
  127661. */
  127662. startTimeQuery(): Nullable<_TimeToken>;
  127663. /**
  127664. * Ends a time query
  127665. * @param token defines the token used to measure the time span
  127666. * @returns the time spent (in ns)
  127667. */
  127668. endTimeQuery(token: _TimeToken): int;
  127669. /** @hidden */
  127670. _currentNonTimestampToken: Nullable<_TimeToken>;
  127671. /** @hidden */
  127672. _createTimeQuery(): WebGLQuery;
  127673. /** @hidden */
  127674. _deleteTimeQuery(query: WebGLQuery): void;
  127675. /** @hidden */
  127676. _getGlAlgorithmType(algorithmType: number): number;
  127677. /** @hidden */
  127678. _getTimeQueryResult(query: WebGLQuery): any;
  127679. /** @hidden */
  127680. _getTimeQueryAvailability(query: WebGLQuery): any;
  127681. }
  127682. interface AbstractMesh {
  127683. /**
  127684. * Backing filed
  127685. * @hidden
  127686. */
  127687. __occlusionDataStorage: _OcclusionDataStorage;
  127688. /**
  127689. * Access property
  127690. * @hidden
  127691. */
  127692. _occlusionDataStorage: _OcclusionDataStorage;
  127693. /**
  127694. * 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.
  127695. * The default value is -1 which means don't break the query and wait till the result
  127696. * @see http://doc.babylonjs.com/features/occlusionquery
  127697. */
  127698. occlusionRetryCount: number;
  127699. /**
  127700. * 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:
  127701. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  127702. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  127703. * * 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.
  127704. * @see http://doc.babylonjs.com/features/occlusionquery
  127705. */
  127706. occlusionType: number;
  127707. /**
  127708. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  127709. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  127710. * * 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.
  127711. * @see http://doc.babylonjs.com/features/occlusionquery
  127712. */
  127713. occlusionQueryAlgorithmType: number;
  127714. /**
  127715. * 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
  127716. * @see http://doc.babylonjs.com/features/occlusionquery
  127717. */
  127718. isOccluded: boolean;
  127719. /**
  127720. * Flag to check the progress status of the query
  127721. * @see http://doc.babylonjs.com/features/occlusionquery
  127722. */
  127723. isOcclusionQueryInProgress: boolean;
  127724. }
  127725. }
  127726. declare module BABYLON {
  127727. /** @hidden */
  127728. export var _forceTransformFeedbackToBundle: boolean;
  127729. interface Engine {
  127730. /**
  127731. * Creates a webGL transform feedback object
  127732. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  127733. * @returns the webGL transform feedback object
  127734. */
  127735. createTransformFeedback(): WebGLTransformFeedback;
  127736. /**
  127737. * Delete a webGL transform feedback object
  127738. * @param value defines the webGL transform feedback object to delete
  127739. */
  127740. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  127741. /**
  127742. * Bind a webGL transform feedback object to the webgl context
  127743. * @param value defines the webGL transform feedback object to bind
  127744. */
  127745. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  127746. /**
  127747. * Begins a transform feedback operation
  127748. * @param usePoints defines if points or triangles must be used
  127749. */
  127750. beginTransformFeedback(usePoints: boolean): void;
  127751. /**
  127752. * Ends a transform feedback operation
  127753. */
  127754. endTransformFeedback(): void;
  127755. /**
  127756. * Specify the varyings to use with transform feedback
  127757. * @param program defines the associated webGL program
  127758. * @param value defines the list of strings representing the varying names
  127759. */
  127760. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  127761. /**
  127762. * Bind a webGL buffer for a transform feedback operation
  127763. * @param value defines the webGL buffer to bind
  127764. */
  127765. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  127766. }
  127767. }
  127768. declare module BABYLON {
  127769. /**
  127770. * Creation options of the multi render target texture.
  127771. */
  127772. export interface IMultiRenderTargetOptions {
  127773. /**
  127774. * Define if the texture needs to create mip maps after render.
  127775. */
  127776. generateMipMaps?: boolean;
  127777. /**
  127778. * Define the types of all the draw buffers we want to create
  127779. */
  127780. types?: number[];
  127781. /**
  127782. * Define the sampling modes of all the draw buffers we want to create
  127783. */
  127784. samplingModes?: number[];
  127785. /**
  127786. * Define if a depth buffer is required
  127787. */
  127788. generateDepthBuffer?: boolean;
  127789. /**
  127790. * Define if a stencil buffer is required
  127791. */
  127792. generateStencilBuffer?: boolean;
  127793. /**
  127794. * Define if a depth texture is required instead of a depth buffer
  127795. */
  127796. generateDepthTexture?: boolean;
  127797. /**
  127798. * Define the number of desired draw buffers
  127799. */
  127800. textureCount?: number;
  127801. /**
  127802. * Define if aspect ratio should be adapted to the texture or stay the scene one
  127803. */
  127804. doNotChangeAspectRatio?: boolean;
  127805. /**
  127806. * Define the default type of the buffers we are creating
  127807. */
  127808. defaultType?: number;
  127809. }
  127810. /**
  127811. * A multi render target, like a render target provides the ability to render to a texture.
  127812. * Unlike the render target, it can render to several draw buffers in one draw.
  127813. * This is specially interesting in deferred rendering or for any effects requiring more than
  127814. * just one color from a single pass.
  127815. */
  127816. export class MultiRenderTarget extends RenderTargetTexture {
  127817. private _internalTextures;
  127818. private _textures;
  127819. private _multiRenderTargetOptions;
  127820. /**
  127821. * Get if draw buffers are currently supported by the used hardware and browser.
  127822. */
  127823. get isSupported(): boolean;
  127824. /**
  127825. * Get the list of textures generated by the multi render target.
  127826. */
  127827. get textures(): Texture[];
  127828. /**
  127829. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  127830. */
  127831. get depthTexture(): Texture;
  127832. /**
  127833. * Set the wrapping mode on U of all the textures we are rendering to.
  127834. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127835. */
  127836. set wrapU(wrap: number);
  127837. /**
  127838. * Set the wrapping mode on V of all the textures we are rendering to.
  127839. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127840. */
  127841. set wrapV(wrap: number);
  127842. /**
  127843. * Instantiate a new multi render target texture.
  127844. * A multi render target, like a render target provides the ability to render to a texture.
  127845. * Unlike the render target, it can render to several draw buffers in one draw.
  127846. * This is specially interesting in deferred rendering or for any effects requiring more than
  127847. * just one color from a single pass.
  127848. * @param name Define the name of the texture
  127849. * @param size Define the size of the buffers to render to
  127850. * @param count Define the number of target we are rendering into
  127851. * @param scene Define the scene the texture belongs to
  127852. * @param options Define the options used to create the multi render target
  127853. */
  127854. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  127855. /** @hidden */
  127856. _rebuild(): void;
  127857. private _createInternalTextures;
  127858. private _createTextures;
  127859. /**
  127860. * Define the number of samples used if MSAA is enabled.
  127861. */
  127862. get samples(): number;
  127863. set samples(value: number);
  127864. /**
  127865. * Resize all the textures in the multi render target.
  127866. * Be carrefull as it will recreate all the data in the new texture.
  127867. * @param size Define the new size
  127868. */
  127869. resize(size: any): void;
  127870. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  127871. /**
  127872. * Dispose the render targets and their associated resources
  127873. */
  127874. dispose(): void;
  127875. /**
  127876. * Release all the underlying texture used as draw buffers.
  127877. */
  127878. releaseInternalTextures(): void;
  127879. }
  127880. }
  127881. declare module BABYLON {
  127882. interface ThinEngine {
  127883. /**
  127884. * Unbind a list of render target textures from the webGL context
  127885. * This is used only when drawBuffer extension or webGL2 are active
  127886. * @param textures defines the render target textures to unbind
  127887. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127888. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127889. */
  127890. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  127891. /**
  127892. * Create a multi render target texture
  127893. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  127894. * @param size defines the size of the texture
  127895. * @param options defines the creation options
  127896. * @returns the cube texture as an InternalTexture
  127897. */
  127898. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  127899. /**
  127900. * Update the sample count for a given multiple render target texture
  127901. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127902. * @param textures defines the textures to update
  127903. * @param samples defines the sample count to set
  127904. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127905. */
  127906. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  127907. }
  127908. }
  127909. declare module BABYLON {
  127910. /**
  127911. * Class used to define an additional view for the engine
  127912. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127913. */
  127914. export class EngineView {
  127915. /** Defines the canvas where to render the view */
  127916. target: HTMLCanvasElement;
  127917. /** Defines an optional camera used to render the view (will use active camera else) */
  127918. camera?: Camera;
  127919. }
  127920. interface Engine {
  127921. /**
  127922. * Gets or sets the HTML element to use for attaching events
  127923. */
  127924. inputElement: Nullable<HTMLElement>;
  127925. /**
  127926. * Gets the current engine view
  127927. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127928. */
  127929. activeView: Nullable<EngineView>;
  127930. /** Gets or sets the list of views */
  127931. views: EngineView[];
  127932. /**
  127933. * Register a new child canvas
  127934. * @param canvas defines the canvas to register
  127935. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  127936. * @returns the associated view
  127937. */
  127938. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  127939. /**
  127940. * Remove a registered child canvas
  127941. * @param canvas defines the canvas to remove
  127942. * @returns the current engine
  127943. */
  127944. unRegisterView(canvas: HTMLCanvasElement): Engine;
  127945. }
  127946. }
  127947. declare module BABYLON {
  127948. interface Engine {
  127949. /** @hidden */
  127950. _excludedCompressedTextures: string[];
  127951. /** @hidden */
  127952. _textureFormatInUse: string;
  127953. /**
  127954. * Gets the list of texture formats supported
  127955. */
  127956. readonly texturesSupported: Array<string>;
  127957. /**
  127958. * Gets the texture format in use
  127959. */
  127960. readonly textureFormatInUse: Nullable<string>;
  127961. /**
  127962. * Set the compressed texture extensions or file names to skip.
  127963. *
  127964. * @param skippedFiles defines the list of those texture files you want to skip
  127965. * Example: [".dds", ".env", "myfile.png"]
  127966. */
  127967. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  127968. /**
  127969. * Set the compressed texture format to use, based on the formats you have, and the formats
  127970. * supported by the hardware / browser.
  127971. *
  127972. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  127973. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  127974. * to API arguments needed to compressed textures. This puts the burden on the container
  127975. * generator to house the arcane code for determining these for current & future formats.
  127976. *
  127977. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  127978. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  127979. *
  127980. * Note: The result of this call is not taken into account when a texture is base64.
  127981. *
  127982. * @param formatsAvailable defines the list of those format families you have created
  127983. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  127984. *
  127985. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  127986. * @returns The extension selected.
  127987. */
  127988. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  127989. }
  127990. }
  127991. declare module BABYLON {
  127992. /**
  127993. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  127994. */
  127995. export interface CubeMapInfo {
  127996. /**
  127997. * The pixel array for the front face.
  127998. * This is stored in format, left to right, up to down format.
  127999. */
  128000. front: Nullable<ArrayBufferView>;
  128001. /**
  128002. * The pixel array for the back face.
  128003. * This is stored in format, left to right, up to down format.
  128004. */
  128005. back: Nullable<ArrayBufferView>;
  128006. /**
  128007. * The pixel array for the left face.
  128008. * This is stored in format, left to right, up to down format.
  128009. */
  128010. left: Nullable<ArrayBufferView>;
  128011. /**
  128012. * The pixel array for the right face.
  128013. * This is stored in format, left to right, up to down format.
  128014. */
  128015. right: Nullable<ArrayBufferView>;
  128016. /**
  128017. * The pixel array for the up face.
  128018. * This is stored in format, left to right, up to down format.
  128019. */
  128020. up: Nullable<ArrayBufferView>;
  128021. /**
  128022. * The pixel array for the down face.
  128023. * This is stored in format, left to right, up to down format.
  128024. */
  128025. down: Nullable<ArrayBufferView>;
  128026. /**
  128027. * The size of the cubemap stored.
  128028. *
  128029. * Each faces will be size * size pixels.
  128030. */
  128031. size: number;
  128032. /**
  128033. * The format of the texture.
  128034. *
  128035. * RGBA, RGB.
  128036. */
  128037. format: number;
  128038. /**
  128039. * The type of the texture data.
  128040. *
  128041. * UNSIGNED_INT, FLOAT.
  128042. */
  128043. type: number;
  128044. /**
  128045. * Specifies whether the texture is in gamma space.
  128046. */
  128047. gammaSpace: boolean;
  128048. }
  128049. /**
  128050. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128051. */
  128052. export class PanoramaToCubeMapTools {
  128053. private static FACE_LEFT;
  128054. private static FACE_RIGHT;
  128055. private static FACE_FRONT;
  128056. private static FACE_BACK;
  128057. private static FACE_DOWN;
  128058. private static FACE_UP;
  128059. /**
  128060. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128061. *
  128062. * @param float32Array The source data.
  128063. * @param inputWidth The width of the input panorama.
  128064. * @param inputHeight The height of the input panorama.
  128065. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128066. * @return The cubemap data
  128067. */
  128068. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128069. private static CreateCubemapTexture;
  128070. private static CalcProjectionSpherical;
  128071. }
  128072. }
  128073. declare module BABYLON {
  128074. /**
  128075. * Helper class dealing with the extraction of spherical polynomial dataArray
  128076. * from a cube map.
  128077. */
  128078. export class CubeMapToSphericalPolynomialTools {
  128079. private static FileFaces;
  128080. /**
  128081. * Converts a texture to the according Spherical Polynomial data.
  128082. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128083. *
  128084. * @param texture The texture to extract the information from.
  128085. * @return The Spherical Polynomial data.
  128086. */
  128087. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  128088. /**
  128089. * Converts a cubemap to the according Spherical Polynomial data.
  128090. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128091. *
  128092. * @param cubeInfo The Cube map to extract the information from.
  128093. * @return The Spherical Polynomial data.
  128094. */
  128095. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  128096. }
  128097. }
  128098. declare module BABYLON {
  128099. interface BaseTexture {
  128100. /**
  128101. * Get the polynomial representation of the texture data.
  128102. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  128103. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  128104. */
  128105. sphericalPolynomial: Nullable<SphericalPolynomial>;
  128106. }
  128107. }
  128108. declare module BABYLON {
  128109. /** @hidden */
  128110. export var rgbdEncodePixelShader: {
  128111. name: string;
  128112. shader: string;
  128113. };
  128114. }
  128115. declare module BABYLON {
  128116. /** @hidden */
  128117. export var rgbdDecodePixelShader: {
  128118. name: string;
  128119. shader: string;
  128120. };
  128121. }
  128122. declare module BABYLON {
  128123. /**
  128124. * Raw texture data and descriptor sufficient for WebGL texture upload
  128125. */
  128126. export interface EnvironmentTextureInfo {
  128127. /**
  128128. * Version of the environment map
  128129. */
  128130. version: number;
  128131. /**
  128132. * Width of image
  128133. */
  128134. width: number;
  128135. /**
  128136. * Irradiance information stored in the file.
  128137. */
  128138. irradiance: any;
  128139. /**
  128140. * Specular information stored in the file.
  128141. */
  128142. specular: any;
  128143. }
  128144. /**
  128145. * Defines One Image in the file. It requires only the position in the file
  128146. * as well as the length.
  128147. */
  128148. interface BufferImageData {
  128149. /**
  128150. * Length of the image data.
  128151. */
  128152. length: number;
  128153. /**
  128154. * Position of the data from the null terminator delimiting the end of the JSON.
  128155. */
  128156. position: number;
  128157. }
  128158. /**
  128159. * Defines the specular data enclosed in the file.
  128160. * This corresponds to the version 1 of the data.
  128161. */
  128162. export interface EnvironmentTextureSpecularInfoV1 {
  128163. /**
  128164. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  128165. */
  128166. specularDataPosition?: number;
  128167. /**
  128168. * This contains all the images data needed to reconstruct the cubemap.
  128169. */
  128170. mipmaps: Array<BufferImageData>;
  128171. /**
  128172. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  128173. */
  128174. lodGenerationScale: number;
  128175. }
  128176. /**
  128177. * Sets of helpers addressing the serialization and deserialization of environment texture
  128178. * stored in a BabylonJS env file.
  128179. * Those files are usually stored as .env files.
  128180. */
  128181. export class EnvironmentTextureTools {
  128182. /**
  128183. * Magic number identifying the env file.
  128184. */
  128185. private static _MagicBytes;
  128186. /**
  128187. * Gets the environment info from an env file.
  128188. * @param data The array buffer containing the .env bytes.
  128189. * @returns the environment file info (the json header) if successfully parsed.
  128190. */
  128191. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  128192. /**
  128193. * Creates an environment texture from a loaded cube texture.
  128194. * @param texture defines the cube texture to convert in env file
  128195. * @return a promise containing the environment data if succesfull.
  128196. */
  128197. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  128198. /**
  128199. * Creates a JSON representation of the spherical data.
  128200. * @param texture defines the texture containing the polynomials
  128201. * @return the JSON representation of the spherical info
  128202. */
  128203. private static _CreateEnvTextureIrradiance;
  128204. /**
  128205. * Creates the ArrayBufferViews used for initializing environment texture image data.
  128206. * @param data the image data
  128207. * @param info parameters that determine what views will be created for accessing the underlying buffer
  128208. * @return the views described by info providing access to the underlying buffer
  128209. */
  128210. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  128211. /**
  128212. * Uploads the texture info contained in the env file to the GPU.
  128213. * @param texture defines the internal texture to upload to
  128214. * @param data defines the data to load
  128215. * @param info defines the texture info retrieved through the GetEnvInfo method
  128216. * @returns a promise
  128217. */
  128218. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  128219. private static _OnImageReadyAsync;
  128220. /**
  128221. * Uploads the levels of image data to the GPU.
  128222. * @param texture defines the internal texture to upload to
  128223. * @param imageData defines the array buffer views of image data [mipmap][face]
  128224. * @returns a promise
  128225. */
  128226. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  128227. /**
  128228. * Uploads spherical polynomials information to the texture.
  128229. * @param texture defines the texture we are trying to upload the information to
  128230. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  128231. */
  128232. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  128233. /** @hidden */
  128234. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  128235. }
  128236. }
  128237. declare module BABYLON {
  128238. /** @hidden */
  128239. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  128240. private _genericAttributeLocation;
  128241. private _varyingLocationCount;
  128242. private _varyingLocationMap;
  128243. private _replacements;
  128244. private _textureCount;
  128245. private _uniforms;
  128246. lineProcessor(line: string): string;
  128247. attributeProcessor(attribute: string): string;
  128248. varyingProcessor(varying: string, isFragment: boolean): string;
  128249. uniformProcessor(uniform: string): string;
  128250. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  128251. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  128252. }
  128253. }
  128254. declare module BABYLON {
  128255. /**
  128256. * Class used to inline functions in shader code
  128257. */
  128258. export class ShaderCodeInliner {
  128259. private static readonly _RegexpFindFunctionNameAndType;
  128260. private _sourceCode;
  128261. private _functionDescr;
  128262. private _numMaxIterations;
  128263. /** Gets or sets the token used to mark the functions to inline */
  128264. inlineToken: string;
  128265. /** Gets or sets the debug mode */
  128266. debug: boolean;
  128267. /** Gets the code after the inlining process */
  128268. get code(): string;
  128269. /**
  128270. * Initializes the inliner
  128271. * @param sourceCode shader code source to inline
  128272. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  128273. */
  128274. constructor(sourceCode: string, numMaxIterations?: number);
  128275. /**
  128276. * Start the processing of the shader code
  128277. */
  128278. processCode(): void;
  128279. private _collectFunctions;
  128280. private _processInlining;
  128281. private _extractBetweenMarkers;
  128282. private _skipWhitespaces;
  128283. private _removeComments;
  128284. private _replaceFunctionCallsByCode;
  128285. private _findBackward;
  128286. private _escapeRegExp;
  128287. private _replaceNames;
  128288. }
  128289. }
  128290. declare module BABYLON {
  128291. /**
  128292. * Container for accessors for natively-stored mesh data buffers.
  128293. */
  128294. class NativeDataBuffer extends DataBuffer {
  128295. /**
  128296. * Accessor value used to identify/retrieve a natively-stored index buffer.
  128297. */
  128298. nativeIndexBuffer?: any;
  128299. /**
  128300. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  128301. */
  128302. nativeVertexBuffer?: any;
  128303. }
  128304. /** @hidden */
  128305. class NativeTexture extends InternalTexture {
  128306. getInternalTexture(): InternalTexture;
  128307. getViewCount(): number;
  128308. }
  128309. /** @hidden */
  128310. export class NativeEngine extends Engine {
  128311. private readonly _native;
  128312. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  128313. private readonly INVALID_HANDLE;
  128314. getHardwareScalingLevel(): number;
  128315. constructor();
  128316. dispose(): void;
  128317. /**
  128318. * Can be used to override the current requestAnimationFrame requester.
  128319. * @hidden
  128320. */
  128321. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  128322. /**
  128323. * Override default engine behavior.
  128324. * @param color
  128325. * @param backBuffer
  128326. * @param depth
  128327. * @param stencil
  128328. */
  128329. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  128330. /**
  128331. * Gets host document
  128332. * @returns the host document object
  128333. */
  128334. getHostDocument(): Nullable<Document>;
  128335. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128336. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  128337. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  128338. recordVertexArrayObject(vertexBuffers: {
  128339. [key: string]: VertexBuffer;
  128340. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  128341. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128342. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128343. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128344. /**
  128345. * Draw a list of indexed primitives
  128346. * @param fillMode defines the primitive to use
  128347. * @param indexStart defines the starting index
  128348. * @param indexCount defines the number of index to draw
  128349. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128350. */
  128351. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128352. /**
  128353. * Draw a list of unindexed primitives
  128354. * @param fillMode defines the primitive to use
  128355. * @param verticesStart defines the index of first vertex to draw
  128356. * @param verticesCount defines the count of vertices to draw
  128357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128358. */
  128359. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128360. createPipelineContext(): IPipelineContext;
  128361. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  128362. /** @hidden */
  128363. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  128364. /** @hidden */
  128365. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  128366. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128367. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128368. protected _setProgram(program: WebGLProgram): void;
  128369. _releaseEffect(effect: Effect): void;
  128370. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  128371. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  128372. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  128373. bindSamplers(effect: Effect): void;
  128374. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  128375. getRenderWidth(useScreen?: boolean): number;
  128376. getRenderHeight(useScreen?: boolean): number;
  128377. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  128378. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128379. /**
  128380. * Set the z offset to apply to current rendering
  128381. * @param value defines the offset to apply
  128382. */
  128383. setZOffset(value: number): void;
  128384. /**
  128385. * Gets the current value of the zOffset
  128386. * @returns the current zOffset state
  128387. */
  128388. getZOffset(): number;
  128389. /**
  128390. * Enable or disable depth buffering
  128391. * @param enable defines the state to set
  128392. */
  128393. setDepthBuffer(enable: boolean): void;
  128394. /**
  128395. * Gets a boolean indicating if depth writing is enabled
  128396. * @returns the current depth writing state
  128397. */
  128398. getDepthWrite(): boolean;
  128399. /**
  128400. * Enable or disable depth writing
  128401. * @param enable defines the state to set
  128402. */
  128403. setDepthWrite(enable: boolean): void;
  128404. /**
  128405. * Enable or disable color writing
  128406. * @param enable defines the state to set
  128407. */
  128408. setColorWrite(enable: boolean): void;
  128409. /**
  128410. * Gets a boolean indicating if color writing is enabled
  128411. * @returns the current color writing state
  128412. */
  128413. getColorWrite(): boolean;
  128414. /**
  128415. * Sets alpha constants used by some alpha blending modes
  128416. * @param r defines the red component
  128417. * @param g defines the green component
  128418. * @param b defines the blue component
  128419. * @param a defines the alpha component
  128420. */
  128421. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  128422. /**
  128423. * Sets the current alpha mode
  128424. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  128425. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128427. */
  128428. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128429. /**
  128430. * Gets the current alpha mode
  128431. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128432. * @returns the current alpha mode
  128433. */
  128434. getAlphaMode(): number;
  128435. setInt(uniform: WebGLUniformLocation, int: number): void;
  128436. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128437. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128438. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128439. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128440. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128441. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128442. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128443. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128444. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128445. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128446. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128447. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128448. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128449. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128450. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128451. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128452. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128453. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128454. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128455. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  128456. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  128457. wipeCaches(bruteForce?: boolean): void;
  128458. _createTexture(): WebGLTexture;
  128459. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  128460. /**
  128461. * Usually called from Texture.ts.
  128462. * Passed information to create a WebGLTexture
  128463. * @param url defines a value which contains one of the following:
  128464. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128465. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128466. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128467. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128468. * @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)
  128469. * @param scene needed for loading to the correct scene
  128470. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128471. * @param onLoad optional callback to be called upon successful completion
  128472. * @param onError optional callback to be called upon failure
  128473. * @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
  128474. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128475. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128476. * @param forcedExtension defines the extension to use to pick the right loader
  128477. * @param mimeType defines an optional mime type
  128478. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128479. */
  128480. 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;
  128481. /**
  128482. * Creates a cube texture
  128483. * @param rootUrl defines the url where the files to load is located
  128484. * @param scene defines the current scene
  128485. * @param files defines the list of files to load (1 per face)
  128486. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  128487. * @param onLoad defines an optional callback raised when the texture is loaded
  128488. * @param onError defines an optional callback raised if there is an issue to load the texture
  128489. * @param format defines the format of the data
  128490. * @param forcedExtension defines the extension to use to pick the right loader
  128491. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  128492. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128493. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128494. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  128495. * @returns the cube texture as an InternalTexture
  128496. */
  128497. 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;
  128498. private _getSamplingFilter;
  128499. private static _GetNativeTextureFormat;
  128500. createRenderTargetTexture(size: number | {
  128501. width: number;
  128502. height: number;
  128503. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  128504. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128505. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128506. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128507. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  128508. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  128509. /**
  128510. * Updates a dynamic vertex buffer.
  128511. * @param vertexBuffer the vertex buffer to update
  128512. * @param data the data used to update the vertex buffer
  128513. * @param byteOffset the byte offset of the data (optional)
  128514. * @param byteLength the byte length of the data (optional)
  128515. */
  128516. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  128517. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  128518. private _updateAnisotropicLevel;
  128519. private _getAddressMode;
  128520. /** @hidden */
  128521. _bindTexture(channel: number, texture: InternalTexture): void;
  128522. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  128523. releaseEffects(): void;
  128524. /** @hidden */
  128525. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128526. /** @hidden */
  128527. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128528. /** @hidden */
  128529. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128530. /** @hidden */
  128531. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128532. }
  128533. }
  128534. declare module BABYLON {
  128535. /**
  128536. * Gather the list of clipboard event types as constants.
  128537. */
  128538. export class ClipboardEventTypes {
  128539. /**
  128540. * The clipboard event is fired when a copy command is active (pressed).
  128541. */
  128542. static readonly COPY: number;
  128543. /**
  128544. * The clipboard event is fired when a cut command is active (pressed).
  128545. */
  128546. static readonly CUT: number;
  128547. /**
  128548. * The clipboard event is fired when a paste command is active (pressed).
  128549. */
  128550. static readonly PASTE: number;
  128551. }
  128552. /**
  128553. * This class is used to store clipboard related info for the onClipboardObservable event.
  128554. */
  128555. export class ClipboardInfo {
  128556. /**
  128557. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128558. */
  128559. type: number;
  128560. /**
  128561. * Defines the related dom event
  128562. */
  128563. event: ClipboardEvent;
  128564. /**
  128565. *Creates an instance of ClipboardInfo.
  128566. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  128567. * @param event Defines the related dom event
  128568. */
  128569. constructor(
  128570. /**
  128571. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128572. */
  128573. type: number,
  128574. /**
  128575. * Defines the related dom event
  128576. */
  128577. event: ClipboardEvent);
  128578. /**
  128579. * Get the clipboard event's type from the keycode.
  128580. * @param keyCode Defines the keyCode for the current keyboard event.
  128581. * @return {number}
  128582. */
  128583. static GetTypeFromCharacter(keyCode: number): number;
  128584. }
  128585. }
  128586. declare module BABYLON {
  128587. /**
  128588. * Google Daydream controller
  128589. */
  128590. export class DaydreamController extends WebVRController {
  128591. /**
  128592. * Base Url for the controller model.
  128593. */
  128594. static MODEL_BASE_URL: string;
  128595. /**
  128596. * File name for the controller model.
  128597. */
  128598. static MODEL_FILENAME: string;
  128599. /**
  128600. * Gamepad Id prefix used to identify Daydream Controller.
  128601. */
  128602. static readonly GAMEPAD_ID_PREFIX: string;
  128603. /**
  128604. * Creates a new DaydreamController from a gamepad
  128605. * @param vrGamepad the gamepad that the controller should be created from
  128606. */
  128607. constructor(vrGamepad: any);
  128608. /**
  128609. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128610. * @param scene scene in which to add meshes
  128611. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128612. */
  128613. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128614. /**
  128615. * Called once for each button that changed state since the last frame
  128616. * @param buttonIdx Which button index changed
  128617. * @param state New state of the button
  128618. * @param changes Which properties on the state changed since last frame
  128619. */
  128620. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128621. }
  128622. }
  128623. declare module BABYLON {
  128624. /**
  128625. * Gear VR Controller
  128626. */
  128627. export class GearVRController extends WebVRController {
  128628. /**
  128629. * Base Url for the controller model.
  128630. */
  128631. static MODEL_BASE_URL: string;
  128632. /**
  128633. * File name for the controller model.
  128634. */
  128635. static MODEL_FILENAME: string;
  128636. /**
  128637. * Gamepad Id prefix used to identify this controller.
  128638. */
  128639. static readonly GAMEPAD_ID_PREFIX: string;
  128640. private readonly _buttonIndexToObservableNameMap;
  128641. /**
  128642. * Creates a new GearVRController from a gamepad
  128643. * @param vrGamepad the gamepad that the controller should be created from
  128644. */
  128645. constructor(vrGamepad: any);
  128646. /**
  128647. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128648. * @param scene scene in which to add meshes
  128649. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128650. */
  128651. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128652. /**
  128653. * Called once for each button that changed state since the last frame
  128654. * @param buttonIdx Which button index changed
  128655. * @param state New state of the button
  128656. * @param changes Which properties on the state changed since last frame
  128657. */
  128658. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128659. }
  128660. }
  128661. declare module BABYLON {
  128662. /**
  128663. * Generic Controller
  128664. */
  128665. export class GenericController extends WebVRController {
  128666. /**
  128667. * Base Url for the controller model.
  128668. */
  128669. static readonly MODEL_BASE_URL: string;
  128670. /**
  128671. * File name for the controller model.
  128672. */
  128673. static readonly MODEL_FILENAME: string;
  128674. /**
  128675. * Creates a new GenericController from a gamepad
  128676. * @param vrGamepad the gamepad that the controller should be created from
  128677. */
  128678. constructor(vrGamepad: any);
  128679. /**
  128680. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128681. * @param scene scene in which to add meshes
  128682. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128683. */
  128684. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128685. /**
  128686. * Called once for each button that changed state since the last frame
  128687. * @param buttonIdx Which button index changed
  128688. * @param state New state of the button
  128689. * @param changes Which properties on the state changed since last frame
  128690. */
  128691. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128692. }
  128693. }
  128694. declare module BABYLON {
  128695. /**
  128696. * Oculus Touch Controller
  128697. */
  128698. export class OculusTouchController extends WebVRController {
  128699. /**
  128700. * Base Url for the controller model.
  128701. */
  128702. static MODEL_BASE_URL: string;
  128703. /**
  128704. * File name for the left controller model.
  128705. */
  128706. static MODEL_LEFT_FILENAME: string;
  128707. /**
  128708. * File name for the right controller model.
  128709. */
  128710. static MODEL_RIGHT_FILENAME: string;
  128711. /**
  128712. * Base Url for the Quest controller model.
  128713. */
  128714. static QUEST_MODEL_BASE_URL: string;
  128715. /**
  128716. * @hidden
  128717. * If the controllers are running on a device that needs the updated Quest controller models
  128718. */
  128719. static _IsQuest: boolean;
  128720. /**
  128721. * Fired when the secondary trigger on this controller is modified
  128722. */
  128723. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  128724. /**
  128725. * Fired when the thumb rest on this controller is modified
  128726. */
  128727. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  128728. /**
  128729. * Creates a new OculusTouchController from a gamepad
  128730. * @param vrGamepad the gamepad that the controller should be created from
  128731. */
  128732. constructor(vrGamepad: any);
  128733. /**
  128734. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128735. * @param scene scene in which to add meshes
  128736. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128737. */
  128738. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128739. /**
  128740. * Fired when the A button on this controller is modified
  128741. */
  128742. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128743. /**
  128744. * Fired when the B button on this controller is modified
  128745. */
  128746. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128747. /**
  128748. * Fired when the X button on this controller is modified
  128749. */
  128750. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128751. /**
  128752. * Fired when the Y button on this controller is modified
  128753. */
  128754. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128755. /**
  128756. * Called once for each button that changed state since the last frame
  128757. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  128758. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  128759. * 2) secondary trigger (same)
  128760. * 3) A (right) X (left), touch, pressed = value
  128761. * 4) B / Y
  128762. * 5) thumb rest
  128763. * @param buttonIdx Which button index changed
  128764. * @param state New state of the button
  128765. * @param changes Which properties on the state changed since last frame
  128766. */
  128767. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128768. }
  128769. }
  128770. declare module BABYLON {
  128771. /**
  128772. * Vive Controller
  128773. */
  128774. export class ViveController extends WebVRController {
  128775. /**
  128776. * Base Url for the controller model.
  128777. */
  128778. static MODEL_BASE_URL: string;
  128779. /**
  128780. * File name for the controller model.
  128781. */
  128782. static MODEL_FILENAME: string;
  128783. /**
  128784. * Creates a new ViveController from a gamepad
  128785. * @param vrGamepad the gamepad that the controller should be created from
  128786. */
  128787. constructor(vrGamepad: any);
  128788. /**
  128789. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128790. * @param scene scene in which to add meshes
  128791. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128792. */
  128793. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128794. /**
  128795. * Fired when the left button on this controller is modified
  128796. */
  128797. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128798. /**
  128799. * Fired when the right button on this controller is modified
  128800. */
  128801. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128802. /**
  128803. * Fired when the menu button on this controller is modified
  128804. */
  128805. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128806. /**
  128807. * Called once for each button that changed state since the last frame
  128808. * Vive mapping:
  128809. * 0: touchpad
  128810. * 1: trigger
  128811. * 2: left AND right buttons
  128812. * 3: menu button
  128813. * @param buttonIdx Which button index changed
  128814. * @param state New state of the button
  128815. * @param changes Which properties on the state changed since last frame
  128816. */
  128817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128818. }
  128819. }
  128820. declare module BABYLON {
  128821. /**
  128822. * Defines the WindowsMotionController object that the state of the windows motion controller
  128823. */
  128824. export class WindowsMotionController extends WebVRController {
  128825. /**
  128826. * The base url used to load the left and right controller models
  128827. */
  128828. static MODEL_BASE_URL: string;
  128829. /**
  128830. * The name of the left controller model file
  128831. */
  128832. static MODEL_LEFT_FILENAME: string;
  128833. /**
  128834. * The name of the right controller model file
  128835. */
  128836. static MODEL_RIGHT_FILENAME: string;
  128837. /**
  128838. * The controller name prefix for this controller type
  128839. */
  128840. static readonly GAMEPAD_ID_PREFIX: string;
  128841. /**
  128842. * The controller id pattern for this controller type
  128843. */
  128844. private static readonly GAMEPAD_ID_PATTERN;
  128845. private _loadedMeshInfo;
  128846. protected readonly _mapping: {
  128847. buttons: string[];
  128848. buttonMeshNames: {
  128849. trigger: string;
  128850. menu: string;
  128851. grip: string;
  128852. thumbstick: string;
  128853. trackpad: string;
  128854. };
  128855. buttonObservableNames: {
  128856. trigger: string;
  128857. menu: string;
  128858. grip: string;
  128859. thumbstick: string;
  128860. trackpad: string;
  128861. };
  128862. axisMeshNames: string[];
  128863. pointingPoseMeshName: string;
  128864. };
  128865. /**
  128866. * Fired when the trackpad on this controller is clicked
  128867. */
  128868. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128869. /**
  128870. * Fired when the trackpad on this controller is modified
  128871. */
  128872. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128873. /**
  128874. * The current x and y values of this controller's trackpad
  128875. */
  128876. trackpad: StickValues;
  128877. /**
  128878. * Creates a new WindowsMotionController from a gamepad
  128879. * @param vrGamepad the gamepad that the controller should be created from
  128880. */
  128881. constructor(vrGamepad: any);
  128882. /**
  128883. * Fired when the trigger on this controller is modified
  128884. */
  128885. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128886. /**
  128887. * Fired when the menu button on this controller is modified
  128888. */
  128889. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128890. /**
  128891. * Fired when the grip button on this controller is modified
  128892. */
  128893. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128894. /**
  128895. * Fired when the thumbstick button on this controller is modified
  128896. */
  128897. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128898. /**
  128899. * Fired when the touchpad button on this controller is modified
  128900. */
  128901. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128902. /**
  128903. * Fired when the touchpad values on this controller are modified
  128904. */
  128905. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  128906. protected _updateTrackpad(): void;
  128907. /**
  128908. * Called once per frame by the engine.
  128909. */
  128910. update(): void;
  128911. /**
  128912. * Called once for each button that changed state since the last frame
  128913. * @param buttonIdx Which button index changed
  128914. * @param state New state of the button
  128915. * @param changes Which properties on the state changed since last frame
  128916. */
  128917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128918. /**
  128919. * Moves the buttons on the controller mesh based on their current state
  128920. * @param buttonName the name of the button to move
  128921. * @param buttonValue the value of the button which determines the buttons new position
  128922. */
  128923. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  128924. /**
  128925. * Moves the axis on the controller mesh based on its current state
  128926. * @param axis the index of the axis
  128927. * @param axisValue the value of the axis which determines the meshes new position
  128928. * @hidden
  128929. */
  128930. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  128931. /**
  128932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128933. * @param scene scene in which to add meshes
  128934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128935. */
  128936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  128937. /**
  128938. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  128939. * can be transformed by button presses and axes values, based on this._mapping.
  128940. *
  128941. * @param scene scene in which the meshes exist
  128942. * @param meshes list of meshes that make up the controller model to process
  128943. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  128944. */
  128945. private processModel;
  128946. private createMeshInfo;
  128947. /**
  128948. * Gets the ray of the controller in the direction the controller is pointing
  128949. * @param length the length the resulting ray should be
  128950. * @returns a ray in the direction the controller is pointing
  128951. */
  128952. getForwardRay(length?: number): Ray;
  128953. /**
  128954. * Disposes of the controller
  128955. */
  128956. dispose(): void;
  128957. }
  128958. /**
  128959. * This class represents a new windows motion controller in XR.
  128960. */
  128961. export class XRWindowsMotionController extends WindowsMotionController {
  128962. /**
  128963. * Changing the original WIndowsMotionController mapping to fir the new mapping
  128964. */
  128965. protected readonly _mapping: {
  128966. buttons: string[];
  128967. buttonMeshNames: {
  128968. trigger: string;
  128969. menu: string;
  128970. grip: string;
  128971. thumbstick: string;
  128972. trackpad: string;
  128973. };
  128974. buttonObservableNames: {
  128975. trigger: string;
  128976. menu: string;
  128977. grip: string;
  128978. thumbstick: string;
  128979. trackpad: string;
  128980. };
  128981. axisMeshNames: string[];
  128982. pointingPoseMeshName: string;
  128983. };
  128984. /**
  128985. * Construct a new XR-Based windows motion controller
  128986. *
  128987. * @param gamepadInfo the gamepad object from the browser
  128988. */
  128989. constructor(gamepadInfo: any);
  128990. /**
  128991. * holds the thumbstick values (X,Y)
  128992. */
  128993. thumbstickValues: StickValues;
  128994. /**
  128995. * Fired when the thumbstick on this controller is clicked
  128996. */
  128997. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  128998. /**
  128999. * Fired when the thumbstick on this controller is modified
  129000. */
  129001. onThumbstickValuesChangedObservable: Observable<StickValues>;
  129002. /**
  129003. * Fired when the touchpad button on this controller is modified
  129004. */
  129005. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129006. /**
  129007. * Fired when the touchpad values on this controller are modified
  129008. */
  129009. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129010. /**
  129011. * Fired when the thumbstick button on this controller is modified
  129012. * here to prevent breaking changes
  129013. */
  129014. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129015. /**
  129016. * updating the thumbstick(!) and not the trackpad.
  129017. * This is named this way due to the difference between WebVR and XR and to avoid
  129018. * changing the parent class.
  129019. */
  129020. protected _updateTrackpad(): void;
  129021. /**
  129022. * Disposes the class with joy
  129023. */
  129024. dispose(): void;
  129025. }
  129026. }
  129027. declare module BABYLON {
  129028. /**
  129029. * Class containing static functions to help procedurally build meshes
  129030. */
  129031. export class PolyhedronBuilder {
  129032. /**
  129033. * Creates a polyhedron mesh
  129034. * * 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
  129035. * * The parameter `size` (positive float, default 1) sets the polygon size
  129036. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129037. * * 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`
  129038. * * 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
  129039. * * 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)`)
  129040. * * 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
  129041. * * 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
  129042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129045. * @param name defines the name of the mesh
  129046. * @param options defines the options used to create the mesh
  129047. * @param scene defines the hosting scene
  129048. * @returns the polyhedron mesh
  129049. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129050. */
  129051. static CreatePolyhedron(name: string, options: {
  129052. type?: number;
  129053. size?: number;
  129054. sizeX?: number;
  129055. sizeY?: number;
  129056. sizeZ?: number;
  129057. custom?: any;
  129058. faceUV?: Vector4[];
  129059. faceColors?: Color4[];
  129060. flat?: boolean;
  129061. updatable?: boolean;
  129062. sideOrientation?: number;
  129063. frontUVs?: Vector4;
  129064. backUVs?: Vector4;
  129065. }, scene?: Nullable<Scene>): Mesh;
  129066. }
  129067. }
  129068. declare module BABYLON {
  129069. /**
  129070. * Gizmo that enables scaling a mesh along 3 axis
  129071. */
  129072. export class ScaleGizmo extends Gizmo {
  129073. /**
  129074. * Internal gizmo used for interactions on the x axis
  129075. */
  129076. xGizmo: AxisScaleGizmo;
  129077. /**
  129078. * Internal gizmo used for interactions on the y axis
  129079. */
  129080. yGizmo: AxisScaleGizmo;
  129081. /**
  129082. * Internal gizmo used for interactions on the z axis
  129083. */
  129084. zGizmo: AxisScaleGizmo;
  129085. /**
  129086. * Internal gizmo used to scale all axis equally
  129087. */
  129088. uniformScaleGizmo: AxisScaleGizmo;
  129089. private _meshAttached;
  129090. private _updateGizmoRotationToMatchAttachedMesh;
  129091. private _snapDistance;
  129092. private _scaleRatio;
  129093. private _uniformScalingMesh;
  129094. private _octahedron;
  129095. private _sensitivity;
  129096. /** Fires an event when any of it's sub gizmos are dragged */
  129097. onDragStartObservable: Observable<unknown>;
  129098. /** Fires an event when any of it's sub gizmos are released from dragging */
  129099. onDragEndObservable: Observable<unknown>;
  129100. get attachedMesh(): Nullable<AbstractMesh>;
  129101. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129102. /**
  129103. * Creates a ScaleGizmo
  129104. * @param gizmoLayer The utility layer the gizmo will be added to
  129105. */
  129106. constructor(gizmoLayer?: UtilityLayerRenderer);
  129107. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129108. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129109. /**
  129110. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129111. */
  129112. set snapDistance(value: number);
  129113. get snapDistance(): number;
  129114. /**
  129115. * Ratio for the scale of the gizmo (Default: 1)
  129116. */
  129117. set scaleRatio(value: number);
  129118. get scaleRatio(): number;
  129119. /**
  129120. * Sensitivity factor for dragging (Default: 1)
  129121. */
  129122. set sensitivity(value: number);
  129123. get sensitivity(): number;
  129124. /**
  129125. * Disposes of the gizmo
  129126. */
  129127. dispose(): void;
  129128. }
  129129. }
  129130. declare module BABYLON {
  129131. /**
  129132. * Single axis scale gizmo
  129133. */
  129134. export class AxisScaleGizmo extends Gizmo {
  129135. /**
  129136. * Drag behavior responsible for the gizmos dragging interactions
  129137. */
  129138. dragBehavior: PointerDragBehavior;
  129139. private _pointerObserver;
  129140. /**
  129141. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129142. */
  129143. snapDistance: number;
  129144. /**
  129145. * Event that fires each time the gizmo snaps to a new location.
  129146. * * snapDistance is the the change in distance
  129147. */
  129148. onSnapObservable: Observable<{
  129149. snapDistance: number;
  129150. }>;
  129151. /**
  129152. * If the scaling operation should be done on all axis (default: false)
  129153. */
  129154. uniformScaling: boolean;
  129155. /**
  129156. * Custom sensitivity value for the drag strength
  129157. */
  129158. sensitivity: number;
  129159. private _isEnabled;
  129160. private _parent;
  129161. private _arrow;
  129162. private _coloredMaterial;
  129163. private _hoverMaterial;
  129164. /**
  129165. * Creates an AxisScaleGizmo
  129166. * @param gizmoLayer The utility layer the gizmo will be added to
  129167. * @param dragAxis The axis which the gizmo will be able to scale on
  129168. * @param color The color of the gizmo
  129169. */
  129170. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  129171. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129172. /**
  129173. * If the gizmo is enabled
  129174. */
  129175. set isEnabled(value: boolean);
  129176. get isEnabled(): boolean;
  129177. /**
  129178. * Disposes of the gizmo
  129179. */
  129180. dispose(): void;
  129181. /**
  129182. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129183. * @param mesh The mesh to replace the default mesh of the gizmo
  129184. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  129185. */
  129186. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  129187. }
  129188. }
  129189. declare module BABYLON {
  129190. /**
  129191. * Bounding box gizmo
  129192. */
  129193. export class BoundingBoxGizmo extends Gizmo {
  129194. private _lineBoundingBox;
  129195. private _rotateSpheresParent;
  129196. private _scaleBoxesParent;
  129197. private _boundingDimensions;
  129198. private _renderObserver;
  129199. private _pointerObserver;
  129200. private _scaleDragSpeed;
  129201. private _tmpQuaternion;
  129202. private _tmpVector;
  129203. private _tmpRotationMatrix;
  129204. /**
  129205. * 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)
  129206. */
  129207. ignoreChildren: boolean;
  129208. /**
  129209. * 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)
  129210. */
  129211. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  129212. /**
  129213. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  129214. */
  129215. rotationSphereSize: number;
  129216. /**
  129217. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  129218. */
  129219. scaleBoxSize: number;
  129220. /**
  129221. * 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)
  129222. */
  129223. fixedDragMeshScreenSize: boolean;
  129224. /**
  129225. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  129226. */
  129227. fixedDragMeshScreenSizeDistanceFactor: number;
  129228. /**
  129229. * Fired when a rotation sphere or scale box is dragged
  129230. */
  129231. onDragStartObservable: Observable<{}>;
  129232. /**
  129233. * Fired when a scale box is dragged
  129234. */
  129235. onScaleBoxDragObservable: Observable<{}>;
  129236. /**
  129237. * Fired when a scale box drag is ended
  129238. */
  129239. onScaleBoxDragEndObservable: Observable<{}>;
  129240. /**
  129241. * Fired when a rotation sphere is dragged
  129242. */
  129243. onRotationSphereDragObservable: Observable<{}>;
  129244. /**
  129245. * Fired when a rotation sphere drag is ended
  129246. */
  129247. onRotationSphereDragEndObservable: Observable<{}>;
  129248. /**
  129249. * 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)
  129250. */
  129251. scalePivot: Nullable<Vector3>;
  129252. /**
  129253. * Mesh used as a pivot to rotate the attached mesh
  129254. */
  129255. private _anchorMesh;
  129256. private _existingMeshScale;
  129257. private _dragMesh;
  129258. private pointerDragBehavior;
  129259. private coloredMaterial;
  129260. private hoverColoredMaterial;
  129261. /**
  129262. * Sets the color of the bounding box gizmo
  129263. * @param color the color to set
  129264. */
  129265. setColor(color: Color3): void;
  129266. /**
  129267. * Creates an BoundingBoxGizmo
  129268. * @param gizmoLayer The utility layer the gizmo will be added to
  129269. * @param color The color of the gizmo
  129270. */
  129271. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  129272. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129273. private _selectNode;
  129274. /**
  129275. * Updates the bounding box information for the Gizmo
  129276. */
  129277. updateBoundingBox(): void;
  129278. private _updateRotationSpheres;
  129279. private _updateScaleBoxes;
  129280. /**
  129281. * Enables rotation on the specified axis and disables rotation on the others
  129282. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  129283. */
  129284. setEnabledRotationAxis(axis: string): void;
  129285. /**
  129286. * Enables/disables scaling
  129287. * @param enable if scaling should be enabled
  129288. * @param homogeneousScaling defines if scaling should only be homogeneous
  129289. */
  129290. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  129291. private _updateDummy;
  129292. /**
  129293. * Enables a pointer drag behavior on the bounding box of the gizmo
  129294. */
  129295. enableDragBehavior(): void;
  129296. /**
  129297. * Disposes of the gizmo
  129298. */
  129299. dispose(): void;
  129300. /**
  129301. * 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)
  129302. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  129303. * @returns the bounding box mesh with the passed in mesh as a child
  129304. */
  129305. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  129306. /**
  129307. * CustomMeshes are not supported by this gizmo
  129308. * @param mesh The mesh to replace the default mesh of the gizmo
  129309. */
  129310. setCustomMesh(mesh: Mesh): void;
  129311. }
  129312. }
  129313. declare module BABYLON {
  129314. /**
  129315. * Single plane rotation gizmo
  129316. */
  129317. export class PlaneRotationGizmo extends Gizmo {
  129318. /**
  129319. * Drag behavior responsible for the gizmos dragging interactions
  129320. */
  129321. dragBehavior: PointerDragBehavior;
  129322. private _pointerObserver;
  129323. /**
  129324. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  129325. */
  129326. snapDistance: number;
  129327. /**
  129328. * Event that fires each time the gizmo snaps to a new location.
  129329. * * snapDistance is the the change in distance
  129330. */
  129331. onSnapObservable: Observable<{
  129332. snapDistance: number;
  129333. }>;
  129334. private _isEnabled;
  129335. private _parent;
  129336. /**
  129337. * Creates a PlaneRotationGizmo
  129338. * @param gizmoLayer The utility layer the gizmo will be added to
  129339. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  129340. * @param color The color of the gizmo
  129341. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129342. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129343. */
  129344. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  129345. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129346. /**
  129347. * If the gizmo is enabled
  129348. */
  129349. set isEnabled(value: boolean);
  129350. get isEnabled(): boolean;
  129351. /**
  129352. * Disposes of the gizmo
  129353. */
  129354. dispose(): void;
  129355. }
  129356. }
  129357. declare module BABYLON {
  129358. /**
  129359. * Gizmo that enables rotating a mesh along 3 axis
  129360. */
  129361. export class RotationGizmo extends Gizmo {
  129362. /**
  129363. * Internal gizmo used for interactions on the x axis
  129364. */
  129365. xGizmo: PlaneRotationGizmo;
  129366. /**
  129367. * Internal gizmo used for interactions on the y axis
  129368. */
  129369. yGizmo: PlaneRotationGizmo;
  129370. /**
  129371. * Internal gizmo used for interactions on the z axis
  129372. */
  129373. zGizmo: PlaneRotationGizmo;
  129374. /** Fires an event when any of it's sub gizmos are dragged */
  129375. onDragStartObservable: Observable<unknown>;
  129376. /** Fires an event when any of it's sub gizmos are released from dragging */
  129377. onDragEndObservable: Observable<unknown>;
  129378. private _meshAttached;
  129379. get attachedMesh(): Nullable<AbstractMesh>;
  129380. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129381. /**
  129382. * Creates a RotationGizmo
  129383. * @param gizmoLayer The utility layer the gizmo will be added to
  129384. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129385. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129386. */
  129387. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  129388. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129389. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129390. /**
  129391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129392. */
  129393. set snapDistance(value: number);
  129394. get snapDistance(): number;
  129395. /**
  129396. * Ratio for the scale of the gizmo (Default: 1)
  129397. */
  129398. set scaleRatio(value: number);
  129399. get scaleRatio(): number;
  129400. /**
  129401. * Disposes of the gizmo
  129402. */
  129403. dispose(): void;
  129404. /**
  129405. * CustomMeshes are not supported by this gizmo
  129406. * @param mesh The mesh to replace the default mesh of the gizmo
  129407. */
  129408. setCustomMesh(mesh: Mesh): void;
  129409. }
  129410. }
  129411. declare module BABYLON {
  129412. /**
  129413. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  129414. */
  129415. export class GizmoManager implements IDisposable {
  129416. private scene;
  129417. /**
  129418. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  129419. */
  129420. gizmos: {
  129421. positionGizmo: Nullable<PositionGizmo>;
  129422. rotationGizmo: Nullable<RotationGizmo>;
  129423. scaleGizmo: Nullable<ScaleGizmo>;
  129424. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  129425. };
  129426. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  129427. clearGizmoOnEmptyPointerEvent: boolean;
  129428. /** Fires an event when the manager is attached to a mesh */
  129429. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  129430. private _gizmosEnabled;
  129431. private _pointerObserver;
  129432. private _attachedMesh;
  129433. private _boundingBoxColor;
  129434. private _defaultUtilityLayer;
  129435. private _defaultKeepDepthUtilityLayer;
  129436. /**
  129437. * When bounding box gizmo is enabled, this can be used to track drag/end events
  129438. */
  129439. boundingBoxDragBehavior: SixDofDragBehavior;
  129440. /**
  129441. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  129442. */
  129443. attachableMeshes: Nullable<Array<AbstractMesh>>;
  129444. /**
  129445. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  129446. */
  129447. usePointerToAttachGizmos: boolean;
  129448. /**
  129449. * Utility layer that the bounding box gizmo belongs to
  129450. */
  129451. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  129452. /**
  129453. * Utility layer that all gizmos besides bounding box belong to
  129454. */
  129455. get utilityLayer(): UtilityLayerRenderer;
  129456. /**
  129457. * Instatiates a gizmo manager
  129458. * @param scene the scene to overlay the gizmos on top of
  129459. */
  129460. constructor(scene: Scene);
  129461. /**
  129462. * Attaches a set of gizmos to the specified mesh
  129463. * @param mesh The mesh the gizmo's should be attached to
  129464. */
  129465. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129466. /**
  129467. * If the position gizmo is enabled
  129468. */
  129469. set positionGizmoEnabled(value: boolean);
  129470. get positionGizmoEnabled(): boolean;
  129471. /**
  129472. * If the rotation gizmo is enabled
  129473. */
  129474. set rotationGizmoEnabled(value: boolean);
  129475. get rotationGizmoEnabled(): boolean;
  129476. /**
  129477. * If the scale gizmo is enabled
  129478. */
  129479. set scaleGizmoEnabled(value: boolean);
  129480. get scaleGizmoEnabled(): boolean;
  129481. /**
  129482. * If the boundingBox gizmo is enabled
  129483. */
  129484. set boundingBoxGizmoEnabled(value: boolean);
  129485. get boundingBoxGizmoEnabled(): boolean;
  129486. /**
  129487. * Disposes of the gizmo manager
  129488. */
  129489. dispose(): void;
  129490. }
  129491. }
  129492. declare module BABYLON {
  129493. /**
  129494. * A directional light is defined by a direction (what a surprise!).
  129495. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  129496. * 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.
  129497. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129498. */
  129499. export class DirectionalLight extends ShadowLight {
  129500. private _shadowFrustumSize;
  129501. /**
  129502. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  129503. */
  129504. get shadowFrustumSize(): number;
  129505. /**
  129506. * Specifies a fix frustum size for the shadow generation.
  129507. */
  129508. set shadowFrustumSize(value: number);
  129509. private _shadowOrthoScale;
  129510. /**
  129511. * Gets the shadow projection scale against the optimal computed one.
  129512. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129513. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129514. */
  129515. get shadowOrthoScale(): number;
  129516. /**
  129517. * Sets the shadow projection scale against the optimal computed one.
  129518. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129519. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129520. */
  129521. set shadowOrthoScale(value: number);
  129522. /**
  129523. * Automatically compute the projection matrix to best fit (including all the casters)
  129524. * on each frame.
  129525. */
  129526. autoUpdateExtends: boolean;
  129527. /**
  129528. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  129529. * on each frame. autoUpdateExtends must be set to true for this to work
  129530. */
  129531. autoCalcShadowZBounds: boolean;
  129532. private _orthoLeft;
  129533. private _orthoRight;
  129534. private _orthoTop;
  129535. private _orthoBottom;
  129536. /**
  129537. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  129538. * The directional light is emitted from everywhere in the given direction.
  129539. * It can cast shadows.
  129540. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129541. * @param name The friendly name of the light
  129542. * @param direction The direction of the light
  129543. * @param scene The scene the light belongs to
  129544. */
  129545. constructor(name: string, direction: Vector3, scene: Scene);
  129546. /**
  129547. * Returns the string "DirectionalLight".
  129548. * @return The class name
  129549. */
  129550. getClassName(): string;
  129551. /**
  129552. * Returns the integer 1.
  129553. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129554. */
  129555. getTypeID(): number;
  129556. /**
  129557. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  129558. * Returns the DirectionalLight Shadow projection matrix.
  129559. */
  129560. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129561. /**
  129562. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  129563. * Returns the DirectionalLight Shadow projection matrix.
  129564. */
  129565. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  129566. /**
  129567. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  129568. * Returns the DirectionalLight Shadow projection matrix.
  129569. */
  129570. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129571. protected _buildUniformLayout(): void;
  129572. /**
  129573. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  129574. * @param effect The effect to update
  129575. * @param lightIndex The index of the light in the effect to update
  129576. * @returns The directional light
  129577. */
  129578. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  129579. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  129580. /**
  129581. * Gets the minZ used for shadow according to both the scene and the light.
  129582. *
  129583. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129584. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129585. * @param activeCamera The camera we are returning the min for
  129586. * @returns the depth min z
  129587. */
  129588. getDepthMinZ(activeCamera: Camera): number;
  129589. /**
  129590. * Gets the maxZ used for shadow according to both the scene and the light.
  129591. *
  129592. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129593. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129594. * @param activeCamera The camera we are returning the max for
  129595. * @returns the depth max z
  129596. */
  129597. getDepthMaxZ(activeCamera: Camera): number;
  129598. /**
  129599. * Prepares the list of defines specific to the light type.
  129600. * @param defines the list of defines
  129601. * @param lightIndex defines the index of the light for the effect
  129602. */
  129603. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129604. }
  129605. }
  129606. declare module BABYLON {
  129607. /**
  129608. * Class containing static functions to help procedurally build meshes
  129609. */
  129610. export class HemisphereBuilder {
  129611. /**
  129612. * Creates a hemisphere mesh
  129613. * @param name defines the name of the mesh
  129614. * @param options defines the options used to create the mesh
  129615. * @param scene defines the hosting scene
  129616. * @returns the hemisphere mesh
  129617. */
  129618. static CreateHemisphere(name: string, options: {
  129619. segments?: number;
  129620. diameter?: number;
  129621. sideOrientation?: number;
  129622. }, scene: any): Mesh;
  129623. }
  129624. }
  129625. declare module BABYLON {
  129626. /**
  129627. * A spot light is defined by a position, a direction, an angle, and an exponent.
  129628. * These values define a cone of light starting from the position, emitting toward the direction.
  129629. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  129630. * and the exponent defines the speed of the decay of the light with distance (reach).
  129631. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129632. */
  129633. export class SpotLight extends ShadowLight {
  129634. private _angle;
  129635. private _innerAngle;
  129636. private _cosHalfAngle;
  129637. private _lightAngleScale;
  129638. private _lightAngleOffset;
  129639. /**
  129640. * Gets the cone angle of the spot light in Radians.
  129641. */
  129642. get angle(): number;
  129643. /**
  129644. * Sets the cone angle of the spot light in Radians.
  129645. */
  129646. set angle(value: number);
  129647. /**
  129648. * Only used in gltf falloff mode, this defines the angle where
  129649. * the directional falloff will start before cutting at angle which could be seen
  129650. * as outer angle.
  129651. */
  129652. get innerAngle(): number;
  129653. /**
  129654. * Only used in gltf falloff mode, this defines the angle where
  129655. * the directional falloff will start before cutting at angle which could be seen
  129656. * as outer angle.
  129657. */
  129658. set innerAngle(value: number);
  129659. private _shadowAngleScale;
  129660. /**
  129661. * Allows scaling the angle of the light for shadow generation only.
  129662. */
  129663. get shadowAngleScale(): number;
  129664. /**
  129665. * Allows scaling the angle of the light for shadow generation only.
  129666. */
  129667. set shadowAngleScale(value: number);
  129668. /**
  129669. * The light decay speed with the distance from the emission spot.
  129670. */
  129671. exponent: number;
  129672. private _projectionTextureMatrix;
  129673. /**
  129674. * Allows reading the projecton texture
  129675. */
  129676. get projectionTextureMatrix(): Matrix;
  129677. protected _projectionTextureLightNear: number;
  129678. /**
  129679. * Gets the near clip of the Spotlight for texture projection.
  129680. */
  129681. get projectionTextureLightNear(): number;
  129682. /**
  129683. * Sets the near clip of the Spotlight for texture projection.
  129684. */
  129685. set projectionTextureLightNear(value: number);
  129686. protected _projectionTextureLightFar: number;
  129687. /**
  129688. * Gets the far clip of the Spotlight for texture projection.
  129689. */
  129690. get projectionTextureLightFar(): number;
  129691. /**
  129692. * Sets the far clip of the Spotlight for texture projection.
  129693. */
  129694. set projectionTextureLightFar(value: number);
  129695. protected _projectionTextureUpDirection: Vector3;
  129696. /**
  129697. * Gets the Up vector of the Spotlight for texture projection.
  129698. */
  129699. get projectionTextureUpDirection(): Vector3;
  129700. /**
  129701. * Sets the Up vector of the Spotlight for texture projection.
  129702. */
  129703. set projectionTextureUpDirection(value: Vector3);
  129704. private _projectionTexture;
  129705. /**
  129706. * Gets the projection texture of the light.
  129707. */
  129708. get projectionTexture(): Nullable<BaseTexture>;
  129709. /**
  129710. * Sets the projection texture of the light.
  129711. */
  129712. set projectionTexture(value: Nullable<BaseTexture>);
  129713. private _projectionTextureViewLightDirty;
  129714. private _projectionTextureProjectionLightDirty;
  129715. private _projectionTextureDirty;
  129716. private _projectionTextureViewTargetVector;
  129717. private _projectionTextureViewLightMatrix;
  129718. private _projectionTextureProjectionLightMatrix;
  129719. private _projectionTextureScalingMatrix;
  129720. /**
  129721. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  129722. * It can cast shadows.
  129723. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129724. * @param name The light friendly name
  129725. * @param position The position of the spot light in the scene
  129726. * @param direction The direction of the light in the scene
  129727. * @param angle The cone angle of the light in Radians
  129728. * @param exponent The light decay speed with the distance from the emission spot
  129729. * @param scene The scene the lights belongs to
  129730. */
  129731. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  129732. /**
  129733. * Returns the string "SpotLight".
  129734. * @returns the class name
  129735. */
  129736. getClassName(): string;
  129737. /**
  129738. * Returns the integer 2.
  129739. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129740. */
  129741. getTypeID(): number;
  129742. /**
  129743. * Overrides the direction setter to recompute the projection texture view light Matrix.
  129744. */
  129745. protected _setDirection(value: Vector3): void;
  129746. /**
  129747. * Overrides the position setter to recompute the projection texture view light Matrix.
  129748. */
  129749. protected _setPosition(value: Vector3): void;
  129750. /**
  129751. * 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.
  129752. * Returns the SpotLight.
  129753. */
  129754. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129755. protected _computeProjectionTextureViewLightMatrix(): void;
  129756. protected _computeProjectionTextureProjectionLightMatrix(): void;
  129757. /**
  129758. * Main function for light texture projection matrix computing.
  129759. */
  129760. protected _computeProjectionTextureMatrix(): void;
  129761. protected _buildUniformLayout(): void;
  129762. private _computeAngleValues;
  129763. /**
  129764. * Sets the passed Effect "effect" with the Light textures.
  129765. * @param effect The effect to update
  129766. * @param lightIndex The index of the light in the effect to update
  129767. * @returns The light
  129768. */
  129769. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  129770. /**
  129771. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  129772. * @param effect The effect to update
  129773. * @param lightIndex The index of the light in the effect to update
  129774. * @returns The spot light
  129775. */
  129776. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  129777. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129778. /**
  129779. * Disposes the light and the associated resources.
  129780. */
  129781. dispose(): void;
  129782. /**
  129783. * Prepares the list of defines specific to the light type.
  129784. * @param defines the list of defines
  129785. * @param lightIndex defines the index of the light for the effect
  129786. */
  129787. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129788. }
  129789. }
  129790. declare module BABYLON {
  129791. /**
  129792. * Gizmo that enables viewing a light
  129793. */
  129794. export class LightGizmo extends Gizmo {
  129795. private _lightMesh;
  129796. private _material;
  129797. private _cachedPosition;
  129798. private _cachedForward;
  129799. private _attachedMeshParent;
  129800. /**
  129801. * Creates a LightGizmo
  129802. * @param gizmoLayer The utility layer the gizmo will be added to
  129803. */
  129804. constructor(gizmoLayer?: UtilityLayerRenderer);
  129805. private _light;
  129806. /**
  129807. * The light that the gizmo is attached to
  129808. */
  129809. set light(light: Nullable<Light>);
  129810. get light(): Nullable<Light>;
  129811. /**
  129812. * Gets the material used to render the light gizmo
  129813. */
  129814. get material(): StandardMaterial;
  129815. /**
  129816. * @hidden
  129817. * Updates the gizmo to match the attached mesh's position/rotation
  129818. */
  129819. protected _update(): void;
  129820. private static _Scale;
  129821. /**
  129822. * Creates the lines for a light mesh
  129823. */
  129824. private static _CreateLightLines;
  129825. /**
  129826. * Disposes of the light gizmo
  129827. */
  129828. dispose(): void;
  129829. private static _CreateHemisphericLightMesh;
  129830. private static _CreatePointLightMesh;
  129831. private static _CreateSpotLightMesh;
  129832. private static _CreateDirectionalLightMesh;
  129833. }
  129834. }
  129835. declare module BABYLON {
  129836. /** @hidden */
  129837. export var backgroundFragmentDeclaration: {
  129838. name: string;
  129839. shader: string;
  129840. };
  129841. }
  129842. declare module BABYLON {
  129843. /** @hidden */
  129844. export var backgroundUboDeclaration: {
  129845. name: string;
  129846. shader: string;
  129847. };
  129848. }
  129849. declare module BABYLON {
  129850. /** @hidden */
  129851. export var backgroundPixelShader: {
  129852. name: string;
  129853. shader: string;
  129854. };
  129855. }
  129856. declare module BABYLON {
  129857. /** @hidden */
  129858. export var backgroundVertexDeclaration: {
  129859. name: string;
  129860. shader: string;
  129861. };
  129862. }
  129863. declare module BABYLON {
  129864. /** @hidden */
  129865. export var backgroundVertexShader: {
  129866. name: string;
  129867. shader: string;
  129868. };
  129869. }
  129870. declare module BABYLON {
  129871. /**
  129872. * Background material used to create an efficient environement around your scene.
  129873. */
  129874. export class BackgroundMaterial extends PushMaterial {
  129875. /**
  129876. * Standard reflectance value at parallel view angle.
  129877. */
  129878. static StandardReflectance0: number;
  129879. /**
  129880. * Standard reflectance value at grazing angle.
  129881. */
  129882. static StandardReflectance90: number;
  129883. protected _primaryColor: Color3;
  129884. /**
  129885. * Key light Color (multiply against the environement texture)
  129886. */
  129887. primaryColor: Color3;
  129888. protected __perceptualColor: Nullable<Color3>;
  129889. /**
  129890. * Experimental Internal Use Only.
  129891. *
  129892. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  129893. * This acts as a helper to set the primary color to a more "human friendly" value.
  129894. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  129895. * output color as close as possible from the chosen value.
  129896. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  129897. * part of lighting setup.)
  129898. */
  129899. get _perceptualColor(): Nullable<Color3>;
  129900. set _perceptualColor(value: Nullable<Color3>);
  129901. protected _primaryColorShadowLevel: float;
  129902. /**
  129903. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  129904. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  129905. */
  129906. get primaryColorShadowLevel(): float;
  129907. set primaryColorShadowLevel(value: float);
  129908. protected _primaryColorHighlightLevel: float;
  129909. /**
  129910. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  129911. * The primary color is used at the level chosen to define what the white area would look.
  129912. */
  129913. get primaryColorHighlightLevel(): float;
  129914. set primaryColorHighlightLevel(value: float);
  129915. protected _reflectionTexture: Nullable<BaseTexture>;
  129916. /**
  129917. * Reflection Texture used in the material.
  129918. * Should be author in a specific way for the best result (refer to the documentation).
  129919. */
  129920. reflectionTexture: Nullable<BaseTexture>;
  129921. protected _reflectionBlur: float;
  129922. /**
  129923. * Reflection Texture level of blur.
  129924. *
  129925. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  129926. * texture twice.
  129927. */
  129928. reflectionBlur: float;
  129929. protected _diffuseTexture: Nullable<BaseTexture>;
  129930. /**
  129931. * Diffuse Texture used in the material.
  129932. * Should be author in a specific way for the best result (refer to the documentation).
  129933. */
  129934. diffuseTexture: Nullable<BaseTexture>;
  129935. protected _shadowLights: Nullable<IShadowLight[]>;
  129936. /**
  129937. * Specify the list of lights casting shadow on the material.
  129938. * All scene shadow lights will be included if null.
  129939. */
  129940. shadowLights: Nullable<IShadowLight[]>;
  129941. protected _shadowLevel: float;
  129942. /**
  129943. * Helps adjusting the shadow to a softer level if required.
  129944. * 0 means black shadows and 1 means no shadows.
  129945. */
  129946. shadowLevel: float;
  129947. protected _sceneCenter: Vector3;
  129948. /**
  129949. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  129950. * It is usually zero but might be interesting to modify according to your setup.
  129951. */
  129952. sceneCenter: Vector3;
  129953. protected _opacityFresnel: boolean;
  129954. /**
  129955. * This helps specifying that the material is falling off to the sky box at grazing angle.
  129956. * This helps ensuring a nice transition when the camera goes under the ground.
  129957. */
  129958. opacityFresnel: boolean;
  129959. protected _reflectionFresnel: boolean;
  129960. /**
  129961. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  129962. * This helps adding a mirror texture on the ground.
  129963. */
  129964. reflectionFresnel: boolean;
  129965. protected _reflectionFalloffDistance: number;
  129966. /**
  129967. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  129968. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  129969. */
  129970. reflectionFalloffDistance: number;
  129971. protected _reflectionAmount: number;
  129972. /**
  129973. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  129974. */
  129975. reflectionAmount: number;
  129976. protected _reflectionReflectance0: number;
  129977. /**
  129978. * This specifies the weight of the reflection at grazing angle.
  129979. */
  129980. reflectionReflectance0: number;
  129981. protected _reflectionReflectance90: number;
  129982. /**
  129983. * This specifies the weight of the reflection at a perpendicular point of view.
  129984. */
  129985. reflectionReflectance90: number;
  129986. /**
  129987. * Sets the reflection reflectance fresnel values according to the default standard
  129988. * empirically know to work well :-)
  129989. */
  129990. set reflectionStandardFresnelWeight(value: number);
  129991. protected _useRGBColor: boolean;
  129992. /**
  129993. * Helps to directly use the maps channels instead of their level.
  129994. */
  129995. useRGBColor: boolean;
  129996. protected _enableNoise: boolean;
  129997. /**
  129998. * This helps reducing the banding effect that could occur on the background.
  129999. */
  130000. enableNoise: boolean;
  130001. /**
  130002. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130003. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  130004. * Recommended to be keep at 1.0 except for special cases.
  130005. */
  130006. get fovMultiplier(): number;
  130007. set fovMultiplier(value: number);
  130008. private _fovMultiplier;
  130009. /**
  130010. * Enable the FOV adjustment feature controlled by fovMultiplier.
  130011. */
  130012. useEquirectangularFOV: boolean;
  130013. private _maxSimultaneousLights;
  130014. /**
  130015. * Number of Simultaneous lights allowed on the material.
  130016. */
  130017. maxSimultaneousLights: int;
  130018. /**
  130019. * Default configuration related to image processing available in the Background Material.
  130020. */
  130021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130022. /**
  130023. * Keep track of the image processing observer to allow dispose and replace.
  130024. */
  130025. private _imageProcessingObserver;
  130026. /**
  130027. * Attaches a new image processing configuration to the PBR Material.
  130028. * @param configuration (if null the scene configuration will be use)
  130029. */
  130030. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130031. /**
  130032. * Gets the image processing configuration used either in this material.
  130033. */
  130034. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130035. /**
  130036. * Sets the Default image processing configuration used either in the this material.
  130037. *
  130038. * If sets to null, the scene one is in use.
  130039. */
  130040. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130041. /**
  130042. * Gets wether the color curves effect is enabled.
  130043. */
  130044. get cameraColorCurvesEnabled(): boolean;
  130045. /**
  130046. * Sets wether the color curves effect is enabled.
  130047. */
  130048. set cameraColorCurvesEnabled(value: boolean);
  130049. /**
  130050. * Gets wether the color grading effect is enabled.
  130051. */
  130052. get cameraColorGradingEnabled(): boolean;
  130053. /**
  130054. * Gets wether the color grading effect is enabled.
  130055. */
  130056. set cameraColorGradingEnabled(value: boolean);
  130057. /**
  130058. * Gets wether tonemapping is enabled or not.
  130059. */
  130060. get cameraToneMappingEnabled(): boolean;
  130061. /**
  130062. * Sets wether tonemapping is enabled or not
  130063. */
  130064. set cameraToneMappingEnabled(value: boolean);
  130065. /**
  130066. * The camera exposure used on this material.
  130067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130068. * This corresponds to a photographic exposure.
  130069. */
  130070. get cameraExposure(): float;
  130071. /**
  130072. * The camera exposure used on this material.
  130073. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130074. * This corresponds to a photographic exposure.
  130075. */
  130076. set cameraExposure(value: float);
  130077. /**
  130078. * Gets The camera contrast used on this material.
  130079. */
  130080. get cameraContrast(): float;
  130081. /**
  130082. * Sets The camera contrast used on this material.
  130083. */
  130084. set cameraContrast(value: float);
  130085. /**
  130086. * Gets the Color Grading 2D Lookup Texture.
  130087. */
  130088. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  130089. /**
  130090. * Sets the Color Grading 2D Lookup Texture.
  130091. */
  130092. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  130093. /**
  130094. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130095. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130096. * 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;
  130097. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130098. */
  130099. get cameraColorCurves(): Nullable<ColorCurves>;
  130100. /**
  130101. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130102. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130103. * 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;
  130104. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130105. */
  130106. set cameraColorCurves(value: Nullable<ColorCurves>);
  130107. /**
  130108. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  130109. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  130110. */
  130111. switchToBGR: boolean;
  130112. private _renderTargets;
  130113. private _reflectionControls;
  130114. private _white;
  130115. private _primaryShadowColor;
  130116. private _primaryHighlightColor;
  130117. /**
  130118. * Instantiates a Background Material in the given scene
  130119. * @param name The friendly name of the material
  130120. * @param scene The scene to add the material to
  130121. */
  130122. constructor(name: string, scene: Scene);
  130123. /**
  130124. * Gets a boolean indicating that current material needs to register RTT
  130125. */
  130126. get hasRenderTargetTextures(): boolean;
  130127. /**
  130128. * The entire material has been created in order to prevent overdraw.
  130129. * @returns false
  130130. */
  130131. needAlphaTesting(): boolean;
  130132. /**
  130133. * The entire material has been created in order to prevent overdraw.
  130134. * @returns true if blending is enable
  130135. */
  130136. needAlphaBlending(): boolean;
  130137. /**
  130138. * Checks wether the material is ready to be rendered for a given mesh.
  130139. * @param mesh The mesh to render
  130140. * @param subMesh The submesh to check against
  130141. * @param useInstances Specify wether or not the material is used with instances
  130142. * @returns true if all the dependencies are ready (Textures, Effects...)
  130143. */
  130144. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130145. /**
  130146. * Compute the primary color according to the chosen perceptual color.
  130147. */
  130148. private _computePrimaryColorFromPerceptualColor;
  130149. /**
  130150. * Compute the highlights and shadow colors according to their chosen levels.
  130151. */
  130152. private _computePrimaryColors;
  130153. /**
  130154. * Build the uniform buffer used in the material.
  130155. */
  130156. buildUniformLayout(): void;
  130157. /**
  130158. * Unbind the material.
  130159. */
  130160. unbind(): void;
  130161. /**
  130162. * Bind only the world matrix to the material.
  130163. * @param world The world matrix to bind.
  130164. */
  130165. bindOnlyWorldMatrix(world: Matrix): void;
  130166. /**
  130167. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  130168. * @param world The world matrix to bind.
  130169. * @param subMesh The submesh to bind for.
  130170. */
  130171. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130172. /**
  130173. * Checks to see if a texture is used in the material.
  130174. * @param texture - Base texture to use.
  130175. * @returns - Boolean specifying if a texture is used in the material.
  130176. */
  130177. hasTexture(texture: BaseTexture): boolean;
  130178. /**
  130179. * Dispose the material.
  130180. * @param forceDisposeEffect Force disposal of the associated effect.
  130181. * @param forceDisposeTextures Force disposal of the associated textures.
  130182. */
  130183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  130184. /**
  130185. * Clones the material.
  130186. * @param name The cloned name.
  130187. * @returns The cloned material.
  130188. */
  130189. clone(name: string): BackgroundMaterial;
  130190. /**
  130191. * Serializes the current material to its JSON representation.
  130192. * @returns The JSON representation.
  130193. */
  130194. serialize(): any;
  130195. /**
  130196. * Gets the class name of the material
  130197. * @returns "BackgroundMaterial"
  130198. */
  130199. getClassName(): string;
  130200. /**
  130201. * Parse a JSON input to create back a background material.
  130202. * @param source The JSON data to parse
  130203. * @param scene The scene to create the parsed material in
  130204. * @param rootUrl The root url of the assets the material depends upon
  130205. * @returns the instantiated BackgroundMaterial.
  130206. */
  130207. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  130208. }
  130209. }
  130210. declare module BABYLON {
  130211. /**
  130212. * Represents the different options available during the creation of
  130213. * a Environment helper.
  130214. *
  130215. * This can control the default ground, skybox and image processing setup of your scene.
  130216. */
  130217. export interface IEnvironmentHelperOptions {
  130218. /**
  130219. * Specifies whether or not to create a ground.
  130220. * True by default.
  130221. */
  130222. createGround: boolean;
  130223. /**
  130224. * Specifies the ground size.
  130225. * 15 by default.
  130226. */
  130227. groundSize: number;
  130228. /**
  130229. * The texture used on the ground for the main color.
  130230. * Comes from the BabylonJS CDN by default.
  130231. *
  130232. * Remarks: Can be either a texture or a url.
  130233. */
  130234. groundTexture: string | BaseTexture;
  130235. /**
  130236. * The color mixed in the ground texture by default.
  130237. * BabylonJS clearColor by default.
  130238. */
  130239. groundColor: Color3;
  130240. /**
  130241. * Specifies the ground opacity.
  130242. * 1 by default.
  130243. */
  130244. groundOpacity: number;
  130245. /**
  130246. * Enables the ground to receive shadows.
  130247. * True by default.
  130248. */
  130249. enableGroundShadow: boolean;
  130250. /**
  130251. * Helps preventing the shadow to be fully black on the ground.
  130252. * 0.5 by default.
  130253. */
  130254. groundShadowLevel: number;
  130255. /**
  130256. * Creates a mirror texture attach to the ground.
  130257. * false by default.
  130258. */
  130259. enableGroundMirror: boolean;
  130260. /**
  130261. * Specifies the ground mirror size ratio.
  130262. * 0.3 by default as the default kernel is 64.
  130263. */
  130264. groundMirrorSizeRatio: number;
  130265. /**
  130266. * Specifies the ground mirror blur kernel size.
  130267. * 64 by default.
  130268. */
  130269. groundMirrorBlurKernel: number;
  130270. /**
  130271. * Specifies the ground mirror visibility amount.
  130272. * 1 by default
  130273. */
  130274. groundMirrorAmount: number;
  130275. /**
  130276. * Specifies the ground mirror reflectance weight.
  130277. * This uses the standard weight of the background material to setup the fresnel effect
  130278. * of the mirror.
  130279. * 1 by default.
  130280. */
  130281. groundMirrorFresnelWeight: number;
  130282. /**
  130283. * Specifies the ground mirror Falloff distance.
  130284. * This can helps reducing the size of the reflection.
  130285. * 0 by Default.
  130286. */
  130287. groundMirrorFallOffDistance: number;
  130288. /**
  130289. * Specifies the ground mirror texture type.
  130290. * Unsigned Int by Default.
  130291. */
  130292. groundMirrorTextureType: number;
  130293. /**
  130294. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  130295. * the shown objects.
  130296. */
  130297. groundYBias: number;
  130298. /**
  130299. * Specifies whether or not to create a skybox.
  130300. * True by default.
  130301. */
  130302. createSkybox: boolean;
  130303. /**
  130304. * Specifies the skybox size.
  130305. * 20 by default.
  130306. */
  130307. skyboxSize: number;
  130308. /**
  130309. * The texture used on the skybox for the main color.
  130310. * Comes from the BabylonJS CDN by default.
  130311. *
  130312. * Remarks: Can be either a texture or a url.
  130313. */
  130314. skyboxTexture: string | BaseTexture;
  130315. /**
  130316. * The color mixed in the skybox texture by default.
  130317. * BabylonJS clearColor by default.
  130318. */
  130319. skyboxColor: Color3;
  130320. /**
  130321. * The background rotation around the Y axis of the scene.
  130322. * This helps aligning the key lights of your scene with the background.
  130323. * 0 by default.
  130324. */
  130325. backgroundYRotation: number;
  130326. /**
  130327. * Compute automatically the size of the elements to best fit with the scene.
  130328. */
  130329. sizeAuto: boolean;
  130330. /**
  130331. * Default position of the rootMesh if autoSize is not true.
  130332. */
  130333. rootPosition: Vector3;
  130334. /**
  130335. * Sets up the image processing in the scene.
  130336. * true by default.
  130337. */
  130338. setupImageProcessing: boolean;
  130339. /**
  130340. * The texture used as your environment texture in the scene.
  130341. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  130342. *
  130343. * Remarks: Can be either a texture or a url.
  130344. */
  130345. environmentTexture: string | BaseTexture;
  130346. /**
  130347. * The value of the exposure to apply to the scene.
  130348. * 0.6 by default if setupImageProcessing is true.
  130349. */
  130350. cameraExposure: number;
  130351. /**
  130352. * The value of the contrast to apply to the scene.
  130353. * 1.6 by default if setupImageProcessing is true.
  130354. */
  130355. cameraContrast: number;
  130356. /**
  130357. * Specifies whether or not tonemapping should be enabled in the scene.
  130358. * true by default if setupImageProcessing is true.
  130359. */
  130360. toneMappingEnabled: boolean;
  130361. }
  130362. /**
  130363. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  130364. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  130365. * It also helps with the default setup of your imageProcessing configuration.
  130366. */
  130367. export class EnvironmentHelper {
  130368. /**
  130369. * Default ground texture URL.
  130370. */
  130371. private static _groundTextureCDNUrl;
  130372. /**
  130373. * Default skybox texture URL.
  130374. */
  130375. private static _skyboxTextureCDNUrl;
  130376. /**
  130377. * Default environment texture URL.
  130378. */
  130379. private static _environmentTextureCDNUrl;
  130380. /**
  130381. * Creates the default options for the helper.
  130382. */
  130383. private static _getDefaultOptions;
  130384. private _rootMesh;
  130385. /**
  130386. * Gets the root mesh created by the helper.
  130387. */
  130388. get rootMesh(): Mesh;
  130389. private _skybox;
  130390. /**
  130391. * Gets the skybox created by the helper.
  130392. */
  130393. get skybox(): Nullable<Mesh>;
  130394. private _skyboxTexture;
  130395. /**
  130396. * Gets the skybox texture created by the helper.
  130397. */
  130398. get skyboxTexture(): Nullable<BaseTexture>;
  130399. private _skyboxMaterial;
  130400. /**
  130401. * Gets the skybox material created by the helper.
  130402. */
  130403. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  130404. private _ground;
  130405. /**
  130406. * Gets the ground mesh created by the helper.
  130407. */
  130408. get ground(): Nullable<Mesh>;
  130409. private _groundTexture;
  130410. /**
  130411. * Gets the ground texture created by the helper.
  130412. */
  130413. get groundTexture(): Nullable<BaseTexture>;
  130414. private _groundMirror;
  130415. /**
  130416. * Gets the ground mirror created by the helper.
  130417. */
  130418. get groundMirror(): Nullable<MirrorTexture>;
  130419. /**
  130420. * Gets the ground mirror render list to helps pushing the meshes
  130421. * you wish in the ground reflection.
  130422. */
  130423. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  130424. private _groundMaterial;
  130425. /**
  130426. * Gets the ground material created by the helper.
  130427. */
  130428. get groundMaterial(): Nullable<BackgroundMaterial>;
  130429. /**
  130430. * Stores the creation options.
  130431. */
  130432. private readonly _scene;
  130433. private _options;
  130434. /**
  130435. * This observable will be notified with any error during the creation of the environment,
  130436. * mainly texture creation errors.
  130437. */
  130438. onErrorObservable: Observable<{
  130439. message?: string;
  130440. exception?: any;
  130441. }>;
  130442. /**
  130443. * constructor
  130444. * @param options Defines the options we want to customize the helper
  130445. * @param scene The scene to add the material to
  130446. */
  130447. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  130448. /**
  130449. * Updates the background according to the new options
  130450. * @param options
  130451. */
  130452. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  130453. /**
  130454. * Sets the primary color of all the available elements.
  130455. * @param color the main color to affect to the ground and the background
  130456. */
  130457. setMainColor(color: Color3): void;
  130458. /**
  130459. * Setup the image processing according to the specified options.
  130460. */
  130461. private _setupImageProcessing;
  130462. /**
  130463. * Setup the environment texture according to the specified options.
  130464. */
  130465. private _setupEnvironmentTexture;
  130466. /**
  130467. * Setup the background according to the specified options.
  130468. */
  130469. private _setupBackground;
  130470. /**
  130471. * Get the scene sizes according to the setup.
  130472. */
  130473. private _getSceneSize;
  130474. /**
  130475. * Setup the ground according to the specified options.
  130476. */
  130477. private _setupGround;
  130478. /**
  130479. * Setup the ground material according to the specified options.
  130480. */
  130481. private _setupGroundMaterial;
  130482. /**
  130483. * Setup the ground diffuse texture according to the specified options.
  130484. */
  130485. private _setupGroundDiffuseTexture;
  130486. /**
  130487. * Setup the ground mirror texture according to the specified options.
  130488. */
  130489. private _setupGroundMirrorTexture;
  130490. /**
  130491. * Setup the ground to receive the mirror texture.
  130492. */
  130493. private _setupMirrorInGroundMaterial;
  130494. /**
  130495. * Setup the skybox according to the specified options.
  130496. */
  130497. private _setupSkybox;
  130498. /**
  130499. * Setup the skybox material according to the specified options.
  130500. */
  130501. private _setupSkyboxMaterial;
  130502. /**
  130503. * Setup the skybox reflection texture according to the specified options.
  130504. */
  130505. private _setupSkyboxReflectionTexture;
  130506. private _errorHandler;
  130507. /**
  130508. * Dispose all the elements created by the Helper.
  130509. */
  130510. dispose(): void;
  130511. }
  130512. }
  130513. declare module BABYLON {
  130514. /**
  130515. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  130516. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  130517. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  130518. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  130519. */
  130520. export class PhotoDome extends TransformNode {
  130521. /**
  130522. * Define the image as a Monoscopic panoramic 360 image.
  130523. */
  130524. static readonly MODE_MONOSCOPIC: number;
  130525. /**
  130526. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130527. */
  130528. static readonly MODE_TOPBOTTOM: number;
  130529. /**
  130530. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130531. */
  130532. static readonly MODE_SIDEBYSIDE: number;
  130533. private _useDirectMapping;
  130534. /**
  130535. * The texture being displayed on the sphere
  130536. */
  130537. protected _photoTexture: Texture;
  130538. /**
  130539. * Gets or sets the texture being displayed on the sphere
  130540. */
  130541. get photoTexture(): Texture;
  130542. set photoTexture(value: Texture);
  130543. /**
  130544. * Observable raised when an error occured while loading the 360 image
  130545. */
  130546. onLoadErrorObservable: Observable<string>;
  130547. /**
  130548. * The skybox material
  130549. */
  130550. protected _material: BackgroundMaterial;
  130551. /**
  130552. * The surface used for the skybox
  130553. */
  130554. protected _mesh: Mesh;
  130555. /**
  130556. * Gets the mesh used for the skybox.
  130557. */
  130558. get mesh(): Mesh;
  130559. /**
  130560. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130561. * Also see the options.resolution property.
  130562. */
  130563. get fovMultiplier(): number;
  130564. set fovMultiplier(value: number);
  130565. private _imageMode;
  130566. /**
  130567. * Gets or set the current video mode for the video. It can be:
  130568. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  130569. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130570. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130571. */
  130572. get imageMode(): number;
  130573. set imageMode(value: number);
  130574. /**
  130575. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  130576. * @param name Element's name, child elements will append suffixes for their own names.
  130577. * @param urlsOfPhoto defines the url of the photo to display
  130578. * @param options defines an object containing optional or exposed sub element properties
  130579. * @param onError defines a callback called when an error occured while loading the texture
  130580. */
  130581. constructor(name: string, urlOfPhoto: string, options: {
  130582. resolution?: number;
  130583. size?: number;
  130584. useDirectMapping?: boolean;
  130585. faceForward?: boolean;
  130586. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  130587. private _onBeforeCameraRenderObserver;
  130588. private _changeImageMode;
  130589. /**
  130590. * Releases resources associated with this node.
  130591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  130592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  130593. */
  130594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  130595. }
  130596. }
  130597. declare module BABYLON {
  130598. /**
  130599. * Class used to host RGBD texture specific utilities
  130600. */
  130601. export class RGBDTextureTools {
  130602. /**
  130603. * Expand the RGBD Texture from RGBD to Half Float if possible.
  130604. * @param texture the texture to expand.
  130605. */
  130606. static ExpandRGBDTexture(texture: Texture): void;
  130607. }
  130608. }
  130609. declare module BABYLON {
  130610. /**
  130611. * Class used to host texture specific utilities
  130612. */
  130613. export class BRDFTextureTools {
  130614. /**
  130615. * Prevents texture cache collision
  130616. */
  130617. private static _instanceNumber;
  130618. /**
  130619. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  130620. * @param scene defines the hosting scene
  130621. * @returns the environment BRDF texture
  130622. */
  130623. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  130624. private static _environmentBRDFBase64Texture;
  130625. }
  130626. }
  130627. declare module BABYLON {
  130628. /**
  130629. * @hidden
  130630. */
  130631. export interface IMaterialClearCoatDefines {
  130632. CLEARCOAT: boolean;
  130633. CLEARCOAT_DEFAULTIOR: boolean;
  130634. CLEARCOAT_TEXTURE: boolean;
  130635. CLEARCOAT_TEXTUREDIRECTUV: number;
  130636. CLEARCOAT_BUMP: boolean;
  130637. CLEARCOAT_BUMPDIRECTUV: number;
  130638. CLEARCOAT_TINT: boolean;
  130639. CLEARCOAT_TINT_TEXTURE: boolean;
  130640. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  130641. /** @hidden */
  130642. _areTexturesDirty: boolean;
  130643. }
  130644. /**
  130645. * Define the code related to the clear coat parameters of the pbr material.
  130646. */
  130647. export class PBRClearCoatConfiguration {
  130648. /**
  130649. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130650. * The default fits with a polyurethane material.
  130651. */
  130652. private static readonly _DefaultIndexOfRefraction;
  130653. private _isEnabled;
  130654. /**
  130655. * Defines if the clear coat is enabled in the material.
  130656. */
  130657. isEnabled: boolean;
  130658. /**
  130659. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  130660. */
  130661. intensity: number;
  130662. /**
  130663. * Defines the clear coat layer roughness.
  130664. */
  130665. roughness: number;
  130666. private _indexOfRefraction;
  130667. /**
  130668. * Defines the index of refraction of the clear coat.
  130669. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130670. * The default fits with a polyurethane material.
  130671. * Changing the default value is more performance intensive.
  130672. */
  130673. indexOfRefraction: number;
  130674. private _texture;
  130675. /**
  130676. * Stores the clear coat values in a texture.
  130677. */
  130678. texture: Nullable<BaseTexture>;
  130679. private _bumpTexture;
  130680. /**
  130681. * Define the clear coat specific bump texture.
  130682. */
  130683. bumpTexture: Nullable<BaseTexture>;
  130684. private _isTintEnabled;
  130685. /**
  130686. * Defines if the clear coat tint is enabled in the material.
  130687. */
  130688. isTintEnabled: boolean;
  130689. /**
  130690. * Defines the clear coat tint of the material.
  130691. * This is only use if tint is enabled
  130692. */
  130693. tintColor: Color3;
  130694. /**
  130695. * Defines the distance at which the tint color should be found in the
  130696. * clear coat media.
  130697. * This is only use if tint is enabled
  130698. */
  130699. tintColorAtDistance: number;
  130700. /**
  130701. * Defines the clear coat layer thickness.
  130702. * This is only use if tint is enabled
  130703. */
  130704. tintThickness: number;
  130705. private _tintTexture;
  130706. /**
  130707. * Stores the clear tint values in a texture.
  130708. * rgb is tint
  130709. * a is a thickness factor
  130710. */
  130711. tintTexture: Nullable<BaseTexture>;
  130712. /** @hidden */
  130713. private _internalMarkAllSubMeshesAsTexturesDirty;
  130714. /** @hidden */
  130715. _markAllSubMeshesAsTexturesDirty(): void;
  130716. /**
  130717. * Instantiate a new istance of clear coat configuration.
  130718. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130719. */
  130720. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130721. /**
  130722. * Gets wehter the submesh is ready to be used or not.
  130723. * @param defines the list of "defines" to update.
  130724. * @param scene defines the scene the material belongs to.
  130725. * @param engine defines the engine the material belongs to.
  130726. * @param disableBumpMap defines wether the material disables bump or not.
  130727. * @returns - boolean indicating that the submesh is ready or not.
  130728. */
  130729. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  130730. /**
  130731. * Checks to see if a texture is used in the material.
  130732. * @param defines the list of "defines" to update.
  130733. * @param scene defines the scene to the material belongs to.
  130734. */
  130735. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  130736. /**
  130737. * Binds the material data.
  130738. * @param uniformBuffer defines the Uniform buffer to fill in.
  130739. * @param scene defines the scene the material belongs to.
  130740. * @param engine defines the engine the material belongs to.
  130741. * @param disableBumpMap defines wether the material disables bump or not.
  130742. * @param isFrozen defines wether the material is frozen or not.
  130743. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  130744. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  130745. */
  130746. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  130747. /**
  130748. * Checks to see if a texture is used in the material.
  130749. * @param texture - Base texture to use.
  130750. * @returns - Boolean specifying if a texture is used in the material.
  130751. */
  130752. hasTexture(texture: BaseTexture): boolean;
  130753. /**
  130754. * Returns an array of the actively used textures.
  130755. * @param activeTextures Array of BaseTextures
  130756. */
  130757. getActiveTextures(activeTextures: BaseTexture[]): void;
  130758. /**
  130759. * Returns the animatable textures.
  130760. * @param animatables Array of animatable textures.
  130761. */
  130762. getAnimatables(animatables: IAnimatable[]): void;
  130763. /**
  130764. * Disposes the resources of the material.
  130765. * @param forceDisposeTextures - Forces the disposal of all textures.
  130766. */
  130767. dispose(forceDisposeTextures?: boolean): void;
  130768. /**
  130769. * Get the current class name of the texture useful for serialization or dynamic coding.
  130770. * @returns "PBRClearCoatConfiguration"
  130771. */
  130772. getClassName(): string;
  130773. /**
  130774. * Add fallbacks to the effect fallbacks list.
  130775. * @param defines defines the Base texture to use.
  130776. * @param fallbacks defines the current fallback list.
  130777. * @param currentRank defines the current fallback rank.
  130778. * @returns the new fallback rank.
  130779. */
  130780. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130781. /**
  130782. * Add the required uniforms to the current list.
  130783. * @param uniforms defines the current uniform list.
  130784. */
  130785. static AddUniforms(uniforms: string[]): void;
  130786. /**
  130787. * Add the required samplers to the current list.
  130788. * @param samplers defines the current sampler list.
  130789. */
  130790. static AddSamplers(samplers: string[]): void;
  130791. /**
  130792. * Add the required uniforms to the current buffer.
  130793. * @param uniformBuffer defines the current uniform buffer.
  130794. */
  130795. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130796. /**
  130797. * Makes a duplicate of the current configuration into another one.
  130798. * @param clearCoatConfiguration define the config where to copy the info
  130799. */
  130800. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  130801. /**
  130802. * Serializes this clear coat configuration.
  130803. * @returns - An object with the serialized config.
  130804. */
  130805. serialize(): any;
  130806. /**
  130807. * Parses a anisotropy Configuration from a serialized object.
  130808. * @param source - Serialized object.
  130809. * @param scene Defines the scene we are parsing for
  130810. * @param rootUrl Defines the rootUrl to load from
  130811. */
  130812. parse(source: any, scene: Scene, rootUrl: string): void;
  130813. }
  130814. }
  130815. declare module BABYLON {
  130816. /**
  130817. * @hidden
  130818. */
  130819. export interface IMaterialAnisotropicDefines {
  130820. ANISOTROPIC: boolean;
  130821. ANISOTROPIC_TEXTURE: boolean;
  130822. ANISOTROPIC_TEXTUREDIRECTUV: number;
  130823. MAINUV1: boolean;
  130824. _areTexturesDirty: boolean;
  130825. _needUVs: boolean;
  130826. }
  130827. /**
  130828. * Define the code related to the anisotropic parameters of the pbr material.
  130829. */
  130830. export class PBRAnisotropicConfiguration {
  130831. private _isEnabled;
  130832. /**
  130833. * Defines if the anisotropy is enabled in the material.
  130834. */
  130835. isEnabled: boolean;
  130836. /**
  130837. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  130838. */
  130839. intensity: number;
  130840. /**
  130841. * Defines if the effect is along the tangents, bitangents or in between.
  130842. * By default, the effect is "strectching" the highlights along the tangents.
  130843. */
  130844. direction: Vector2;
  130845. private _texture;
  130846. /**
  130847. * Stores the anisotropy values in a texture.
  130848. * rg is direction (like normal from -1 to 1)
  130849. * b is a intensity
  130850. */
  130851. texture: Nullable<BaseTexture>;
  130852. /** @hidden */
  130853. private _internalMarkAllSubMeshesAsTexturesDirty;
  130854. /** @hidden */
  130855. _markAllSubMeshesAsTexturesDirty(): void;
  130856. /**
  130857. * Instantiate a new istance of anisotropy configuration.
  130858. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130859. */
  130860. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130861. /**
  130862. * Specifies that the submesh is ready to be used.
  130863. * @param defines the list of "defines" to update.
  130864. * @param scene defines the scene the material belongs to.
  130865. * @returns - boolean indicating that the submesh is ready or not.
  130866. */
  130867. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  130868. /**
  130869. * Checks to see if a texture is used in the material.
  130870. * @param defines the list of "defines" to update.
  130871. * @param mesh the mesh we are preparing the defines for.
  130872. * @param scene defines the scene the material belongs to.
  130873. */
  130874. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  130875. /**
  130876. * Binds the material data.
  130877. * @param uniformBuffer defines the Uniform buffer to fill in.
  130878. * @param scene defines the scene the material belongs to.
  130879. * @param isFrozen defines wether the material is frozen or not.
  130880. */
  130881. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130882. /**
  130883. * Checks to see if a texture is used in the material.
  130884. * @param texture - Base texture to use.
  130885. * @returns - Boolean specifying if a texture is used in the material.
  130886. */
  130887. hasTexture(texture: BaseTexture): boolean;
  130888. /**
  130889. * Returns an array of the actively used textures.
  130890. * @param activeTextures Array of BaseTextures
  130891. */
  130892. getActiveTextures(activeTextures: BaseTexture[]): void;
  130893. /**
  130894. * Returns the animatable textures.
  130895. * @param animatables Array of animatable textures.
  130896. */
  130897. getAnimatables(animatables: IAnimatable[]): void;
  130898. /**
  130899. * Disposes the resources of the material.
  130900. * @param forceDisposeTextures - Forces the disposal of all textures.
  130901. */
  130902. dispose(forceDisposeTextures?: boolean): void;
  130903. /**
  130904. * Get the current class name of the texture useful for serialization or dynamic coding.
  130905. * @returns "PBRAnisotropicConfiguration"
  130906. */
  130907. getClassName(): string;
  130908. /**
  130909. * Add fallbacks to the effect fallbacks list.
  130910. * @param defines defines the Base texture to use.
  130911. * @param fallbacks defines the current fallback list.
  130912. * @param currentRank defines the current fallback rank.
  130913. * @returns the new fallback rank.
  130914. */
  130915. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130916. /**
  130917. * Add the required uniforms to the current list.
  130918. * @param uniforms defines the current uniform list.
  130919. */
  130920. static AddUniforms(uniforms: string[]): void;
  130921. /**
  130922. * Add the required uniforms to the current buffer.
  130923. * @param uniformBuffer defines the current uniform buffer.
  130924. */
  130925. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130926. /**
  130927. * Add the required samplers to the current list.
  130928. * @param samplers defines the current sampler list.
  130929. */
  130930. static AddSamplers(samplers: string[]): void;
  130931. /**
  130932. * Makes a duplicate of the current configuration into another one.
  130933. * @param anisotropicConfiguration define the config where to copy the info
  130934. */
  130935. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  130936. /**
  130937. * Serializes this anisotropy configuration.
  130938. * @returns - An object with the serialized config.
  130939. */
  130940. serialize(): any;
  130941. /**
  130942. * Parses a anisotropy Configuration from a serialized object.
  130943. * @param source - Serialized object.
  130944. * @param scene Defines the scene we are parsing for
  130945. * @param rootUrl Defines the rootUrl to load from
  130946. */
  130947. parse(source: any, scene: Scene, rootUrl: string): void;
  130948. }
  130949. }
  130950. declare module BABYLON {
  130951. /**
  130952. * @hidden
  130953. */
  130954. export interface IMaterialBRDFDefines {
  130955. BRDF_V_HEIGHT_CORRELATED: boolean;
  130956. MS_BRDF_ENERGY_CONSERVATION: boolean;
  130957. SPHERICAL_HARMONICS: boolean;
  130958. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  130959. /** @hidden */
  130960. _areMiscDirty: boolean;
  130961. }
  130962. /**
  130963. * Define the code related to the BRDF parameters of the pbr material.
  130964. */
  130965. export class PBRBRDFConfiguration {
  130966. /**
  130967. * Default value used for the energy conservation.
  130968. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130969. */
  130970. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  130971. /**
  130972. * Default value used for the Smith Visibility Height Correlated mode.
  130973. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130974. */
  130975. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  130976. /**
  130977. * Default value used for the IBL diffuse part.
  130978. * This can help switching back to the polynomials mode globally which is a tiny bit
  130979. * less GPU intensive at the drawback of a lower quality.
  130980. */
  130981. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  130982. /**
  130983. * Default value used for activating energy conservation for the specular workflow.
  130984. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130985. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130986. */
  130987. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  130988. private _useEnergyConservation;
  130989. /**
  130990. * Defines if the material uses energy conservation.
  130991. */
  130992. useEnergyConservation: boolean;
  130993. private _useSmithVisibilityHeightCorrelated;
  130994. /**
  130995. * LEGACY Mode set to false
  130996. * Defines if the material uses height smith correlated visibility term.
  130997. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  130998. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  130999. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  131000. * Not relying on height correlated will also disable energy conservation.
  131001. */
  131002. useSmithVisibilityHeightCorrelated: boolean;
  131003. private _useSphericalHarmonics;
  131004. /**
  131005. * LEGACY Mode set to false
  131006. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  131007. * diffuse part of the IBL.
  131008. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  131009. * to the ground truth.
  131010. */
  131011. useSphericalHarmonics: boolean;
  131012. private _useSpecularGlossinessInputEnergyConservation;
  131013. /**
  131014. * Defines if the material uses energy conservation, when the specular workflow is active.
  131015. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131016. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131017. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  131018. */
  131019. useSpecularGlossinessInputEnergyConservation: boolean;
  131020. /** @hidden */
  131021. private _internalMarkAllSubMeshesAsMiscDirty;
  131022. /** @hidden */
  131023. _markAllSubMeshesAsMiscDirty(): void;
  131024. /**
  131025. * Instantiate a new istance of clear coat configuration.
  131026. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  131027. */
  131028. constructor(markAllSubMeshesAsMiscDirty: () => void);
  131029. /**
  131030. * Checks to see if a texture is used in the material.
  131031. * @param defines the list of "defines" to update.
  131032. */
  131033. prepareDefines(defines: IMaterialBRDFDefines): void;
  131034. /**
  131035. * Get the current class name of the texture useful for serialization or dynamic coding.
  131036. * @returns "PBRClearCoatConfiguration"
  131037. */
  131038. getClassName(): string;
  131039. /**
  131040. * Makes a duplicate of the current configuration into another one.
  131041. * @param brdfConfiguration define the config where to copy the info
  131042. */
  131043. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131044. /**
  131045. * Serializes this BRDF configuration.
  131046. * @returns - An object with the serialized config.
  131047. */
  131048. serialize(): any;
  131049. /**
  131050. * Parses a anisotropy Configuration from a serialized object.
  131051. * @param source - Serialized object.
  131052. * @param scene Defines the scene we are parsing for
  131053. * @param rootUrl Defines the rootUrl to load from
  131054. */
  131055. parse(source: any, scene: Scene, rootUrl: string): void;
  131056. }
  131057. }
  131058. declare module BABYLON {
  131059. /**
  131060. * @hidden
  131061. */
  131062. export interface IMaterialSheenDefines {
  131063. SHEEN: boolean;
  131064. SHEEN_TEXTURE: boolean;
  131065. SHEEN_TEXTUREDIRECTUV: number;
  131066. SHEEN_LINKWITHALBEDO: boolean;
  131067. SHEEN_ROUGHNESS: boolean;
  131068. SHEEN_ALBEDOSCALING: boolean;
  131069. /** @hidden */
  131070. _areTexturesDirty: boolean;
  131071. }
  131072. /**
  131073. * Define the code related to the Sheen parameters of the pbr material.
  131074. */
  131075. export class PBRSheenConfiguration {
  131076. private _isEnabled;
  131077. /**
  131078. * Defines if the material uses sheen.
  131079. */
  131080. isEnabled: boolean;
  131081. private _linkSheenWithAlbedo;
  131082. /**
  131083. * Defines if the sheen is linked to the sheen color.
  131084. */
  131085. linkSheenWithAlbedo: boolean;
  131086. /**
  131087. * Defines the sheen intensity.
  131088. */
  131089. intensity: number;
  131090. /**
  131091. * Defines the sheen color.
  131092. */
  131093. color: Color3;
  131094. private _texture;
  131095. /**
  131096. * Stores the sheen tint values in a texture.
  131097. * rgb is tint
  131098. * a is a intensity
  131099. */
  131100. texture: Nullable<BaseTexture>;
  131101. private _roughness;
  131102. /**
  131103. * Defines the sheen roughness.
  131104. * It is not taken into account if linkSheenWithAlbedo is true.
  131105. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  131106. */
  131107. roughness: Nullable<number>;
  131108. private _albedoScaling;
  131109. /**
  131110. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  131111. * It allows the strength of the sheen effect to not depend on the base color of the material,
  131112. * making it easier to setup and tweak the effect
  131113. */
  131114. albedoScaling: boolean;
  131115. /** @hidden */
  131116. private _internalMarkAllSubMeshesAsTexturesDirty;
  131117. /** @hidden */
  131118. _markAllSubMeshesAsTexturesDirty(): void;
  131119. /**
  131120. * Instantiate a new istance of clear coat configuration.
  131121. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131122. */
  131123. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131124. /**
  131125. * Specifies that the submesh is ready to be used.
  131126. * @param defines the list of "defines" to update.
  131127. * @param scene defines the scene the material belongs to.
  131128. * @returns - boolean indicating that the submesh is ready or not.
  131129. */
  131130. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  131131. /**
  131132. * Checks to see if a texture is used in the material.
  131133. * @param defines the list of "defines" to update.
  131134. * @param scene defines the scene the material belongs to.
  131135. */
  131136. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  131137. /**
  131138. * Binds the material data.
  131139. * @param uniformBuffer defines the Uniform buffer to fill in.
  131140. * @param scene defines the scene the material belongs to.
  131141. * @param isFrozen defines wether the material is frozen or not.
  131142. */
  131143. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131144. /**
  131145. * Checks to see if a texture is used in the material.
  131146. * @param texture - Base texture to use.
  131147. * @returns - Boolean specifying if a texture is used in the material.
  131148. */
  131149. hasTexture(texture: BaseTexture): boolean;
  131150. /**
  131151. * Returns an array of the actively used textures.
  131152. * @param activeTextures Array of BaseTextures
  131153. */
  131154. getActiveTextures(activeTextures: BaseTexture[]): void;
  131155. /**
  131156. * Returns the animatable textures.
  131157. * @param animatables Array of animatable textures.
  131158. */
  131159. getAnimatables(animatables: IAnimatable[]): void;
  131160. /**
  131161. * Disposes the resources of the material.
  131162. * @param forceDisposeTextures - Forces the disposal of all textures.
  131163. */
  131164. dispose(forceDisposeTextures?: boolean): void;
  131165. /**
  131166. * Get the current class name of the texture useful for serialization or dynamic coding.
  131167. * @returns "PBRSheenConfiguration"
  131168. */
  131169. getClassName(): string;
  131170. /**
  131171. * Add fallbacks to the effect fallbacks list.
  131172. * @param defines defines the Base texture to use.
  131173. * @param fallbacks defines the current fallback list.
  131174. * @param currentRank defines the current fallback rank.
  131175. * @returns the new fallback rank.
  131176. */
  131177. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131178. /**
  131179. * Add the required uniforms to the current list.
  131180. * @param uniforms defines the current uniform list.
  131181. */
  131182. static AddUniforms(uniforms: string[]): void;
  131183. /**
  131184. * Add the required uniforms to the current buffer.
  131185. * @param uniformBuffer defines the current uniform buffer.
  131186. */
  131187. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131188. /**
  131189. * Add the required samplers to the current list.
  131190. * @param samplers defines the current sampler list.
  131191. */
  131192. static AddSamplers(samplers: string[]): void;
  131193. /**
  131194. * Makes a duplicate of the current configuration into another one.
  131195. * @param sheenConfiguration define the config where to copy the info
  131196. */
  131197. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  131198. /**
  131199. * Serializes this BRDF configuration.
  131200. * @returns - An object with the serialized config.
  131201. */
  131202. serialize(): any;
  131203. /**
  131204. * Parses a anisotropy Configuration from a serialized object.
  131205. * @param source - Serialized object.
  131206. * @param scene Defines the scene we are parsing for
  131207. * @param rootUrl Defines the rootUrl to load from
  131208. */
  131209. parse(source: any, scene: Scene, rootUrl: string): void;
  131210. }
  131211. }
  131212. declare module BABYLON {
  131213. /**
  131214. * @hidden
  131215. */
  131216. export interface IMaterialSubSurfaceDefines {
  131217. SUBSURFACE: boolean;
  131218. SS_REFRACTION: boolean;
  131219. SS_TRANSLUCENCY: boolean;
  131220. SS_SCATERRING: boolean;
  131221. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131222. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131223. SS_REFRACTIONMAP_3D: boolean;
  131224. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131225. SS_LODINREFRACTIONALPHA: boolean;
  131226. SS_GAMMAREFRACTION: boolean;
  131227. SS_RGBDREFRACTION: boolean;
  131228. SS_LINEARSPECULARREFRACTION: boolean;
  131229. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131230. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131231. /** @hidden */
  131232. _areTexturesDirty: boolean;
  131233. }
  131234. /**
  131235. * Define the code related to the sub surface parameters of the pbr material.
  131236. */
  131237. export class PBRSubSurfaceConfiguration {
  131238. private _isRefractionEnabled;
  131239. /**
  131240. * Defines if the refraction is enabled in the material.
  131241. */
  131242. isRefractionEnabled: boolean;
  131243. private _isTranslucencyEnabled;
  131244. /**
  131245. * Defines if the translucency is enabled in the material.
  131246. */
  131247. isTranslucencyEnabled: boolean;
  131248. private _isScatteringEnabled;
  131249. /**
  131250. * Defines the refraction intensity of the material.
  131251. * The refraction when enabled replaces the Diffuse part of the material.
  131252. * The intensity helps transitionning between diffuse and refraction.
  131253. */
  131254. refractionIntensity: number;
  131255. /**
  131256. * Defines the translucency intensity of the material.
  131257. * When translucency has been enabled, this defines how much of the "translucency"
  131258. * is addded to the diffuse part of the material.
  131259. */
  131260. translucencyIntensity: number;
  131261. /**
  131262. * Defines the scattering intensity of the material.
  131263. * When scattering has been enabled, this defines how much of the "scattered light"
  131264. * is addded to the diffuse part of the material.
  131265. */
  131266. scatteringIntensity: number;
  131267. private _thicknessTexture;
  131268. /**
  131269. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  131270. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  131271. * 0 would mean minimumThickness
  131272. * 1 would mean maximumThickness
  131273. * The other channels might be use as a mask to vary the different effects intensity.
  131274. */
  131275. thicknessTexture: Nullable<BaseTexture>;
  131276. private _refractionTexture;
  131277. /**
  131278. * Defines the texture to use for refraction.
  131279. */
  131280. refractionTexture: Nullable<BaseTexture>;
  131281. private _indexOfRefraction;
  131282. /**
  131283. * Index of refraction of the material base layer.
  131284. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  131285. *
  131286. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  131287. *
  131288. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  131289. */
  131290. indexOfRefraction: number;
  131291. private _invertRefractionY;
  131292. /**
  131293. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  131294. */
  131295. invertRefractionY: boolean;
  131296. private _linkRefractionWithTransparency;
  131297. /**
  131298. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  131299. * Materials half opaque for instance using refraction could benefit from this control.
  131300. */
  131301. linkRefractionWithTransparency: boolean;
  131302. /**
  131303. * Defines the minimum thickness stored in the thickness map.
  131304. * If no thickness map is defined, this value will be used to simulate thickness.
  131305. */
  131306. minimumThickness: number;
  131307. /**
  131308. * Defines the maximum thickness stored in the thickness map.
  131309. */
  131310. maximumThickness: number;
  131311. /**
  131312. * Defines the volume tint of the material.
  131313. * This is used for both translucency and scattering.
  131314. */
  131315. tintColor: Color3;
  131316. /**
  131317. * Defines the distance at which the tint color should be found in the media.
  131318. * This is used for refraction only.
  131319. */
  131320. tintColorAtDistance: number;
  131321. /**
  131322. * Defines how far each channel transmit through the media.
  131323. * It is defined as a color to simplify it selection.
  131324. */
  131325. diffusionDistance: Color3;
  131326. private _useMaskFromThicknessTexture;
  131327. /**
  131328. * Stores the intensity of the different subsurface effects in the thickness texture.
  131329. * * the green channel is the translucency intensity.
  131330. * * the blue channel is the scattering intensity.
  131331. * * the alpha channel is the refraction intensity.
  131332. */
  131333. useMaskFromThicknessTexture: boolean;
  131334. /** @hidden */
  131335. private _internalMarkAllSubMeshesAsTexturesDirty;
  131336. /** @hidden */
  131337. _markAllSubMeshesAsTexturesDirty(): void;
  131338. /**
  131339. * Instantiate a new istance of sub surface configuration.
  131340. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131341. */
  131342. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131343. /**
  131344. * Gets wehter the submesh is ready to be used or not.
  131345. * @param defines the list of "defines" to update.
  131346. * @param scene defines the scene the material belongs to.
  131347. * @returns - boolean indicating that the submesh is ready or not.
  131348. */
  131349. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  131350. /**
  131351. * Checks to see if a texture is used in the material.
  131352. * @param defines the list of "defines" to update.
  131353. * @param scene defines the scene to the material belongs to.
  131354. */
  131355. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  131356. /**
  131357. * Binds the material data.
  131358. * @param uniformBuffer defines the Uniform buffer to fill in.
  131359. * @param scene defines the scene the material belongs to.
  131360. * @param engine defines the engine the material belongs to.
  131361. * @param isFrozen defines whether the material is frozen or not.
  131362. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  131363. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  131364. */
  131365. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  131366. /**
  131367. * Unbinds the material from the mesh.
  131368. * @param activeEffect defines the effect that should be unbound from.
  131369. * @returns true if unbound, otherwise false
  131370. */
  131371. unbind(activeEffect: Effect): boolean;
  131372. /**
  131373. * Returns the texture used for refraction or null if none is used.
  131374. * @param scene defines the scene the material belongs to.
  131375. * @returns - Refraction texture if present. If no refraction texture and refraction
  131376. * is linked with transparency, returns environment texture. Otherwise, returns null.
  131377. */
  131378. private _getRefractionTexture;
  131379. /**
  131380. * Returns true if alpha blending should be disabled.
  131381. */
  131382. get disableAlphaBlending(): boolean;
  131383. /**
  131384. * Fills the list of render target textures.
  131385. * @param renderTargets the list of render targets to update
  131386. */
  131387. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  131388. /**
  131389. * Checks to see if a texture is used in the material.
  131390. * @param texture - Base texture to use.
  131391. * @returns - Boolean specifying if a texture is used in the material.
  131392. */
  131393. hasTexture(texture: BaseTexture): boolean;
  131394. /**
  131395. * Gets a boolean indicating that current material needs to register RTT
  131396. * @returns true if this uses a render target otherwise false.
  131397. */
  131398. hasRenderTargetTextures(): boolean;
  131399. /**
  131400. * Returns an array of the actively used textures.
  131401. * @param activeTextures Array of BaseTextures
  131402. */
  131403. getActiveTextures(activeTextures: BaseTexture[]): void;
  131404. /**
  131405. * Returns the animatable textures.
  131406. * @param animatables Array of animatable textures.
  131407. */
  131408. getAnimatables(animatables: IAnimatable[]): void;
  131409. /**
  131410. * Disposes the resources of the material.
  131411. * @param forceDisposeTextures - Forces the disposal of all textures.
  131412. */
  131413. dispose(forceDisposeTextures?: boolean): void;
  131414. /**
  131415. * Get the current class name of the texture useful for serialization or dynamic coding.
  131416. * @returns "PBRSubSurfaceConfiguration"
  131417. */
  131418. getClassName(): string;
  131419. /**
  131420. * Add fallbacks to the effect fallbacks list.
  131421. * @param defines defines the Base texture to use.
  131422. * @param fallbacks defines the current fallback list.
  131423. * @param currentRank defines the current fallback rank.
  131424. * @returns the new fallback rank.
  131425. */
  131426. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131427. /**
  131428. * Add the required uniforms to the current list.
  131429. * @param uniforms defines the current uniform list.
  131430. */
  131431. static AddUniforms(uniforms: string[]): void;
  131432. /**
  131433. * Add the required samplers to the current list.
  131434. * @param samplers defines the current sampler list.
  131435. */
  131436. static AddSamplers(samplers: string[]): void;
  131437. /**
  131438. * Add the required uniforms to the current buffer.
  131439. * @param uniformBuffer defines the current uniform buffer.
  131440. */
  131441. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131442. /**
  131443. * Makes a duplicate of the current configuration into another one.
  131444. * @param configuration define the config where to copy the info
  131445. */
  131446. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  131447. /**
  131448. * Serializes this Sub Surface configuration.
  131449. * @returns - An object with the serialized config.
  131450. */
  131451. serialize(): any;
  131452. /**
  131453. * Parses a anisotropy Configuration from a serialized object.
  131454. * @param source - Serialized object.
  131455. * @param scene Defines the scene we are parsing for
  131456. * @param rootUrl Defines the rootUrl to load from
  131457. */
  131458. parse(source: any, scene: Scene, rootUrl: string): void;
  131459. }
  131460. }
  131461. declare module BABYLON {
  131462. /** @hidden */
  131463. export var pbrFragmentDeclaration: {
  131464. name: string;
  131465. shader: string;
  131466. };
  131467. }
  131468. declare module BABYLON {
  131469. /** @hidden */
  131470. export var pbrUboDeclaration: {
  131471. name: string;
  131472. shader: string;
  131473. };
  131474. }
  131475. declare module BABYLON {
  131476. /** @hidden */
  131477. export var pbrFragmentExtraDeclaration: {
  131478. name: string;
  131479. shader: string;
  131480. };
  131481. }
  131482. declare module BABYLON {
  131483. /** @hidden */
  131484. export var pbrFragmentSamplersDeclaration: {
  131485. name: string;
  131486. shader: string;
  131487. };
  131488. }
  131489. declare module BABYLON {
  131490. /** @hidden */
  131491. export var importanceSampling: {
  131492. name: string;
  131493. shader: string;
  131494. };
  131495. }
  131496. declare module BABYLON {
  131497. /** @hidden */
  131498. export var pbrHelperFunctions: {
  131499. name: string;
  131500. shader: string;
  131501. };
  131502. }
  131503. declare module BABYLON {
  131504. /** @hidden */
  131505. export var harmonicsFunctions: {
  131506. name: string;
  131507. shader: string;
  131508. };
  131509. }
  131510. declare module BABYLON {
  131511. /** @hidden */
  131512. export var pbrDirectLightingSetupFunctions: {
  131513. name: string;
  131514. shader: string;
  131515. };
  131516. }
  131517. declare module BABYLON {
  131518. /** @hidden */
  131519. export var pbrDirectLightingFalloffFunctions: {
  131520. name: string;
  131521. shader: string;
  131522. };
  131523. }
  131524. declare module BABYLON {
  131525. /** @hidden */
  131526. export var pbrBRDFFunctions: {
  131527. name: string;
  131528. shader: string;
  131529. };
  131530. }
  131531. declare module BABYLON {
  131532. /** @hidden */
  131533. export var hdrFilteringFunctions: {
  131534. name: string;
  131535. shader: string;
  131536. };
  131537. }
  131538. declare module BABYLON {
  131539. /** @hidden */
  131540. export var pbrDirectLightingFunctions: {
  131541. name: string;
  131542. shader: string;
  131543. };
  131544. }
  131545. declare module BABYLON {
  131546. /** @hidden */
  131547. export var pbrIBLFunctions: {
  131548. name: string;
  131549. shader: string;
  131550. };
  131551. }
  131552. declare module BABYLON {
  131553. /** @hidden */
  131554. export var pbrBlockAlbedoOpacity: {
  131555. name: string;
  131556. shader: string;
  131557. };
  131558. }
  131559. declare module BABYLON {
  131560. /** @hidden */
  131561. export var pbrBlockReflectivity: {
  131562. name: string;
  131563. shader: string;
  131564. };
  131565. }
  131566. declare module BABYLON {
  131567. /** @hidden */
  131568. export var pbrBlockAmbientOcclusion: {
  131569. name: string;
  131570. shader: string;
  131571. };
  131572. }
  131573. declare module BABYLON {
  131574. /** @hidden */
  131575. export var pbrBlockAlphaFresnel: {
  131576. name: string;
  131577. shader: string;
  131578. };
  131579. }
  131580. declare module BABYLON {
  131581. /** @hidden */
  131582. export var pbrBlockAnisotropic: {
  131583. name: string;
  131584. shader: string;
  131585. };
  131586. }
  131587. declare module BABYLON {
  131588. /** @hidden */
  131589. export var pbrBlockReflection: {
  131590. name: string;
  131591. shader: string;
  131592. };
  131593. }
  131594. declare module BABYLON {
  131595. /** @hidden */
  131596. export var pbrBlockSheen: {
  131597. name: string;
  131598. shader: string;
  131599. };
  131600. }
  131601. declare module BABYLON {
  131602. /** @hidden */
  131603. export var pbrBlockClearcoat: {
  131604. name: string;
  131605. shader: string;
  131606. };
  131607. }
  131608. declare module BABYLON {
  131609. /** @hidden */
  131610. export var pbrBlockSubSurface: {
  131611. name: string;
  131612. shader: string;
  131613. };
  131614. }
  131615. declare module BABYLON {
  131616. /** @hidden */
  131617. export var pbrBlockNormalGeometric: {
  131618. name: string;
  131619. shader: string;
  131620. };
  131621. }
  131622. declare module BABYLON {
  131623. /** @hidden */
  131624. export var pbrBlockNormalFinal: {
  131625. name: string;
  131626. shader: string;
  131627. };
  131628. }
  131629. declare module BABYLON {
  131630. /** @hidden */
  131631. export var pbrBlockGeometryInfo: {
  131632. name: string;
  131633. shader: string;
  131634. };
  131635. }
  131636. declare module BABYLON {
  131637. /** @hidden */
  131638. export var pbrBlockReflectance0: {
  131639. name: string;
  131640. shader: string;
  131641. };
  131642. }
  131643. declare module BABYLON {
  131644. /** @hidden */
  131645. export var pbrBlockReflectance: {
  131646. name: string;
  131647. shader: string;
  131648. };
  131649. }
  131650. declare module BABYLON {
  131651. /** @hidden */
  131652. export var pbrBlockDirectLighting: {
  131653. name: string;
  131654. shader: string;
  131655. };
  131656. }
  131657. declare module BABYLON {
  131658. /** @hidden */
  131659. export var pbrBlockFinalLitComponents: {
  131660. name: string;
  131661. shader: string;
  131662. };
  131663. }
  131664. declare module BABYLON {
  131665. /** @hidden */
  131666. export var pbrBlockFinalUnlitComponents: {
  131667. name: string;
  131668. shader: string;
  131669. };
  131670. }
  131671. declare module BABYLON {
  131672. /** @hidden */
  131673. export var pbrBlockFinalColorComposition: {
  131674. name: string;
  131675. shader: string;
  131676. };
  131677. }
  131678. declare module BABYLON {
  131679. /** @hidden */
  131680. export var pbrBlockImageProcessing: {
  131681. name: string;
  131682. shader: string;
  131683. };
  131684. }
  131685. declare module BABYLON {
  131686. /** @hidden */
  131687. export var pbrDebug: {
  131688. name: string;
  131689. shader: string;
  131690. };
  131691. }
  131692. declare module BABYLON {
  131693. /** @hidden */
  131694. export var pbrPixelShader: {
  131695. name: string;
  131696. shader: string;
  131697. };
  131698. }
  131699. declare module BABYLON {
  131700. /** @hidden */
  131701. export var pbrVertexDeclaration: {
  131702. name: string;
  131703. shader: string;
  131704. };
  131705. }
  131706. declare module BABYLON {
  131707. /** @hidden */
  131708. export var pbrVertexShader: {
  131709. name: string;
  131710. shader: string;
  131711. };
  131712. }
  131713. declare module BABYLON {
  131714. /**
  131715. * Manages the defines for the PBR Material.
  131716. * @hidden
  131717. */
  131718. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  131719. PBR: boolean;
  131720. NUM_SAMPLES: string;
  131721. REALTIME_FILTERING: boolean;
  131722. MAINUV1: boolean;
  131723. MAINUV2: boolean;
  131724. UV1: boolean;
  131725. UV2: boolean;
  131726. ALBEDO: boolean;
  131727. GAMMAALBEDO: boolean;
  131728. ALBEDODIRECTUV: number;
  131729. VERTEXCOLOR: boolean;
  131730. AMBIENT: boolean;
  131731. AMBIENTDIRECTUV: number;
  131732. AMBIENTINGRAYSCALE: boolean;
  131733. OPACITY: boolean;
  131734. VERTEXALPHA: boolean;
  131735. OPACITYDIRECTUV: number;
  131736. OPACITYRGB: boolean;
  131737. ALPHATEST: boolean;
  131738. DEPTHPREPASS: boolean;
  131739. ALPHABLEND: boolean;
  131740. ALPHAFROMALBEDO: boolean;
  131741. ALPHATESTVALUE: string;
  131742. SPECULAROVERALPHA: boolean;
  131743. RADIANCEOVERALPHA: boolean;
  131744. ALPHAFRESNEL: boolean;
  131745. LINEARALPHAFRESNEL: boolean;
  131746. PREMULTIPLYALPHA: boolean;
  131747. EMISSIVE: boolean;
  131748. EMISSIVEDIRECTUV: number;
  131749. REFLECTIVITY: boolean;
  131750. REFLECTIVITYDIRECTUV: number;
  131751. SPECULARTERM: boolean;
  131752. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  131753. MICROSURFACEAUTOMATIC: boolean;
  131754. LODBASEDMICROSFURACE: boolean;
  131755. MICROSURFACEMAP: boolean;
  131756. MICROSURFACEMAPDIRECTUV: number;
  131757. METALLICWORKFLOW: boolean;
  131758. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  131759. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  131760. METALLNESSSTOREINMETALMAPBLUE: boolean;
  131761. AOSTOREINMETALMAPRED: boolean;
  131762. METALLIC_REFLECTANCE: boolean;
  131763. METALLIC_REFLECTANCEDIRECTUV: number;
  131764. ENVIRONMENTBRDF: boolean;
  131765. ENVIRONMENTBRDF_RGBD: boolean;
  131766. NORMAL: boolean;
  131767. TANGENT: boolean;
  131768. BUMP: boolean;
  131769. BUMPDIRECTUV: number;
  131770. OBJECTSPACE_NORMALMAP: boolean;
  131771. PARALLAX: boolean;
  131772. PARALLAXOCCLUSION: boolean;
  131773. NORMALXYSCALE: boolean;
  131774. LIGHTMAP: boolean;
  131775. LIGHTMAPDIRECTUV: number;
  131776. USELIGHTMAPASSHADOWMAP: boolean;
  131777. GAMMALIGHTMAP: boolean;
  131778. RGBDLIGHTMAP: boolean;
  131779. REFLECTION: boolean;
  131780. REFLECTIONMAP_3D: boolean;
  131781. REFLECTIONMAP_SPHERICAL: boolean;
  131782. REFLECTIONMAP_PLANAR: boolean;
  131783. REFLECTIONMAP_CUBIC: boolean;
  131784. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  131785. REFLECTIONMAP_PROJECTION: boolean;
  131786. REFLECTIONMAP_SKYBOX: boolean;
  131787. REFLECTIONMAP_EXPLICIT: boolean;
  131788. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  131789. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  131790. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  131791. INVERTCUBICMAP: boolean;
  131792. USESPHERICALFROMREFLECTIONMAP: boolean;
  131793. USEIRRADIANCEMAP: boolean;
  131794. SPHERICAL_HARMONICS: boolean;
  131795. USESPHERICALINVERTEX: boolean;
  131796. REFLECTIONMAP_OPPOSITEZ: boolean;
  131797. LODINREFLECTIONALPHA: boolean;
  131798. GAMMAREFLECTION: boolean;
  131799. RGBDREFLECTION: boolean;
  131800. LINEARSPECULARREFLECTION: boolean;
  131801. RADIANCEOCCLUSION: boolean;
  131802. HORIZONOCCLUSION: boolean;
  131803. INSTANCES: boolean;
  131804. THIN_INSTANCES: boolean;
  131805. NUM_BONE_INFLUENCERS: number;
  131806. BonesPerMesh: number;
  131807. BONETEXTURE: boolean;
  131808. NONUNIFORMSCALING: boolean;
  131809. MORPHTARGETS: boolean;
  131810. MORPHTARGETS_NORMAL: boolean;
  131811. MORPHTARGETS_TANGENT: boolean;
  131812. MORPHTARGETS_UV: boolean;
  131813. NUM_MORPH_INFLUENCERS: number;
  131814. IMAGEPROCESSING: boolean;
  131815. VIGNETTE: boolean;
  131816. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131817. VIGNETTEBLENDMODEOPAQUE: boolean;
  131818. TONEMAPPING: boolean;
  131819. TONEMAPPING_ACES: boolean;
  131820. CONTRAST: boolean;
  131821. COLORCURVES: boolean;
  131822. COLORGRADING: boolean;
  131823. COLORGRADING3D: boolean;
  131824. SAMPLER3DGREENDEPTH: boolean;
  131825. SAMPLER3DBGRMAP: boolean;
  131826. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131827. EXPOSURE: boolean;
  131828. MULTIVIEW: boolean;
  131829. USEPHYSICALLIGHTFALLOFF: boolean;
  131830. USEGLTFLIGHTFALLOFF: boolean;
  131831. TWOSIDEDLIGHTING: boolean;
  131832. SHADOWFLOAT: boolean;
  131833. CLIPPLANE: boolean;
  131834. CLIPPLANE2: boolean;
  131835. CLIPPLANE3: boolean;
  131836. CLIPPLANE4: boolean;
  131837. CLIPPLANE5: boolean;
  131838. CLIPPLANE6: boolean;
  131839. POINTSIZE: boolean;
  131840. FOG: boolean;
  131841. LOGARITHMICDEPTH: boolean;
  131842. FORCENORMALFORWARD: boolean;
  131843. SPECULARAA: boolean;
  131844. CLEARCOAT: boolean;
  131845. CLEARCOAT_DEFAULTIOR: boolean;
  131846. CLEARCOAT_TEXTURE: boolean;
  131847. CLEARCOAT_TEXTUREDIRECTUV: number;
  131848. CLEARCOAT_BUMP: boolean;
  131849. CLEARCOAT_BUMPDIRECTUV: number;
  131850. CLEARCOAT_TINT: boolean;
  131851. CLEARCOAT_TINT_TEXTURE: boolean;
  131852. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131853. ANISOTROPIC: boolean;
  131854. ANISOTROPIC_TEXTURE: boolean;
  131855. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131856. BRDF_V_HEIGHT_CORRELATED: boolean;
  131857. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131858. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131859. SHEEN: boolean;
  131860. SHEEN_TEXTURE: boolean;
  131861. SHEEN_TEXTUREDIRECTUV: number;
  131862. SHEEN_LINKWITHALBEDO: boolean;
  131863. SHEEN_ROUGHNESS: boolean;
  131864. SHEEN_ALBEDOSCALING: boolean;
  131865. SUBSURFACE: boolean;
  131866. SS_REFRACTION: boolean;
  131867. SS_TRANSLUCENCY: boolean;
  131868. SS_SCATERRING: boolean;
  131869. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131870. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131871. SS_REFRACTIONMAP_3D: boolean;
  131872. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131873. SS_LODINREFRACTIONALPHA: boolean;
  131874. SS_GAMMAREFRACTION: boolean;
  131875. SS_RGBDREFRACTION: boolean;
  131876. SS_LINEARSPECULARREFRACTION: boolean;
  131877. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131878. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131879. UNLIT: boolean;
  131880. DEBUGMODE: number;
  131881. /**
  131882. * Initializes the PBR Material defines.
  131883. */
  131884. constructor();
  131885. /**
  131886. * Resets the PBR Material defines.
  131887. */
  131888. reset(): void;
  131889. }
  131890. /**
  131891. * The Physically based material base class of BJS.
  131892. *
  131893. * This offers the main features of a standard PBR material.
  131894. * For more information, please refer to the documentation :
  131895. * https://doc.babylonjs.com/how_to/physically_based_rendering
  131896. */
  131897. export abstract class PBRBaseMaterial extends PushMaterial {
  131898. /**
  131899. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  131900. */
  131901. static readonly PBRMATERIAL_OPAQUE: number;
  131902. /**
  131903. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  131904. */
  131905. static readonly PBRMATERIAL_ALPHATEST: number;
  131906. /**
  131907. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131908. */
  131909. static readonly PBRMATERIAL_ALPHABLEND: number;
  131910. /**
  131911. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131912. * They are also discarded below the alpha cutoff threshold to improve performances.
  131913. */
  131914. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  131915. /**
  131916. * Defines the default value of how much AO map is occluding the analytical lights
  131917. * (point spot...).
  131918. */
  131919. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  131920. /**
  131921. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  131922. */
  131923. static readonly LIGHTFALLOFF_PHYSICAL: number;
  131924. /**
  131925. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  131926. * to enhance interoperability with other engines.
  131927. */
  131928. static readonly LIGHTFALLOFF_GLTF: number;
  131929. /**
  131930. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  131931. * to enhance interoperability with other materials.
  131932. */
  131933. static readonly LIGHTFALLOFF_STANDARD: number;
  131934. /**
  131935. * Intensity of the direct lights e.g. the four lights available in your scene.
  131936. * This impacts both the direct diffuse and specular highlights.
  131937. */
  131938. protected _directIntensity: number;
  131939. /**
  131940. * Intensity of the emissive part of the material.
  131941. * This helps controlling the emissive effect without modifying the emissive color.
  131942. */
  131943. protected _emissiveIntensity: number;
  131944. /**
  131945. * Intensity of the environment e.g. how much the environment will light the object
  131946. * either through harmonics for rough material or through the refelction for shiny ones.
  131947. */
  131948. protected _environmentIntensity: number;
  131949. /**
  131950. * This is a special control allowing the reduction of the specular highlights coming from the
  131951. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  131952. */
  131953. protected _specularIntensity: number;
  131954. /**
  131955. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  131956. */
  131957. private _lightingInfos;
  131958. /**
  131959. * Debug Control allowing disabling the bump map on this material.
  131960. */
  131961. protected _disableBumpMap: boolean;
  131962. /**
  131963. * AKA Diffuse Texture in standard nomenclature.
  131964. */
  131965. protected _albedoTexture: Nullable<BaseTexture>;
  131966. /**
  131967. * AKA Occlusion Texture in other nomenclature.
  131968. */
  131969. protected _ambientTexture: Nullable<BaseTexture>;
  131970. /**
  131971. * AKA Occlusion Texture Intensity in other nomenclature.
  131972. */
  131973. protected _ambientTextureStrength: number;
  131974. /**
  131975. * Defines how much the AO map is occluding the analytical lights (point spot...).
  131976. * 1 means it completely occludes it
  131977. * 0 mean it has no impact
  131978. */
  131979. protected _ambientTextureImpactOnAnalyticalLights: number;
  131980. /**
  131981. * Stores the alpha values in a texture.
  131982. */
  131983. protected _opacityTexture: Nullable<BaseTexture>;
  131984. /**
  131985. * Stores the reflection values in a texture.
  131986. */
  131987. protected _reflectionTexture: Nullable<BaseTexture>;
  131988. /**
  131989. * Stores the emissive values in a texture.
  131990. */
  131991. protected _emissiveTexture: Nullable<BaseTexture>;
  131992. /**
  131993. * AKA Specular texture in other nomenclature.
  131994. */
  131995. protected _reflectivityTexture: Nullable<BaseTexture>;
  131996. /**
  131997. * Used to switch from specular/glossiness to metallic/roughness workflow.
  131998. */
  131999. protected _metallicTexture: Nullable<BaseTexture>;
  132000. /**
  132001. * Specifies the metallic scalar of the metallic/roughness workflow.
  132002. * Can also be used to scale the metalness values of the metallic texture.
  132003. */
  132004. protected _metallic: Nullable<number>;
  132005. /**
  132006. * Specifies the roughness scalar of the metallic/roughness workflow.
  132007. * Can also be used to scale the roughness values of the metallic texture.
  132008. */
  132009. protected _roughness: Nullable<number>;
  132010. /**
  132011. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132012. * By default the indexOfrefraction is used to compute F0;
  132013. *
  132014. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132015. *
  132016. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132017. * F90 = metallicReflectanceColor;
  132018. */
  132019. protected _metallicF0Factor: number;
  132020. /**
  132021. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132022. * By default the F90 is always 1;
  132023. *
  132024. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132025. *
  132026. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132027. * F90 = metallicReflectanceColor;
  132028. */
  132029. protected _metallicReflectanceColor: Color3;
  132030. /**
  132031. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132032. * This is multiply against the scalar values defined in the material.
  132033. */
  132034. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132035. /**
  132036. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132037. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132038. */
  132039. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132040. /**
  132041. * Stores surface normal data used to displace a mesh in a texture.
  132042. */
  132043. protected _bumpTexture: Nullable<BaseTexture>;
  132044. /**
  132045. * Stores the pre-calculated light information of a mesh in a texture.
  132046. */
  132047. protected _lightmapTexture: Nullable<BaseTexture>;
  132048. /**
  132049. * The color of a material in ambient lighting.
  132050. */
  132051. protected _ambientColor: Color3;
  132052. /**
  132053. * AKA Diffuse Color in other nomenclature.
  132054. */
  132055. protected _albedoColor: Color3;
  132056. /**
  132057. * AKA Specular Color in other nomenclature.
  132058. */
  132059. protected _reflectivityColor: Color3;
  132060. /**
  132061. * The color applied when light is reflected from a material.
  132062. */
  132063. protected _reflectionColor: Color3;
  132064. /**
  132065. * The color applied when light is emitted from a material.
  132066. */
  132067. protected _emissiveColor: Color3;
  132068. /**
  132069. * AKA Glossiness in other nomenclature.
  132070. */
  132071. protected _microSurface: number;
  132072. /**
  132073. * Specifies that the material will use the light map as a show map.
  132074. */
  132075. protected _useLightmapAsShadowmap: boolean;
  132076. /**
  132077. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132078. * makes the reflect vector face the model (under horizon).
  132079. */
  132080. protected _useHorizonOcclusion: boolean;
  132081. /**
  132082. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132083. * too much the area relying on ambient texture to define their ambient occlusion.
  132084. */
  132085. protected _useRadianceOcclusion: boolean;
  132086. /**
  132087. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132088. */
  132089. protected _useAlphaFromAlbedoTexture: boolean;
  132090. /**
  132091. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  132092. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132093. */
  132094. protected _useSpecularOverAlpha: boolean;
  132095. /**
  132096. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132097. */
  132098. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132099. /**
  132100. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132101. */
  132102. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  132103. /**
  132104. * Specifies if the metallic texture contains the roughness information in its green channel.
  132105. */
  132106. protected _useRoughnessFromMetallicTextureGreen: boolean;
  132107. /**
  132108. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132109. */
  132110. protected _useMetallnessFromMetallicTextureBlue: boolean;
  132111. /**
  132112. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132113. */
  132114. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  132115. /**
  132116. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132117. */
  132118. protected _useAmbientInGrayScale: boolean;
  132119. /**
  132120. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132121. * The material will try to infer what glossiness each pixel should be.
  132122. */
  132123. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  132124. /**
  132125. * Defines the falloff type used in this material.
  132126. * It by default is Physical.
  132127. */
  132128. protected _lightFalloff: number;
  132129. /**
  132130. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132131. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132132. */
  132133. protected _useRadianceOverAlpha: boolean;
  132134. /**
  132135. * Allows using an object space normal map (instead of tangent space).
  132136. */
  132137. protected _useObjectSpaceNormalMap: boolean;
  132138. /**
  132139. * Allows using the bump map in parallax mode.
  132140. */
  132141. protected _useParallax: boolean;
  132142. /**
  132143. * Allows using the bump map in parallax occlusion mode.
  132144. */
  132145. protected _useParallaxOcclusion: boolean;
  132146. /**
  132147. * Controls the scale bias of the parallax mode.
  132148. */
  132149. protected _parallaxScaleBias: number;
  132150. /**
  132151. * If sets to true, disables all the lights affecting the material.
  132152. */
  132153. protected _disableLighting: boolean;
  132154. /**
  132155. * Number of Simultaneous lights allowed on the material.
  132156. */
  132157. protected _maxSimultaneousLights: number;
  132158. /**
  132159. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132160. */
  132161. protected _invertNormalMapX: boolean;
  132162. /**
  132163. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132164. */
  132165. protected _invertNormalMapY: boolean;
  132166. /**
  132167. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132168. */
  132169. protected _twoSidedLighting: boolean;
  132170. /**
  132171. * Defines the alpha limits in alpha test mode.
  132172. */
  132173. protected _alphaCutOff: number;
  132174. /**
  132175. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132176. */
  132177. protected _forceAlphaTest: boolean;
  132178. /**
  132179. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132180. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132181. */
  132182. protected _useAlphaFresnel: boolean;
  132183. /**
  132184. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132185. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132186. */
  132187. protected _useLinearAlphaFresnel: boolean;
  132188. /**
  132189. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  132190. * from cos thetav and roughness:
  132191. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  132192. */
  132193. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  132194. /**
  132195. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132196. */
  132197. protected _forceIrradianceInFragment: boolean;
  132198. private _realTimeFiltering;
  132199. /**
  132200. * Enables realtime filtering on the texture.
  132201. */
  132202. get realTimeFiltering(): boolean;
  132203. set realTimeFiltering(b: boolean);
  132204. private _realTimeFilteringQuality;
  132205. /**
  132206. * Quality switch for realtime filtering
  132207. */
  132208. get realTimeFilteringQuality(): number;
  132209. set realTimeFilteringQuality(n: number);
  132210. /**
  132211. * Force normal to face away from face.
  132212. */
  132213. protected _forceNormalForward: boolean;
  132214. /**
  132215. * Enables specular anti aliasing in the PBR shader.
  132216. * It will both interacts on the Geometry for analytical and IBL lighting.
  132217. * It also prefilter the roughness map based on the bump values.
  132218. */
  132219. protected _enableSpecularAntiAliasing: boolean;
  132220. /**
  132221. * Default configuration related to image processing available in the PBR Material.
  132222. */
  132223. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132224. /**
  132225. * Keep track of the image processing observer to allow dispose and replace.
  132226. */
  132227. private _imageProcessingObserver;
  132228. /**
  132229. * Attaches a new image processing configuration to the PBR Material.
  132230. * @param configuration
  132231. */
  132232. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132233. /**
  132234. * Stores the available render targets.
  132235. */
  132236. private _renderTargets;
  132237. /**
  132238. * Sets the global ambient color for the material used in lighting calculations.
  132239. */
  132240. private _globalAmbientColor;
  132241. /**
  132242. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  132243. */
  132244. private _useLogarithmicDepth;
  132245. /**
  132246. * If set to true, no lighting calculations will be applied.
  132247. */
  132248. private _unlit;
  132249. private _debugMode;
  132250. /**
  132251. * @hidden
  132252. * This is reserved for the inspector.
  132253. * Defines the material debug mode.
  132254. * It helps seeing only some components of the material while troubleshooting.
  132255. */
  132256. debugMode: number;
  132257. /**
  132258. * @hidden
  132259. * This is reserved for the inspector.
  132260. * Specify from where on screen the debug mode should start.
  132261. * The value goes from -1 (full screen) to 1 (not visible)
  132262. * It helps with side by side comparison against the final render
  132263. * This defaults to -1
  132264. */
  132265. private debugLimit;
  132266. /**
  132267. * @hidden
  132268. * This is reserved for the inspector.
  132269. * As the default viewing range might not be enough (if the ambient is really small for instance)
  132270. * You can use the factor to better multiply the final value.
  132271. */
  132272. private debugFactor;
  132273. /**
  132274. * Defines the clear coat layer parameters for the material.
  132275. */
  132276. readonly clearCoat: PBRClearCoatConfiguration;
  132277. /**
  132278. * Defines the anisotropic parameters for the material.
  132279. */
  132280. readonly anisotropy: PBRAnisotropicConfiguration;
  132281. /**
  132282. * Defines the BRDF parameters for the material.
  132283. */
  132284. readonly brdf: PBRBRDFConfiguration;
  132285. /**
  132286. * Defines the Sheen parameters for the material.
  132287. */
  132288. readonly sheen: PBRSheenConfiguration;
  132289. /**
  132290. * Defines the SubSurface parameters for the material.
  132291. */
  132292. readonly subSurface: PBRSubSurfaceConfiguration;
  132293. protected _rebuildInParallel: boolean;
  132294. /**
  132295. * Instantiates a new PBRMaterial instance.
  132296. *
  132297. * @param name The material name
  132298. * @param scene The scene the material will be use in.
  132299. */
  132300. constructor(name: string, scene: Scene);
  132301. /**
  132302. * Gets a boolean indicating that current material needs to register RTT
  132303. */
  132304. get hasRenderTargetTextures(): boolean;
  132305. /**
  132306. * Gets the name of the material class.
  132307. */
  132308. getClassName(): string;
  132309. /**
  132310. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132311. */
  132312. get useLogarithmicDepth(): boolean;
  132313. /**
  132314. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132315. */
  132316. set useLogarithmicDepth(value: boolean);
  132317. /**
  132318. * Returns true if alpha blending should be disabled.
  132319. */
  132320. protected get _disableAlphaBlending(): boolean;
  132321. /**
  132322. * Specifies whether or not this material should be rendered in alpha blend mode.
  132323. */
  132324. needAlphaBlending(): boolean;
  132325. /**
  132326. * Specifies whether or not this material should be rendered in alpha test mode.
  132327. */
  132328. needAlphaTesting(): boolean;
  132329. /**
  132330. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  132331. */
  132332. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  132333. /**
  132334. * Gets the texture used for the alpha test.
  132335. */
  132336. getAlphaTestTexture(): Nullable<BaseTexture>;
  132337. /**
  132338. * Specifies that the submesh is ready to be used.
  132339. * @param mesh - BJS mesh.
  132340. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  132341. * @param useInstances - Specifies that instances should be used.
  132342. * @returns - boolean indicating that the submesh is ready or not.
  132343. */
  132344. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132345. /**
  132346. * Specifies if the material uses metallic roughness workflow.
  132347. * @returns boolean specifiying if the material uses metallic roughness workflow.
  132348. */
  132349. isMetallicWorkflow(): boolean;
  132350. private _prepareEffect;
  132351. private _prepareDefines;
  132352. /**
  132353. * Force shader compilation
  132354. */
  132355. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  132356. /**
  132357. * Initializes the uniform buffer layout for the shader.
  132358. */
  132359. buildUniformLayout(): void;
  132360. /**
  132361. * Unbinds the material from the mesh
  132362. */
  132363. unbind(): void;
  132364. /**
  132365. * Binds the submesh data.
  132366. * @param world - The world matrix.
  132367. * @param mesh - The BJS mesh.
  132368. * @param subMesh - A submesh of the BJS mesh.
  132369. */
  132370. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132371. /**
  132372. * Returns the animatable textures.
  132373. * @returns - Array of animatable textures.
  132374. */
  132375. getAnimatables(): IAnimatable[];
  132376. /**
  132377. * Returns the texture used for reflections.
  132378. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  132379. */
  132380. private _getReflectionTexture;
  132381. /**
  132382. * Returns an array of the actively used textures.
  132383. * @returns - Array of BaseTextures
  132384. */
  132385. getActiveTextures(): BaseTexture[];
  132386. /**
  132387. * Checks to see if a texture is used in the material.
  132388. * @param texture - Base texture to use.
  132389. * @returns - Boolean specifying if a texture is used in the material.
  132390. */
  132391. hasTexture(texture: BaseTexture): boolean;
  132392. /**
  132393. * Disposes the resources of the material.
  132394. * @param forceDisposeEffect - Forces the disposal of effects.
  132395. * @param forceDisposeTextures - Forces the disposal of all textures.
  132396. */
  132397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132398. }
  132399. }
  132400. declare module BABYLON {
  132401. /**
  132402. * The Physically based material of BJS.
  132403. *
  132404. * This offers the main features of a standard PBR material.
  132405. * For more information, please refer to the documentation :
  132406. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132407. */
  132408. export class PBRMaterial extends PBRBaseMaterial {
  132409. /**
  132410. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132411. */
  132412. static readonly PBRMATERIAL_OPAQUE: number;
  132413. /**
  132414. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132415. */
  132416. static readonly PBRMATERIAL_ALPHATEST: number;
  132417. /**
  132418. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132419. */
  132420. static readonly PBRMATERIAL_ALPHABLEND: number;
  132421. /**
  132422. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132423. * They are also discarded below the alpha cutoff threshold to improve performances.
  132424. */
  132425. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132426. /**
  132427. * Defines the default value of how much AO map is occluding the analytical lights
  132428. * (point spot...).
  132429. */
  132430. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132431. /**
  132432. * Intensity of the direct lights e.g. the four lights available in your scene.
  132433. * This impacts both the direct diffuse and specular highlights.
  132434. */
  132435. directIntensity: number;
  132436. /**
  132437. * Intensity of the emissive part of the material.
  132438. * This helps controlling the emissive effect without modifying the emissive color.
  132439. */
  132440. emissiveIntensity: number;
  132441. /**
  132442. * Intensity of the environment e.g. how much the environment will light the object
  132443. * either through harmonics for rough material or through the refelction for shiny ones.
  132444. */
  132445. environmentIntensity: number;
  132446. /**
  132447. * This is a special control allowing the reduction of the specular highlights coming from the
  132448. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132449. */
  132450. specularIntensity: number;
  132451. /**
  132452. * Debug Control allowing disabling the bump map on this material.
  132453. */
  132454. disableBumpMap: boolean;
  132455. /**
  132456. * AKA Diffuse Texture in standard nomenclature.
  132457. */
  132458. albedoTexture: BaseTexture;
  132459. /**
  132460. * AKA Occlusion Texture in other nomenclature.
  132461. */
  132462. ambientTexture: BaseTexture;
  132463. /**
  132464. * AKA Occlusion Texture Intensity in other nomenclature.
  132465. */
  132466. ambientTextureStrength: number;
  132467. /**
  132468. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132469. * 1 means it completely occludes it
  132470. * 0 mean it has no impact
  132471. */
  132472. ambientTextureImpactOnAnalyticalLights: number;
  132473. /**
  132474. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  132475. */
  132476. opacityTexture: BaseTexture;
  132477. /**
  132478. * Stores the reflection values in a texture.
  132479. */
  132480. reflectionTexture: Nullable<BaseTexture>;
  132481. /**
  132482. * Stores the emissive values in a texture.
  132483. */
  132484. emissiveTexture: BaseTexture;
  132485. /**
  132486. * AKA Specular texture in other nomenclature.
  132487. */
  132488. reflectivityTexture: BaseTexture;
  132489. /**
  132490. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132491. */
  132492. metallicTexture: BaseTexture;
  132493. /**
  132494. * Specifies the metallic scalar of the metallic/roughness workflow.
  132495. * Can also be used to scale the metalness values of the metallic texture.
  132496. */
  132497. metallic: Nullable<number>;
  132498. /**
  132499. * Specifies the roughness scalar of the metallic/roughness workflow.
  132500. * Can also be used to scale the roughness values of the metallic texture.
  132501. */
  132502. roughness: Nullable<number>;
  132503. /**
  132504. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132505. * By default the indexOfrefraction is used to compute F0;
  132506. *
  132507. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132508. *
  132509. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132510. * F90 = metallicReflectanceColor;
  132511. */
  132512. metallicF0Factor: number;
  132513. /**
  132514. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132515. * By default the F90 is always 1;
  132516. *
  132517. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132518. *
  132519. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132520. * F90 = metallicReflectanceColor;
  132521. */
  132522. metallicReflectanceColor: Color3;
  132523. /**
  132524. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132525. * This is multiply against the scalar values defined in the material.
  132526. */
  132527. metallicReflectanceTexture: Nullable<BaseTexture>;
  132528. /**
  132529. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132530. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132531. */
  132532. microSurfaceTexture: BaseTexture;
  132533. /**
  132534. * Stores surface normal data used to displace a mesh in a texture.
  132535. */
  132536. bumpTexture: BaseTexture;
  132537. /**
  132538. * Stores the pre-calculated light information of a mesh in a texture.
  132539. */
  132540. lightmapTexture: BaseTexture;
  132541. /**
  132542. * Stores the refracted light information in a texture.
  132543. */
  132544. get refractionTexture(): Nullable<BaseTexture>;
  132545. set refractionTexture(value: Nullable<BaseTexture>);
  132546. /**
  132547. * The color of a material in ambient lighting.
  132548. */
  132549. ambientColor: Color3;
  132550. /**
  132551. * AKA Diffuse Color in other nomenclature.
  132552. */
  132553. albedoColor: Color3;
  132554. /**
  132555. * AKA Specular Color in other nomenclature.
  132556. */
  132557. reflectivityColor: Color3;
  132558. /**
  132559. * The color reflected from the material.
  132560. */
  132561. reflectionColor: Color3;
  132562. /**
  132563. * The color emitted from the material.
  132564. */
  132565. emissiveColor: Color3;
  132566. /**
  132567. * AKA Glossiness in other nomenclature.
  132568. */
  132569. microSurface: number;
  132570. /**
  132571. * Index of refraction of the material base layer.
  132572. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132573. *
  132574. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132575. *
  132576. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132577. */
  132578. get indexOfRefraction(): number;
  132579. set indexOfRefraction(value: number);
  132580. /**
  132581. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132582. */
  132583. get invertRefractionY(): boolean;
  132584. set invertRefractionY(value: boolean);
  132585. /**
  132586. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132587. * Materials half opaque for instance using refraction could benefit from this control.
  132588. */
  132589. get linkRefractionWithTransparency(): boolean;
  132590. set linkRefractionWithTransparency(value: boolean);
  132591. /**
  132592. * If true, the light map contains occlusion information instead of lighting info.
  132593. */
  132594. useLightmapAsShadowmap: boolean;
  132595. /**
  132596. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132597. */
  132598. useAlphaFromAlbedoTexture: boolean;
  132599. /**
  132600. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132601. */
  132602. forceAlphaTest: boolean;
  132603. /**
  132604. * Defines the alpha limits in alpha test mode.
  132605. */
  132606. alphaCutOff: number;
  132607. /**
  132608. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  132609. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132610. */
  132611. useSpecularOverAlpha: boolean;
  132612. /**
  132613. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132614. */
  132615. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132616. /**
  132617. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132618. */
  132619. useRoughnessFromMetallicTextureAlpha: boolean;
  132620. /**
  132621. * Specifies if the metallic texture contains the roughness information in its green channel.
  132622. */
  132623. useRoughnessFromMetallicTextureGreen: boolean;
  132624. /**
  132625. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132626. */
  132627. useMetallnessFromMetallicTextureBlue: boolean;
  132628. /**
  132629. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132630. */
  132631. useAmbientOcclusionFromMetallicTextureRed: boolean;
  132632. /**
  132633. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132634. */
  132635. useAmbientInGrayScale: boolean;
  132636. /**
  132637. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132638. * The material will try to infer what glossiness each pixel should be.
  132639. */
  132640. useAutoMicroSurfaceFromReflectivityMap: boolean;
  132641. /**
  132642. * BJS is using an harcoded light falloff based on a manually sets up range.
  132643. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132644. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132645. */
  132646. get usePhysicalLightFalloff(): boolean;
  132647. /**
  132648. * BJS is using an harcoded light falloff based on a manually sets up range.
  132649. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132650. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132651. */
  132652. set usePhysicalLightFalloff(value: boolean);
  132653. /**
  132654. * In order to support the falloff compatibility with gltf, a special mode has been added
  132655. * to reproduce the gltf light falloff.
  132656. */
  132657. get useGLTFLightFalloff(): boolean;
  132658. /**
  132659. * In order to support the falloff compatibility with gltf, a special mode has been added
  132660. * to reproduce the gltf light falloff.
  132661. */
  132662. set useGLTFLightFalloff(value: boolean);
  132663. /**
  132664. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132665. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132666. */
  132667. useRadianceOverAlpha: boolean;
  132668. /**
  132669. * Allows using an object space normal map (instead of tangent space).
  132670. */
  132671. useObjectSpaceNormalMap: boolean;
  132672. /**
  132673. * Allows using the bump map in parallax mode.
  132674. */
  132675. useParallax: boolean;
  132676. /**
  132677. * Allows using the bump map in parallax occlusion mode.
  132678. */
  132679. useParallaxOcclusion: boolean;
  132680. /**
  132681. * Controls the scale bias of the parallax mode.
  132682. */
  132683. parallaxScaleBias: number;
  132684. /**
  132685. * If sets to true, disables all the lights affecting the material.
  132686. */
  132687. disableLighting: boolean;
  132688. /**
  132689. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132690. */
  132691. forceIrradianceInFragment: boolean;
  132692. /**
  132693. * Number of Simultaneous lights allowed on the material.
  132694. */
  132695. maxSimultaneousLights: number;
  132696. /**
  132697. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132698. */
  132699. invertNormalMapX: boolean;
  132700. /**
  132701. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132702. */
  132703. invertNormalMapY: boolean;
  132704. /**
  132705. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132706. */
  132707. twoSidedLighting: boolean;
  132708. /**
  132709. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132710. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132711. */
  132712. useAlphaFresnel: boolean;
  132713. /**
  132714. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132715. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132716. */
  132717. useLinearAlphaFresnel: boolean;
  132718. /**
  132719. * Let user defines the brdf lookup texture used for IBL.
  132720. * A default 8bit version is embedded but you could point at :
  132721. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  132722. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  132723. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  132724. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  132725. */
  132726. environmentBRDFTexture: Nullable<BaseTexture>;
  132727. /**
  132728. * Force normal to face away from face.
  132729. */
  132730. forceNormalForward: boolean;
  132731. /**
  132732. * Enables specular anti aliasing in the PBR shader.
  132733. * It will both interacts on the Geometry for analytical and IBL lighting.
  132734. * It also prefilter the roughness map based on the bump values.
  132735. */
  132736. enableSpecularAntiAliasing: boolean;
  132737. /**
  132738. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132739. * makes the reflect vector face the model (under horizon).
  132740. */
  132741. useHorizonOcclusion: boolean;
  132742. /**
  132743. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132744. * too much the area relying on ambient texture to define their ambient occlusion.
  132745. */
  132746. useRadianceOcclusion: boolean;
  132747. /**
  132748. * If set to true, no lighting calculations will be applied.
  132749. */
  132750. unlit: boolean;
  132751. /**
  132752. * Gets the image processing configuration used either in this material.
  132753. */
  132754. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  132755. /**
  132756. * Sets the Default image processing configuration used either in the this material.
  132757. *
  132758. * If sets to null, the scene one is in use.
  132759. */
  132760. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  132761. /**
  132762. * Gets wether the color curves effect is enabled.
  132763. */
  132764. get cameraColorCurvesEnabled(): boolean;
  132765. /**
  132766. * Sets wether the color curves effect is enabled.
  132767. */
  132768. set cameraColorCurvesEnabled(value: boolean);
  132769. /**
  132770. * Gets wether the color grading effect is enabled.
  132771. */
  132772. get cameraColorGradingEnabled(): boolean;
  132773. /**
  132774. * Gets wether the color grading effect is enabled.
  132775. */
  132776. set cameraColorGradingEnabled(value: boolean);
  132777. /**
  132778. * Gets wether tonemapping is enabled or not.
  132779. */
  132780. get cameraToneMappingEnabled(): boolean;
  132781. /**
  132782. * Sets wether tonemapping is enabled or not
  132783. */
  132784. set cameraToneMappingEnabled(value: boolean);
  132785. /**
  132786. * The camera exposure used on this material.
  132787. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132788. * This corresponds to a photographic exposure.
  132789. */
  132790. get cameraExposure(): number;
  132791. /**
  132792. * The camera exposure used on this material.
  132793. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132794. * This corresponds to a photographic exposure.
  132795. */
  132796. set cameraExposure(value: number);
  132797. /**
  132798. * Gets The camera contrast used on this material.
  132799. */
  132800. get cameraContrast(): number;
  132801. /**
  132802. * Sets The camera contrast used on this material.
  132803. */
  132804. set cameraContrast(value: number);
  132805. /**
  132806. * Gets the Color Grading 2D Lookup Texture.
  132807. */
  132808. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132809. /**
  132810. * Sets the Color Grading 2D Lookup Texture.
  132811. */
  132812. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132813. /**
  132814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132816. * 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;
  132817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132818. */
  132819. get cameraColorCurves(): Nullable<ColorCurves>;
  132820. /**
  132821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132823. * 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;
  132824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132825. */
  132826. set cameraColorCurves(value: Nullable<ColorCurves>);
  132827. /**
  132828. * Instantiates a new PBRMaterial instance.
  132829. *
  132830. * @param name The material name
  132831. * @param scene The scene the material will be use in.
  132832. */
  132833. constructor(name: string, scene: Scene);
  132834. /**
  132835. * Returns the name of this material class.
  132836. */
  132837. getClassName(): string;
  132838. /**
  132839. * Makes a duplicate of the current material.
  132840. * @param name - name to use for the new material.
  132841. */
  132842. clone(name: string): PBRMaterial;
  132843. /**
  132844. * Serializes this PBR Material.
  132845. * @returns - An object with the serialized material.
  132846. */
  132847. serialize(): any;
  132848. /**
  132849. * Parses a PBR Material from a serialized object.
  132850. * @param source - Serialized object.
  132851. * @param scene - BJS scene instance.
  132852. * @param rootUrl - url for the scene object
  132853. * @returns - PBRMaterial
  132854. */
  132855. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  132856. }
  132857. }
  132858. declare module BABYLON {
  132859. /**
  132860. * Direct draw surface info
  132861. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  132862. */
  132863. export interface DDSInfo {
  132864. /**
  132865. * Width of the texture
  132866. */
  132867. width: number;
  132868. /**
  132869. * Width of the texture
  132870. */
  132871. height: number;
  132872. /**
  132873. * Number of Mipmaps for the texture
  132874. * @see https://en.wikipedia.org/wiki/Mipmap
  132875. */
  132876. mipmapCount: number;
  132877. /**
  132878. * If the textures format is a known fourCC format
  132879. * @see https://www.fourcc.org/
  132880. */
  132881. isFourCC: boolean;
  132882. /**
  132883. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  132884. */
  132885. isRGB: boolean;
  132886. /**
  132887. * If the texture is a lumincance format
  132888. */
  132889. isLuminance: boolean;
  132890. /**
  132891. * If this is a cube texture
  132892. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  132893. */
  132894. isCube: boolean;
  132895. /**
  132896. * If the texture is a compressed format eg. FOURCC_DXT1
  132897. */
  132898. isCompressed: boolean;
  132899. /**
  132900. * The dxgiFormat of the texture
  132901. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  132902. */
  132903. dxgiFormat: number;
  132904. /**
  132905. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  132906. */
  132907. textureType: number;
  132908. /**
  132909. * Sphericle polynomial created for the dds texture
  132910. */
  132911. sphericalPolynomial?: SphericalPolynomial;
  132912. }
  132913. /**
  132914. * Class used to provide DDS decompression tools
  132915. */
  132916. export class DDSTools {
  132917. /**
  132918. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  132919. */
  132920. static StoreLODInAlphaChannel: boolean;
  132921. /**
  132922. * Gets DDS information from an array buffer
  132923. * @param data defines the array buffer view to read data from
  132924. * @returns the DDS information
  132925. */
  132926. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  132927. private static _FloatView;
  132928. private static _Int32View;
  132929. private static _ToHalfFloat;
  132930. private static _FromHalfFloat;
  132931. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  132932. private static _GetHalfFloatRGBAArrayBuffer;
  132933. private static _GetFloatRGBAArrayBuffer;
  132934. private static _GetFloatAsUIntRGBAArrayBuffer;
  132935. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  132936. private static _GetRGBAArrayBuffer;
  132937. private static _ExtractLongWordOrder;
  132938. private static _GetRGBArrayBuffer;
  132939. private static _GetLuminanceArrayBuffer;
  132940. /**
  132941. * Uploads DDS Levels to a Babylon Texture
  132942. * @hidden
  132943. */
  132944. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  132945. }
  132946. interface ThinEngine {
  132947. /**
  132948. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  132949. * @param rootUrl defines the url where the file to load is located
  132950. * @param scene defines the current scene
  132951. * @param lodScale defines scale to apply to the mip map selection
  132952. * @param lodOffset defines offset to apply to the mip map selection
  132953. * @param onLoad defines an optional callback raised when the texture is loaded
  132954. * @param onError defines an optional callback raised if there is an issue to load the texture
  132955. * @param format defines the format of the data
  132956. * @param forcedExtension defines the extension to use to pick the right loader
  132957. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  132958. * @returns the cube texture as an InternalTexture
  132959. */
  132960. 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;
  132961. }
  132962. }
  132963. declare module BABYLON {
  132964. /**
  132965. * Implementation of the DDS Texture Loader.
  132966. * @hidden
  132967. */
  132968. export class _DDSTextureLoader implements IInternalTextureLoader {
  132969. /**
  132970. * Defines wether the loader supports cascade loading the different faces.
  132971. */
  132972. readonly supportCascades: boolean;
  132973. /**
  132974. * This returns if the loader support the current file information.
  132975. * @param extension defines the file extension of the file being loaded
  132976. * @returns true if the loader can load the specified file
  132977. */
  132978. canLoad(extension: string): boolean;
  132979. /**
  132980. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132981. * @param data contains the texture data
  132982. * @param texture defines the BabylonJS internal texture
  132983. * @param createPolynomials will be true if polynomials have been requested
  132984. * @param onLoad defines the callback to trigger once the texture is ready
  132985. * @param onError defines the callback to trigger in case of error
  132986. */
  132987. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132988. /**
  132989. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132990. * @param data contains the texture data
  132991. * @param texture defines the BabylonJS internal texture
  132992. * @param callback defines the method to call once ready to upload
  132993. */
  132994. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132995. }
  132996. }
  132997. declare module BABYLON {
  132998. /**
  132999. * Implementation of the ENV Texture Loader.
  133000. * @hidden
  133001. */
  133002. export class _ENVTextureLoader implements IInternalTextureLoader {
  133003. /**
  133004. * Defines wether the loader supports cascade loading the different faces.
  133005. */
  133006. readonly supportCascades: boolean;
  133007. /**
  133008. * This returns if the loader support the current file information.
  133009. * @param extension defines the file extension of the file being loaded
  133010. * @returns true if the loader can load the specified file
  133011. */
  133012. canLoad(extension: string): boolean;
  133013. /**
  133014. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133015. * @param data contains the texture data
  133016. * @param texture defines the BabylonJS internal texture
  133017. * @param createPolynomials will be true if polynomials have been requested
  133018. * @param onLoad defines the callback to trigger once the texture is ready
  133019. * @param onError defines the callback to trigger in case of error
  133020. */
  133021. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133022. /**
  133023. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133024. * @param data contains the texture data
  133025. * @param texture defines the BabylonJS internal texture
  133026. * @param callback defines the method to call once ready to upload
  133027. */
  133028. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133029. }
  133030. }
  133031. declare module BABYLON {
  133032. /**
  133033. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133034. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133035. */
  133036. export class KhronosTextureContainer {
  133037. /** contents of the KTX container file */
  133038. data: ArrayBufferView;
  133039. private static HEADER_LEN;
  133040. private static COMPRESSED_2D;
  133041. private static COMPRESSED_3D;
  133042. private static TEX_2D;
  133043. private static TEX_3D;
  133044. /**
  133045. * Gets the openGL type
  133046. */
  133047. glType: number;
  133048. /**
  133049. * Gets the openGL type size
  133050. */
  133051. glTypeSize: number;
  133052. /**
  133053. * Gets the openGL format
  133054. */
  133055. glFormat: number;
  133056. /**
  133057. * Gets the openGL internal format
  133058. */
  133059. glInternalFormat: number;
  133060. /**
  133061. * Gets the base internal format
  133062. */
  133063. glBaseInternalFormat: number;
  133064. /**
  133065. * Gets image width in pixel
  133066. */
  133067. pixelWidth: number;
  133068. /**
  133069. * Gets image height in pixel
  133070. */
  133071. pixelHeight: number;
  133072. /**
  133073. * Gets image depth in pixels
  133074. */
  133075. pixelDepth: number;
  133076. /**
  133077. * Gets the number of array elements
  133078. */
  133079. numberOfArrayElements: number;
  133080. /**
  133081. * Gets the number of faces
  133082. */
  133083. numberOfFaces: number;
  133084. /**
  133085. * Gets the number of mipmap levels
  133086. */
  133087. numberOfMipmapLevels: number;
  133088. /**
  133089. * Gets the bytes of key value data
  133090. */
  133091. bytesOfKeyValueData: number;
  133092. /**
  133093. * Gets the load type
  133094. */
  133095. loadType: number;
  133096. /**
  133097. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  133098. */
  133099. isInvalid: boolean;
  133100. /**
  133101. * Creates a new KhronosTextureContainer
  133102. * @param data contents of the KTX container file
  133103. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  133104. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  133105. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  133106. */
  133107. constructor(
  133108. /** contents of the KTX container file */
  133109. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  133110. /**
  133111. * Uploads KTX content to a Babylon Texture.
  133112. * It is assumed that the texture has already been created & is currently bound
  133113. * @hidden
  133114. */
  133115. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  133116. private _upload2DCompressedLevels;
  133117. /**
  133118. * Checks if the given data starts with a KTX file identifier.
  133119. * @param data the data to check
  133120. * @returns true if the data is a KTX file or false otherwise
  133121. */
  133122. static IsValid(data: ArrayBufferView): boolean;
  133123. }
  133124. }
  133125. declare module BABYLON {
  133126. /**
  133127. * Class for loading KTX2 files
  133128. * !!! Experimental Extension Subject to Changes !!!
  133129. * @hidden
  133130. */
  133131. export class KhronosTextureContainer2 {
  133132. private static _ModulePromise;
  133133. private static _TranscodeFormat;
  133134. constructor(engine: ThinEngine);
  133135. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  133136. private _determineTranscodeFormat;
  133137. /**
  133138. * Checks if the given data starts with a KTX2 file identifier.
  133139. * @param data the data to check
  133140. * @returns true if the data is a KTX2 file or false otherwise
  133141. */
  133142. static IsValid(data: ArrayBufferView): boolean;
  133143. }
  133144. }
  133145. declare module BABYLON {
  133146. /**
  133147. * Implementation of the KTX Texture Loader.
  133148. * @hidden
  133149. */
  133150. export class _KTXTextureLoader implements IInternalTextureLoader {
  133151. /**
  133152. * Defines wether the loader supports cascade loading the different faces.
  133153. */
  133154. readonly supportCascades: boolean;
  133155. /**
  133156. * This returns if the loader support the current file information.
  133157. * @param extension defines the file extension of the file being loaded
  133158. * @returns true if the loader can load the specified file
  133159. */
  133160. canLoad(extension: string): boolean;
  133161. /**
  133162. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133163. * @param data contains the texture data
  133164. * @param texture defines the BabylonJS internal texture
  133165. * @param createPolynomials will be true if polynomials have been requested
  133166. * @param onLoad defines the callback to trigger once the texture is ready
  133167. * @param onError defines the callback to trigger in case of error
  133168. */
  133169. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133170. /**
  133171. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133172. * @param data contains the texture data
  133173. * @param texture defines the BabylonJS internal texture
  133174. * @param callback defines the method to call once ready to upload
  133175. */
  133176. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  133177. }
  133178. }
  133179. declare module BABYLON {
  133180. /** @hidden */
  133181. export var _forceSceneHelpersToBundle: boolean;
  133182. interface Scene {
  133183. /**
  133184. * Creates a default light for the scene.
  133185. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  133186. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  133187. */
  133188. createDefaultLight(replace?: boolean): void;
  133189. /**
  133190. * Creates a default camera for the scene.
  133191. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  133192. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133193. * @param replace has default false, when true replaces the active camera in the scene
  133194. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  133195. */
  133196. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133197. /**
  133198. * Creates a default camera and a default light.
  133199. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  133200. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133201. * @param replace has the default false, when true replaces the active camera/light in the scene
  133202. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  133203. */
  133204. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133205. /**
  133206. * Creates a new sky box
  133207. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  133208. * @param environmentTexture defines the texture to use as environment texture
  133209. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  133210. * @param scale defines the overall scale of the skybox
  133211. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  133212. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  133213. * @returns a new mesh holding the sky box
  133214. */
  133215. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  133216. /**
  133217. * Creates a new environment
  133218. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  133219. * @param options defines the options you can use to configure the environment
  133220. * @returns the new EnvironmentHelper
  133221. */
  133222. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  133223. /**
  133224. * Creates a new VREXperienceHelper
  133225. * @see http://doc.babylonjs.com/how_to/webvr_helper
  133226. * @param webVROptions defines the options used to create the new VREXperienceHelper
  133227. * @returns a new VREXperienceHelper
  133228. */
  133229. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  133230. /**
  133231. * Creates a new WebXRDefaultExperience
  133232. * @see http://doc.babylonjs.com/how_to/webxr
  133233. * @param options experience options
  133234. * @returns a promise for a new WebXRDefaultExperience
  133235. */
  133236. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133237. }
  133238. }
  133239. declare module BABYLON {
  133240. /**
  133241. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  133242. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  133243. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  133244. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133245. */
  133246. export class VideoDome extends TransformNode {
  133247. /**
  133248. * Define the video source as a Monoscopic panoramic 360 video.
  133249. */
  133250. static readonly MODE_MONOSCOPIC: number;
  133251. /**
  133252. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133253. */
  133254. static readonly MODE_TOPBOTTOM: number;
  133255. /**
  133256. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133257. */
  133258. static readonly MODE_SIDEBYSIDE: number;
  133259. private _halfDome;
  133260. private _useDirectMapping;
  133261. /**
  133262. * The video texture being displayed on the sphere
  133263. */
  133264. protected _videoTexture: VideoTexture;
  133265. /**
  133266. * Gets the video texture being displayed on the sphere
  133267. */
  133268. get videoTexture(): VideoTexture;
  133269. /**
  133270. * The skybox material
  133271. */
  133272. protected _material: BackgroundMaterial;
  133273. /**
  133274. * The surface used for the skybox
  133275. */
  133276. protected _mesh: Mesh;
  133277. /**
  133278. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  133279. */
  133280. private _halfDomeMask;
  133281. /**
  133282. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133283. * Also see the options.resolution property.
  133284. */
  133285. get fovMultiplier(): number;
  133286. set fovMultiplier(value: number);
  133287. private _videoMode;
  133288. /**
  133289. * Gets or set the current video mode for the video. It can be:
  133290. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  133291. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133292. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133293. */
  133294. get videoMode(): number;
  133295. set videoMode(value: number);
  133296. /**
  133297. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  133298. *
  133299. */
  133300. get halfDome(): boolean;
  133301. /**
  133302. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  133303. */
  133304. set halfDome(enabled: boolean);
  133305. /**
  133306. * Oberserver used in Stereoscopic VR Mode.
  133307. */
  133308. private _onBeforeCameraRenderObserver;
  133309. /**
  133310. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  133311. * @param name Element's name, child elements will append suffixes for their own names.
  133312. * @param urlsOrVideo defines the url(s) or the video element to use
  133313. * @param options An object containing optional or exposed sub element properties
  133314. */
  133315. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  133316. resolution?: number;
  133317. clickToPlay?: boolean;
  133318. autoPlay?: boolean;
  133319. loop?: boolean;
  133320. size?: number;
  133321. poster?: string;
  133322. faceForward?: boolean;
  133323. useDirectMapping?: boolean;
  133324. halfDomeMode?: boolean;
  133325. }, scene: Scene);
  133326. private _changeVideoMode;
  133327. /**
  133328. * Releases resources associated with this node.
  133329. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133330. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133331. */
  133332. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133333. }
  133334. }
  133335. declare module BABYLON {
  133336. /**
  133337. * This class can be used to get instrumentation data from a Babylon engine
  133338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133339. */
  133340. export class EngineInstrumentation implements IDisposable {
  133341. /**
  133342. * Define the instrumented engine.
  133343. */
  133344. engine: Engine;
  133345. private _captureGPUFrameTime;
  133346. private _gpuFrameTimeToken;
  133347. private _gpuFrameTime;
  133348. private _captureShaderCompilationTime;
  133349. private _shaderCompilationTime;
  133350. private _onBeginFrameObserver;
  133351. private _onEndFrameObserver;
  133352. private _onBeforeShaderCompilationObserver;
  133353. private _onAfterShaderCompilationObserver;
  133354. /**
  133355. * Gets the perf counter used for GPU frame time
  133356. */
  133357. get gpuFrameTimeCounter(): PerfCounter;
  133358. /**
  133359. * Gets the GPU frame time capture status
  133360. */
  133361. get captureGPUFrameTime(): boolean;
  133362. /**
  133363. * Enable or disable the GPU frame time capture
  133364. */
  133365. set captureGPUFrameTime(value: boolean);
  133366. /**
  133367. * Gets the perf counter used for shader compilation time
  133368. */
  133369. get shaderCompilationTimeCounter(): PerfCounter;
  133370. /**
  133371. * Gets the shader compilation time capture status
  133372. */
  133373. get captureShaderCompilationTime(): boolean;
  133374. /**
  133375. * Enable or disable the shader compilation time capture
  133376. */
  133377. set captureShaderCompilationTime(value: boolean);
  133378. /**
  133379. * Instantiates a new engine instrumentation.
  133380. * This class can be used to get instrumentation data from a Babylon engine
  133381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133382. * @param engine Defines the engine to instrument
  133383. */
  133384. constructor(
  133385. /**
  133386. * Define the instrumented engine.
  133387. */
  133388. engine: Engine);
  133389. /**
  133390. * Dispose and release associated resources.
  133391. */
  133392. dispose(): void;
  133393. }
  133394. }
  133395. declare module BABYLON {
  133396. /**
  133397. * This class can be used to get instrumentation data from a Babylon engine
  133398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133399. */
  133400. export class SceneInstrumentation implements IDisposable {
  133401. /**
  133402. * Defines the scene to instrument
  133403. */
  133404. scene: Scene;
  133405. private _captureActiveMeshesEvaluationTime;
  133406. private _activeMeshesEvaluationTime;
  133407. private _captureRenderTargetsRenderTime;
  133408. private _renderTargetsRenderTime;
  133409. private _captureFrameTime;
  133410. private _frameTime;
  133411. private _captureRenderTime;
  133412. private _renderTime;
  133413. private _captureInterFrameTime;
  133414. private _interFrameTime;
  133415. private _captureParticlesRenderTime;
  133416. private _particlesRenderTime;
  133417. private _captureSpritesRenderTime;
  133418. private _spritesRenderTime;
  133419. private _capturePhysicsTime;
  133420. private _physicsTime;
  133421. private _captureAnimationsTime;
  133422. private _animationsTime;
  133423. private _captureCameraRenderTime;
  133424. private _cameraRenderTime;
  133425. private _onBeforeActiveMeshesEvaluationObserver;
  133426. private _onAfterActiveMeshesEvaluationObserver;
  133427. private _onBeforeRenderTargetsRenderObserver;
  133428. private _onAfterRenderTargetsRenderObserver;
  133429. private _onAfterRenderObserver;
  133430. private _onBeforeDrawPhaseObserver;
  133431. private _onAfterDrawPhaseObserver;
  133432. private _onBeforeAnimationsObserver;
  133433. private _onBeforeParticlesRenderingObserver;
  133434. private _onAfterParticlesRenderingObserver;
  133435. private _onBeforeSpritesRenderingObserver;
  133436. private _onAfterSpritesRenderingObserver;
  133437. private _onBeforePhysicsObserver;
  133438. private _onAfterPhysicsObserver;
  133439. private _onAfterAnimationsObserver;
  133440. private _onBeforeCameraRenderObserver;
  133441. private _onAfterCameraRenderObserver;
  133442. /**
  133443. * Gets the perf counter used for active meshes evaluation time
  133444. */
  133445. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  133446. /**
  133447. * Gets the active meshes evaluation time capture status
  133448. */
  133449. get captureActiveMeshesEvaluationTime(): boolean;
  133450. /**
  133451. * Enable or disable the active meshes evaluation time capture
  133452. */
  133453. set captureActiveMeshesEvaluationTime(value: boolean);
  133454. /**
  133455. * Gets the perf counter used for render targets render time
  133456. */
  133457. get renderTargetsRenderTimeCounter(): PerfCounter;
  133458. /**
  133459. * Gets the render targets render time capture status
  133460. */
  133461. get captureRenderTargetsRenderTime(): boolean;
  133462. /**
  133463. * Enable or disable the render targets render time capture
  133464. */
  133465. set captureRenderTargetsRenderTime(value: boolean);
  133466. /**
  133467. * Gets the perf counter used for particles render time
  133468. */
  133469. get particlesRenderTimeCounter(): PerfCounter;
  133470. /**
  133471. * Gets the particles render time capture status
  133472. */
  133473. get captureParticlesRenderTime(): boolean;
  133474. /**
  133475. * Enable or disable the particles render time capture
  133476. */
  133477. set captureParticlesRenderTime(value: boolean);
  133478. /**
  133479. * Gets the perf counter used for sprites render time
  133480. */
  133481. get spritesRenderTimeCounter(): PerfCounter;
  133482. /**
  133483. * Gets the sprites render time capture status
  133484. */
  133485. get captureSpritesRenderTime(): boolean;
  133486. /**
  133487. * Enable or disable the sprites render time capture
  133488. */
  133489. set captureSpritesRenderTime(value: boolean);
  133490. /**
  133491. * Gets the perf counter used for physics time
  133492. */
  133493. get physicsTimeCounter(): PerfCounter;
  133494. /**
  133495. * Gets the physics time capture status
  133496. */
  133497. get capturePhysicsTime(): boolean;
  133498. /**
  133499. * Enable or disable the physics time capture
  133500. */
  133501. set capturePhysicsTime(value: boolean);
  133502. /**
  133503. * Gets the perf counter used for animations time
  133504. */
  133505. get animationsTimeCounter(): PerfCounter;
  133506. /**
  133507. * Gets the animations time capture status
  133508. */
  133509. get captureAnimationsTime(): boolean;
  133510. /**
  133511. * Enable or disable the animations time capture
  133512. */
  133513. set captureAnimationsTime(value: boolean);
  133514. /**
  133515. * Gets the perf counter used for frame time capture
  133516. */
  133517. get frameTimeCounter(): PerfCounter;
  133518. /**
  133519. * Gets the frame time capture status
  133520. */
  133521. get captureFrameTime(): boolean;
  133522. /**
  133523. * Enable or disable the frame time capture
  133524. */
  133525. set captureFrameTime(value: boolean);
  133526. /**
  133527. * Gets the perf counter used for inter-frames time capture
  133528. */
  133529. get interFrameTimeCounter(): PerfCounter;
  133530. /**
  133531. * Gets the inter-frames time capture status
  133532. */
  133533. get captureInterFrameTime(): boolean;
  133534. /**
  133535. * Enable or disable the inter-frames time capture
  133536. */
  133537. set captureInterFrameTime(value: boolean);
  133538. /**
  133539. * Gets the perf counter used for render time capture
  133540. */
  133541. get renderTimeCounter(): PerfCounter;
  133542. /**
  133543. * Gets the render time capture status
  133544. */
  133545. get captureRenderTime(): boolean;
  133546. /**
  133547. * Enable or disable the render time capture
  133548. */
  133549. set captureRenderTime(value: boolean);
  133550. /**
  133551. * Gets the perf counter used for camera render time capture
  133552. */
  133553. get cameraRenderTimeCounter(): PerfCounter;
  133554. /**
  133555. * Gets the camera render time capture status
  133556. */
  133557. get captureCameraRenderTime(): boolean;
  133558. /**
  133559. * Enable or disable the camera render time capture
  133560. */
  133561. set captureCameraRenderTime(value: boolean);
  133562. /**
  133563. * Gets the perf counter used for draw calls
  133564. */
  133565. get drawCallsCounter(): PerfCounter;
  133566. /**
  133567. * Instantiates a new scene instrumentation.
  133568. * This class can be used to get instrumentation data from a Babylon engine
  133569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133570. * @param scene Defines the scene to instrument
  133571. */
  133572. constructor(
  133573. /**
  133574. * Defines the scene to instrument
  133575. */
  133576. scene: Scene);
  133577. /**
  133578. * Dispose and release associated resources.
  133579. */
  133580. dispose(): void;
  133581. }
  133582. }
  133583. declare module BABYLON {
  133584. /** @hidden */
  133585. export var glowMapGenerationPixelShader: {
  133586. name: string;
  133587. shader: string;
  133588. };
  133589. }
  133590. declare module BABYLON {
  133591. /** @hidden */
  133592. export var glowMapGenerationVertexShader: {
  133593. name: string;
  133594. shader: string;
  133595. };
  133596. }
  133597. declare module BABYLON {
  133598. /**
  133599. * Effect layer options. This helps customizing the behaviour
  133600. * of the effect layer.
  133601. */
  133602. export interface IEffectLayerOptions {
  133603. /**
  133604. * Multiplication factor apply to the canvas size to compute the render target size
  133605. * used to generated the objects (the smaller the faster).
  133606. */
  133607. mainTextureRatio: number;
  133608. /**
  133609. * Enforces a fixed size texture to ensure effect stability across devices.
  133610. */
  133611. mainTextureFixedSize?: number;
  133612. /**
  133613. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  133614. */
  133615. alphaBlendingMode: number;
  133616. /**
  133617. * The camera attached to the layer.
  133618. */
  133619. camera: Nullable<Camera>;
  133620. /**
  133621. * The rendering group to draw the layer in.
  133622. */
  133623. renderingGroupId: number;
  133624. }
  133625. /**
  133626. * The effect layer Helps adding post process effect blended with the main pass.
  133627. *
  133628. * This can be for instance use to generate glow or higlight effects on the scene.
  133629. *
  133630. * The effect layer class can not be used directly and is intented to inherited from to be
  133631. * customized per effects.
  133632. */
  133633. export abstract class EffectLayer {
  133634. private _vertexBuffers;
  133635. private _indexBuffer;
  133636. private _cachedDefines;
  133637. private _effectLayerMapGenerationEffect;
  133638. private _effectLayerOptions;
  133639. private _mergeEffect;
  133640. protected _scene: Scene;
  133641. protected _engine: Engine;
  133642. protected _maxSize: number;
  133643. protected _mainTextureDesiredSize: ISize;
  133644. protected _mainTexture: RenderTargetTexture;
  133645. protected _shouldRender: boolean;
  133646. protected _postProcesses: PostProcess[];
  133647. protected _textures: BaseTexture[];
  133648. protected _emissiveTextureAndColor: {
  133649. texture: Nullable<BaseTexture>;
  133650. color: Color4;
  133651. };
  133652. /**
  133653. * The name of the layer
  133654. */
  133655. name: string;
  133656. /**
  133657. * The clear color of the texture used to generate the glow map.
  133658. */
  133659. neutralColor: Color4;
  133660. /**
  133661. * Specifies whether the highlight layer is enabled or not.
  133662. */
  133663. isEnabled: boolean;
  133664. /**
  133665. * Gets the camera attached to the layer.
  133666. */
  133667. get camera(): Nullable<Camera>;
  133668. /**
  133669. * Gets the rendering group id the layer should render in.
  133670. */
  133671. get renderingGroupId(): number;
  133672. set renderingGroupId(renderingGroupId: number);
  133673. /**
  133674. * An event triggered when the effect layer has been disposed.
  133675. */
  133676. onDisposeObservable: Observable<EffectLayer>;
  133677. /**
  133678. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  133679. */
  133680. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  133681. /**
  133682. * An event triggered when the generated texture is being merged in the scene.
  133683. */
  133684. onBeforeComposeObservable: Observable<EffectLayer>;
  133685. /**
  133686. * An event triggered when the mesh is rendered into the effect render target.
  133687. */
  133688. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  133689. /**
  133690. * An event triggered after the mesh has been rendered into the effect render target.
  133691. */
  133692. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  133693. /**
  133694. * An event triggered when the generated texture has been merged in the scene.
  133695. */
  133696. onAfterComposeObservable: Observable<EffectLayer>;
  133697. /**
  133698. * An event triggered when the efffect layer changes its size.
  133699. */
  133700. onSizeChangedObservable: Observable<EffectLayer>;
  133701. /** @hidden */
  133702. static _SceneComponentInitialization: (scene: Scene) => void;
  133703. /**
  133704. * Instantiates a new effect Layer and references it in the scene.
  133705. * @param name The name of the layer
  133706. * @param scene The scene to use the layer in
  133707. */
  133708. constructor(
  133709. /** The Friendly of the effect in the scene */
  133710. name: string, scene: Scene);
  133711. /**
  133712. * Get the effect name of the layer.
  133713. * @return The effect name
  133714. */
  133715. abstract getEffectName(): string;
  133716. /**
  133717. * Checks for the readiness of the element composing the layer.
  133718. * @param subMesh the mesh to check for
  133719. * @param useInstances specify whether or not to use instances to render the mesh
  133720. * @return true if ready otherwise, false
  133721. */
  133722. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133723. /**
  133724. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133725. * @returns true if the effect requires stencil during the main canvas render pass.
  133726. */
  133727. abstract needStencil(): boolean;
  133728. /**
  133729. * Create the merge effect. This is the shader use to blit the information back
  133730. * to the main canvas at the end of the scene rendering.
  133731. * @returns The effect containing the shader used to merge the effect on the main canvas
  133732. */
  133733. protected abstract _createMergeEffect(): Effect;
  133734. /**
  133735. * Creates the render target textures and post processes used in the effect layer.
  133736. */
  133737. protected abstract _createTextureAndPostProcesses(): void;
  133738. /**
  133739. * Implementation specific of rendering the generating effect on the main canvas.
  133740. * @param effect The effect used to render through
  133741. */
  133742. protected abstract _internalRender(effect: Effect): void;
  133743. /**
  133744. * Sets the required values for both the emissive texture and and the main color.
  133745. */
  133746. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133747. /**
  133748. * Free any resources and references associated to a mesh.
  133749. * Internal use
  133750. * @param mesh The mesh to free.
  133751. */
  133752. abstract _disposeMesh(mesh: Mesh): void;
  133753. /**
  133754. * Serializes this layer (Glow or Highlight for example)
  133755. * @returns a serialized layer object
  133756. */
  133757. abstract serialize?(): any;
  133758. /**
  133759. * Initializes the effect layer with the required options.
  133760. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  133761. */
  133762. protected _init(options: Partial<IEffectLayerOptions>): void;
  133763. /**
  133764. * Generates the index buffer of the full screen quad blending to the main canvas.
  133765. */
  133766. private _generateIndexBuffer;
  133767. /**
  133768. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  133769. */
  133770. private _generateVertexBuffer;
  133771. /**
  133772. * Sets the main texture desired size which is the closest power of two
  133773. * of the engine canvas size.
  133774. */
  133775. private _setMainTextureSize;
  133776. /**
  133777. * Creates the main texture for the effect layer.
  133778. */
  133779. protected _createMainTexture(): void;
  133780. /**
  133781. * Adds specific effects defines.
  133782. * @param defines The defines to add specifics to.
  133783. */
  133784. protected _addCustomEffectDefines(defines: string[]): void;
  133785. /**
  133786. * Checks for the readiness of the element composing the layer.
  133787. * @param subMesh the mesh to check for
  133788. * @param useInstances specify whether or not to use instances to render the mesh
  133789. * @param emissiveTexture the associated emissive texture used to generate the glow
  133790. * @return true if ready otherwise, false
  133791. */
  133792. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  133793. /**
  133794. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  133795. */
  133796. render(): void;
  133797. /**
  133798. * Determine if a given mesh will be used in the current effect.
  133799. * @param mesh mesh to test
  133800. * @returns true if the mesh will be used
  133801. */
  133802. hasMesh(mesh: AbstractMesh): boolean;
  133803. /**
  133804. * Returns true if the layer contains information to display, otherwise false.
  133805. * @returns true if the glow layer should be rendered
  133806. */
  133807. shouldRender(): boolean;
  133808. /**
  133809. * Returns true if the mesh should render, otherwise false.
  133810. * @param mesh The mesh to render
  133811. * @returns true if it should render otherwise false
  133812. */
  133813. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  133814. /**
  133815. * Returns true if the mesh can be rendered, otherwise false.
  133816. * @param mesh The mesh to render
  133817. * @param material The material used on the mesh
  133818. * @returns true if it can be rendered otherwise false
  133819. */
  133820. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133821. /**
  133822. * Returns true if the mesh should render, otherwise false.
  133823. * @param mesh The mesh to render
  133824. * @returns true if it should render otherwise false
  133825. */
  133826. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  133827. /**
  133828. * Renders the submesh passed in parameter to the generation map.
  133829. */
  133830. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  133831. /**
  133832. * Defines whether the current material of the mesh should be use to render the effect.
  133833. * @param mesh defines the current mesh to render
  133834. */
  133835. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133836. /**
  133837. * Rebuild the required buffers.
  133838. * @hidden Internal use only.
  133839. */
  133840. _rebuild(): void;
  133841. /**
  133842. * Dispose only the render target textures and post process.
  133843. */
  133844. private _disposeTextureAndPostProcesses;
  133845. /**
  133846. * Dispose the highlight layer and free resources.
  133847. */
  133848. dispose(): void;
  133849. /**
  133850. * Gets the class name of the effect layer
  133851. * @returns the string with the class name of the effect layer
  133852. */
  133853. getClassName(): string;
  133854. /**
  133855. * Creates an effect layer from parsed effect layer data
  133856. * @param parsedEffectLayer defines effect layer data
  133857. * @param scene defines the current scene
  133858. * @param rootUrl defines the root URL containing the effect layer information
  133859. * @returns a parsed effect Layer
  133860. */
  133861. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  133862. }
  133863. }
  133864. declare module BABYLON {
  133865. interface AbstractScene {
  133866. /**
  133867. * The list of effect layers (highlights/glow) added to the scene
  133868. * @see http://doc.babylonjs.com/how_to/highlight_layer
  133869. * @see http://doc.babylonjs.com/how_to/glow_layer
  133870. */
  133871. effectLayers: Array<EffectLayer>;
  133872. /**
  133873. * Removes the given effect layer from this scene.
  133874. * @param toRemove defines the effect layer to remove
  133875. * @returns the index of the removed effect layer
  133876. */
  133877. removeEffectLayer(toRemove: EffectLayer): number;
  133878. /**
  133879. * Adds the given effect layer to this scene
  133880. * @param newEffectLayer defines the effect layer to add
  133881. */
  133882. addEffectLayer(newEffectLayer: EffectLayer): void;
  133883. }
  133884. /**
  133885. * Defines the layer scene component responsible to manage any effect layers
  133886. * in a given scene.
  133887. */
  133888. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  133889. /**
  133890. * The component name helpfull to identify the component in the list of scene components.
  133891. */
  133892. readonly name: string;
  133893. /**
  133894. * The scene the component belongs to.
  133895. */
  133896. scene: Scene;
  133897. private _engine;
  133898. private _renderEffects;
  133899. private _needStencil;
  133900. private _previousStencilState;
  133901. /**
  133902. * Creates a new instance of the component for the given scene
  133903. * @param scene Defines the scene to register the component in
  133904. */
  133905. constructor(scene: Scene);
  133906. /**
  133907. * Registers the component in a given scene
  133908. */
  133909. register(): void;
  133910. /**
  133911. * Rebuilds the elements related to this component in case of
  133912. * context lost for instance.
  133913. */
  133914. rebuild(): void;
  133915. /**
  133916. * Serializes the component data to the specified json object
  133917. * @param serializationObject The object to serialize to
  133918. */
  133919. serialize(serializationObject: any): void;
  133920. /**
  133921. * Adds all the elements from the container to the scene
  133922. * @param container the container holding the elements
  133923. */
  133924. addFromContainer(container: AbstractScene): void;
  133925. /**
  133926. * Removes all the elements in the container from the scene
  133927. * @param container contains the elements to remove
  133928. * @param dispose if the removed element should be disposed (default: false)
  133929. */
  133930. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133931. /**
  133932. * Disposes the component and the associated ressources.
  133933. */
  133934. dispose(): void;
  133935. private _isReadyForMesh;
  133936. private _renderMainTexture;
  133937. private _setStencil;
  133938. private _setStencilBack;
  133939. private _draw;
  133940. private _drawCamera;
  133941. private _drawRenderingGroup;
  133942. }
  133943. }
  133944. declare module BABYLON {
  133945. /** @hidden */
  133946. export var glowMapMergePixelShader: {
  133947. name: string;
  133948. shader: string;
  133949. };
  133950. }
  133951. declare module BABYLON {
  133952. /** @hidden */
  133953. export var glowMapMergeVertexShader: {
  133954. name: string;
  133955. shader: string;
  133956. };
  133957. }
  133958. declare module BABYLON {
  133959. interface AbstractScene {
  133960. /**
  133961. * Return a the first highlight layer of the scene with a given name.
  133962. * @param name The name of the highlight layer to look for.
  133963. * @return The highlight layer if found otherwise null.
  133964. */
  133965. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  133966. }
  133967. /**
  133968. * Glow layer options. This helps customizing the behaviour
  133969. * of the glow layer.
  133970. */
  133971. export interface IGlowLayerOptions {
  133972. /**
  133973. * Multiplication factor apply to the canvas size to compute the render target size
  133974. * used to generated the glowing objects (the smaller the faster).
  133975. */
  133976. mainTextureRatio: number;
  133977. /**
  133978. * Enforces a fixed size texture to ensure resize independant blur.
  133979. */
  133980. mainTextureFixedSize?: number;
  133981. /**
  133982. * How big is the kernel of the blur texture.
  133983. */
  133984. blurKernelSize: number;
  133985. /**
  133986. * The camera attached to the layer.
  133987. */
  133988. camera: Nullable<Camera>;
  133989. /**
  133990. * Enable MSAA by chosing the number of samples.
  133991. */
  133992. mainTextureSamples?: number;
  133993. /**
  133994. * The rendering group to draw the layer in.
  133995. */
  133996. renderingGroupId: number;
  133997. }
  133998. /**
  133999. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  134000. *
  134001. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  134002. *
  134003. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  134004. */
  134005. export class GlowLayer extends EffectLayer {
  134006. /**
  134007. * Effect Name of the layer.
  134008. */
  134009. static readonly EffectName: string;
  134010. /**
  134011. * The default blur kernel size used for the glow.
  134012. */
  134013. static DefaultBlurKernelSize: number;
  134014. /**
  134015. * The default texture size ratio used for the glow.
  134016. */
  134017. static DefaultTextureRatio: number;
  134018. /**
  134019. * Sets the kernel size of the blur.
  134020. */
  134021. set blurKernelSize(value: number);
  134022. /**
  134023. * Gets the kernel size of the blur.
  134024. */
  134025. get blurKernelSize(): number;
  134026. /**
  134027. * Sets the glow intensity.
  134028. */
  134029. set intensity(value: number);
  134030. /**
  134031. * Gets the glow intensity.
  134032. */
  134033. get intensity(): number;
  134034. private _options;
  134035. private _intensity;
  134036. private _horizontalBlurPostprocess1;
  134037. private _verticalBlurPostprocess1;
  134038. private _horizontalBlurPostprocess2;
  134039. private _verticalBlurPostprocess2;
  134040. private _blurTexture1;
  134041. private _blurTexture2;
  134042. private _postProcesses1;
  134043. private _postProcesses2;
  134044. private _includedOnlyMeshes;
  134045. private _excludedMeshes;
  134046. private _meshesUsingTheirOwnMaterials;
  134047. /**
  134048. * Callback used to let the user override the color selection on a per mesh basis
  134049. */
  134050. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134051. /**
  134052. * Callback used to let the user override the texture selection on a per mesh basis
  134053. */
  134054. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134055. /**
  134056. * Instantiates a new glow Layer and references it to the scene.
  134057. * @param name The name of the layer
  134058. * @param scene The scene to use the layer in
  134059. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  134060. */
  134061. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  134062. /**
  134063. * Get the effect name of the layer.
  134064. * @return The effect name
  134065. */
  134066. getEffectName(): string;
  134067. /**
  134068. * Create the merge effect. This is the shader use to blit the information back
  134069. * to the main canvas at the end of the scene rendering.
  134070. */
  134071. protected _createMergeEffect(): Effect;
  134072. /**
  134073. * Creates the render target textures and post processes used in the glow layer.
  134074. */
  134075. protected _createTextureAndPostProcesses(): void;
  134076. /**
  134077. * Checks for the readiness of the element composing the layer.
  134078. * @param subMesh the mesh to check for
  134079. * @param useInstances specify wether or not to use instances to render the mesh
  134080. * @param emissiveTexture the associated emissive texture used to generate the glow
  134081. * @return true if ready otherwise, false
  134082. */
  134083. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134084. /**
  134085. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134086. */
  134087. needStencil(): boolean;
  134088. /**
  134089. * Returns true if the mesh can be rendered, otherwise false.
  134090. * @param mesh The mesh to render
  134091. * @param material The material used on the mesh
  134092. * @returns true if it can be rendered otherwise false
  134093. */
  134094. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134095. /**
  134096. * Implementation specific of rendering the generating effect on the main canvas.
  134097. * @param effect The effect used to render through
  134098. */
  134099. protected _internalRender(effect: Effect): void;
  134100. /**
  134101. * Sets the required values for both the emissive texture and and the main color.
  134102. */
  134103. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134104. /**
  134105. * Returns true if the mesh should render, otherwise false.
  134106. * @param mesh The mesh to render
  134107. * @returns true if it should render otherwise false
  134108. */
  134109. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134110. /**
  134111. * Adds specific effects defines.
  134112. * @param defines The defines to add specifics to.
  134113. */
  134114. protected _addCustomEffectDefines(defines: string[]): void;
  134115. /**
  134116. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  134117. * @param mesh The mesh to exclude from the glow layer
  134118. */
  134119. addExcludedMesh(mesh: Mesh): void;
  134120. /**
  134121. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  134122. * @param mesh The mesh to remove
  134123. */
  134124. removeExcludedMesh(mesh: Mesh): void;
  134125. /**
  134126. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  134127. * @param mesh The mesh to include in the glow layer
  134128. */
  134129. addIncludedOnlyMesh(mesh: Mesh): void;
  134130. /**
  134131. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  134132. * @param mesh The mesh to remove
  134133. */
  134134. removeIncludedOnlyMesh(mesh: Mesh): void;
  134135. /**
  134136. * Determine if a given mesh will be used in the glow layer
  134137. * @param mesh The mesh to test
  134138. * @returns true if the mesh will be highlighted by the current glow layer
  134139. */
  134140. hasMesh(mesh: AbstractMesh): boolean;
  134141. /**
  134142. * Defines whether the current material of the mesh should be use to render the effect.
  134143. * @param mesh defines the current mesh to render
  134144. */
  134145. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134146. /**
  134147. * Add a mesh to be rendered through its own material and not with emissive only.
  134148. * @param mesh The mesh for which we need to use its material
  134149. */
  134150. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  134151. /**
  134152. * Remove a mesh from being rendered through its own material and not with emissive only.
  134153. * @param mesh The mesh for which we need to not use its material
  134154. */
  134155. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  134156. /**
  134157. * Free any resources and references associated to a mesh.
  134158. * Internal use
  134159. * @param mesh The mesh to free.
  134160. * @hidden
  134161. */
  134162. _disposeMesh(mesh: Mesh): void;
  134163. /**
  134164. * Gets the class name of the effect layer
  134165. * @returns the string with the class name of the effect layer
  134166. */
  134167. getClassName(): string;
  134168. /**
  134169. * Serializes this glow layer
  134170. * @returns a serialized glow layer object
  134171. */
  134172. serialize(): any;
  134173. /**
  134174. * Creates a Glow Layer from parsed glow layer data
  134175. * @param parsedGlowLayer defines glow layer data
  134176. * @param scene defines the current scene
  134177. * @param rootUrl defines the root URL containing the glow layer information
  134178. * @returns a parsed Glow Layer
  134179. */
  134180. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  134181. }
  134182. }
  134183. declare module BABYLON {
  134184. /** @hidden */
  134185. export var glowBlurPostProcessPixelShader: {
  134186. name: string;
  134187. shader: string;
  134188. };
  134189. }
  134190. declare module BABYLON {
  134191. interface AbstractScene {
  134192. /**
  134193. * Return a the first highlight layer of the scene with a given name.
  134194. * @param name The name of the highlight layer to look for.
  134195. * @return The highlight layer if found otherwise null.
  134196. */
  134197. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  134198. }
  134199. /**
  134200. * Highlight layer options. This helps customizing the behaviour
  134201. * of the highlight layer.
  134202. */
  134203. export interface IHighlightLayerOptions {
  134204. /**
  134205. * Multiplication factor apply to the canvas size to compute the render target size
  134206. * used to generated the glowing objects (the smaller the faster).
  134207. */
  134208. mainTextureRatio: number;
  134209. /**
  134210. * Enforces a fixed size texture to ensure resize independant blur.
  134211. */
  134212. mainTextureFixedSize?: number;
  134213. /**
  134214. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  134215. * of the picture to blur (the smaller the faster).
  134216. */
  134217. blurTextureSizeRatio: number;
  134218. /**
  134219. * How big in texel of the blur texture is the vertical blur.
  134220. */
  134221. blurVerticalSize: number;
  134222. /**
  134223. * How big in texel of the blur texture is the horizontal blur.
  134224. */
  134225. blurHorizontalSize: number;
  134226. /**
  134227. * Alpha blending mode used to apply the blur. Default is combine.
  134228. */
  134229. alphaBlendingMode: number;
  134230. /**
  134231. * The camera attached to the layer.
  134232. */
  134233. camera: Nullable<Camera>;
  134234. /**
  134235. * Should we display highlight as a solid stroke?
  134236. */
  134237. isStroke?: boolean;
  134238. /**
  134239. * The rendering group to draw the layer in.
  134240. */
  134241. renderingGroupId: number;
  134242. }
  134243. /**
  134244. * The highlight layer Helps adding a glow effect around a mesh.
  134245. *
  134246. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  134247. * glowy meshes to your scene.
  134248. *
  134249. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  134250. */
  134251. export class HighlightLayer extends EffectLayer {
  134252. name: string;
  134253. /**
  134254. * Effect Name of the highlight layer.
  134255. */
  134256. static readonly EffectName: string;
  134257. /**
  134258. * The neutral color used during the preparation of the glow effect.
  134259. * This is black by default as the blend operation is a blend operation.
  134260. */
  134261. static NeutralColor: Color4;
  134262. /**
  134263. * Stencil value used for glowing meshes.
  134264. */
  134265. static GlowingMeshStencilReference: number;
  134266. /**
  134267. * Stencil value used for the other meshes in the scene.
  134268. */
  134269. static NormalMeshStencilReference: number;
  134270. /**
  134271. * Specifies whether or not the inner glow is ACTIVE in the layer.
  134272. */
  134273. innerGlow: boolean;
  134274. /**
  134275. * Specifies whether or not the outer glow is ACTIVE in the layer.
  134276. */
  134277. outerGlow: boolean;
  134278. /**
  134279. * Specifies the horizontal size of the blur.
  134280. */
  134281. set blurHorizontalSize(value: number);
  134282. /**
  134283. * Specifies the vertical size of the blur.
  134284. */
  134285. set blurVerticalSize(value: number);
  134286. /**
  134287. * Gets the horizontal size of the blur.
  134288. */
  134289. get blurHorizontalSize(): number;
  134290. /**
  134291. * Gets the vertical size of the blur.
  134292. */
  134293. get blurVerticalSize(): number;
  134294. /**
  134295. * An event triggered when the highlight layer is being blurred.
  134296. */
  134297. onBeforeBlurObservable: Observable<HighlightLayer>;
  134298. /**
  134299. * An event triggered when the highlight layer has been blurred.
  134300. */
  134301. onAfterBlurObservable: Observable<HighlightLayer>;
  134302. private _instanceGlowingMeshStencilReference;
  134303. private _options;
  134304. private _downSamplePostprocess;
  134305. private _horizontalBlurPostprocess;
  134306. private _verticalBlurPostprocess;
  134307. private _blurTexture;
  134308. private _meshes;
  134309. private _excludedMeshes;
  134310. /**
  134311. * Instantiates a new highlight Layer and references it to the scene..
  134312. * @param name The name of the layer
  134313. * @param scene The scene to use the layer in
  134314. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  134315. */
  134316. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  134317. /**
  134318. * Get the effect name of the layer.
  134319. * @return The effect name
  134320. */
  134321. getEffectName(): string;
  134322. /**
  134323. * Create the merge effect. This is the shader use to blit the information back
  134324. * to the main canvas at the end of the scene rendering.
  134325. */
  134326. protected _createMergeEffect(): Effect;
  134327. /**
  134328. * Creates the render target textures and post processes used in the highlight layer.
  134329. */
  134330. protected _createTextureAndPostProcesses(): void;
  134331. /**
  134332. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  134333. */
  134334. needStencil(): boolean;
  134335. /**
  134336. * Checks for the readiness of the element composing the layer.
  134337. * @param subMesh the mesh to check for
  134338. * @param useInstances specify wether or not to use instances to render the mesh
  134339. * @param emissiveTexture the associated emissive texture used to generate the glow
  134340. * @return true if ready otherwise, false
  134341. */
  134342. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134343. /**
  134344. * Implementation specific of rendering the generating effect on the main canvas.
  134345. * @param effect The effect used to render through
  134346. */
  134347. protected _internalRender(effect: Effect): void;
  134348. /**
  134349. * Returns true if the layer contains information to display, otherwise false.
  134350. */
  134351. shouldRender(): boolean;
  134352. /**
  134353. * Returns true if the mesh should render, otherwise false.
  134354. * @param mesh The mesh to render
  134355. * @returns true if it should render otherwise false
  134356. */
  134357. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134358. /**
  134359. * Adds specific effects defines.
  134360. * @param defines The defines to add specifics to.
  134361. */
  134362. protected _addCustomEffectDefines(defines: string[]): void;
  134363. /**
  134364. * Sets the required values for both the emissive texture and and the main color.
  134365. */
  134366. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134367. /**
  134368. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  134369. * @param mesh The mesh to exclude from the highlight layer
  134370. */
  134371. addExcludedMesh(mesh: Mesh): void;
  134372. /**
  134373. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  134374. * @param mesh The mesh to highlight
  134375. */
  134376. removeExcludedMesh(mesh: Mesh): void;
  134377. /**
  134378. * Determine if a given mesh will be highlighted by the current HighlightLayer
  134379. * @param mesh mesh to test
  134380. * @returns true if the mesh will be highlighted by the current HighlightLayer
  134381. */
  134382. hasMesh(mesh: AbstractMesh): boolean;
  134383. /**
  134384. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  134385. * @param mesh The mesh to highlight
  134386. * @param color The color of the highlight
  134387. * @param glowEmissiveOnly Extract the glow from the emissive texture
  134388. */
  134389. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  134390. /**
  134391. * Remove a mesh from the highlight layer in order to make it stop glowing.
  134392. * @param mesh The mesh to highlight
  134393. */
  134394. removeMesh(mesh: Mesh): void;
  134395. /**
  134396. * Remove all the meshes currently referenced in the highlight layer
  134397. */
  134398. removeAllMeshes(): void;
  134399. /**
  134400. * Force the stencil to the normal expected value for none glowing parts
  134401. */
  134402. private _defaultStencilReference;
  134403. /**
  134404. * Free any resources and references associated to a mesh.
  134405. * Internal use
  134406. * @param mesh The mesh to free.
  134407. * @hidden
  134408. */
  134409. _disposeMesh(mesh: Mesh): void;
  134410. /**
  134411. * Dispose the highlight layer and free resources.
  134412. */
  134413. dispose(): void;
  134414. /**
  134415. * Gets the class name of the effect layer
  134416. * @returns the string with the class name of the effect layer
  134417. */
  134418. getClassName(): string;
  134419. /**
  134420. * Serializes this Highlight layer
  134421. * @returns a serialized Highlight layer object
  134422. */
  134423. serialize(): any;
  134424. /**
  134425. * Creates a Highlight layer from parsed Highlight layer data
  134426. * @param parsedHightlightLayer defines the Highlight layer data
  134427. * @param scene defines the current scene
  134428. * @param rootUrl defines the root URL containing the Highlight layer information
  134429. * @returns a parsed Highlight layer
  134430. */
  134431. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  134432. }
  134433. }
  134434. declare module BABYLON {
  134435. interface AbstractScene {
  134436. /**
  134437. * The list of layers (background and foreground) of the scene
  134438. */
  134439. layers: Array<Layer>;
  134440. }
  134441. /**
  134442. * Defines the layer scene component responsible to manage any layers
  134443. * in a given scene.
  134444. */
  134445. export class LayerSceneComponent implements ISceneComponent {
  134446. /**
  134447. * The component name helpfull to identify the component in the list of scene components.
  134448. */
  134449. readonly name: string;
  134450. /**
  134451. * The scene the component belongs to.
  134452. */
  134453. scene: Scene;
  134454. private _engine;
  134455. /**
  134456. * Creates a new instance of the component for the given scene
  134457. * @param scene Defines the scene to register the component in
  134458. */
  134459. constructor(scene: Scene);
  134460. /**
  134461. * Registers the component in a given scene
  134462. */
  134463. register(): void;
  134464. /**
  134465. * Rebuilds the elements related to this component in case of
  134466. * context lost for instance.
  134467. */
  134468. rebuild(): void;
  134469. /**
  134470. * Disposes the component and the associated ressources.
  134471. */
  134472. dispose(): void;
  134473. private _draw;
  134474. private _drawCameraPredicate;
  134475. private _drawCameraBackground;
  134476. private _drawCameraForeground;
  134477. private _drawRenderTargetPredicate;
  134478. private _drawRenderTargetBackground;
  134479. private _drawRenderTargetForeground;
  134480. /**
  134481. * Adds all the elements from the container to the scene
  134482. * @param container the container holding the elements
  134483. */
  134484. addFromContainer(container: AbstractScene): void;
  134485. /**
  134486. * Removes all the elements in the container from the scene
  134487. * @param container contains the elements to remove
  134488. * @param dispose if the removed element should be disposed (default: false)
  134489. */
  134490. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134491. }
  134492. }
  134493. declare module BABYLON {
  134494. /** @hidden */
  134495. export var layerPixelShader: {
  134496. name: string;
  134497. shader: string;
  134498. };
  134499. }
  134500. declare module BABYLON {
  134501. /** @hidden */
  134502. export var layerVertexShader: {
  134503. name: string;
  134504. shader: string;
  134505. };
  134506. }
  134507. declare module BABYLON {
  134508. /**
  134509. * This represents a full screen 2d layer.
  134510. * This can be useful to display a picture in the background of your scene for instance.
  134511. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134512. */
  134513. export class Layer {
  134514. /**
  134515. * Define the name of the layer.
  134516. */
  134517. name: string;
  134518. /**
  134519. * Define the texture the layer should display.
  134520. */
  134521. texture: Nullable<Texture>;
  134522. /**
  134523. * Is the layer in background or foreground.
  134524. */
  134525. isBackground: boolean;
  134526. /**
  134527. * Define the color of the layer (instead of texture).
  134528. */
  134529. color: Color4;
  134530. /**
  134531. * Define the scale of the layer in order to zoom in out of the texture.
  134532. */
  134533. scale: Vector2;
  134534. /**
  134535. * Define an offset for the layer in order to shift the texture.
  134536. */
  134537. offset: Vector2;
  134538. /**
  134539. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  134540. */
  134541. alphaBlendingMode: number;
  134542. /**
  134543. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  134544. * Alpha test will not mix with the background color in case of transparency.
  134545. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  134546. */
  134547. alphaTest: boolean;
  134548. /**
  134549. * Define a mask to restrict the layer to only some of the scene cameras.
  134550. */
  134551. layerMask: number;
  134552. /**
  134553. * Define the list of render target the layer is visible into.
  134554. */
  134555. renderTargetTextures: RenderTargetTexture[];
  134556. /**
  134557. * Define if the layer is only used in renderTarget or if it also
  134558. * renders in the main frame buffer of the canvas.
  134559. */
  134560. renderOnlyInRenderTargetTextures: boolean;
  134561. private _scene;
  134562. private _vertexBuffers;
  134563. private _indexBuffer;
  134564. private _effect;
  134565. private _previousDefines;
  134566. /**
  134567. * An event triggered when the layer is disposed.
  134568. */
  134569. onDisposeObservable: Observable<Layer>;
  134570. private _onDisposeObserver;
  134571. /**
  134572. * Back compatibility with callback before the onDisposeObservable existed.
  134573. * The set callback will be triggered when the layer has been disposed.
  134574. */
  134575. set onDispose(callback: () => void);
  134576. /**
  134577. * An event triggered before rendering the scene
  134578. */
  134579. onBeforeRenderObservable: Observable<Layer>;
  134580. private _onBeforeRenderObserver;
  134581. /**
  134582. * Back compatibility with callback before the onBeforeRenderObservable existed.
  134583. * The set callback will be triggered just before rendering the layer.
  134584. */
  134585. set onBeforeRender(callback: () => void);
  134586. /**
  134587. * An event triggered after rendering the scene
  134588. */
  134589. onAfterRenderObservable: Observable<Layer>;
  134590. private _onAfterRenderObserver;
  134591. /**
  134592. * Back compatibility with callback before the onAfterRenderObservable existed.
  134593. * The set callback will be triggered just after rendering the layer.
  134594. */
  134595. set onAfterRender(callback: () => void);
  134596. /**
  134597. * Instantiates a new layer.
  134598. * This represents a full screen 2d layer.
  134599. * This can be useful to display a picture in the background of your scene for instance.
  134600. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134601. * @param name Define the name of the layer in the scene
  134602. * @param imgUrl Define the url of the texture to display in the layer
  134603. * @param scene Define the scene the layer belongs to
  134604. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  134605. * @param color Defines a color for the layer
  134606. */
  134607. constructor(
  134608. /**
  134609. * Define the name of the layer.
  134610. */
  134611. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  134612. private _createIndexBuffer;
  134613. /** @hidden */
  134614. _rebuild(): void;
  134615. /**
  134616. * Renders the layer in the scene.
  134617. */
  134618. render(): void;
  134619. /**
  134620. * Disposes and releases the associated ressources.
  134621. */
  134622. dispose(): void;
  134623. }
  134624. }
  134625. declare module BABYLON {
  134626. /** @hidden */
  134627. export var lensFlarePixelShader: {
  134628. name: string;
  134629. shader: string;
  134630. };
  134631. }
  134632. declare module BABYLON {
  134633. /** @hidden */
  134634. export var lensFlareVertexShader: {
  134635. name: string;
  134636. shader: string;
  134637. };
  134638. }
  134639. declare module BABYLON {
  134640. /**
  134641. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134642. * It is usually composed of several `lensFlare`.
  134643. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134644. */
  134645. export class LensFlareSystem {
  134646. /**
  134647. * Define the name of the lens flare system
  134648. */
  134649. name: string;
  134650. /**
  134651. * List of lens flares used in this system.
  134652. */
  134653. lensFlares: LensFlare[];
  134654. /**
  134655. * Define a limit from the border the lens flare can be visible.
  134656. */
  134657. borderLimit: number;
  134658. /**
  134659. * Define a viewport border we do not want to see the lens flare in.
  134660. */
  134661. viewportBorder: number;
  134662. /**
  134663. * Define a predicate which could limit the list of meshes able to occlude the effect.
  134664. */
  134665. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134666. /**
  134667. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  134668. */
  134669. layerMask: number;
  134670. /**
  134671. * Define the id of the lens flare system in the scene.
  134672. * (equal to name by default)
  134673. */
  134674. id: string;
  134675. private _scene;
  134676. private _emitter;
  134677. private _vertexBuffers;
  134678. private _indexBuffer;
  134679. private _effect;
  134680. private _positionX;
  134681. private _positionY;
  134682. private _isEnabled;
  134683. /** @hidden */
  134684. static _SceneComponentInitialization: (scene: Scene) => void;
  134685. /**
  134686. * Instantiates a lens flare system.
  134687. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134688. * It is usually composed of several `lensFlare`.
  134689. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134690. * @param name Define the name of the lens flare system in the scene
  134691. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  134692. * @param scene Define the scene the lens flare system belongs to
  134693. */
  134694. constructor(
  134695. /**
  134696. * Define the name of the lens flare system
  134697. */
  134698. name: string, emitter: any, scene: Scene);
  134699. /**
  134700. * Define if the lens flare system is enabled.
  134701. */
  134702. get isEnabled(): boolean;
  134703. set isEnabled(value: boolean);
  134704. /**
  134705. * Get the scene the effects belongs to.
  134706. * @returns the scene holding the lens flare system
  134707. */
  134708. getScene(): Scene;
  134709. /**
  134710. * Get the emitter of the lens flare system.
  134711. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134712. * @returns the emitter of the lens flare system
  134713. */
  134714. getEmitter(): any;
  134715. /**
  134716. * Set the emitter of the lens flare system.
  134717. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134718. * @param newEmitter Define the new emitter of the system
  134719. */
  134720. setEmitter(newEmitter: any): void;
  134721. /**
  134722. * Get the lens flare system emitter position.
  134723. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  134724. * @returns the position
  134725. */
  134726. getEmitterPosition(): Vector3;
  134727. /**
  134728. * @hidden
  134729. */
  134730. computeEffectivePosition(globalViewport: Viewport): boolean;
  134731. /** @hidden */
  134732. _isVisible(): boolean;
  134733. /**
  134734. * @hidden
  134735. */
  134736. render(): boolean;
  134737. /**
  134738. * Dispose and release the lens flare with its associated resources.
  134739. */
  134740. dispose(): void;
  134741. /**
  134742. * Parse a lens flare system from a JSON repressentation
  134743. * @param parsedLensFlareSystem Define the JSON to parse
  134744. * @param scene Define the scene the parsed system should be instantiated in
  134745. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  134746. * @returns the parsed system
  134747. */
  134748. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  134749. /**
  134750. * Serialize the current Lens Flare System into a JSON representation.
  134751. * @returns the serialized JSON
  134752. */
  134753. serialize(): any;
  134754. }
  134755. }
  134756. declare module BABYLON {
  134757. /**
  134758. * This represents one of the lens effect in a `lensFlareSystem`.
  134759. * It controls one of the indiviual texture used in the effect.
  134760. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134761. */
  134762. export class LensFlare {
  134763. /**
  134764. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134765. */
  134766. size: number;
  134767. /**
  134768. * 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.
  134769. */
  134770. position: number;
  134771. /**
  134772. * Define the lens color.
  134773. */
  134774. color: Color3;
  134775. /**
  134776. * Define the lens texture.
  134777. */
  134778. texture: Nullable<Texture>;
  134779. /**
  134780. * Define the alpha mode to render this particular lens.
  134781. */
  134782. alphaMode: number;
  134783. private _system;
  134784. /**
  134785. * Creates a new Lens Flare.
  134786. * This represents one of the lens effect in a `lensFlareSystem`.
  134787. * It controls one of the indiviual texture used in the effect.
  134788. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134789. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  134790. * @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.
  134791. * @param color Define the lens color
  134792. * @param imgUrl Define the lens texture url
  134793. * @param system Define the `lensFlareSystem` this flare is part of
  134794. * @returns The newly created Lens Flare
  134795. */
  134796. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  134797. /**
  134798. * Instantiates a new Lens Flare.
  134799. * This represents one of the lens effect in a `lensFlareSystem`.
  134800. * It controls one of the indiviual texture used in the effect.
  134801. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134802. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  134803. * @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.
  134804. * @param color Define the lens color
  134805. * @param imgUrl Define the lens texture url
  134806. * @param system Define the `lensFlareSystem` this flare is part of
  134807. */
  134808. constructor(
  134809. /**
  134810. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134811. */
  134812. size: number,
  134813. /**
  134814. * 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.
  134815. */
  134816. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  134817. /**
  134818. * Dispose and release the lens flare with its associated resources.
  134819. */
  134820. dispose(): void;
  134821. }
  134822. }
  134823. declare module BABYLON {
  134824. interface AbstractScene {
  134825. /**
  134826. * The list of lens flare system added to the scene
  134827. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134828. */
  134829. lensFlareSystems: Array<LensFlareSystem>;
  134830. /**
  134831. * Removes the given lens flare system from this scene.
  134832. * @param toRemove The lens flare system to remove
  134833. * @returns The index of the removed lens flare system
  134834. */
  134835. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  134836. /**
  134837. * Adds the given lens flare system to this scene
  134838. * @param newLensFlareSystem The lens flare system to add
  134839. */
  134840. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  134841. /**
  134842. * Gets a lens flare system using its name
  134843. * @param name defines the name to look for
  134844. * @returns the lens flare system or null if not found
  134845. */
  134846. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  134847. /**
  134848. * Gets a lens flare system using its id
  134849. * @param id defines the id to look for
  134850. * @returns the lens flare system or null if not found
  134851. */
  134852. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  134853. }
  134854. /**
  134855. * Defines the lens flare scene component responsible to manage any lens flares
  134856. * in a given scene.
  134857. */
  134858. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  134859. /**
  134860. * The component name helpfull to identify the component in the list of scene components.
  134861. */
  134862. readonly name: string;
  134863. /**
  134864. * The scene the component belongs to.
  134865. */
  134866. scene: Scene;
  134867. /**
  134868. * Creates a new instance of the component for the given scene
  134869. * @param scene Defines the scene to register the component in
  134870. */
  134871. constructor(scene: Scene);
  134872. /**
  134873. * Registers the component in a given scene
  134874. */
  134875. register(): void;
  134876. /**
  134877. * Rebuilds the elements related to this component in case of
  134878. * context lost for instance.
  134879. */
  134880. rebuild(): void;
  134881. /**
  134882. * Adds all the elements from the container to the scene
  134883. * @param container the container holding the elements
  134884. */
  134885. addFromContainer(container: AbstractScene): void;
  134886. /**
  134887. * Removes all the elements in the container from the scene
  134888. * @param container contains the elements to remove
  134889. * @param dispose if the removed element should be disposed (default: false)
  134890. */
  134891. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134892. /**
  134893. * Serializes the component data to the specified json object
  134894. * @param serializationObject The object to serialize to
  134895. */
  134896. serialize(serializationObject: any): void;
  134897. /**
  134898. * Disposes the component and the associated ressources.
  134899. */
  134900. dispose(): void;
  134901. private _draw;
  134902. }
  134903. }
  134904. declare module BABYLON {
  134905. /** @hidden */
  134906. export var depthPixelShader: {
  134907. name: string;
  134908. shader: string;
  134909. };
  134910. }
  134911. declare module BABYLON {
  134912. /** @hidden */
  134913. export var depthVertexShader: {
  134914. name: string;
  134915. shader: string;
  134916. };
  134917. }
  134918. declare module BABYLON {
  134919. /**
  134920. * This represents a depth renderer in Babylon.
  134921. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  134922. */
  134923. export class DepthRenderer {
  134924. private _scene;
  134925. private _depthMap;
  134926. private _effect;
  134927. private readonly _storeNonLinearDepth;
  134928. private readonly _clearColor;
  134929. /** Get if the depth renderer is using packed depth or not */
  134930. readonly isPacked: boolean;
  134931. private _cachedDefines;
  134932. private _camera;
  134933. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  134934. enabled: boolean;
  134935. /**
  134936. * Specifiess that the depth renderer will only be used within
  134937. * the camera it is created for.
  134938. * This can help forcing its rendering during the camera processing.
  134939. */
  134940. useOnlyInActiveCamera: boolean;
  134941. /** @hidden */
  134942. static _SceneComponentInitialization: (scene: Scene) => void;
  134943. /**
  134944. * Instantiates a depth renderer
  134945. * @param scene The scene the renderer belongs to
  134946. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  134947. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  134948. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  134949. */
  134950. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  134951. /**
  134952. * Creates the depth rendering effect and checks if the effect is ready.
  134953. * @param subMesh The submesh to be used to render the depth map of
  134954. * @param useInstances If multiple world instances should be used
  134955. * @returns if the depth renderer is ready to render the depth map
  134956. */
  134957. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134958. /**
  134959. * Gets the texture which the depth map will be written to.
  134960. * @returns The depth map texture
  134961. */
  134962. getDepthMap(): RenderTargetTexture;
  134963. /**
  134964. * Disposes of the depth renderer.
  134965. */
  134966. dispose(): void;
  134967. }
  134968. }
  134969. declare module BABYLON {
  134970. /** @hidden */
  134971. export var minmaxReduxPixelShader: {
  134972. name: string;
  134973. shader: string;
  134974. };
  134975. }
  134976. declare module BABYLON {
  134977. /**
  134978. * This class computes a min/max reduction from a texture: it means it computes the minimum
  134979. * and maximum values from all values of the texture.
  134980. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  134981. * The source values are read from the red channel of the texture.
  134982. */
  134983. export class MinMaxReducer {
  134984. /**
  134985. * Observable triggered when the computation has been performed
  134986. */
  134987. onAfterReductionPerformed: Observable<{
  134988. min: number;
  134989. max: number;
  134990. }>;
  134991. protected _camera: Camera;
  134992. protected _sourceTexture: Nullable<RenderTargetTexture>;
  134993. protected _reductionSteps: Nullable<Array<PostProcess>>;
  134994. protected _postProcessManager: PostProcessManager;
  134995. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  134996. protected _forceFullscreenViewport: boolean;
  134997. /**
  134998. * Creates a min/max reducer
  134999. * @param camera The camera to use for the post processes
  135000. */
  135001. constructor(camera: Camera);
  135002. /**
  135003. * Gets the texture used to read the values from.
  135004. */
  135005. get sourceTexture(): Nullable<RenderTargetTexture>;
  135006. /**
  135007. * Sets the source texture to read the values from.
  135008. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  135009. * because in such textures '1' value must not be taken into account to compute the maximum
  135010. * as this value is used to clear the texture.
  135011. * Note that the computation is not activated by calling this function, you must call activate() for that!
  135012. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  135013. * @param depthRedux Indicates if the texture is a depth texture or not
  135014. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  135015. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135016. */
  135017. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135018. /**
  135019. * Defines the refresh rate of the computation.
  135020. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135021. */
  135022. get refreshRate(): number;
  135023. set refreshRate(value: number);
  135024. protected _activated: boolean;
  135025. /**
  135026. * Gets the activation status of the reducer
  135027. */
  135028. get activated(): boolean;
  135029. /**
  135030. * Activates the reduction computation.
  135031. * When activated, the observers registered in onAfterReductionPerformed are
  135032. * called after the compuation is performed
  135033. */
  135034. activate(): void;
  135035. /**
  135036. * Deactivates the reduction computation.
  135037. */
  135038. deactivate(): void;
  135039. /**
  135040. * Disposes the min/max reducer
  135041. * @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.
  135042. */
  135043. dispose(disposeAll?: boolean): void;
  135044. }
  135045. }
  135046. declare module BABYLON {
  135047. /**
  135048. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135049. */
  135050. export class DepthReducer extends MinMaxReducer {
  135051. private _depthRenderer;
  135052. private _depthRendererId;
  135053. /**
  135054. * Gets the depth renderer used for the computation.
  135055. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  135056. */
  135057. get depthRenderer(): Nullable<DepthRenderer>;
  135058. /**
  135059. * Creates a depth reducer
  135060. * @param camera The camera used to render the depth texture
  135061. */
  135062. constructor(camera: Camera);
  135063. /**
  135064. * Sets the depth renderer to use to generate the depth map
  135065. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  135066. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  135067. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135068. */
  135069. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  135070. /** @hidden */
  135071. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135072. /**
  135073. * Activates the reduction computation.
  135074. * When activated, the observers registered in onAfterReductionPerformed are
  135075. * called after the compuation is performed
  135076. */
  135077. activate(): void;
  135078. /**
  135079. * Deactivates the reduction computation.
  135080. */
  135081. deactivate(): void;
  135082. /**
  135083. * Disposes the depth reducer
  135084. * @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.
  135085. */
  135086. dispose(disposeAll?: boolean): void;
  135087. }
  135088. }
  135089. declare module BABYLON {
  135090. /**
  135091. * A CSM implementation allowing casting shadows on large scenes.
  135092. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135093. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  135094. */
  135095. export class CascadedShadowGenerator extends ShadowGenerator {
  135096. private static readonly frustumCornersNDCSpace;
  135097. /**
  135098. * Name of the CSM class
  135099. */
  135100. static CLASSNAME: string;
  135101. /**
  135102. * Defines the default number of cascades used by the CSM.
  135103. */
  135104. static readonly DEFAULT_CASCADES_COUNT: number;
  135105. /**
  135106. * Defines the minimum number of cascades used by the CSM.
  135107. */
  135108. static readonly MIN_CASCADES_COUNT: number;
  135109. /**
  135110. * Defines the maximum number of cascades used by the CSM.
  135111. */
  135112. static readonly MAX_CASCADES_COUNT: number;
  135113. protected _validateFilter(filter: number): number;
  135114. /**
  135115. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  135116. */
  135117. penumbraDarkness: number;
  135118. private _numCascades;
  135119. /**
  135120. * Gets or set the number of cascades used by the CSM.
  135121. */
  135122. get numCascades(): number;
  135123. set numCascades(value: number);
  135124. /**
  135125. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  135126. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  135127. */
  135128. stabilizeCascades: boolean;
  135129. private _freezeShadowCastersBoundingInfo;
  135130. private _freezeShadowCastersBoundingInfoObservable;
  135131. /**
  135132. * Enables or disables the shadow casters bounding info computation.
  135133. * If your shadow casters don't move, you can disable this feature.
  135134. * If it is enabled, the bounding box computation is done every frame.
  135135. */
  135136. get freezeShadowCastersBoundingInfo(): boolean;
  135137. set freezeShadowCastersBoundingInfo(freeze: boolean);
  135138. private _scbiMin;
  135139. private _scbiMax;
  135140. protected _computeShadowCastersBoundingInfo(): void;
  135141. protected _shadowCastersBoundingInfo: BoundingInfo;
  135142. /**
  135143. * Gets or sets the shadow casters bounding info.
  135144. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  135145. * so that the system won't overwrite the bounds you provide
  135146. */
  135147. get shadowCastersBoundingInfo(): BoundingInfo;
  135148. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  135149. protected _breaksAreDirty: boolean;
  135150. protected _minDistance: number;
  135151. protected _maxDistance: number;
  135152. /**
  135153. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  135154. *
  135155. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  135156. * If you don't know these values, simply leave them to their defaults and don't call this function.
  135157. * @param min minimal distance for the breaks (default to 0.)
  135158. * @param max maximal distance for the breaks (default to 1.)
  135159. */
  135160. setMinMaxDistance(min: number, max: number): void;
  135161. /** Gets the minimal distance used in the cascade break computation */
  135162. get minDistance(): number;
  135163. /** Gets the maximal distance used in the cascade break computation */
  135164. get maxDistance(): number;
  135165. /**
  135166. * Gets the class name of that object
  135167. * @returns "CascadedShadowGenerator"
  135168. */
  135169. getClassName(): string;
  135170. private _cascadeMinExtents;
  135171. private _cascadeMaxExtents;
  135172. /**
  135173. * Gets a cascade minimum extents
  135174. * @param cascadeIndex index of the cascade
  135175. * @returns the minimum cascade extents
  135176. */
  135177. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  135178. /**
  135179. * Gets a cascade maximum extents
  135180. * @param cascadeIndex index of the cascade
  135181. * @returns the maximum cascade extents
  135182. */
  135183. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  135184. private _cascades;
  135185. private _currentLayer;
  135186. private _viewSpaceFrustumsZ;
  135187. private _viewMatrices;
  135188. private _projectionMatrices;
  135189. private _transformMatrices;
  135190. private _transformMatricesAsArray;
  135191. private _frustumLengths;
  135192. private _lightSizeUVCorrection;
  135193. private _depthCorrection;
  135194. private _frustumCornersWorldSpace;
  135195. private _frustumCenter;
  135196. private _shadowCameraPos;
  135197. private _shadowMaxZ;
  135198. /**
  135199. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  135200. * It defaults to camera.maxZ
  135201. */
  135202. get shadowMaxZ(): number;
  135203. /**
  135204. * Sets the shadow max z distance.
  135205. */
  135206. set shadowMaxZ(value: number);
  135207. protected _debug: boolean;
  135208. /**
  135209. * Gets or sets the debug flag.
  135210. * When enabled, the cascades are materialized by different colors on the screen.
  135211. */
  135212. get debug(): boolean;
  135213. set debug(dbg: boolean);
  135214. private _depthClamp;
  135215. /**
  135216. * Gets or sets the depth clamping value.
  135217. *
  135218. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  135219. * to account for the shadow casters far away.
  135220. *
  135221. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  135222. */
  135223. get depthClamp(): boolean;
  135224. set depthClamp(value: boolean);
  135225. private _cascadeBlendPercentage;
  135226. /**
  135227. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  135228. * It defaults to 0.1 (10% blending).
  135229. */
  135230. get cascadeBlendPercentage(): number;
  135231. set cascadeBlendPercentage(value: number);
  135232. private _lambda;
  135233. /**
  135234. * Gets or set the lambda parameter.
  135235. * This parameter is used to split the camera frustum and create the cascades.
  135236. * 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.
  135237. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  135238. */
  135239. get lambda(): number;
  135240. set lambda(value: number);
  135241. /**
  135242. * Gets the view matrix corresponding to a given cascade
  135243. * @param cascadeNum cascade to retrieve the view matrix from
  135244. * @returns the cascade view matrix
  135245. */
  135246. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  135247. /**
  135248. * Gets the projection matrix corresponding to a given cascade
  135249. * @param cascadeNum cascade to retrieve the projection matrix from
  135250. * @returns the cascade projection matrix
  135251. */
  135252. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  135253. /**
  135254. * Gets the transformation matrix corresponding to a given cascade
  135255. * @param cascadeNum cascade to retrieve the transformation matrix from
  135256. * @returns the cascade transformation matrix
  135257. */
  135258. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  135259. private _depthRenderer;
  135260. /**
  135261. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  135262. *
  135263. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  135264. *
  135265. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  135266. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  135267. * @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
  135268. */
  135269. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  135270. private _depthReducer;
  135271. private _autoCalcDepthBounds;
  135272. /**
  135273. * Gets or sets the autoCalcDepthBounds property.
  135274. *
  135275. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  135276. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  135277. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  135278. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  135279. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  135280. */
  135281. get autoCalcDepthBounds(): boolean;
  135282. set autoCalcDepthBounds(value: boolean);
  135283. /**
  135284. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  135285. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135286. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  135287. * for setting the refresh rate on the renderer yourself!
  135288. */
  135289. get autoCalcDepthBoundsRefreshRate(): number;
  135290. set autoCalcDepthBoundsRefreshRate(value: number);
  135291. /**
  135292. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  135293. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  135294. * you change the camera near/far planes!
  135295. */
  135296. splitFrustum(): void;
  135297. private _splitFrustum;
  135298. private _computeMatrices;
  135299. private _computeFrustumInWorldSpace;
  135300. private _computeCascadeFrustum;
  135301. /**
  135302. * Support test.
  135303. */
  135304. static get IsSupported(): boolean;
  135305. /** @hidden */
  135306. static _SceneComponentInitialization: (scene: Scene) => void;
  135307. /**
  135308. * Creates a Cascaded Shadow Generator object.
  135309. * A ShadowGenerator is the required tool to use the shadows.
  135310. * Each directional light casting shadows needs to use its own ShadowGenerator.
  135311. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135312. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  135313. * @param light The directional light object generating the shadows.
  135314. * @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.
  135315. */
  135316. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  135317. protected _initializeGenerator(): void;
  135318. protected _createTargetRenderTexture(): void;
  135319. protected _initializeShadowMap(): void;
  135320. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  135321. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  135322. /**
  135323. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  135324. * @param defines Defines of the material we want to update
  135325. * @param lightIndex Index of the light in the enabled light list of the material
  135326. */
  135327. prepareDefines(defines: any, lightIndex: number): void;
  135328. /**
  135329. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  135330. * defined in the generator but impacting the effect).
  135331. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  135332. * @param effect The effect we are binfing the information for
  135333. */
  135334. bindShadowLight(lightIndex: string, effect: Effect): void;
  135335. /**
  135336. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  135337. * (eq to view projection * shadow projection matrices)
  135338. * @returns The transform matrix used to create the shadow map
  135339. */
  135340. getTransformMatrix(): Matrix;
  135341. /**
  135342. * Disposes the ShadowGenerator.
  135343. * Returns nothing.
  135344. */
  135345. dispose(): void;
  135346. /**
  135347. * Serializes the shadow generator setup to a json object.
  135348. * @returns The serialized JSON object
  135349. */
  135350. serialize(): any;
  135351. /**
  135352. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  135353. * @param parsedShadowGenerator The JSON object to parse
  135354. * @param scene The scene to create the shadow map for
  135355. * @returns The parsed shadow generator
  135356. */
  135357. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  135358. }
  135359. }
  135360. declare module BABYLON {
  135361. /**
  135362. * Defines the shadow generator component responsible to manage any shadow generators
  135363. * in a given scene.
  135364. */
  135365. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  135366. /**
  135367. * The component name helpfull to identify the component in the list of scene components.
  135368. */
  135369. readonly name: string;
  135370. /**
  135371. * The scene the component belongs to.
  135372. */
  135373. scene: Scene;
  135374. /**
  135375. * Creates a new instance of the component for the given scene
  135376. * @param scene Defines the scene to register the component in
  135377. */
  135378. constructor(scene: Scene);
  135379. /**
  135380. * Registers the component in a given scene
  135381. */
  135382. register(): void;
  135383. /**
  135384. * Rebuilds the elements related to this component in case of
  135385. * context lost for instance.
  135386. */
  135387. rebuild(): void;
  135388. /**
  135389. * Serializes the component data to the specified json object
  135390. * @param serializationObject The object to serialize to
  135391. */
  135392. serialize(serializationObject: any): void;
  135393. /**
  135394. * Adds all the elements from the container to the scene
  135395. * @param container the container holding the elements
  135396. */
  135397. addFromContainer(container: AbstractScene): void;
  135398. /**
  135399. * Removes all the elements in the container from the scene
  135400. * @param container contains the elements to remove
  135401. * @param dispose if the removed element should be disposed (default: false)
  135402. */
  135403. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135404. /**
  135405. * Rebuilds the elements related to this component in case of
  135406. * context lost for instance.
  135407. */
  135408. dispose(): void;
  135409. private _gatherRenderTargets;
  135410. }
  135411. }
  135412. declare module BABYLON {
  135413. /**
  135414. * A point light is a light defined by an unique point in world space.
  135415. * The light is emitted in every direction from this point.
  135416. * A good example of a point light is a standard light bulb.
  135417. * Documentation: https://doc.babylonjs.com/babylon101/lights
  135418. */
  135419. export class PointLight extends ShadowLight {
  135420. private _shadowAngle;
  135421. /**
  135422. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135423. * This specifies what angle the shadow will use to be created.
  135424. *
  135425. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135426. */
  135427. get shadowAngle(): number;
  135428. /**
  135429. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135430. * This specifies what angle the shadow will use to be created.
  135431. *
  135432. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135433. */
  135434. set shadowAngle(value: number);
  135435. /**
  135436. * Gets the direction if it has been set.
  135437. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135438. */
  135439. get direction(): Vector3;
  135440. /**
  135441. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135442. */
  135443. set direction(value: Vector3);
  135444. /**
  135445. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  135446. * A PointLight emits the light in every direction.
  135447. * It can cast shadows.
  135448. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  135449. * ```javascript
  135450. * var pointLight = new PointLight("pl", camera.position, scene);
  135451. * ```
  135452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  135453. * @param name The light friendly name
  135454. * @param position The position of the point light in the scene
  135455. * @param scene The scene the lights belongs to
  135456. */
  135457. constructor(name: string, position: Vector3, scene: Scene);
  135458. /**
  135459. * Returns the string "PointLight"
  135460. * @returns the class name
  135461. */
  135462. getClassName(): string;
  135463. /**
  135464. * Returns the integer 0.
  135465. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  135466. */
  135467. getTypeID(): number;
  135468. /**
  135469. * Specifies wether or not the shadowmap should be a cube texture.
  135470. * @returns true if the shadowmap needs to be a cube texture.
  135471. */
  135472. needCube(): boolean;
  135473. /**
  135474. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  135475. * @param faceIndex The index of the face we are computed the direction to generate shadow
  135476. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  135477. */
  135478. getShadowDirection(faceIndex?: number): Vector3;
  135479. /**
  135480. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  135481. * - fov = PI / 2
  135482. * - aspect ratio : 1.0
  135483. * - z-near and far equal to the active camera minZ and maxZ.
  135484. * Returns the PointLight.
  135485. */
  135486. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  135487. protected _buildUniformLayout(): void;
  135488. /**
  135489. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  135490. * @param effect The effect to update
  135491. * @param lightIndex The index of the light in the effect to update
  135492. * @returns The point light
  135493. */
  135494. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  135495. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135496. /**
  135497. * Prepares the list of defines specific to the light type.
  135498. * @param defines the list of defines
  135499. * @param lightIndex defines the index of the light for the effect
  135500. */
  135501. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135502. }
  135503. }
  135504. declare module BABYLON {
  135505. /**
  135506. * Header information of HDR texture files.
  135507. */
  135508. export interface HDRInfo {
  135509. /**
  135510. * The height of the texture in pixels.
  135511. */
  135512. height: number;
  135513. /**
  135514. * The width of the texture in pixels.
  135515. */
  135516. width: number;
  135517. /**
  135518. * The index of the beginning of the data in the binary file.
  135519. */
  135520. dataPosition: number;
  135521. }
  135522. /**
  135523. * This groups tools to convert HDR texture to native colors array.
  135524. */
  135525. export class HDRTools {
  135526. private static Ldexp;
  135527. private static Rgbe2float;
  135528. private static readStringLine;
  135529. /**
  135530. * Reads header information from an RGBE texture stored in a native array.
  135531. * More information on this format are available here:
  135532. * https://en.wikipedia.org/wiki/RGBE_image_format
  135533. *
  135534. * @param uint8array The binary file stored in native array.
  135535. * @return The header information.
  135536. */
  135537. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  135538. /**
  135539. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  135540. * This RGBE texture needs to store the information as a panorama.
  135541. *
  135542. * More information on this format are available here:
  135543. * https://en.wikipedia.org/wiki/RGBE_image_format
  135544. *
  135545. * @param buffer The binary file stored in an array buffer.
  135546. * @param size The expected size of the extracted cubemap.
  135547. * @return The Cube Map information.
  135548. */
  135549. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  135550. /**
  135551. * Returns the pixels data extracted from an RGBE texture.
  135552. * This pixels will be stored left to right up to down in the R G B order in one array.
  135553. *
  135554. * More information on this format are available here:
  135555. * https://en.wikipedia.org/wiki/RGBE_image_format
  135556. *
  135557. * @param uint8array The binary file stored in an array buffer.
  135558. * @param hdrInfo The header information of the file.
  135559. * @return The pixels data in RGB right to left up to down order.
  135560. */
  135561. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  135562. private static RGBE_ReadPixels_RLE;
  135563. }
  135564. }
  135565. declare module BABYLON {
  135566. /**
  135567. * Effect Render Options
  135568. */
  135569. export interface IEffectRendererOptions {
  135570. /**
  135571. * Defines the vertices positions.
  135572. */
  135573. positions?: number[];
  135574. /**
  135575. * Defines the indices.
  135576. */
  135577. indices?: number[];
  135578. }
  135579. /**
  135580. * Helper class to render one or more effects.
  135581. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135582. */
  135583. export class EffectRenderer {
  135584. private engine;
  135585. private static _DefaultOptions;
  135586. private _vertexBuffers;
  135587. private _indexBuffer;
  135588. private _fullscreenViewport;
  135589. /**
  135590. * Creates an effect renderer
  135591. * @param engine the engine to use for rendering
  135592. * @param options defines the options of the effect renderer
  135593. */
  135594. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135595. /**
  135596. * Sets the current viewport in normalized coordinates 0-1
  135597. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135598. */
  135599. setViewport(viewport?: Viewport): void;
  135600. /**
  135601. * Binds the embedded attributes buffer to the effect.
  135602. * @param effect Defines the effect to bind the attributes for
  135603. */
  135604. bindBuffers(effect: Effect): void;
  135605. /**
  135606. * Sets the current effect wrapper to use during draw.
  135607. * The effect needs to be ready before calling this api.
  135608. * This also sets the default full screen position attribute.
  135609. * @param effectWrapper Defines the effect to draw with
  135610. */
  135611. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135612. /**
  135613. * Restores engine states
  135614. */
  135615. restoreStates(): void;
  135616. /**
  135617. * Draws a full screen quad.
  135618. */
  135619. draw(): void;
  135620. private isRenderTargetTexture;
  135621. /**
  135622. * renders one or more effects to a specified texture
  135623. * @param effectWrapper the effect to renderer
  135624. * @param outputTexture texture to draw to, if null it will render to the screen.
  135625. */
  135626. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135627. /**
  135628. * Disposes of the effect renderer
  135629. */
  135630. dispose(): void;
  135631. }
  135632. /**
  135633. * Options to create an EffectWrapper
  135634. */
  135635. interface EffectWrapperCreationOptions {
  135636. /**
  135637. * Engine to use to create the effect
  135638. */
  135639. engine: ThinEngine;
  135640. /**
  135641. * Fragment shader for the effect
  135642. */
  135643. fragmentShader: string;
  135644. /**
  135645. * Use the shader store instead of direct source code
  135646. */
  135647. useShaderStore?: boolean;
  135648. /**
  135649. * Vertex shader for the effect
  135650. */
  135651. vertexShader?: string;
  135652. /**
  135653. * Attributes to use in the shader
  135654. */
  135655. attributeNames?: Array<string>;
  135656. /**
  135657. * Uniforms to use in the shader
  135658. */
  135659. uniformNames?: Array<string>;
  135660. /**
  135661. * Texture sampler names to use in the shader
  135662. */
  135663. samplerNames?: Array<string>;
  135664. /**
  135665. * Defines to use in the shader
  135666. */
  135667. defines?: Array<string>;
  135668. /**
  135669. * Callback when effect is compiled
  135670. */
  135671. onCompiled?: Nullable<(effect: Effect) => void>;
  135672. /**
  135673. * The friendly name of the effect displayed in Spector.
  135674. */
  135675. name?: string;
  135676. }
  135677. /**
  135678. * Wraps an effect to be used for rendering
  135679. */
  135680. export class EffectWrapper {
  135681. /**
  135682. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135683. */
  135684. onApplyObservable: Observable<{}>;
  135685. /**
  135686. * The underlying effect
  135687. */
  135688. effect: Effect;
  135689. /**
  135690. * Creates an effect to be renderer
  135691. * @param creationOptions options to create the effect
  135692. */
  135693. constructor(creationOptions: EffectWrapperCreationOptions);
  135694. /**
  135695. * Disposes of the effect wrapper
  135696. */
  135697. dispose(): void;
  135698. }
  135699. }
  135700. declare module BABYLON {
  135701. /** @hidden */
  135702. export var hdrFilteringVertexShader: {
  135703. name: string;
  135704. shader: string;
  135705. };
  135706. }
  135707. declare module BABYLON {
  135708. /** @hidden */
  135709. export var hdrFilteringPixelShader: {
  135710. name: string;
  135711. shader: string;
  135712. };
  135713. }
  135714. declare module BABYLON {
  135715. /**
  135716. * Options for texture filtering
  135717. */
  135718. interface IHDRFilteringOptions {
  135719. /**
  135720. * Scales pixel intensity for the input HDR map.
  135721. */
  135722. hdrScale?: number;
  135723. /**
  135724. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  135725. */
  135726. quality?: number;
  135727. }
  135728. /**
  135729. * Filters HDR maps to get correct renderings of PBR reflections
  135730. */
  135731. export class HDRFiltering {
  135732. private _engine;
  135733. private _effectRenderer;
  135734. private _effectWrapper;
  135735. private _lodGenerationOffset;
  135736. private _lodGenerationScale;
  135737. /**
  135738. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  135739. * you care about baking speed.
  135740. */
  135741. quality: number;
  135742. /**
  135743. * Scales pixel intensity for the input HDR map.
  135744. */
  135745. hdrScale: number;
  135746. /**
  135747. * Instantiates HDR filter for reflection maps
  135748. *
  135749. * @param engine Thin engine
  135750. * @param options Options
  135751. */
  135752. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  135753. private _createRenderTarget;
  135754. private _prefilterInternal;
  135755. private _createEffect;
  135756. /**
  135757. * Get a value indicating if the filter is ready to be used
  135758. * @param texture Texture to filter
  135759. * @returns true if the filter is ready
  135760. */
  135761. isReady(texture: BaseTexture): boolean;
  135762. /**
  135763. * Prefilters a cube texture to have mipmap levels representing roughness values.
  135764. * Prefiltering will be invoked at the end of next rendering pass.
  135765. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  135766. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  135767. * @param texture Texture to filter
  135768. * @param onFinished Callback when filtering is done
  135769. * @return Promise called when prefiltering is done
  135770. */
  135771. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  135772. }
  135773. }
  135774. declare module BABYLON {
  135775. /**
  135776. * This represents a texture coming from an HDR input.
  135777. *
  135778. * The only supported format is currently panorama picture stored in RGBE format.
  135779. * Example of such files can be found on HDRLib: http://hdrlib.com/
  135780. */
  135781. export class HDRCubeTexture extends BaseTexture {
  135782. private static _facesMapping;
  135783. private _generateHarmonics;
  135784. private _noMipmap;
  135785. private _prefilterOnLoad;
  135786. private _textureMatrix;
  135787. private _size;
  135788. private _onLoad;
  135789. private _onError;
  135790. /**
  135791. * The texture URL.
  135792. */
  135793. url: string;
  135794. /**
  135795. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  135796. */
  135797. coordinatesMode: number;
  135798. protected _isBlocking: boolean;
  135799. /**
  135800. * Sets wether or not the texture is blocking during loading.
  135801. */
  135802. set isBlocking(value: boolean);
  135803. /**
  135804. * Gets wether or not the texture is blocking during loading.
  135805. */
  135806. get isBlocking(): boolean;
  135807. protected _rotationY: number;
  135808. /**
  135809. * Sets texture matrix rotation angle around Y axis in radians.
  135810. */
  135811. set rotationY(value: number);
  135812. /**
  135813. * Gets texture matrix rotation angle around Y axis radians.
  135814. */
  135815. get rotationY(): number;
  135816. /**
  135817. * Gets or sets the center of the bounding box associated with the cube texture
  135818. * It must define where the camera used to render the texture was set
  135819. */
  135820. boundingBoxPosition: Vector3;
  135821. private _boundingBoxSize;
  135822. /**
  135823. * Gets or sets the size of the bounding box associated with the cube texture
  135824. * When defined, the cubemap will switch to local mode
  135825. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  135826. * @example https://www.babylonjs-playground.com/#RNASML
  135827. */
  135828. set boundingBoxSize(value: Vector3);
  135829. get boundingBoxSize(): Vector3;
  135830. /**
  135831. * Instantiates an HDRTexture from the following parameters.
  135832. *
  135833. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  135834. * @param sceneOrEngine The scene or engine the texture will be used in
  135835. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  135836. * @param noMipmap Forces to not generate the mipmap if true
  135837. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  135838. * @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)
  135839. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  135840. */
  135841. 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>);
  135842. /**
  135843. * Get the current class name of the texture useful for serialization or dynamic coding.
  135844. * @returns "HDRCubeTexture"
  135845. */
  135846. getClassName(): string;
  135847. /**
  135848. * Occurs when the file is raw .hdr file.
  135849. */
  135850. private loadTexture;
  135851. clone(): HDRCubeTexture;
  135852. delayLoad(): void;
  135853. /**
  135854. * Get the texture reflection matrix used to rotate/transform the reflection.
  135855. * @returns the reflection matrix
  135856. */
  135857. getReflectionTextureMatrix(): Matrix;
  135858. /**
  135859. * Set the texture reflection matrix used to rotate/transform the reflection.
  135860. * @param value Define the reflection matrix to set
  135861. */
  135862. setReflectionTextureMatrix(value: Matrix): void;
  135863. /**
  135864. * Parses a JSON representation of an HDR Texture in order to create the texture
  135865. * @param parsedTexture Define the JSON representation
  135866. * @param scene Define the scene the texture should be created in
  135867. * @param rootUrl Define the root url in case we need to load relative dependencies
  135868. * @returns the newly created texture after parsing
  135869. */
  135870. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  135871. serialize(): any;
  135872. }
  135873. }
  135874. declare module BABYLON {
  135875. /**
  135876. * Class used to control physics engine
  135877. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135878. */
  135879. export class PhysicsEngine implements IPhysicsEngine {
  135880. private _physicsPlugin;
  135881. /**
  135882. * Global value used to control the smallest number supported by the simulation
  135883. */
  135884. static Epsilon: number;
  135885. private _impostors;
  135886. private _joints;
  135887. private _subTimeStep;
  135888. /**
  135889. * Gets the gravity vector used by the simulation
  135890. */
  135891. gravity: Vector3;
  135892. /**
  135893. * Factory used to create the default physics plugin.
  135894. * @returns The default physics plugin
  135895. */
  135896. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  135897. /**
  135898. * Creates a new Physics Engine
  135899. * @param gravity defines the gravity vector used by the simulation
  135900. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  135901. */
  135902. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  135903. /**
  135904. * Sets the gravity vector used by the simulation
  135905. * @param gravity defines the gravity vector to use
  135906. */
  135907. setGravity(gravity: Vector3): void;
  135908. /**
  135909. * Set the time step of the physics engine.
  135910. * Default is 1/60.
  135911. * To slow it down, enter 1/600 for example.
  135912. * To speed it up, 1/30
  135913. * @param newTimeStep defines the new timestep to apply to this world.
  135914. */
  135915. setTimeStep(newTimeStep?: number): void;
  135916. /**
  135917. * Get the time step of the physics engine.
  135918. * @returns the current time step
  135919. */
  135920. getTimeStep(): number;
  135921. /**
  135922. * Set the sub time step of the physics engine.
  135923. * Default is 0 meaning there is no sub steps
  135924. * To increase physics resolution precision, set a small value (like 1 ms)
  135925. * @param subTimeStep defines the new sub timestep used for physics resolution.
  135926. */
  135927. setSubTimeStep(subTimeStep?: number): void;
  135928. /**
  135929. * Get the sub time step of the physics engine.
  135930. * @returns the current sub time step
  135931. */
  135932. getSubTimeStep(): number;
  135933. /**
  135934. * Release all resources
  135935. */
  135936. dispose(): void;
  135937. /**
  135938. * Gets the name of the current physics plugin
  135939. * @returns the name of the plugin
  135940. */
  135941. getPhysicsPluginName(): string;
  135942. /**
  135943. * Adding a new impostor for the impostor tracking.
  135944. * This will be done by the impostor itself.
  135945. * @param impostor the impostor to add
  135946. */
  135947. addImpostor(impostor: PhysicsImpostor): void;
  135948. /**
  135949. * Remove an impostor from the engine.
  135950. * This impostor and its mesh will not longer be updated by the physics engine.
  135951. * @param impostor the impostor to remove
  135952. */
  135953. removeImpostor(impostor: PhysicsImpostor): void;
  135954. /**
  135955. * Add a joint to the physics engine
  135956. * @param mainImpostor defines the main impostor to which the joint is added.
  135957. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  135958. * @param joint defines the joint that will connect both impostors.
  135959. */
  135960. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135961. /**
  135962. * Removes a joint from the simulation
  135963. * @param mainImpostor defines the impostor used with the joint
  135964. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  135965. * @param joint defines the joint to remove
  135966. */
  135967. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135968. /**
  135969. * Called by the scene. No need to call it.
  135970. * @param delta defines the timespam between frames
  135971. */
  135972. _step(delta: number): void;
  135973. /**
  135974. * Gets the current plugin used to run the simulation
  135975. * @returns current plugin
  135976. */
  135977. getPhysicsPlugin(): IPhysicsEnginePlugin;
  135978. /**
  135979. * Gets the list of physic impostors
  135980. * @returns an array of PhysicsImpostor
  135981. */
  135982. getImpostors(): Array<PhysicsImpostor>;
  135983. /**
  135984. * Gets the impostor for a physics enabled object
  135985. * @param object defines the object impersonated by the impostor
  135986. * @returns the PhysicsImpostor or null if not found
  135987. */
  135988. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  135989. /**
  135990. * Gets the impostor for a physics body object
  135991. * @param body defines physics body used by the impostor
  135992. * @returns the PhysicsImpostor or null if not found
  135993. */
  135994. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  135995. /**
  135996. * Does a raycast in the physics world
  135997. * @param from when should the ray start?
  135998. * @param to when should the ray end?
  135999. * @returns PhysicsRaycastResult
  136000. */
  136001. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136002. }
  136003. }
  136004. declare module BABYLON {
  136005. /** @hidden */
  136006. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  136007. private _useDeltaForWorldStep;
  136008. world: any;
  136009. name: string;
  136010. private _physicsMaterials;
  136011. private _fixedTimeStep;
  136012. private _cannonRaycastResult;
  136013. private _raycastResult;
  136014. private _physicsBodysToRemoveAfterStep;
  136015. private _firstFrame;
  136016. BJSCANNON: any;
  136017. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  136018. setGravity(gravity: Vector3): void;
  136019. setTimeStep(timeStep: number): void;
  136020. getTimeStep(): number;
  136021. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136022. private _removeMarkedPhysicsBodiesFromWorld;
  136023. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136024. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136025. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136026. private _processChildMeshes;
  136027. removePhysicsBody(impostor: PhysicsImpostor): void;
  136028. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136029. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136030. private _addMaterial;
  136031. private _checkWithEpsilon;
  136032. private _createShape;
  136033. private _createHeightmap;
  136034. private _minus90X;
  136035. private _plus90X;
  136036. private _tmpPosition;
  136037. private _tmpDeltaPosition;
  136038. private _tmpUnityRotation;
  136039. private _updatePhysicsBodyTransformation;
  136040. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136041. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136042. isSupported(): boolean;
  136043. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136044. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136045. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136046. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136047. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136048. getBodyMass(impostor: PhysicsImpostor): number;
  136049. getBodyFriction(impostor: PhysicsImpostor): number;
  136050. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136051. getBodyRestitution(impostor: PhysicsImpostor): number;
  136052. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136053. sleepBody(impostor: PhysicsImpostor): void;
  136054. wakeUpBody(impostor: PhysicsImpostor): void;
  136055. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  136056. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136057. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136058. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136059. getRadius(impostor: PhysicsImpostor): number;
  136060. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136061. dispose(): void;
  136062. private _extendNamespace;
  136063. /**
  136064. * Does a raycast in the physics world
  136065. * @param from when should the ray start?
  136066. * @param to when should the ray end?
  136067. * @returns PhysicsRaycastResult
  136068. */
  136069. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136070. }
  136071. }
  136072. declare module BABYLON {
  136073. /** @hidden */
  136074. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  136075. private _useDeltaForWorldStep;
  136076. world: any;
  136077. name: string;
  136078. BJSOIMO: any;
  136079. private _raycastResult;
  136080. private _fixedTimeStep;
  136081. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  136082. setGravity(gravity: Vector3): void;
  136083. setTimeStep(timeStep: number): void;
  136084. getTimeStep(): number;
  136085. private _tmpImpostorsArray;
  136086. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136087. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136088. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136089. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136090. private _tmpPositionVector;
  136091. removePhysicsBody(impostor: PhysicsImpostor): void;
  136092. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136093. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136094. isSupported(): boolean;
  136095. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136096. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136097. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136098. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136100. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136102. getBodyMass(impostor: PhysicsImpostor): number;
  136103. getBodyFriction(impostor: PhysicsImpostor): number;
  136104. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136105. getBodyRestitution(impostor: PhysicsImpostor): number;
  136106. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136107. sleepBody(impostor: PhysicsImpostor): void;
  136108. wakeUpBody(impostor: PhysicsImpostor): void;
  136109. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136110. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  136111. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  136112. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136113. getRadius(impostor: PhysicsImpostor): number;
  136114. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136115. dispose(): void;
  136116. /**
  136117. * Does a raycast in the physics world
  136118. * @param from when should the ray start?
  136119. * @param to when should the ray end?
  136120. * @returns PhysicsRaycastResult
  136121. */
  136122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136123. }
  136124. }
  136125. declare module BABYLON {
  136126. /**
  136127. * Class containing static functions to help procedurally build meshes
  136128. */
  136129. export class RibbonBuilder {
  136130. /**
  136131. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136132. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136133. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136134. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136135. * * 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
  136136. * * 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
  136137. * * 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
  136138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136140. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136141. * * 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
  136142. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136143. * * 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
  136144. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136146. * @param name defines the name of the mesh
  136147. * @param options defines the options used to create the mesh
  136148. * @param scene defines the hosting scene
  136149. * @returns the ribbon mesh
  136150. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136151. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136152. */
  136153. static CreateRibbon(name: string, options: {
  136154. pathArray: Vector3[][];
  136155. closeArray?: boolean;
  136156. closePath?: boolean;
  136157. offset?: number;
  136158. updatable?: boolean;
  136159. sideOrientation?: number;
  136160. frontUVs?: Vector4;
  136161. backUVs?: Vector4;
  136162. instance?: Mesh;
  136163. invertUV?: boolean;
  136164. uvs?: Vector2[];
  136165. colors?: Color4[];
  136166. }, scene?: Nullable<Scene>): Mesh;
  136167. }
  136168. }
  136169. declare module BABYLON {
  136170. /**
  136171. * Class containing static functions to help procedurally build meshes
  136172. */
  136173. export class ShapeBuilder {
  136174. /**
  136175. * 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.
  136176. * * 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.
  136177. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136178. * * 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.
  136179. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136180. * * 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
  136181. * * 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
  136182. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136187. * @param name defines the name of the mesh
  136188. * @param options defines the options used to create the mesh
  136189. * @param scene defines the hosting scene
  136190. * @returns the extruded shape mesh
  136191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136193. */
  136194. static ExtrudeShape(name: string, options: {
  136195. shape: Vector3[];
  136196. path: Vector3[];
  136197. scale?: number;
  136198. rotation?: number;
  136199. cap?: number;
  136200. updatable?: boolean;
  136201. sideOrientation?: number;
  136202. frontUVs?: Vector4;
  136203. backUVs?: Vector4;
  136204. instance?: Mesh;
  136205. invertUV?: boolean;
  136206. }, scene?: Nullable<Scene>): Mesh;
  136207. /**
  136208. * Creates an custom extruded shape mesh.
  136209. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136210. * * 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.
  136211. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136212. * * 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
  136213. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136214. * * 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
  136215. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136216. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136217. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136218. * * 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
  136219. * * 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
  136220. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136225. * @param name defines the name of the mesh
  136226. * @param options defines the options used to create the mesh
  136227. * @param scene defines the hosting scene
  136228. * @returns the custom extruded shape mesh
  136229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136232. */
  136233. static ExtrudeShapeCustom(name: string, options: {
  136234. shape: Vector3[];
  136235. path: Vector3[];
  136236. scaleFunction?: any;
  136237. rotationFunction?: any;
  136238. ribbonCloseArray?: boolean;
  136239. ribbonClosePath?: boolean;
  136240. cap?: number;
  136241. updatable?: boolean;
  136242. sideOrientation?: number;
  136243. frontUVs?: Vector4;
  136244. backUVs?: Vector4;
  136245. instance?: Mesh;
  136246. invertUV?: boolean;
  136247. }, scene?: Nullable<Scene>): Mesh;
  136248. private static _ExtrudeShapeGeneric;
  136249. }
  136250. }
  136251. declare module BABYLON {
  136252. /**
  136253. * AmmoJS Physics plugin
  136254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  136255. * @see https://github.com/kripken/ammo.js/
  136256. */
  136257. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  136258. private _useDeltaForWorldStep;
  136259. /**
  136260. * Reference to the Ammo library
  136261. */
  136262. bjsAMMO: any;
  136263. /**
  136264. * Created ammoJS world which physics bodies are added to
  136265. */
  136266. world: any;
  136267. /**
  136268. * Name of the plugin
  136269. */
  136270. name: string;
  136271. private _timeStep;
  136272. private _fixedTimeStep;
  136273. private _maxSteps;
  136274. private _tmpQuaternion;
  136275. private _tmpAmmoTransform;
  136276. private _tmpAmmoQuaternion;
  136277. private _tmpAmmoConcreteContactResultCallback;
  136278. private _collisionConfiguration;
  136279. private _dispatcher;
  136280. private _overlappingPairCache;
  136281. private _solver;
  136282. private _softBodySolver;
  136283. private _tmpAmmoVectorA;
  136284. private _tmpAmmoVectorB;
  136285. private _tmpAmmoVectorC;
  136286. private _tmpAmmoVectorD;
  136287. private _tmpContactCallbackResult;
  136288. private _tmpAmmoVectorRCA;
  136289. private _tmpAmmoVectorRCB;
  136290. private _raycastResult;
  136291. private static readonly DISABLE_COLLISION_FLAG;
  136292. private static readonly KINEMATIC_FLAG;
  136293. private static readonly DISABLE_DEACTIVATION_FLAG;
  136294. /**
  136295. * Initializes the ammoJS plugin
  136296. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  136297. * @param ammoInjection can be used to inject your own ammo reference
  136298. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  136299. */
  136300. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  136301. /**
  136302. * Sets the gravity of the physics world (m/(s^2))
  136303. * @param gravity Gravity to set
  136304. */
  136305. setGravity(gravity: Vector3): void;
  136306. /**
  136307. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  136308. * @param timeStep timestep to use in seconds
  136309. */
  136310. setTimeStep(timeStep: number): void;
  136311. /**
  136312. * 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)
  136313. * @param fixedTimeStep fixedTimeStep to use in seconds
  136314. */
  136315. setFixedTimeStep(fixedTimeStep: number): void;
  136316. /**
  136317. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  136318. * @param maxSteps the maximum number of steps by the physics engine per frame
  136319. */
  136320. setMaxSteps(maxSteps: number): void;
  136321. /**
  136322. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  136323. * @returns the current timestep in seconds
  136324. */
  136325. getTimeStep(): number;
  136326. /**
  136327. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  136328. */
  136329. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  136330. private _isImpostorInContact;
  136331. private _isImpostorPairInContact;
  136332. private _stepSimulation;
  136333. /**
  136334. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  136335. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  136336. * After the step the babylon meshes are set to the position of the physics imposters
  136337. * @param delta amount of time to step forward
  136338. * @param impostors array of imposters to update before/after the step
  136339. */
  136340. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136341. /**
  136342. * Update babylon mesh to match physics world object
  136343. * @param impostor imposter to match
  136344. */
  136345. private _afterSoftStep;
  136346. /**
  136347. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136348. * @param impostor imposter to match
  136349. */
  136350. private _ropeStep;
  136351. /**
  136352. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136353. * @param impostor imposter to match
  136354. */
  136355. private _softbodyOrClothStep;
  136356. private _tmpMatrix;
  136357. /**
  136358. * Applies an impulse on the imposter
  136359. * @param impostor imposter to apply impulse to
  136360. * @param force amount of force to be applied to the imposter
  136361. * @param contactPoint the location to apply the impulse on the imposter
  136362. */
  136363. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136364. /**
  136365. * Applies a force on the imposter
  136366. * @param impostor imposter to apply force
  136367. * @param force amount of force to be applied to the imposter
  136368. * @param contactPoint the location to apply the force on the imposter
  136369. */
  136370. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136371. /**
  136372. * Creates a physics body using the plugin
  136373. * @param impostor the imposter to create the physics body on
  136374. */
  136375. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136376. /**
  136377. * Removes the physics body from the imposter and disposes of the body's memory
  136378. * @param impostor imposter to remove the physics body from
  136379. */
  136380. removePhysicsBody(impostor: PhysicsImpostor): void;
  136381. /**
  136382. * Generates a joint
  136383. * @param impostorJoint the imposter joint to create the joint with
  136384. */
  136385. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136386. /**
  136387. * Removes a joint
  136388. * @param impostorJoint the imposter joint to remove the joint from
  136389. */
  136390. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136391. private _addMeshVerts;
  136392. /**
  136393. * Initialise the soft body vertices to match its object's (mesh) vertices
  136394. * Softbody vertices (nodes) are in world space and to match this
  136395. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  136396. * @param impostor to create the softbody for
  136397. */
  136398. private _softVertexData;
  136399. /**
  136400. * Create an impostor's soft body
  136401. * @param impostor to create the softbody for
  136402. */
  136403. private _createSoftbody;
  136404. /**
  136405. * Create cloth for an impostor
  136406. * @param impostor to create the softbody for
  136407. */
  136408. private _createCloth;
  136409. /**
  136410. * Create rope for an impostor
  136411. * @param impostor to create the softbody for
  136412. */
  136413. private _createRope;
  136414. /**
  136415. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  136416. * @param impostor to create the custom physics shape for
  136417. */
  136418. private _createCustom;
  136419. private _addHullVerts;
  136420. private _createShape;
  136421. /**
  136422. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  136423. * @param impostor imposter containing the physics body and babylon object
  136424. */
  136425. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136426. /**
  136427. * Sets the babylon object's position/rotation from the physics body's position/rotation
  136428. * @param impostor imposter containing the physics body and babylon object
  136429. * @param newPosition new position
  136430. * @param newRotation new rotation
  136431. */
  136432. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136433. /**
  136434. * If this plugin is supported
  136435. * @returns true if its supported
  136436. */
  136437. isSupported(): boolean;
  136438. /**
  136439. * Sets the linear velocity of the physics body
  136440. * @param impostor imposter to set the velocity on
  136441. * @param velocity velocity to set
  136442. */
  136443. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136444. /**
  136445. * Sets the angular velocity of the physics body
  136446. * @param impostor imposter to set the velocity on
  136447. * @param velocity velocity to set
  136448. */
  136449. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136450. /**
  136451. * gets the linear velocity
  136452. * @param impostor imposter to get linear velocity from
  136453. * @returns linear velocity
  136454. */
  136455. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136456. /**
  136457. * gets the angular velocity
  136458. * @param impostor imposter to get angular velocity from
  136459. * @returns angular velocity
  136460. */
  136461. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136462. /**
  136463. * Sets the mass of physics body
  136464. * @param impostor imposter to set the mass on
  136465. * @param mass mass to set
  136466. */
  136467. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136468. /**
  136469. * Gets the mass of the physics body
  136470. * @param impostor imposter to get the mass from
  136471. * @returns mass
  136472. */
  136473. getBodyMass(impostor: PhysicsImpostor): number;
  136474. /**
  136475. * Gets friction of the impostor
  136476. * @param impostor impostor to get friction from
  136477. * @returns friction value
  136478. */
  136479. getBodyFriction(impostor: PhysicsImpostor): number;
  136480. /**
  136481. * Sets friction of the impostor
  136482. * @param impostor impostor to set friction on
  136483. * @param friction friction value
  136484. */
  136485. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136486. /**
  136487. * Gets restitution of the impostor
  136488. * @param impostor impostor to get restitution from
  136489. * @returns restitution value
  136490. */
  136491. getBodyRestitution(impostor: PhysicsImpostor): number;
  136492. /**
  136493. * Sets resitution of the impostor
  136494. * @param impostor impostor to set resitution on
  136495. * @param restitution resitution value
  136496. */
  136497. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136498. /**
  136499. * Gets pressure inside the impostor
  136500. * @param impostor impostor to get pressure from
  136501. * @returns pressure value
  136502. */
  136503. getBodyPressure(impostor: PhysicsImpostor): number;
  136504. /**
  136505. * Sets pressure inside a soft body impostor
  136506. * Cloth and rope must remain 0 pressure
  136507. * @param impostor impostor to set pressure on
  136508. * @param pressure pressure value
  136509. */
  136510. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  136511. /**
  136512. * Gets stiffness of the impostor
  136513. * @param impostor impostor to get stiffness from
  136514. * @returns pressure value
  136515. */
  136516. getBodyStiffness(impostor: PhysicsImpostor): number;
  136517. /**
  136518. * Sets stiffness of the impostor
  136519. * @param impostor impostor to set stiffness on
  136520. * @param stiffness stiffness value from 0 to 1
  136521. */
  136522. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  136523. /**
  136524. * Gets velocityIterations of the impostor
  136525. * @param impostor impostor to get velocity iterations from
  136526. * @returns velocityIterations value
  136527. */
  136528. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  136529. /**
  136530. * Sets velocityIterations of the impostor
  136531. * @param impostor impostor to set velocity iterations on
  136532. * @param velocityIterations velocityIterations value
  136533. */
  136534. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  136535. /**
  136536. * Gets positionIterations of the impostor
  136537. * @param impostor impostor to get position iterations from
  136538. * @returns positionIterations value
  136539. */
  136540. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  136541. /**
  136542. * Sets positionIterations of the impostor
  136543. * @param impostor impostor to set position on
  136544. * @param positionIterations positionIterations value
  136545. */
  136546. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  136547. /**
  136548. * Append an anchor to a cloth object
  136549. * @param impostor is the cloth impostor to add anchor to
  136550. * @param otherImpostor is the rigid impostor to anchor to
  136551. * @param width ratio across width from 0 to 1
  136552. * @param height ratio up height from 0 to 1
  136553. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  136554. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136555. */
  136556. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136557. /**
  136558. * Append an hook to a rope object
  136559. * @param impostor is the rope impostor to add hook to
  136560. * @param otherImpostor is the rigid impostor to hook to
  136561. * @param length ratio along the rope from 0 to 1
  136562. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  136563. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136564. */
  136565. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136566. /**
  136567. * Sleeps the physics body and stops it from being active
  136568. * @param impostor impostor to sleep
  136569. */
  136570. sleepBody(impostor: PhysicsImpostor): void;
  136571. /**
  136572. * Activates the physics body
  136573. * @param impostor impostor to activate
  136574. */
  136575. wakeUpBody(impostor: PhysicsImpostor): void;
  136576. /**
  136577. * Updates the distance parameters of the joint
  136578. * @param joint joint to update
  136579. * @param maxDistance maximum distance of the joint
  136580. * @param minDistance minimum distance of the joint
  136581. */
  136582. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136583. /**
  136584. * Sets a motor on the joint
  136585. * @param joint joint to set motor on
  136586. * @param speed speed of the motor
  136587. * @param maxForce maximum force of the motor
  136588. * @param motorIndex index of the motor
  136589. */
  136590. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136591. /**
  136592. * Sets the motors limit
  136593. * @param joint joint to set limit on
  136594. * @param upperLimit upper limit
  136595. * @param lowerLimit lower limit
  136596. */
  136597. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136598. /**
  136599. * Syncs the position and rotation of a mesh with the impostor
  136600. * @param mesh mesh to sync
  136601. * @param impostor impostor to update the mesh with
  136602. */
  136603. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136604. /**
  136605. * Gets the radius of the impostor
  136606. * @param impostor impostor to get radius from
  136607. * @returns the radius
  136608. */
  136609. getRadius(impostor: PhysicsImpostor): number;
  136610. /**
  136611. * Gets the box size of the impostor
  136612. * @param impostor impostor to get box size from
  136613. * @param result the resulting box size
  136614. */
  136615. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136616. /**
  136617. * Disposes of the impostor
  136618. */
  136619. dispose(): void;
  136620. /**
  136621. * Does a raycast in the physics world
  136622. * @param from when should the ray start?
  136623. * @param to when should the ray end?
  136624. * @returns PhysicsRaycastResult
  136625. */
  136626. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136627. }
  136628. }
  136629. declare module BABYLON {
  136630. interface AbstractScene {
  136631. /**
  136632. * The list of reflection probes added to the scene
  136633. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136634. */
  136635. reflectionProbes: Array<ReflectionProbe>;
  136636. /**
  136637. * Removes the given reflection probe from this scene.
  136638. * @param toRemove The reflection probe to remove
  136639. * @returns The index of the removed reflection probe
  136640. */
  136641. removeReflectionProbe(toRemove: ReflectionProbe): number;
  136642. /**
  136643. * Adds the given reflection probe to this scene.
  136644. * @param newReflectionProbe The reflection probe to add
  136645. */
  136646. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  136647. }
  136648. /**
  136649. * Class used to generate realtime reflection / refraction cube textures
  136650. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136651. */
  136652. export class ReflectionProbe {
  136653. /** defines the name of the probe */
  136654. name: string;
  136655. private _scene;
  136656. private _renderTargetTexture;
  136657. private _projectionMatrix;
  136658. private _viewMatrix;
  136659. private _target;
  136660. private _add;
  136661. private _attachedMesh;
  136662. private _invertYAxis;
  136663. /** Gets or sets probe position (center of the cube map) */
  136664. position: Vector3;
  136665. /**
  136666. * Creates a new reflection probe
  136667. * @param name defines the name of the probe
  136668. * @param size defines the texture resolution (for each face)
  136669. * @param scene defines the hosting scene
  136670. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  136671. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  136672. */
  136673. constructor(
  136674. /** defines the name of the probe */
  136675. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  136676. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  136677. get samples(): number;
  136678. set samples(value: number);
  136679. /** Gets or sets the refresh rate to use (on every frame by default) */
  136680. get refreshRate(): number;
  136681. set refreshRate(value: number);
  136682. /**
  136683. * Gets the hosting scene
  136684. * @returns a Scene
  136685. */
  136686. getScene(): Scene;
  136687. /** Gets the internal CubeTexture used to render to */
  136688. get cubeTexture(): RenderTargetTexture;
  136689. /** Gets the list of meshes to render */
  136690. get renderList(): Nullable<AbstractMesh[]>;
  136691. /**
  136692. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  136693. * @param mesh defines the mesh to attach to
  136694. */
  136695. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136696. /**
  136697. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  136698. * @param renderingGroupId The rendering group id corresponding to its index
  136699. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136700. */
  136701. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  136702. /**
  136703. * Clean all associated resources
  136704. */
  136705. dispose(): void;
  136706. /**
  136707. * Converts the reflection probe information to a readable string for debug purpose.
  136708. * @param fullDetails Supports for multiple levels of logging within scene loading
  136709. * @returns the human readable reflection probe info
  136710. */
  136711. toString(fullDetails?: boolean): string;
  136712. /**
  136713. * Get the class name of the relfection probe.
  136714. * @returns "ReflectionProbe"
  136715. */
  136716. getClassName(): string;
  136717. /**
  136718. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  136719. * @returns The JSON representation of the texture
  136720. */
  136721. serialize(): any;
  136722. /**
  136723. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  136724. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  136725. * @param scene Define the scene the parsed reflection probe should be instantiated in
  136726. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  136727. * @returns The parsed reflection probe if successful
  136728. */
  136729. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  136730. }
  136731. }
  136732. declare module BABYLON {
  136733. /** @hidden */
  136734. export var _BabylonLoaderRegistered: boolean;
  136735. /**
  136736. * Helps setting up some configuration for the babylon file loader.
  136737. */
  136738. export class BabylonFileLoaderConfiguration {
  136739. /**
  136740. * The loader does not allow injecting custom physix engine into the plugins.
  136741. * Unfortunately in ES6, we need to manually inject them into the plugin.
  136742. * So you could set this variable to your engine import to make it work.
  136743. */
  136744. static LoaderInjectedPhysicsEngine: any;
  136745. }
  136746. }
  136747. declare module BABYLON {
  136748. /**
  136749. * The Physically based simple base material of BJS.
  136750. *
  136751. * This enables better naming and convention enforcements on top of the pbrMaterial.
  136752. * It is used as the base class for both the specGloss and metalRough conventions.
  136753. */
  136754. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  136755. /**
  136756. * Number of Simultaneous lights allowed on the material.
  136757. */
  136758. maxSimultaneousLights: number;
  136759. /**
  136760. * If sets to true, disables all the lights affecting the material.
  136761. */
  136762. disableLighting: boolean;
  136763. /**
  136764. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  136765. */
  136766. environmentTexture: BaseTexture;
  136767. /**
  136768. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136769. */
  136770. invertNormalMapX: boolean;
  136771. /**
  136772. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136773. */
  136774. invertNormalMapY: boolean;
  136775. /**
  136776. * Normal map used in the model.
  136777. */
  136778. normalTexture: BaseTexture;
  136779. /**
  136780. * Emissivie color used to self-illuminate the model.
  136781. */
  136782. emissiveColor: Color3;
  136783. /**
  136784. * Emissivie texture used to self-illuminate the model.
  136785. */
  136786. emissiveTexture: BaseTexture;
  136787. /**
  136788. * Occlusion Channel Strenght.
  136789. */
  136790. occlusionStrength: number;
  136791. /**
  136792. * Occlusion Texture of the material (adding extra occlusion effects).
  136793. */
  136794. occlusionTexture: BaseTexture;
  136795. /**
  136796. * Defines the alpha limits in alpha test mode.
  136797. */
  136798. alphaCutOff: number;
  136799. /**
  136800. * Gets the current double sided mode.
  136801. */
  136802. get doubleSided(): boolean;
  136803. /**
  136804. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136805. */
  136806. set doubleSided(value: boolean);
  136807. /**
  136808. * Stores the pre-calculated light information of a mesh in a texture.
  136809. */
  136810. lightmapTexture: BaseTexture;
  136811. /**
  136812. * If true, the light map contains occlusion information instead of lighting info.
  136813. */
  136814. useLightmapAsShadowmap: boolean;
  136815. /**
  136816. * Instantiates a new PBRMaterial instance.
  136817. *
  136818. * @param name The material name
  136819. * @param scene The scene the material will be use in.
  136820. */
  136821. constructor(name: string, scene: Scene);
  136822. getClassName(): string;
  136823. }
  136824. }
  136825. declare module BABYLON {
  136826. /**
  136827. * The PBR material of BJS following the metal roughness convention.
  136828. *
  136829. * This fits to the PBR convention in the GLTF definition:
  136830. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  136831. */
  136832. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  136833. /**
  136834. * The base color has two different interpretations depending on the value of metalness.
  136835. * When the material is a metal, the base color is the specific measured reflectance value
  136836. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  136837. * of the material.
  136838. */
  136839. baseColor: Color3;
  136840. /**
  136841. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  136842. * well as opacity information in the alpha channel.
  136843. */
  136844. baseTexture: BaseTexture;
  136845. /**
  136846. * Specifies the metallic scalar value of the material.
  136847. * Can also be used to scale the metalness values of the metallic texture.
  136848. */
  136849. metallic: number;
  136850. /**
  136851. * Specifies the roughness scalar value of the material.
  136852. * Can also be used to scale the roughness values of the metallic texture.
  136853. */
  136854. roughness: number;
  136855. /**
  136856. * Texture containing both the metallic value in the B channel and the
  136857. * roughness value in the G channel to keep better precision.
  136858. */
  136859. metallicRoughnessTexture: BaseTexture;
  136860. /**
  136861. * Instantiates a new PBRMetalRoughnessMaterial instance.
  136862. *
  136863. * @param name The material name
  136864. * @param scene The scene the material will be use in.
  136865. */
  136866. constructor(name: string, scene: Scene);
  136867. /**
  136868. * Return the currrent class name of the material.
  136869. */
  136870. getClassName(): string;
  136871. /**
  136872. * Makes a duplicate of the current material.
  136873. * @param name - name to use for the new material.
  136874. */
  136875. clone(name: string): PBRMetallicRoughnessMaterial;
  136876. /**
  136877. * Serialize the material to a parsable JSON object.
  136878. */
  136879. serialize(): any;
  136880. /**
  136881. * Parses a JSON object correponding to the serialize function.
  136882. */
  136883. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  136884. }
  136885. }
  136886. declare module BABYLON {
  136887. /**
  136888. * The PBR material of BJS following the specular glossiness convention.
  136889. *
  136890. * This fits to the PBR convention in the GLTF definition:
  136891. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  136892. */
  136893. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  136894. /**
  136895. * Specifies the diffuse color of the material.
  136896. */
  136897. diffuseColor: Color3;
  136898. /**
  136899. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  136900. * channel.
  136901. */
  136902. diffuseTexture: BaseTexture;
  136903. /**
  136904. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  136905. */
  136906. specularColor: Color3;
  136907. /**
  136908. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  136909. */
  136910. glossiness: number;
  136911. /**
  136912. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  136913. */
  136914. specularGlossinessTexture: BaseTexture;
  136915. /**
  136916. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  136917. *
  136918. * @param name The material name
  136919. * @param scene The scene the material will be use in.
  136920. */
  136921. constructor(name: string, scene: Scene);
  136922. /**
  136923. * Return the currrent class name of the material.
  136924. */
  136925. getClassName(): string;
  136926. /**
  136927. * Makes a duplicate of the current material.
  136928. * @param name - name to use for the new material.
  136929. */
  136930. clone(name: string): PBRSpecularGlossinessMaterial;
  136931. /**
  136932. * Serialize the material to a parsable JSON object.
  136933. */
  136934. serialize(): any;
  136935. /**
  136936. * Parses a JSON object correponding to the serialize function.
  136937. */
  136938. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  136939. }
  136940. }
  136941. declare module BABYLON {
  136942. /**
  136943. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  136944. * It can help converting any input color in a desired output one. This can then be used to create effects
  136945. * from sepia, black and white to sixties or futuristic rendering...
  136946. *
  136947. * The only supported format is currently 3dl.
  136948. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  136949. */
  136950. export class ColorGradingTexture extends BaseTexture {
  136951. /**
  136952. * The texture URL.
  136953. */
  136954. url: string;
  136955. /**
  136956. * Empty line regex stored for GC.
  136957. */
  136958. private static _noneEmptyLineRegex;
  136959. private _textureMatrix;
  136960. private _onLoad;
  136961. /**
  136962. * Instantiates a ColorGradingTexture from the following parameters.
  136963. *
  136964. * @param url The location of the color gradind data (currently only supporting 3dl)
  136965. * @param sceneOrEngine The scene or engine the texture will be used in
  136966. * @param onLoad defines a callback triggered when the texture has been loaded
  136967. */
  136968. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  136969. /**
  136970. * Fires the onload event from the constructor if requested.
  136971. */
  136972. private _triggerOnLoad;
  136973. /**
  136974. * Returns the texture matrix used in most of the material.
  136975. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  136976. */
  136977. getTextureMatrix(): Matrix;
  136978. /**
  136979. * Occurs when the file being loaded is a .3dl LUT file.
  136980. */
  136981. private load3dlTexture;
  136982. /**
  136983. * Starts the loading process of the texture.
  136984. */
  136985. private loadTexture;
  136986. /**
  136987. * Clones the color gradind texture.
  136988. */
  136989. clone(): ColorGradingTexture;
  136990. /**
  136991. * Called during delayed load for textures.
  136992. */
  136993. delayLoad(): void;
  136994. /**
  136995. * Parses a color grading texture serialized by Babylon.
  136996. * @param parsedTexture The texture information being parsedTexture
  136997. * @param scene The scene to load the texture in
  136998. * @param rootUrl The root url of the data assets to load
  136999. * @return A color gradind texture
  137000. */
  137001. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  137002. /**
  137003. * Serializes the LUT texture to json format.
  137004. */
  137005. serialize(): any;
  137006. }
  137007. }
  137008. declare module BABYLON {
  137009. /**
  137010. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  137011. */
  137012. export class EquiRectangularCubeTexture extends BaseTexture {
  137013. /** The six faces of the cube. */
  137014. private static _FacesMapping;
  137015. private _noMipmap;
  137016. private _onLoad;
  137017. private _onError;
  137018. /** The size of the cubemap. */
  137019. private _size;
  137020. /** The buffer of the image. */
  137021. private _buffer;
  137022. /** The width of the input image. */
  137023. private _width;
  137024. /** The height of the input image. */
  137025. private _height;
  137026. /** The URL to the image. */
  137027. url: string;
  137028. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  137029. coordinatesMode: number;
  137030. /**
  137031. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  137032. * @param url The location of the image
  137033. * @param scene The scene the texture will be used in
  137034. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137035. * @param noMipmap Forces to not generate the mipmap if true
  137036. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137037. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137038. * @param onLoad — defines a callback called when texture is loaded
  137039. * @param onError — defines a callback called if there is an error
  137040. */
  137041. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137042. /**
  137043. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137044. */
  137045. private loadImage;
  137046. /**
  137047. * Convert the image buffer into a cubemap and create a CubeTexture.
  137048. */
  137049. private loadTexture;
  137050. /**
  137051. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137052. * @param buffer The ArrayBuffer that should be converted.
  137053. * @returns The buffer as Float32Array.
  137054. */
  137055. private getFloat32ArrayFromArrayBuffer;
  137056. /**
  137057. * Get the current class name of the texture useful for serialization or dynamic coding.
  137058. * @returns "EquiRectangularCubeTexture"
  137059. */
  137060. getClassName(): string;
  137061. /**
  137062. * Create a clone of the current EquiRectangularCubeTexture and return it.
  137063. * @returns A clone of the current EquiRectangularCubeTexture.
  137064. */
  137065. clone(): EquiRectangularCubeTexture;
  137066. }
  137067. }
  137068. declare module BABYLON {
  137069. /**
  137070. * Defines the options related to the creation of an HtmlElementTexture
  137071. */
  137072. export interface IHtmlElementTextureOptions {
  137073. /**
  137074. * Defines wether mip maps should be created or not.
  137075. */
  137076. generateMipMaps?: boolean;
  137077. /**
  137078. * Defines the sampling mode of the texture.
  137079. */
  137080. samplingMode?: number;
  137081. /**
  137082. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  137083. */
  137084. engine: Nullable<ThinEngine>;
  137085. /**
  137086. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  137087. */
  137088. scene: Nullable<Scene>;
  137089. }
  137090. /**
  137091. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  137092. * To be as efficient as possible depending on your constraints nothing aside the first upload
  137093. * is automatically managed.
  137094. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  137095. * in your application.
  137096. *
  137097. * As the update is not automatic, you need to call them manually.
  137098. */
  137099. export class HtmlElementTexture extends BaseTexture {
  137100. /**
  137101. * The texture URL.
  137102. */
  137103. element: HTMLVideoElement | HTMLCanvasElement;
  137104. private static readonly DefaultOptions;
  137105. private _textureMatrix;
  137106. private _isVideo;
  137107. private _generateMipMaps;
  137108. private _samplingMode;
  137109. /**
  137110. * Instantiates a HtmlElementTexture from the following parameters.
  137111. *
  137112. * @param name Defines the name of the texture
  137113. * @param element Defines the video or canvas the texture is filled with
  137114. * @param options Defines the other none mandatory texture creation options
  137115. */
  137116. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  137117. private _createInternalTexture;
  137118. /**
  137119. * Returns the texture matrix used in most of the material.
  137120. */
  137121. getTextureMatrix(): Matrix;
  137122. /**
  137123. * Updates the content of the texture.
  137124. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  137125. */
  137126. update(invertY?: Nullable<boolean>): void;
  137127. }
  137128. }
  137129. declare module BABYLON {
  137130. /**
  137131. * Based on jsTGALoader - Javascript loader for TGA file
  137132. * By Vincent Thibault
  137133. * @see http://blog.robrowser.com/javascript-tga-loader.html
  137134. */
  137135. export class TGATools {
  137136. private static _TYPE_INDEXED;
  137137. private static _TYPE_RGB;
  137138. private static _TYPE_GREY;
  137139. private static _TYPE_RLE_INDEXED;
  137140. private static _TYPE_RLE_RGB;
  137141. private static _TYPE_RLE_GREY;
  137142. private static _ORIGIN_MASK;
  137143. private static _ORIGIN_SHIFT;
  137144. private static _ORIGIN_BL;
  137145. private static _ORIGIN_BR;
  137146. private static _ORIGIN_UL;
  137147. private static _ORIGIN_UR;
  137148. /**
  137149. * Gets the header of a TGA file
  137150. * @param data defines the TGA data
  137151. * @returns the header
  137152. */
  137153. static GetTGAHeader(data: Uint8Array): any;
  137154. /**
  137155. * Uploads TGA content to a Babylon Texture
  137156. * @hidden
  137157. */
  137158. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  137159. /** @hidden */
  137160. 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;
  137161. /** @hidden */
  137162. 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;
  137163. /** @hidden */
  137164. 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;
  137165. /** @hidden */
  137166. 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;
  137167. /** @hidden */
  137168. 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;
  137169. /** @hidden */
  137170. 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;
  137171. }
  137172. }
  137173. declare module BABYLON {
  137174. /**
  137175. * Implementation of the TGA Texture Loader.
  137176. * @hidden
  137177. */
  137178. export class _TGATextureLoader implements IInternalTextureLoader {
  137179. /**
  137180. * Defines wether the loader supports cascade loading the different faces.
  137181. */
  137182. readonly supportCascades: boolean;
  137183. /**
  137184. * This returns if the loader support the current file information.
  137185. * @param extension defines the file extension of the file being loaded
  137186. * @returns true if the loader can load the specified file
  137187. */
  137188. canLoad(extension: string): boolean;
  137189. /**
  137190. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137191. * @param data contains the texture data
  137192. * @param texture defines the BabylonJS internal texture
  137193. * @param createPolynomials will be true if polynomials have been requested
  137194. * @param onLoad defines the callback to trigger once the texture is ready
  137195. * @param onError defines the callback to trigger in case of error
  137196. */
  137197. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137198. /**
  137199. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137200. * @param data contains the texture data
  137201. * @param texture defines the BabylonJS internal texture
  137202. * @param callback defines the method to call once ready to upload
  137203. */
  137204. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137205. }
  137206. }
  137207. declare module BABYLON {
  137208. /**
  137209. * Info about the .basis files
  137210. */
  137211. class BasisFileInfo {
  137212. /**
  137213. * If the file has alpha
  137214. */
  137215. hasAlpha: boolean;
  137216. /**
  137217. * Info about each image of the basis file
  137218. */
  137219. images: Array<{
  137220. levels: Array<{
  137221. width: number;
  137222. height: number;
  137223. transcodedPixels: ArrayBufferView;
  137224. }>;
  137225. }>;
  137226. }
  137227. /**
  137228. * Result of transcoding a basis file
  137229. */
  137230. class TranscodeResult {
  137231. /**
  137232. * Info about the .basis file
  137233. */
  137234. fileInfo: BasisFileInfo;
  137235. /**
  137236. * Format to use when loading the file
  137237. */
  137238. format: number;
  137239. }
  137240. /**
  137241. * Configuration options for the Basis transcoder
  137242. */
  137243. export class BasisTranscodeConfiguration {
  137244. /**
  137245. * Supported compression formats used to determine the supported output format of the transcoder
  137246. */
  137247. supportedCompressionFormats?: {
  137248. /**
  137249. * etc1 compression format
  137250. */
  137251. etc1?: boolean;
  137252. /**
  137253. * s3tc compression format
  137254. */
  137255. s3tc?: boolean;
  137256. /**
  137257. * pvrtc compression format
  137258. */
  137259. pvrtc?: boolean;
  137260. /**
  137261. * etc2 compression format
  137262. */
  137263. etc2?: boolean;
  137264. };
  137265. /**
  137266. * If mipmap levels should be loaded for transcoded images (Default: true)
  137267. */
  137268. loadMipmapLevels?: boolean;
  137269. /**
  137270. * Index of a single image to load (Default: all images)
  137271. */
  137272. loadSingleImage?: number;
  137273. }
  137274. /**
  137275. * Used to load .Basis files
  137276. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  137277. */
  137278. export class BasisTools {
  137279. private static _IgnoreSupportedFormats;
  137280. /**
  137281. * URL to use when loading the basis transcoder
  137282. */
  137283. static JSModuleURL: string;
  137284. /**
  137285. * URL to use when loading the wasm module for the transcoder
  137286. */
  137287. static WasmModuleURL: string;
  137288. /**
  137289. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  137290. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  137291. * @returns internal format corresponding to the Basis format
  137292. */
  137293. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  137294. private static _WorkerPromise;
  137295. private static _Worker;
  137296. private static _actionId;
  137297. private static _CreateWorkerAsync;
  137298. /**
  137299. * Transcodes a loaded image file to compressed pixel data
  137300. * @param data image data to transcode
  137301. * @param config configuration options for the transcoding
  137302. * @returns a promise resulting in the transcoded image
  137303. */
  137304. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  137305. /**
  137306. * Loads a texture from the transcode result
  137307. * @param texture texture load to
  137308. * @param transcodeResult the result of transcoding the basis file to load from
  137309. */
  137310. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  137311. }
  137312. }
  137313. declare module BABYLON {
  137314. /**
  137315. * Loader for .basis file format
  137316. */
  137317. export class _BasisTextureLoader implements IInternalTextureLoader {
  137318. /**
  137319. * Defines whether the loader supports cascade loading the different faces.
  137320. */
  137321. readonly supportCascades: boolean;
  137322. /**
  137323. * This returns if the loader support the current file information.
  137324. * @param extension defines the file extension of the file being loaded
  137325. * @returns true if the loader can load the specified file
  137326. */
  137327. canLoad(extension: string): boolean;
  137328. /**
  137329. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137330. * @param data contains the texture data
  137331. * @param texture defines the BabylonJS internal texture
  137332. * @param createPolynomials will be true if polynomials have been requested
  137333. * @param onLoad defines the callback to trigger once the texture is ready
  137334. * @param onError defines the callback to trigger in case of error
  137335. */
  137336. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137337. /**
  137338. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137339. * @param data contains the texture data
  137340. * @param texture defines the BabylonJS internal texture
  137341. * @param callback defines the method to call once ready to upload
  137342. */
  137343. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137344. }
  137345. }
  137346. declare module BABYLON {
  137347. /**
  137348. * Defines the basic options interface of a TexturePacker Frame
  137349. */
  137350. export interface ITexturePackerFrame {
  137351. /**
  137352. * The frame ID
  137353. */
  137354. id: number;
  137355. /**
  137356. * The frames Scale
  137357. */
  137358. scale: Vector2;
  137359. /**
  137360. * The Frames offset
  137361. */
  137362. offset: Vector2;
  137363. }
  137364. /**
  137365. * This is a support class for frame Data on texture packer sets.
  137366. */
  137367. export class TexturePackerFrame implements ITexturePackerFrame {
  137368. /**
  137369. * The frame ID
  137370. */
  137371. id: number;
  137372. /**
  137373. * The frames Scale
  137374. */
  137375. scale: Vector2;
  137376. /**
  137377. * The Frames offset
  137378. */
  137379. offset: Vector2;
  137380. /**
  137381. * Initializes a texture package frame.
  137382. * @param id The numerical frame identifier
  137383. * @param scale Scalar Vector2 for UV frame
  137384. * @param offset Vector2 for the frame position in UV units.
  137385. * @returns TexturePackerFrame
  137386. */
  137387. constructor(id: number, scale: Vector2, offset: Vector2);
  137388. }
  137389. }
  137390. declare module BABYLON {
  137391. /**
  137392. * Defines the basic options interface of a TexturePacker
  137393. */
  137394. export interface ITexturePackerOptions {
  137395. /**
  137396. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  137397. */
  137398. map?: string[];
  137399. /**
  137400. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137401. */
  137402. uvsIn?: string;
  137403. /**
  137404. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137405. */
  137406. uvsOut?: string;
  137407. /**
  137408. * number representing the layout style. Defaults to LAYOUT_STRIP
  137409. */
  137410. layout?: number;
  137411. /**
  137412. * number of columns if using custom column count layout(2). This defaults to 4.
  137413. */
  137414. colnum?: number;
  137415. /**
  137416. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  137417. */
  137418. updateInputMeshes?: boolean;
  137419. /**
  137420. * boolean flag to dispose all the source textures. Defaults to true.
  137421. */
  137422. disposeSources?: boolean;
  137423. /**
  137424. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  137425. */
  137426. fillBlanks?: boolean;
  137427. /**
  137428. * string value representing the context fill style color. Defaults to 'black'.
  137429. */
  137430. customFillColor?: string;
  137431. /**
  137432. * Width and Height Value of each Frame in the TexturePacker Sets
  137433. */
  137434. frameSize?: number;
  137435. /**
  137436. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  137437. */
  137438. paddingRatio?: number;
  137439. /**
  137440. * Number that declares the fill method for the padding gutter.
  137441. */
  137442. paddingMode?: number;
  137443. /**
  137444. * If in SUBUV_COLOR padding mode what color to use.
  137445. */
  137446. paddingColor?: Color3 | Color4;
  137447. }
  137448. /**
  137449. * Defines the basic interface of a TexturePacker JSON File
  137450. */
  137451. export interface ITexturePackerJSON {
  137452. /**
  137453. * The frame ID
  137454. */
  137455. name: string;
  137456. /**
  137457. * The base64 channel data
  137458. */
  137459. sets: any;
  137460. /**
  137461. * The options of the Packer
  137462. */
  137463. options: ITexturePackerOptions;
  137464. /**
  137465. * The frame data of the Packer
  137466. */
  137467. frames: Array<number>;
  137468. }
  137469. /**
  137470. * This is a support class that generates a series of packed texture sets.
  137471. * @see https://doc.babylonjs.com/babylon101/materials
  137472. */
  137473. export class TexturePacker {
  137474. /** Packer Layout Constant 0 */
  137475. static readonly LAYOUT_STRIP: number;
  137476. /** Packer Layout Constant 1 */
  137477. static readonly LAYOUT_POWER2: number;
  137478. /** Packer Layout Constant 2 */
  137479. static readonly LAYOUT_COLNUM: number;
  137480. /** Packer Layout Constant 0 */
  137481. static readonly SUBUV_WRAP: number;
  137482. /** Packer Layout Constant 1 */
  137483. static readonly SUBUV_EXTEND: number;
  137484. /** Packer Layout Constant 2 */
  137485. static readonly SUBUV_COLOR: number;
  137486. /** The Name of the Texture Package */
  137487. name: string;
  137488. /** The scene scope of the TexturePacker */
  137489. scene: Scene;
  137490. /** The Meshes to target */
  137491. meshes: AbstractMesh[];
  137492. /** Arguments passed with the Constructor */
  137493. options: ITexturePackerOptions;
  137494. /** The promise that is started upon initialization */
  137495. promise: Nullable<Promise<TexturePacker | string>>;
  137496. /** The Container object for the channel sets that are generated */
  137497. sets: object;
  137498. /** The Container array for the frames that are generated */
  137499. frames: TexturePackerFrame[];
  137500. /** The expected number of textures the system is parsing. */
  137501. private _expecting;
  137502. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  137503. private _paddingValue;
  137504. /**
  137505. * Initializes a texture package series from an array of meshes or a single mesh.
  137506. * @param name The name of the package
  137507. * @param meshes The target meshes to compose the package from
  137508. * @param options The arguments that texture packer should follow while building.
  137509. * @param scene The scene which the textures are scoped to.
  137510. * @returns TexturePacker
  137511. */
  137512. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  137513. /**
  137514. * Starts the package process
  137515. * @param resolve The promises resolution function
  137516. * @returns TexturePacker
  137517. */
  137518. private _createFrames;
  137519. /**
  137520. * Calculates the Size of the Channel Sets
  137521. * @returns Vector2
  137522. */
  137523. private _calculateSize;
  137524. /**
  137525. * Calculates the UV data for the frames.
  137526. * @param baseSize the base frameSize
  137527. * @param padding the base frame padding
  137528. * @param dtSize size of the Dynamic Texture for that channel
  137529. * @param dtUnits is 1/dtSize
  137530. * @param update flag to update the input meshes
  137531. */
  137532. private _calculateMeshUVFrames;
  137533. /**
  137534. * Calculates the frames Offset.
  137535. * @param index of the frame
  137536. * @returns Vector2
  137537. */
  137538. private _getFrameOffset;
  137539. /**
  137540. * Updates a Mesh to the frame data
  137541. * @param mesh that is the target
  137542. * @param frameID or the frame index
  137543. */
  137544. private _updateMeshUV;
  137545. /**
  137546. * Updates a Meshes materials to use the texture packer channels
  137547. * @param m is the mesh to target
  137548. * @param force all channels on the packer to be set.
  137549. */
  137550. private _updateTextureReferences;
  137551. /**
  137552. * Public method to set a Mesh to a frame
  137553. * @param m that is the target
  137554. * @param frameID or the frame index
  137555. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  137556. */
  137557. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  137558. /**
  137559. * Starts the async promise to compile the texture packer.
  137560. * @returns Promise<void>
  137561. */
  137562. processAsync(): Promise<void>;
  137563. /**
  137564. * Disposes all textures associated with this packer
  137565. */
  137566. dispose(): void;
  137567. /**
  137568. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  137569. * @param imageType is the image type to use.
  137570. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  137571. */
  137572. download(imageType?: string, quality?: number): void;
  137573. /**
  137574. * Public method to load a texturePacker JSON file.
  137575. * @param data of the JSON file in string format.
  137576. */
  137577. updateFromJSON(data: string): void;
  137578. }
  137579. }
  137580. declare module BABYLON {
  137581. /**
  137582. * 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.
  137583. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137584. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137585. */
  137586. export class CustomProceduralTexture extends ProceduralTexture {
  137587. private _animate;
  137588. private _time;
  137589. private _config;
  137590. private _texturePath;
  137591. /**
  137592. * Instantiates a new Custom Procedural Texture.
  137593. * 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.
  137594. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137595. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137596. * @param name Define the name of the texture
  137597. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  137598. * @param size Define the size of the texture to create
  137599. * @param scene Define the scene the texture belongs to
  137600. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  137601. * @param generateMipMaps Define if the texture should creates mip maps or not
  137602. */
  137603. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137604. private _loadJson;
  137605. /**
  137606. * Is the texture ready to be used ? (rendered at least once)
  137607. * @returns true if ready, otherwise, false.
  137608. */
  137609. isReady(): boolean;
  137610. /**
  137611. * Render the texture to its associated render target.
  137612. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  137613. */
  137614. render(useCameraPostProcess?: boolean): void;
  137615. /**
  137616. * Update the list of dependant textures samplers in the shader.
  137617. */
  137618. updateTextures(): void;
  137619. /**
  137620. * Update the uniform values of the procedural texture in the shader.
  137621. */
  137622. updateShaderUniforms(): void;
  137623. /**
  137624. * Define if the texture animates or not.
  137625. */
  137626. get animate(): boolean;
  137627. set animate(value: boolean);
  137628. }
  137629. }
  137630. declare module BABYLON {
  137631. /** @hidden */
  137632. export var noisePixelShader: {
  137633. name: string;
  137634. shader: string;
  137635. };
  137636. }
  137637. declare module BABYLON {
  137638. /**
  137639. * Class used to generate noise procedural textures
  137640. */
  137641. export class NoiseProceduralTexture extends ProceduralTexture {
  137642. private _time;
  137643. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  137644. brightness: number;
  137645. /** Defines the number of octaves to process */
  137646. octaves: number;
  137647. /** Defines the level of persistence (0.8 by default) */
  137648. persistence: number;
  137649. /** Gets or sets animation speed factor (default is 1) */
  137650. animationSpeedFactor: number;
  137651. /**
  137652. * Creates a new NoiseProceduralTexture
  137653. * @param name defines the name fo the texture
  137654. * @param size defines the size of the texture (default is 256)
  137655. * @param scene defines the hosting scene
  137656. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  137657. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  137658. */
  137659. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137660. private _updateShaderUniforms;
  137661. protected _getDefines(): string;
  137662. /** Generate the current state of the procedural texture */
  137663. render(useCameraPostProcess?: boolean): void;
  137664. /**
  137665. * Serializes this noise procedural texture
  137666. * @returns a serialized noise procedural texture object
  137667. */
  137668. serialize(): any;
  137669. /**
  137670. * Clone the texture.
  137671. * @returns the cloned texture
  137672. */
  137673. clone(): NoiseProceduralTexture;
  137674. /**
  137675. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  137676. * @param parsedTexture defines parsed texture data
  137677. * @param scene defines the current scene
  137678. * @param rootUrl defines the root URL containing noise procedural texture information
  137679. * @returns a parsed NoiseProceduralTexture
  137680. */
  137681. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  137682. }
  137683. }
  137684. declare module BABYLON {
  137685. /**
  137686. * Raw cube texture where the raw buffers are passed in
  137687. */
  137688. export class RawCubeTexture extends CubeTexture {
  137689. /**
  137690. * Creates a cube texture where the raw buffers are passed in.
  137691. * @param scene defines the scene the texture is attached to
  137692. * @param data defines the array of data to use to create each face
  137693. * @param size defines the size of the textures
  137694. * @param format defines the format of the data
  137695. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  137696. * @param generateMipMaps defines if the engine should generate the mip levels
  137697. * @param invertY defines if data must be stored with Y axis inverted
  137698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  137699. * @param compression defines the compression used (null by default)
  137700. */
  137701. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  137702. /**
  137703. * Updates the raw cube texture.
  137704. * @param data defines the data to store
  137705. * @param format defines the data format
  137706. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  137707. * @param invertY defines if data must be stored with Y axis inverted
  137708. * @param compression defines the compression used (null by default)
  137709. * @param level defines which level of the texture to update
  137710. */
  137711. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  137712. /**
  137713. * Updates a raw cube texture with RGBD encoded data.
  137714. * @param data defines the array of data [mipmap][face] to use to create each face
  137715. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  137716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137718. * @returns a promsie that resolves when the operation is complete
  137719. */
  137720. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  137721. /**
  137722. * Clones the raw cube texture.
  137723. * @return a new cube texture
  137724. */
  137725. clone(): CubeTexture;
  137726. /** @hidden */
  137727. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137728. }
  137729. }
  137730. declare module BABYLON {
  137731. /**
  137732. * Class used to store 2D array textures containing user data
  137733. */
  137734. export class RawTexture2DArray extends Texture {
  137735. /** Gets or sets the texture format to use */
  137736. format: number;
  137737. /**
  137738. * Create a new RawTexture2DArray
  137739. * @param data defines the data of the texture
  137740. * @param width defines the width of the texture
  137741. * @param height defines the height of the texture
  137742. * @param depth defines the number of layers of the texture
  137743. * @param format defines the texture format to use
  137744. * @param scene defines the hosting scene
  137745. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137746. * @param invertY defines if texture must be stored with Y axis inverted
  137747. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137749. */
  137750. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137751. /** Gets or sets the texture format to use */
  137752. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137753. /**
  137754. * Update the texture with new data
  137755. * @param data defines the data to store in the texture
  137756. */
  137757. update(data: ArrayBufferView): void;
  137758. }
  137759. }
  137760. declare module BABYLON {
  137761. /**
  137762. * Class used to store 3D textures containing user data
  137763. */
  137764. export class RawTexture3D extends Texture {
  137765. /** Gets or sets the texture format to use */
  137766. format: number;
  137767. /**
  137768. * Create a new RawTexture3D
  137769. * @param data defines the data of the texture
  137770. * @param width defines the width of the texture
  137771. * @param height defines the height of the texture
  137772. * @param depth defines the depth of the texture
  137773. * @param format defines the texture format to use
  137774. * @param scene defines the hosting scene
  137775. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137776. * @param invertY defines if texture must be stored with Y axis inverted
  137777. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137778. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137779. */
  137780. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137781. /** Gets or sets the texture format to use */
  137782. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137783. /**
  137784. * Update the texture with new data
  137785. * @param data defines the data to store in the texture
  137786. */
  137787. update(data: ArrayBufferView): void;
  137788. }
  137789. }
  137790. declare module BABYLON {
  137791. /**
  137792. * Creates a refraction texture used by refraction channel of the standard material.
  137793. * It is like a mirror but to see through a material.
  137794. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137795. */
  137796. export class RefractionTexture extends RenderTargetTexture {
  137797. /**
  137798. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  137799. * 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.
  137800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137801. */
  137802. refractionPlane: Plane;
  137803. /**
  137804. * Define how deep under the surface we should see.
  137805. */
  137806. depth: number;
  137807. /**
  137808. * Creates a refraction texture used by refraction channel of the standard material.
  137809. * It is like a mirror but to see through a material.
  137810. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137811. * @param name Define the texture name
  137812. * @param size Define the size of the underlying texture
  137813. * @param scene Define the scene the refraction belongs to
  137814. * @param generateMipMaps Define if we need to generate mips level for the refraction
  137815. */
  137816. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  137817. /**
  137818. * Clone the refraction texture.
  137819. * @returns the cloned texture
  137820. */
  137821. clone(): RefractionTexture;
  137822. /**
  137823. * Serialize the texture to a JSON representation you could use in Parse later on
  137824. * @returns the serialized JSON representation
  137825. */
  137826. serialize(): any;
  137827. }
  137828. }
  137829. declare module BABYLON {
  137830. /**
  137831. * Block used to add support for vertex skinning (bones)
  137832. */
  137833. export class BonesBlock extends NodeMaterialBlock {
  137834. /**
  137835. * Creates a new BonesBlock
  137836. * @param name defines the block name
  137837. */
  137838. constructor(name: string);
  137839. /**
  137840. * Initialize the block and prepare the context for build
  137841. * @param state defines the state that will be used for the build
  137842. */
  137843. initialize(state: NodeMaterialBuildState): void;
  137844. /**
  137845. * Gets the current class name
  137846. * @returns the class name
  137847. */
  137848. getClassName(): string;
  137849. /**
  137850. * Gets the matrix indices input component
  137851. */
  137852. get matricesIndices(): NodeMaterialConnectionPoint;
  137853. /**
  137854. * Gets the matrix weights input component
  137855. */
  137856. get matricesWeights(): NodeMaterialConnectionPoint;
  137857. /**
  137858. * Gets the extra matrix indices input component
  137859. */
  137860. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  137861. /**
  137862. * Gets the extra matrix weights input component
  137863. */
  137864. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  137865. /**
  137866. * Gets the world input component
  137867. */
  137868. get world(): NodeMaterialConnectionPoint;
  137869. /**
  137870. * Gets the output component
  137871. */
  137872. get output(): NodeMaterialConnectionPoint;
  137873. autoConfigure(material: NodeMaterial): void;
  137874. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  137875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137877. protected _buildBlock(state: NodeMaterialBuildState): this;
  137878. }
  137879. }
  137880. declare module BABYLON {
  137881. /**
  137882. * Block used to add support for instances
  137883. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  137884. */
  137885. export class InstancesBlock extends NodeMaterialBlock {
  137886. /**
  137887. * Creates a new InstancesBlock
  137888. * @param name defines the block name
  137889. */
  137890. constructor(name: string);
  137891. /**
  137892. * Gets the current class name
  137893. * @returns the class name
  137894. */
  137895. getClassName(): string;
  137896. /**
  137897. * Gets the first world row input component
  137898. */
  137899. get world0(): NodeMaterialConnectionPoint;
  137900. /**
  137901. * Gets the second world row input component
  137902. */
  137903. get world1(): NodeMaterialConnectionPoint;
  137904. /**
  137905. * Gets the third world row input component
  137906. */
  137907. get world2(): NodeMaterialConnectionPoint;
  137908. /**
  137909. * Gets the forth world row input component
  137910. */
  137911. get world3(): NodeMaterialConnectionPoint;
  137912. /**
  137913. * Gets the world input component
  137914. */
  137915. get world(): NodeMaterialConnectionPoint;
  137916. /**
  137917. * Gets the output component
  137918. */
  137919. get output(): NodeMaterialConnectionPoint;
  137920. /**
  137921. * Gets the isntanceID component
  137922. */
  137923. get instanceID(): NodeMaterialConnectionPoint;
  137924. autoConfigure(material: NodeMaterial): void;
  137925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  137926. protected _buildBlock(state: NodeMaterialBuildState): this;
  137927. }
  137928. }
  137929. declare module BABYLON {
  137930. /**
  137931. * Block used to add morph targets support to vertex shader
  137932. */
  137933. export class MorphTargetsBlock extends NodeMaterialBlock {
  137934. private _repeatableContentAnchor;
  137935. /**
  137936. * Create a new MorphTargetsBlock
  137937. * @param name defines the block name
  137938. */
  137939. constructor(name: string);
  137940. /**
  137941. * Gets the current class name
  137942. * @returns the class name
  137943. */
  137944. getClassName(): string;
  137945. /**
  137946. * Gets the position input component
  137947. */
  137948. get position(): NodeMaterialConnectionPoint;
  137949. /**
  137950. * Gets the normal input component
  137951. */
  137952. get normal(): NodeMaterialConnectionPoint;
  137953. /**
  137954. * Gets the tangent input component
  137955. */
  137956. get tangent(): NodeMaterialConnectionPoint;
  137957. /**
  137958. * Gets the tangent input component
  137959. */
  137960. get uv(): NodeMaterialConnectionPoint;
  137961. /**
  137962. * Gets the position output component
  137963. */
  137964. get positionOutput(): NodeMaterialConnectionPoint;
  137965. /**
  137966. * Gets the normal output component
  137967. */
  137968. get normalOutput(): NodeMaterialConnectionPoint;
  137969. /**
  137970. * Gets the tangent output component
  137971. */
  137972. get tangentOutput(): NodeMaterialConnectionPoint;
  137973. /**
  137974. * Gets the tangent output component
  137975. */
  137976. get uvOutput(): NodeMaterialConnectionPoint;
  137977. initialize(state: NodeMaterialBuildState): void;
  137978. autoConfigure(material: NodeMaterial): void;
  137979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137980. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137981. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  137982. protected _buildBlock(state: NodeMaterialBuildState): this;
  137983. }
  137984. }
  137985. declare module BABYLON {
  137986. /**
  137987. * Block used to get data information from a light
  137988. */
  137989. export class LightInformationBlock extends NodeMaterialBlock {
  137990. private _lightDataUniformName;
  137991. private _lightColorUniformName;
  137992. private _lightTypeDefineName;
  137993. /**
  137994. * Gets or sets the light associated with this block
  137995. */
  137996. light: Nullable<Light>;
  137997. /**
  137998. * Creates a new LightInformationBlock
  137999. * @param name defines the block name
  138000. */
  138001. constructor(name: string);
  138002. /**
  138003. * Gets the current class name
  138004. * @returns the class name
  138005. */
  138006. getClassName(): string;
  138007. /**
  138008. * Gets the world position input component
  138009. */
  138010. get worldPosition(): NodeMaterialConnectionPoint;
  138011. /**
  138012. * Gets the direction output component
  138013. */
  138014. get direction(): NodeMaterialConnectionPoint;
  138015. /**
  138016. * Gets the direction output component
  138017. */
  138018. get color(): NodeMaterialConnectionPoint;
  138019. /**
  138020. * Gets the direction output component
  138021. */
  138022. get intensity(): NodeMaterialConnectionPoint;
  138023. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138025. protected _buildBlock(state: NodeMaterialBuildState): this;
  138026. serialize(): any;
  138027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138028. }
  138029. }
  138030. declare module BABYLON {
  138031. /**
  138032. * Block used to add image processing support to fragment shader
  138033. */
  138034. export class ImageProcessingBlock extends NodeMaterialBlock {
  138035. /**
  138036. * Create a new ImageProcessingBlock
  138037. * @param name defines the block name
  138038. */
  138039. constructor(name: string);
  138040. /**
  138041. * Gets the current class name
  138042. * @returns the class name
  138043. */
  138044. getClassName(): string;
  138045. /**
  138046. * Gets the color input component
  138047. */
  138048. get color(): NodeMaterialConnectionPoint;
  138049. /**
  138050. * Gets the output component
  138051. */
  138052. get output(): NodeMaterialConnectionPoint;
  138053. /**
  138054. * Initialize the block and prepare the context for build
  138055. * @param state defines the state that will be used for the build
  138056. */
  138057. initialize(state: NodeMaterialBuildState): void;
  138058. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  138059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138061. protected _buildBlock(state: NodeMaterialBuildState): this;
  138062. }
  138063. }
  138064. declare module BABYLON {
  138065. /**
  138066. * Block used to pertub normals based on a normal map
  138067. */
  138068. export class PerturbNormalBlock extends NodeMaterialBlock {
  138069. private _tangentSpaceParameterName;
  138070. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  138071. invertX: boolean;
  138072. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  138073. invertY: boolean;
  138074. /**
  138075. * Create a new PerturbNormalBlock
  138076. * @param name defines the block name
  138077. */
  138078. constructor(name: string);
  138079. /**
  138080. * Gets the current class name
  138081. * @returns the class name
  138082. */
  138083. getClassName(): string;
  138084. /**
  138085. * Gets the world position input component
  138086. */
  138087. get worldPosition(): NodeMaterialConnectionPoint;
  138088. /**
  138089. * Gets the world normal input component
  138090. */
  138091. get worldNormal(): NodeMaterialConnectionPoint;
  138092. /**
  138093. * Gets the world tangent input component
  138094. */
  138095. get worldTangent(): NodeMaterialConnectionPoint;
  138096. /**
  138097. * Gets the uv input component
  138098. */
  138099. get uv(): NodeMaterialConnectionPoint;
  138100. /**
  138101. * Gets the normal map color input component
  138102. */
  138103. get normalMapColor(): NodeMaterialConnectionPoint;
  138104. /**
  138105. * Gets the strength input component
  138106. */
  138107. get strength(): NodeMaterialConnectionPoint;
  138108. /**
  138109. * Gets the output component
  138110. */
  138111. get output(): NodeMaterialConnectionPoint;
  138112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138114. autoConfigure(material: NodeMaterial): void;
  138115. protected _buildBlock(state: NodeMaterialBuildState): this;
  138116. protected _dumpPropertiesCode(): string;
  138117. serialize(): any;
  138118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138119. }
  138120. }
  138121. declare module BABYLON {
  138122. /**
  138123. * Block used to discard a pixel if a value is smaller than a cutoff
  138124. */
  138125. export class DiscardBlock extends NodeMaterialBlock {
  138126. /**
  138127. * Create a new DiscardBlock
  138128. * @param name defines the block name
  138129. */
  138130. constructor(name: string);
  138131. /**
  138132. * Gets the current class name
  138133. * @returns the class name
  138134. */
  138135. getClassName(): string;
  138136. /**
  138137. * Gets the color input component
  138138. */
  138139. get value(): NodeMaterialConnectionPoint;
  138140. /**
  138141. * Gets the cutoff input component
  138142. */
  138143. get cutoff(): NodeMaterialConnectionPoint;
  138144. protected _buildBlock(state: NodeMaterialBuildState): this;
  138145. }
  138146. }
  138147. declare module BABYLON {
  138148. /**
  138149. * Block used to test if the fragment shader is front facing
  138150. */
  138151. export class FrontFacingBlock extends NodeMaterialBlock {
  138152. /**
  138153. * Creates a new FrontFacingBlock
  138154. * @param name defines the block name
  138155. */
  138156. constructor(name: string);
  138157. /**
  138158. * Gets the current class name
  138159. * @returns the class name
  138160. */
  138161. getClassName(): string;
  138162. /**
  138163. * Gets the output component
  138164. */
  138165. get output(): NodeMaterialConnectionPoint;
  138166. protected _buildBlock(state: NodeMaterialBuildState): this;
  138167. }
  138168. }
  138169. declare module BABYLON {
  138170. /**
  138171. * Block used to get the derivative value on x and y of a given input
  138172. */
  138173. export class DerivativeBlock extends NodeMaterialBlock {
  138174. /**
  138175. * Create a new DerivativeBlock
  138176. * @param name defines the block name
  138177. */
  138178. constructor(name: string);
  138179. /**
  138180. * Gets the current class name
  138181. * @returns the class name
  138182. */
  138183. getClassName(): string;
  138184. /**
  138185. * Gets the input component
  138186. */
  138187. get input(): NodeMaterialConnectionPoint;
  138188. /**
  138189. * Gets the derivative output on x
  138190. */
  138191. get dx(): NodeMaterialConnectionPoint;
  138192. /**
  138193. * Gets the derivative output on y
  138194. */
  138195. get dy(): NodeMaterialConnectionPoint;
  138196. protected _buildBlock(state: NodeMaterialBuildState): this;
  138197. }
  138198. }
  138199. declare module BABYLON {
  138200. /**
  138201. * Block used to add support for scene fog
  138202. */
  138203. export class FogBlock extends NodeMaterialBlock {
  138204. private _fogDistanceName;
  138205. private _fogParameters;
  138206. /**
  138207. * Create a new FogBlock
  138208. * @param name defines the block name
  138209. */
  138210. constructor(name: string);
  138211. /**
  138212. * Gets the current class name
  138213. * @returns the class name
  138214. */
  138215. getClassName(): string;
  138216. /**
  138217. * Gets the world position input component
  138218. */
  138219. get worldPosition(): NodeMaterialConnectionPoint;
  138220. /**
  138221. * Gets the view input component
  138222. */
  138223. get view(): NodeMaterialConnectionPoint;
  138224. /**
  138225. * Gets the color input component
  138226. */
  138227. get input(): NodeMaterialConnectionPoint;
  138228. /**
  138229. * Gets the fog color input component
  138230. */
  138231. get fogColor(): NodeMaterialConnectionPoint;
  138232. /**
  138233. * Gets the output component
  138234. */
  138235. get output(): NodeMaterialConnectionPoint;
  138236. autoConfigure(material: NodeMaterial): void;
  138237. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138238. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138239. protected _buildBlock(state: NodeMaterialBuildState): this;
  138240. }
  138241. }
  138242. declare module BABYLON {
  138243. /**
  138244. * Block used to add light in the fragment shader
  138245. */
  138246. export class LightBlock extends NodeMaterialBlock {
  138247. private _lightId;
  138248. /**
  138249. * Gets or sets the light associated with this block
  138250. */
  138251. light: Nullable<Light>;
  138252. /**
  138253. * Create a new LightBlock
  138254. * @param name defines the block name
  138255. */
  138256. constructor(name: string);
  138257. /**
  138258. * Gets the current class name
  138259. * @returns the class name
  138260. */
  138261. getClassName(): string;
  138262. /**
  138263. * Gets the world position input component
  138264. */
  138265. get worldPosition(): NodeMaterialConnectionPoint;
  138266. /**
  138267. * Gets the world normal input component
  138268. */
  138269. get worldNormal(): NodeMaterialConnectionPoint;
  138270. /**
  138271. * Gets the camera (or eye) position component
  138272. */
  138273. get cameraPosition(): NodeMaterialConnectionPoint;
  138274. /**
  138275. * Gets the glossiness component
  138276. */
  138277. get glossiness(): NodeMaterialConnectionPoint;
  138278. /**
  138279. * Gets the glossinness power component
  138280. */
  138281. get glossPower(): NodeMaterialConnectionPoint;
  138282. /**
  138283. * Gets the diffuse color component
  138284. */
  138285. get diffuseColor(): NodeMaterialConnectionPoint;
  138286. /**
  138287. * Gets the specular color component
  138288. */
  138289. get specularColor(): NodeMaterialConnectionPoint;
  138290. /**
  138291. * Gets the diffuse output component
  138292. */
  138293. get diffuseOutput(): NodeMaterialConnectionPoint;
  138294. /**
  138295. * Gets the specular output component
  138296. */
  138297. get specularOutput(): NodeMaterialConnectionPoint;
  138298. /**
  138299. * Gets the shadow output component
  138300. */
  138301. get shadow(): NodeMaterialConnectionPoint;
  138302. autoConfigure(material: NodeMaterial): void;
  138303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138304. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138305. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138306. private _injectVertexCode;
  138307. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  138308. serialize(): any;
  138309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138310. }
  138311. }
  138312. declare module BABYLON {
  138313. /**
  138314. * Block used to read a reflection texture from a sampler
  138315. */
  138316. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  138317. /**
  138318. * Create a new ReflectionTextureBlock
  138319. * @param name defines the block name
  138320. */
  138321. constructor(name: string);
  138322. /**
  138323. * Gets the current class name
  138324. * @returns the class name
  138325. */
  138326. getClassName(): string;
  138327. /**
  138328. * Gets the world position input component
  138329. */
  138330. get position(): NodeMaterialConnectionPoint;
  138331. /**
  138332. * Gets the world position input component
  138333. */
  138334. get worldPosition(): NodeMaterialConnectionPoint;
  138335. /**
  138336. * Gets the world normal input component
  138337. */
  138338. get worldNormal(): NodeMaterialConnectionPoint;
  138339. /**
  138340. * Gets the world input component
  138341. */
  138342. get world(): NodeMaterialConnectionPoint;
  138343. /**
  138344. * Gets the camera (or eye) position component
  138345. */
  138346. get cameraPosition(): NodeMaterialConnectionPoint;
  138347. /**
  138348. * Gets the view input component
  138349. */
  138350. get view(): NodeMaterialConnectionPoint;
  138351. /**
  138352. * Gets the rgb output component
  138353. */
  138354. get rgb(): NodeMaterialConnectionPoint;
  138355. /**
  138356. * Gets the r output component
  138357. */
  138358. get r(): NodeMaterialConnectionPoint;
  138359. /**
  138360. * Gets the g output component
  138361. */
  138362. get g(): NodeMaterialConnectionPoint;
  138363. /**
  138364. * Gets the b output component
  138365. */
  138366. get b(): NodeMaterialConnectionPoint;
  138367. autoConfigure(material: NodeMaterial): void;
  138368. protected _buildBlock(state: NodeMaterialBuildState): this;
  138369. }
  138370. }
  138371. declare module BABYLON {
  138372. /**
  138373. * Block used to add 2 vectors
  138374. */
  138375. export class AddBlock extends NodeMaterialBlock {
  138376. /**
  138377. * Creates a new AddBlock
  138378. * @param name defines the block name
  138379. */
  138380. constructor(name: string);
  138381. /**
  138382. * Gets the current class name
  138383. * @returns the class name
  138384. */
  138385. getClassName(): string;
  138386. /**
  138387. * Gets the left operand input component
  138388. */
  138389. get left(): NodeMaterialConnectionPoint;
  138390. /**
  138391. * Gets the right operand input component
  138392. */
  138393. get right(): NodeMaterialConnectionPoint;
  138394. /**
  138395. * Gets the output component
  138396. */
  138397. get output(): NodeMaterialConnectionPoint;
  138398. protected _buildBlock(state: NodeMaterialBuildState): this;
  138399. }
  138400. }
  138401. declare module BABYLON {
  138402. /**
  138403. * Block used to scale a vector by a float
  138404. */
  138405. export class ScaleBlock extends NodeMaterialBlock {
  138406. /**
  138407. * Creates a new ScaleBlock
  138408. * @param name defines the block name
  138409. */
  138410. constructor(name: string);
  138411. /**
  138412. * Gets the current class name
  138413. * @returns the class name
  138414. */
  138415. getClassName(): string;
  138416. /**
  138417. * Gets the input component
  138418. */
  138419. get input(): NodeMaterialConnectionPoint;
  138420. /**
  138421. * Gets the factor input component
  138422. */
  138423. get factor(): NodeMaterialConnectionPoint;
  138424. /**
  138425. * Gets the output component
  138426. */
  138427. get output(): NodeMaterialConnectionPoint;
  138428. protected _buildBlock(state: NodeMaterialBuildState): this;
  138429. }
  138430. }
  138431. declare module BABYLON {
  138432. /**
  138433. * Block used to clamp a float
  138434. */
  138435. export class ClampBlock extends NodeMaterialBlock {
  138436. /** Gets or sets the minimum range */
  138437. minimum: number;
  138438. /** Gets or sets the maximum range */
  138439. maximum: number;
  138440. /**
  138441. * Creates a new ClampBlock
  138442. * @param name defines the block name
  138443. */
  138444. constructor(name: string);
  138445. /**
  138446. * Gets the current class name
  138447. * @returns the class name
  138448. */
  138449. getClassName(): string;
  138450. /**
  138451. * Gets the value input component
  138452. */
  138453. get value(): NodeMaterialConnectionPoint;
  138454. /**
  138455. * Gets the output component
  138456. */
  138457. get output(): NodeMaterialConnectionPoint;
  138458. protected _buildBlock(state: NodeMaterialBuildState): this;
  138459. protected _dumpPropertiesCode(): string;
  138460. serialize(): any;
  138461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138462. }
  138463. }
  138464. declare module BABYLON {
  138465. /**
  138466. * Block used to apply a cross product between 2 vectors
  138467. */
  138468. export class CrossBlock extends NodeMaterialBlock {
  138469. /**
  138470. * Creates a new CrossBlock
  138471. * @param name defines the block name
  138472. */
  138473. constructor(name: string);
  138474. /**
  138475. * Gets the current class name
  138476. * @returns the class name
  138477. */
  138478. getClassName(): string;
  138479. /**
  138480. * Gets the left operand input component
  138481. */
  138482. get left(): NodeMaterialConnectionPoint;
  138483. /**
  138484. * Gets the right operand input component
  138485. */
  138486. get right(): NodeMaterialConnectionPoint;
  138487. /**
  138488. * Gets the output component
  138489. */
  138490. get output(): NodeMaterialConnectionPoint;
  138491. protected _buildBlock(state: NodeMaterialBuildState): this;
  138492. }
  138493. }
  138494. declare module BABYLON {
  138495. /**
  138496. * Block used to apply a dot product between 2 vectors
  138497. */
  138498. export class DotBlock extends NodeMaterialBlock {
  138499. /**
  138500. * Creates a new DotBlock
  138501. * @param name defines the block name
  138502. */
  138503. constructor(name: string);
  138504. /**
  138505. * Gets the current class name
  138506. * @returns the class name
  138507. */
  138508. getClassName(): string;
  138509. /**
  138510. * Gets the left operand input component
  138511. */
  138512. get left(): NodeMaterialConnectionPoint;
  138513. /**
  138514. * Gets the right operand input component
  138515. */
  138516. get right(): NodeMaterialConnectionPoint;
  138517. /**
  138518. * Gets the output component
  138519. */
  138520. get output(): NodeMaterialConnectionPoint;
  138521. protected _buildBlock(state: NodeMaterialBuildState): this;
  138522. }
  138523. }
  138524. declare module BABYLON {
  138525. /**
  138526. * Block used to normalize a vector
  138527. */
  138528. export class NormalizeBlock extends NodeMaterialBlock {
  138529. /**
  138530. * Creates a new NormalizeBlock
  138531. * @param name defines the block name
  138532. */
  138533. constructor(name: string);
  138534. /**
  138535. * Gets the current class name
  138536. * @returns the class name
  138537. */
  138538. getClassName(): string;
  138539. /**
  138540. * Gets the input component
  138541. */
  138542. get input(): NodeMaterialConnectionPoint;
  138543. /**
  138544. * Gets the output component
  138545. */
  138546. get output(): NodeMaterialConnectionPoint;
  138547. protected _buildBlock(state: NodeMaterialBuildState): this;
  138548. }
  138549. }
  138550. declare module BABYLON {
  138551. /**
  138552. * Operations supported by the Trigonometry block
  138553. */
  138554. export enum TrigonometryBlockOperations {
  138555. /** Cos */
  138556. Cos = 0,
  138557. /** Sin */
  138558. Sin = 1,
  138559. /** Abs */
  138560. Abs = 2,
  138561. /** Exp */
  138562. Exp = 3,
  138563. /** Exp2 */
  138564. Exp2 = 4,
  138565. /** Round */
  138566. Round = 5,
  138567. /** Floor */
  138568. Floor = 6,
  138569. /** Ceiling */
  138570. Ceiling = 7,
  138571. /** Square root */
  138572. Sqrt = 8,
  138573. /** Log */
  138574. Log = 9,
  138575. /** Tangent */
  138576. Tan = 10,
  138577. /** Arc tangent */
  138578. ArcTan = 11,
  138579. /** Arc cosinus */
  138580. ArcCos = 12,
  138581. /** Arc sinus */
  138582. ArcSin = 13,
  138583. /** Fraction */
  138584. Fract = 14,
  138585. /** Sign */
  138586. Sign = 15,
  138587. /** To radians (from degrees) */
  138588. Radians = 16,
  138589. /** To degrees (from radians) */
  138590. Degrees = 17
  138591. }
  138592. /**
  138593. * Block used to apply trigonometry operation to floats
  138594. */
  138595. export class TrigonometryBlock extends NodeMaterialBlock {
  138596. /**
  138597. * Gets or sets the operation applied by the block
  138598. */
  138599. operation: TrigonometryBlockOperations;
  138600. /**
  138601. * Creates a new TrigonometryBlock
  138602. * @param name defines the block name
  138603. */
  138604. constructor(name: string);
  138605. /**
  138606. * Gets the current class name
  138607. * @returns the class name
  138608. */
  138609. getClassName(): string;
  138610. /**
  138611. * Gets the input component
  138612. */
  138613. get input(): NodeMaterialConnectionPoint;
  138614. /**
  138615. * Gets the output component
  138616. */
  138617. get output(): NodeMaterialConnectionPoint;
  138618. protected _buildBlock(state: NodeMaterialBuildState): this;
  138619. serialize(): any;
  138620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138621. protected _dumpPropertiesCode(): string;
  138622. }
  138623. }
  138624. declare module BABYLON {
  138625. /**
  138626. * Block used to create a Color3/4 out of individual inputs (one for each component)
  138627. */
  138628. export class ColorMergerBlock extends NodeMaterialBlock {
  138629. /**
  138630. * Create a new ColorMergerBlock
  138631. * @param name defines the block name
  138632. */
  138633. constructor(name: string);
  138634. /**
  138635. * Gets the current class name
  138636. * @returns the class name
  138637. */
  138638. getClassName(): string;
  138639. /**
  138640. * Gets the rgb component (input)
  138641. */
  138642. get rgbIn(): NodeMaterialConnectionPoint;
  138643. /**
  138644. * Gets the r component (input)
  138645. */
  138646. get r(): NodeMaterialConnectionPoint;
  138647. /**
  138648. * Gets the g component (input)
  138649. */
  138650. get g(): NodeMaterialConnectionPoint;
  138651. /**
  138652. * Gets the b component (input)
  138653. */
  138654. get b(): NodeMaterialConnectionPoint;
  138655. /**
  138656. * Gets the a component (input)
  138657. */
  138658. get a(): NodeMaterialConnectionPoint;
  138659. /**
  138660. * Gets the rgba component (output)
  138661. */
  138662. get rgba(): NodeMaterialConnectionPoint;
  138663. /**
  138664. * Gets the rgb component (output)
  138665. */
  138666. get rgbOut(): NodeMaterialConnectionPoint;
  138667. /**
  138668. * Gets the rgb component (output)
  138669. * @deprecated Please use rgbOut instead.
  138670. */
  138671. get rgb(): NodeMaterialConnectionPoint;
  138672. protected _buildBlock(state: NodeMaterialBuildState): this;
  138673. }
  138674. }
  138675. declare module BABYLON {
  138676. /**
  138677. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  138678. */
  138679. export class VectorSplitterBlock extends NodeMaterialBlock {
  138680. /**
  138681. * Create a new VectorSplitterBlock
  138682. * @param name defines the block name
  138683. */
  138684. constructor(name: string);
  138685. /**
  138686. * Gets the current class name
  138687. * @returns the class name
  138688. */
  138689. getClassName(): string;
  138690. /**
  138691. * Gets the xyzw component (input)
  138692. */
  138693. get xyzw(): NodeMaterialConnectionPoint;
  138694. /**
  138695. * Gets the xyz component (input)
  138696. */
  138697. get xyzIn(): NodeMaterialConnectionPoint;
  138698. /**
  138699. * Gets the xy component (input)
  138700. */
  138701. get xyIn(): NodeMaterialConnectionPoint;
  138702. /**
  138703. * Gets the xyz component (output)
  138704. */
  138705. get xyzOut(): NodeMaterialConnectionPoint;
  138706. /**
  138707. * Gets the xy component (output)
  138708. */
  138709. get xyOut(): NodeMaterialConnectionPoint;
  138710. /**
  138711. * Gets the x component (output)
  138712. */
  138713. get x(): NodeMaterialConnectionPoint;
  138714. /**
  138715. * Gets the y component (output)
  138716. */
  138717. get y(): NodeMaterialConnectionPoint;
  138718. /**
  138719. * Gets the z component (output)
  138720. */
  138721. get z(): NodeMaterialConnectionPoint;
  138722. /**
  138723. * Gets the w component (output)
  138724. */
  138725. get w(): NodeMaterialConnectionPoint;
  138726. protected _inputRename(name: string): string;
  138727. protected _outputRename(name: string): string;
  138728. protected _buildBlock(state: NodeMaterialBuildState): this;
  138729. }
  138730. }
  138731. declare module BABYLON {
  138732. /**
  138733. * Block used to lerp between 2 values
  138734. */
  138735. export class LerpBlock extends NodeMaterialBlock {
  138736. /**
  138737. * Creates a new LerpBlock
  138738. * @param name defines the block name
  138739. */
  138740. constructor(name: string);
  138741. /**
  138742. * Gets the current class name
  138743. * @returns the class name
  138744. */
  138745. getClassName(): string;
  138746. /**
  138747. * Gets the left operand input component
  138748. */
  138749. get left(): NodeMaterialConnectionPoint;
  138750. /**
  138751. * Gets the right operand input component
  138752. */
  138753. get right(): NodeMaterialConnectionPoint;
  138754. /**
  138755. * Gets the gradient operand input component
  138756. */
  138757. get gradient(): NodeMaterialConnectionPoint;
  138758. /**
  138759. * Gets the output component
  138760. */
  138761. get output(): NodeMaterialConnectionPoint;
  138762. protected _buildBlock(state: NodeMaterialBuildState): this;
  138763. }
  138764. }
  138765. declare module BABYLON {
  138766. /**
  138767. * Block used to divide 2 vectors
  138768. */
  138769. export class DivideBlock extends NodeMaterialBlock {
  138770. /**
  138771. * Creates a new DivideBlock
  138772. * @param name defines the block name
  138773. */
  138774. constructor(name: string);
  138775. /**
  138776. * Gets the current class name
  138777. * @returns the class name
  138778. */
  138779. getClassName(): string;
  138780. /**
  138781. * Gets the left operand input component
  138782. */
  138783. get left(): NodeMaterialConnectionPoint;
  138784. /**
  138785. * Gets the right operand input component
  138786. */
  138787. get right(): NodeMaterialConnectionPoint;
  138788. /**
  138789. * Gets the output component
  138790. */
  138791. get output(): NodeMaterialConnectionPoint;
  138792. protected _buildBlock(state: NodeMaterialBuildState): this;
  138793. }
  138794. }
  138795. declare module BABYLON {
  138796. /**
  138797. * Block used to subtract 2 vectors
  138798. */
  138799. export class SubtractBlock extends NodeMaterialBlock {
  138800. /**
  138801. * Creates a new SubtractBlock
  138802. * @param name defines the block name
  138803. */
  138804. constructor(name: string);
  138805. /**
  138806. * Gets the current class name
  138807. * @returns the class name
  138808. */
  138809. getClassName(): string;
  138810. /**
  138811. * Gets the left operand input component
  138812. */
  138813. get left(): NodeMaterialConnectionPoint;
  138814. /**
  138815. * Gets the right operand input component
  138816. */
  138817. get right(): NodeMaterialConnectionPoint;
  138818. /**
  138819. * Gets the output component
  138820. */
  138821. get output(): NodeMaterialConnectionPoint;
  138822. protected _buildBlock(state: NodeMaterialBuildState): this;
  138823. }
  138824. }
  138825. declare module BABYLON {
  138826. /**
  138827. * Block used to step a value
  138828. */
  138829. export class StepBlock extends NodeMaterialBlock {
  138830. /**
  138831. * Creates a new StepBlock
  138832. * @param name defines the block name
  138833. */
  138834. constructor(name: string);
  138835. /**
  138836. * Gets the current class name
  138837. * @returns the class name
  138838. */
  138839. getClassName(): string;
  138840. /**
  138841. * Gets the value operand input component
  138842. */
  138843. get value(): NodeMaterialConnectionPoint;
  138844. /**
  138845. * Gets the edge operand input component
  138846. */
  138847. get edge(): NodeMaterialConnectionPoint;
  138848. /**
  138849. * Gets the output component
  138850. */
  138851. get output(): NodeMaterialConnectionPoint;
  138852. protected _buildBlock(state: NodeMaterialBuildState): this;
  138853. }
  138854. }
  138855. declare module BABYLON {
  138856. /**
  138857. * Block used to get the opposite (1 - x) of a value
  138858. */
  138859. export class OneMinusBlock extends NodeMaterialBlock {
  138860. /**
  138861. * Creates a new OneMinusBlock
  138862. * @param name defines the block name
  138863. */
  138864. constructor(name: string);
  138865. /**
  138866. * Gets the current class name
  138867. * @returns the class name
  138868. */
  138869. getClassName(): string;
  138870. /**
  138871. * Gets the input component
  138872. */
  138873. get input(): NodeMaterialConnectionPoint;
  138874. /**
  138875. * Gets the output component
  138876. */
  138877. get output(): NodeMaterialConnectionPoint;
  138878. protected _buildBlock(state: NodeMaterialBuildState): this;
  138879. }
  138880. }
  138881. declare module BABYLON {
  138882. /**
  138883. * Block used to get the view direction
  138884. */
  138885. export class ViewDirectionBlock extends NodeMaterialBlock {
  138886. /**
  138887. * Creates a new ViewDirectionBlock
  138888. * @param name defines the block name
  138889. */
  138890. constructor(name: string);
  138891. /**
  138892. * Gets the current class name
  138893. * @returns the class name
  138894. */
  138895. getClassName(): string;
  138896. /**
  138897. * Gets the world position component
  138898. */
  138899. get worldPosition(): NodeMaterialConnectionPoint;
  138900. /**
  138901. * Gets the camera position component
  138902. */
  138903. get cameraPosition(): NodeMaterialConnectionPoint;
  138904. /**
  138905. * Gets the output component
  138906. */
  138907. get output(): NodeMaterialConnectionPoint;
  138908. autoConfigure(material: NodeMaterial): void;
  138909. protected _buildBlock(state: NodeMaterialBuildState): this;
  138910. }
  138911. }
  138912. declare module BABYLON {
  138913. /**
  138914. * Block used to compute fresnel value
  138915. */
  138916. export class FresnelBlock extends NodeMaterialBlock {
  138917. /**
  138918. * Create a new FresnelBlock
  138919. * @param name defines the block name
  138920. */
  138921. constructor(name: string);
  138922. /**
  138923. * Gets the current class name
  138924. * @returns the class name
  138925. */
  138926. getClassName(): string;
  138927. /**
  138928. * Gets the world normal input component
  138929. */
  138930. get worldNormal(): NodeMaterialConnectionPoint;
  138931. /**
  138932. * Gets the view direction input component
  138933. */
  138934. get viewDirection(): NodeMaterialConnectionPoint;
  138935. /**
  138936. * Gets the bias input component
  138937. */
  138938. get bias(): NodeMaterialConnectionPoint;
  138939. /**
  138940. * Gets the camera (or eye) position component
  138941. */
  138942. get power(): NodeMaterialConnectionPoint;
  138943. /**
  138944. * Gets the fresnel output component
  138945. */
  138946. get fresnel(): NodeMaterialConnectionPoint;
  138947. autoConfigure(material: NodeMaterial): void;
  138948. protected _buildBlock(state: NodeMaterialBuildState): this;
  138949. }
  138950. }
  138951. declare module BABYLON {
  138952. /**
  138953. * Block used to get the max of 2 values
  138954. */
  138955. export class MaxBlock extends NodeMaterialBlock {
  138956. /**
  138957. * Creates a new MaxBlock
  138958. * @param name defines the block name
  138959. */
  138960. constructor(name: string);
  138961. /**
  138962. * Gets the current class name
  138963. * @returns the class name
  138964. */
  138965. getClassName(): string;
  138966. /**
  138967. * Gets the left operand input component
  138968. */
  138969. get left(): NodeMaterialConnectionPoint;
  138970. /**
  138971. * Gets the right operand input component
  138972. */
  138973. get right(): NodeMaterialConnectionPoint;
  138974. /**
  138975. * Gets the output component
  138976. */
  138977. get output(): NodeMaterialConnectionPoint;
  138978. protected _buildBlock(state: NodeMaterialBuildState): this;
  138979. }
  138980. }
  138981. declare module BABYLON {
  138982. /**
  138983. * Block used to get the min of 2 values
  138984. */
  138985. export class MinBlock extends NodeMaterialBlock {
  138986. /**
  138987. * Creates a new MinBlock
  138988. * @param name defines the block name
  138989. */
  138990. constructor(name: string);
  138991. /**
  138992. * Gets the current class name
  138993. * @returns the class name
  138994. */
  138995. getClassName(): string;
  138996. /**
  138997. * Gets the left operand input component
  138998. */
  138999. get left(): NodeMaterialConnectionPoint;
  139000. /**
  139001. * Gets the right operand input component
  139002. */
  139003. get right(): NodeMaterialConnectionPoint;
  139004. /**
  139005. * Gets the output component
  139006. */
  139007. get output(): NodeMaterialConnectionPoint;
  139008. protected _buildBlock(state: NodeMaterialBuildState): this;
  139009. }
  139010. }
  139011. declare module BABYLON {
  139012. /**
  139013. * Block used to get the distance between 2 values
  139014. */
  139015. export class DistanceBlock extends NodeMaterialBlock {
  139016. /**
  139017. * Creates a new DistanceBlock
  139018. * @param name defines the block name
  139019. */
  139020. constructor(name: string);
  139021. /**
  139022. * Gets the current class name
  139023. * @returns the class name
  139024. */
  139025. getClassName(): string;
  139026. /**
  139027. * Gets the left operand input component
  139028. */
  139029. get left(): NodeMaterialConnectionPoint;
  139030. /**
  139031. * Gets the right operand input component
  139032. */
  139033. get right(): NodeMaterialConnectionPoint;
  139034. /**
  139035. * Gets the output component
  139036. */
  139037. get output(): NodeMaterialConnectionPoint;
  139038. protected _buildBlock(state: NodeMaterialBuildState): this;
  139039. }
  139040. }
  139041. declare module BABYLON {
  139042. /**
  139043. * Block used to get the length of a vector
  139044. */
  139045. export class LengthBlock extends NodeMaterialBlock {
  139046. /**
  139047. * Creates a new LengthBlock
  139048. * @param name defines the block name
  139049. */
  139050. constructor(name: string);
  139051. /**
  139052. * Gets the current class name
  139053. * @returns the class name
  139054. */
  139055. getClassName(): string;
  139056. /**
  139057. * Gets the value input component
  139058. */
  139059. get value(): NodeMaterialConnectionPoint;
  139060. /**
  139061. * Gets the output component
  139062. */
  139063. get output(): NodeMaterialConnectionPoint;
  139064. protected _buildBlock(state: NodeMaterialBuildState): this;
  139065. }
  139066. }
  139067. declare module BABYLON {
  139068. /**
  139069. * Block used to get negative version of a value (i.e. x * -1)
  139070. */
  139071. export class NegateBlock extends NodeMaterialBlock {
  139072. /**
  139073. * Creates a new NegateBlock
  139074. * @param name defines the block name
  139075. */
  139076. constructor(name: string);
  139077. /**
  139078. * Gets the current class name
  139079. * @returns the class name
  139080. */
  139081. getClassName(): string;
  139082. /**
  139083. * Gets the value input component
  139084. */
  139085. get value(): NodeMaterialConnectionPoint;
  139086. /**
  139087. * Gets the output component
  139088. */
  139089. get output(): NodeMaterialConnectionPoint;
  139090. protected _buildBlock(state: NodeMaterialBuildState): this;
  139091. }
  139092. }
  139093. declare module BABYLON {
  139094. /**
  139095. * Block used to get the value of the first parameter raised to the power of the second
  139096. */
  139097. export class PowBlock extends NodeMaterialBlock {
  139098. /**
  139099. * Creates a new PowBlock
  139100. * @param name defines the block name
  139101. */
  139102. constructor(name: string);
  139103. /**
  139104. * Gets the current class name
  139105. * @returns the class name
  139106. */
  139107. getClassName(): string;
  139108. /**
  139109. * Gets the value operand input component
  139110. */
  139111. get value(): NodeMaterialConnectionPoint;
  139112. /**
  139113. * Gets the power operand input component
  139114. */
  139115. get power(): NodeMaterialConnectionPoint;
  139116. /**
  139117. * Gets the output component
  139118. */
  139119. get output(): NodeMaterialConnectionPoint;
  139120. protected _buildBlock(state: NodeMaterialBuildState): this;
  139121. }
  139122. }
  139123. declare module BABYLON {
  139124. /**
  139125. * Block used to get a random number
  139126. */
  139127. export class RandomNumberBlock extends NodeMaterialBlock {
  139128. /**
  139129. * Creates a new RandomNumberBlock
  139130. * @param name defines the block name
  139131. */
  139132. constructor(name: string);
  139133. /**
  139134. * Gets the current class name
  139135. * @returns the class name
  139136. */
  139137. getClassName(): string;
  139138. /**
  139139. * Gets the seed input component
  139140. */
  139141. get seed(): NodeMaterialConnectionPoint;
  139142. /**
  139143. * Gets the output component
  139144. */
  139145. get output(): NodeMaterialConnectionPoint;
  139146. protected _buildBlock(state: NodeMaterialBuildState): this;
  139147. }
  139148. }
  139149. declare module BABYLON {
  139150. /**
  139151. * Block used to compute arc tangent of 2 values
  139152. */
  139153. export class ArcTan2Block extends NodeMaterialBlock {
  139154. /**
  139155. * Creates a new ArcTan2Block
  139156. * @param name defines the block name
  139157. */
  139158. constructor(name: string);
  139159. /**
  139160. * Gets the current class name
  139161. * @returns the class name
  139162. */
  139163. getClassName(): string;
  139164. /**
  139165. * Gets the x operand input component
  139166. */
  139167. get x(): NodeMaterialConnectionPoint;
  139168. /**
  139169. * Gets the y operand input component
  139170. */
  139171. get y(): NodeMaterialConnectionPoint;
  139172. /**
  139173. * Gets the output component
  139174. */
  139175. get output(): NodeMaterialConnectionPoint;
  139176. protected _buildBlock(state: NodeMaterialBuildState): this;
  139177. }
  139178. }
  139179. declare module BABYLON {
  139180. /**
  139181. * Block used to smooth step a value
  139182. */
  139183. export class SmoothStepBlock extends NodeMaterialBlock {
  139184. /**
  139185. * Creates a new SmoothStepBlock
  139186. * @param name defines the block name
  139187. */
  139188. constructor(name: string);
  139189. /**
  139190. * Gets the current class name
  139191. * @returns the class name
  139192. */
  139193. getClassName(): string;
  139194. /**
  139195. * Gets the value operand input component
  139196. */
  139197. get value(): NodeMaterialConnectionPoint;
  139198. /**
  139199. * Gets the first edge operand input component
  139200. */
  139201. get edge0(): NodeMaterialConnectionPoint;
  139202. /**
  139203. * Gets the second edge operand input component
  139204. */
  139205. get edge1(): NodeMaterialConnectionPoint;
  139206. /**
  139207. * Gets the output component
  139208. */
  139209. get output(): NodeMaterialConnectionPoint;
  139210. protected _buildBlock(state: NodeMaterialBuildState): this;
  139211. }
  139212. }
  139213. declare module BABYLON {
  139214. /**
  139215. * Block used to get the reciprocal (1 / x) of a value
  139216. */
  139217. export class ReciprocalBlock extends NodeMaterialBlock {
  139218. /**
  139219. * Creates a new ReciprocalBlock
  139220. * @param name defines the block name
  139221. */
  139222. constructor(name: string);
  139223. /**
  139224. * Gets the current class name
  139225. * @returns the class name
  139226. */
  139227. getClassName(): string;
  139228. /**
  139229. * Gets the input component
  139230. */
  139231. get input(): NodeMaterialConnectionPoint;
  139232. /**
  139233. * Gets the output component
  139234. */
  139235. get output(): NodeMaterialConnectionPoint;
  139236. protected _buildBlock(state: NodeMaterialBuildState): this;
  139237. }
  139238. }
  139239. declare module BABYLON {
  139240. /**
  139241. * Block used to replace a color by another one
  139242. */
  139243. export class ReplaceColorBlock extends NodeMaterialBlock {
  139244. /**
  139245. * Creates a new ReplaceColorBlock
  139246. * @param name defines the block name
  139247. */
  139248. constructor(name: string);
  139249. /**
  139250. * Gets the current class name
  139251. * @returns the class name
  139252. */
  139253. getClassName(): string;
  139254. /**
  139255. * Gets the value input component
  139256. */
  139257. get value(): NodeMaterialConnectionPoint;
  139258. /**
  139259. * Gets the reference input component
  139260. */
  139261. get reference(): NodeMaterialConnectionPoint;
  139262. /**
  139263. * Gets the distance input component
  139264. */
  139265. get distance(): NodeMaterialConnectionPoint;
  139266. /**
  139267. * Gets the replacement input component
  139268. */
  139269. get replacement(): NodeMaterialConnectionPoint;
  139270. /**
  139271. * Gets the output component
  139272. */
  139273. get output(): NodeMaterialConnectionPoint;
  139274. protected _buildBlock(state: NodeMaterialBuildState): this;
  139275. }
  139276. }
  139277. declare module BABYLON {
  139278. /**
  139279. * Block used to posterize a value
  139280. * @see https://en.wikipedia.org/wiki/Posterization
  139281. */
  139282. export class PosterizeBlock extends NodeMaterialBlock {
  139283. /**
  139284. * Creates a new PosterizeBlock
  139285. * @param name defines the block name
  139286. */
  139287. constructor(name: string);
  139288. /**
  139289. * Gets the current class name
  139290. * @returns the class name
  139291. */
  139292. getClassName(): string;
  139293. /**
  139294. * Gets the value input component
  139295. */
  139296. get value(): NodeMaterialConnectionPoint;
  139297. /**
  139298. * Gets the steps input component
  139299. */
  139300. get steps(): NodeMaterialConnectionPoint;
  139301. /**
  139302. * Gets the output component
  139303. */
  139304. get output(): NodeMaterialConnectionPoint;
  139305. protected _buildBlock(state: NodeMaterialBuildState): this;
  139306. }
  139307. }
  139308. declare module BABYLON {
  139309. /**
  139310. * Operations supported by the Wave block
  139311. */
  139312. export enum WaveBlockKind {
  139313. /** SawTooth */
  139314. SawTooth = 0,
  139315. /** Square */
  139316. Square = 1,
  139317. /** Triangle */
  139318. Triangle = 2
  139319. }
  139320. /**
  139321. * Block used to apply wave operation to floats
  139322. */
  139323. export class WaveBlock extends NodeMaterialBlock {
  139324. /**
  139325. * Gets or sets the kibnd of wave to be applied by the block
  139326. */
  139327. kind: WaveBlockKind;
  139328. /**
  139329. * Creates a new WaveBlock
  139330. * @param name defines the block name
  139331. */
  139332. constructor(name: string);
  139333. /**
  139334. * Gets the current class name
  139335. * @returns the class name
  139336. */
  139337. getClassName(): string;
  139338. /**
  139339. * Gets the input component
  139340. */
  139341. get input(): NodeMaterialConnectionPoint;
  139342. /**
  139343. * Gets the output component
  139344. */
  139345. get output(): NodeMaterialConnectionPoint;
  139346. protected _buildBlock(state: NodeMaterialBuildState): this;
  139347. serialize(): any;
  139348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139349. }
  139350. }
  139351. declare module BABYLON {
  139352. /**
  139353. * Class used to store a color step for the GradientBlock
  139354. */
  139355. export class GradientBlockColorStep {
  139356. /**
  139357. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139358. */
  139359. step: number;
  139360. /**
  139361. * Gets or sets the color associated with this step
  139362. */
  139363. color: Color3;
  139364. /**
  139365. * Creates a new GradientBlockColorStep
  139366. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  139367. * @param color defines the color associated with this step
  139368. */
  139369. constructor(
  139370. /**
  139371. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139372. */
  139373. step: number,
  139374. /**
  139375. * Gets or sets the color associated with this step
  139376. */
  139377. color: Color3);
  139378. }
  139379. /**
  139380. * Block used to return a color from a gradient based on an input value between 0 and 1
  139381. */
  139382. export class GradientBlock extends NodeMaterialBlock {
  139383. /**
  139384. * Gets or sets the list of color steps
  139385. */
  139386. colorSteps: GradientBlockColorStep[];
  139387. /**
  139388. * Creates a new GradientBlock
  139389. * @param name defines the block name
  139390. */
  139391. constructor(name: string);
  139392. /**
  139393. * Gets the current class name
  139394. * @returns the class name
  139395. */
  139396. getClassName(): string;
  139397. /**
  139398. * Gets the gradient input component
  139399. */
  139400. get gradient(): NodeMaterialConnectionPoint;
  139401. /**
  139402. * Gets the output component
  139403. */
  139404. get output(): NodeMaterialConnectionPoint;
  139405. private _writeColorConstant;
  139406. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139407. serialize(): any;
  139408. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139409. protected _dumpPropertiesCode(): string;
  139410. }
  139411. }
  139412. declare module BABYLON {
  139413. /**
  139414. * Block used to normalize lerp between 2 values
  139415. */
  139416. export class NLerpBlock extends NodeMaterialBlock {
  139417. /**
  139418. * Creates a new NLerpBlock
  139419. * @param name defines the block name
  139420. */
  139421. constructor(name: string);
  139422. /**
  139423. * Gets the current class name
  139424. * @returns the class name
  139425. */
  139426. getClassName(): string;
  139427. /**
  139428. * Gets the left operand input component
  139429. */
  139430. get left(): NodeMaterialConnectionPoint;
  139431. /**
  139432. * Gets the right operand input component
  139433. */
  139434. get right(): NodeMaterialConnectionPoint;
  139435. /**
  139436. * Gets the gradient operand input component
  139437. */
  139438. get gradient(): NodeMaterialConnectionPoint;
  139439. /**
  139440. * Gets the output component
  139441. */
  139442. get output(): NodeMaterialConnectionPoint;
  139443. protected _buildBlock(state: NodeMaterialBuildState): this;
  139444. }
  139445. }
  139446. declare module BABYLON {
  139447. /**
  139448. * block used to Generate a Worley Noise 3D Noise Pattern
  139449. */
  139450. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  139451. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139452. manhattanDistance: boolean;
  139453. /**
  139454. * Creates a new WorleyNoise3DBlock
  139455. * @param name defines the block name
  139456. */
  139457. constructor(name: string);
  139458. /**
  139459. * Gets the current class name
  139460. * @returns the class name
  139461. */
  139462. getClassName(): string;
  139463. /**
  139464. * Gets the seed input component
  139465. */
  139466. get seed(): NodeMaterialConnectionPoint;
  139467. /**
  139468. * Gets the jitter input component
  139469. */
  139470. get jitter(): NodeMaterialConnectionPoint;
  139471. /**
  139472. * Gets the output component
  139473. */
  139474. get output(): NodeMaterialConnectionPoint;
  139475. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139476. /**
  139477. * Exposes the properties to the UI?
  139478. */
  139479. protected _dumpPropertiesCode(): string;
  139480. /**
  139481. * Exposes the properties to the Seralize?
  139482. */
  139483. serialize(): any;
  139484. /**
  139485. * Exposes the properties to the deseralize?
  139486. */
  139487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139488. }
  139489. }
  139490. declare module BABYLON {
  139491. /**
  139492. * block used to Generate a Simplex Perlin 3d Noise Pattern
  139493. */
  139494. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  139495. /**
  139496. * Creates a new SimplexPerlin3DBlock
  139497. * @param name defines the block name
  139498. */
  139499. constructor(name: string);
  139500. /**
  139501. * Gets the current class name
  139502. * @returns the class name
  139503. */
  139504. getClassName(): string;
  139505. /**
  139506. * Gets the seed operand input component
  139507. */
  139508. get seed(): NodeMaterialConnectionPoint;
  139509. /**
  139510. * Gets the output component
  139511. */
  139512. get output(): NodeMaterialConnectionPoint;
  139513. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139514. }
  139515. }
  139516. declare module BABYLON {
  139517. /**
  139518. * Block used to blend normals
  139519. */
  139520. export class NormalBlendBlock extends NodeMaterialBlock {
  139521. /**
  139522. * Creates a new NormalBlendBlock
  139523. * @param name defines the block name
  139524. */
  139525. constructor(name: string);
  139526. /**
  139527. * Gets the current class name
  139528. * @returns the class name
  139529. */
  139530. getClassName(): string;
  139531. /**
  139532. * Gets the first input component
  139533. */
  139534. get normalMap0(): NodeMaterialConnectionPoint;
  139535. /**
  139536. * Gets the second input component
  139537. */
  139538. get normalMap1(): NodeMaterialConnectionPoint;
  139539. /**
  139540. * Gets the output component
  139541. */
  139542. get output(): NodeMaterialConnectionPoint;
  139543. protected _buildBlock(state: NodeMaterialBuildState): this;
  139544. }
  139545. }
  139546. declare module BABYLON {
  139547. /**
  139548. * Block used to rotate a 2d vector by a given angle
  139549. */
  139550. export class Rotate2dBlock extends NodeMaterialBlock {
  139551. /**
  139552. * Creates a new Rotate2dBlock
  139553. * @param name defines the block name
  139554. */
  139555. constructor(name: string);
  139556. /**
  139557. * Gets the current class name
  139558. * @returns the class name
  139559. */
  139560. getClassName(): string;
  139561. /**
  139562. * Gets the input vector
  139563. */
  139564. get input(): NodeMaterialConnectionPoint;
  139565. /**
  139566. * Gets the input angle
  139567. */
  139568. get angle(): NodeMaterialConnectionPoint;
  139569. /**
  139570. * Gets the output component
  139571. */
  139572. get output(): NodeMaterialConnectionPoint;
  139573. autoConfigure(material: NodeMaterial): void;
  139574. protected _buildBlock(state: NodeMaterialBuildState): this;
  139575. }
  139576. }
  139577. declare module BABYLON {
  139578. /**
  139579. * Block used to get the reflected vector from a direction and a normal
  139580. */
  139581. export class ReflectBlock extends NodeMaterialBlock {
  139582. /**
  139583. * Creates a new ReflectBlock
  139584. * @param name defines the block name
  139585. */
  139586. constructor(name: string);
  139587. /**
  139588. * Gets the current class name
  139589. * @returns the class name
  139590. */
  139591. getClassName(): string;
  139592. /**
  139593. * Gets the incident component
  139594. */
  139595. get incident(): NodeMaterialConnectionPoint;
  139596. /**
  139597. * Gets the normal component
  139598. */
  139599. get normal(): NodeMaterialConnectionPoint;
  139600. /**
  139601. * Gets the output component
  139602. */
  139603. get output(): NodeMaterialConnectionPoint;
  139604. protected _buildBlock(state: NodeMaterialBuildState): this;
  139605. }
  139606. }
  139607. declare module BABYLON {
  139608. /**
  139609. * Block used to get the refracted vector from a direction and a normal
  139610. */
  139611. export class RefractBlock extends NodeMaterialBlock {
  139612. /**
  139613. * Creates a new RefractBlock
  139614. * @param name defines the block name
  139615. */
  139616. constructor(name: string);
  139617. /**
  139618. * Gets the current class name
  139619. * @returns the class name
  139620. */
  139621. getClassName(): string;
  139622. /**
  139623. * Gets the incident component
  139624. */
  139625. get incident(): NodeMaterialConnectionPoint;
  139626. /**
  139627. * Gets the normal component
  139628. */
  139629. get normal(): NodeMaterialConnectionPoint;
  139630. /**
  139631. * Gets the index of refraction component
  139632. */
  139633. get ior(): NodeMaterialConnectionPoint;
  139634. /**
  139635. * Gets the output component
  139636. */
  139637. get output(): NodeMaterialConnectionPoint;
  139638. protected _buildBlock(state: NodeMaterialBuildState): this;
  139639. }
  139640. }
  139641. declare module BABYLON {
  139642. /**
  139643. * Block used to desaturate a color
  139644. */
  139645. export class DesaturateBlock extends NodeMaterialBlock {
  139646. /**
  139647. * Creates a new DesaturateBlock
  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 color operand input component
  139658. */
  139659. get color(): NodeMaterialConnectionPoint;
  139660. /**
  139661. * Gets the level operand input component
  139662. */
  139663. get level(): NodeMaterialConnectionPoint;
  139664. /**
  139665. * Gets the output component
  139666. */
  139667. get output(): NodeMaterialConnectionPoint;
  139668. protected _buildBlock(state: NodeMaterialBuildState): this;
  139669. }
  139670. }
  139671. declare module BABYLON {
  139672. /**
  139673. * Block used to implement the ambient occlusion module of the PBR material
  139674. */
  139675. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  139676. /**
  139677. * Create a new AmbientOcclusionBlock
  139678. * @param name defines the block name
  139679. */
  139680. constructor(name: string);
  139681. /**
  139682. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  139683. */
  139684. useAmbientInGrayScale: boolean;
  139685. /**
  139686. * Initialize the block and prepare the context for build
  139687. * @param state defines the state that will be used for the build
  139688. */
  139689. initialize(state: NodeMaterialBuildState): void;
  139690. /**
  139691. * Gets the current class name
  139692. * @returns the class name
  139693. */
  139694. getClassName(): string;
  139695. /**
  139696. * Gets the texture input component
  139697. */
  139698. get texture(): NodeMaterialConnectionPoint;
  139699. /**
  139700. * Gets the texture intensity component
  139701. */
  139702. get intensity(): NodeMaterialConnectionPoint;
  139703. /**
  139704. * Gets the direct light intensity input component
  139705. */
  139706. get directLightIntensity(): NodeMaterialConnectionPoint;
  139707. /**
  139708. * Gets the ambient occlusion object output component
  139709. */
  139710. get ambientOcclusion(): NodeMaterialConnectionPoint;
  139711. /**
  139712. * Gets the main code of the block (fragment side)
  139713. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  139714. * @returns the shader code
  139715. */
  139716. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  139717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139718. protected _buildBlock(state: NodeMaterialBuildState): this;
  139719. protected _dumpPropertiesCode(): string;
  139720. serialize(): any;
  139721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139722. }
  139723. }
  139724. declare module BABYLON {
  139725. /**
  139726. * Block used to implement the reflection module of the PBR material
  139727. */
  139728. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  139729. /** @hidden */
  139730. _defineLODReflectionAlpha: string;
  139731. /** @hidden */
  139732. _defineLinearSpecularReflection: string;
  139733. private _vEnvironmentIrradianceName;
  139734. /** @hidden */
  139735. _vReflectionMicrosurfaceInfosName: string;
  139736. /** @hidden */
  139737. _vReflectionInfosName: string;
  139738. private _scene;
  139739. /**
  139740. * The three properties below are set by the main PBR block prior to calling methods of this class.
  139741. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139742. * It's less burden on the user side in the editor part.
  139743. */
  139744. /** @hidden */
  139745. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139746. /** @hidden */
  139747. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139748. /** @hidden */
  139749. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  139750. /**
  139751. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  139752. * diffuse part of the IBL.
  139753. */
  139754. useSphericalHarmonics: boolean;
  139755. /**
  139756. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  139757. */
  139758. forceIrradianceInFragment: boolean;
  139759. /**
  139760. * Create a new ReflectionBlock
  139761. * @param name defines the block name
  139762. */
  139763. constructor(name: string);
  139764. /**
  139765. * Gets the current class name
  139766. * @returns the class name
  139767. */
  139768. getClassName(): string;
  139769. /**
  139770. * Gets the position input component
  139771. */
  139772. get position(): NodeMaterialConnectionPoint;
  139773. /**
  139774. * Gets the world position input component
  139775. */
  139776. get worldPosition(): NodeMaterialConnectionPoint;
  139777. /**
  139778. * Gets the world normal input component
  139779. */
  139780. get worldNormal(): NodeMaterialConnectionPoint;
  139781. /**
  139782. * Gets the world input component
  139783. */
  139784. get world(): NodeMaterialConnectionPoint;
  139785. /**
  139786. * Gets the camera (or eye) position component
  139787. */
  139788. get cameraPosition(): NodeMaterialConnectionPoint;
  139789. /**
  139790. * Gets the view input component
  139791. */
  139792. get view(): NodeMaterialConnectionPoint;
  139793. /**
  139794. * Gets the color input component
  139795. */
  139796. get color(): NodeMaterialConnectionPoint;
  139797. /**
  139798. * Gets the reflection object output component
  139799. */
  139800. get reflection(): NodeMaterialConnectionPoint;
  139801. /**
  139802. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  139803. */
  139804. get hasTexture(): boolean;
  139805. /**
  139806. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  139807. */
  139808. get reflectionColor(): string;
  139809. protected _getTexture(): Nullable<BaseTexture>;
  139810. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139811. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  139812. /**
  139813. * Gets the code to inject in the vertex shader
  139814. * @param state current state of the node material building
  139815. * @returns the shader code
  139816. */
  139817. handleVertexSide(state: NodeMaterialBuildState): string;
  139818. /**
  139819. * Gets the main code of the block (fragment side)
  139820. * @param state current state of the node material building
  139821. * @param normalVarName name of the existing variable corresponding to the normal
  139822. * @returns the shader code
  139823. */
  139824. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  139825. protected _buildBlock(state: NodeMaterialBuildState): this;
  139826. protected _dumpPropertiesCode(): string;
  139827. serialize(): any;
  139828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139829. }
  139830. }
  139831. declare module BABYLON {
  139832. /**
  139833. * Block used to implement the sheen module of the PBR material
  139834. */
  139835. export class SheenBlock extends NodeMaterialBlock {
  139836. /**
  139837. * Create a new SheenBlock
  139838. * @param name defines the block name
  139839. */
  139840. constructor(name: string);
  139841. /**
  139842. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  139843. * It allows the strength of the sheen effect to not depend on the base color of the material,
  139844. * making it easier to setup and tweak the effect
  139845. */
  139846. albedoScaling: boolean;
  139847. /**
  139848. * Defines if the sheen is linked to the sheen color.
  139849. */
  139850. linkSheenWithAlbedo: boolean;
  139851. /**
  139852. * Initialize the block and prepare the context for build
  139853. * @param state defines the state that will be used for the build
  139854. */
  139855. initialize(state: NodeMaterialBuildState): void;
  139856. /**
  139857. * Gets the current class name
  139858. * @returns the class name
  139859. */
  139860. getClassName(): string;
  139861. /**
  139862. * Gets the intensity input component
  139863. */
  139864. get intensity(): NodeMaterialConnectionPoint;
  139865. /**
  139866. * Gets the color input component
  139867. */
  139868. get color(): NodeMaterialConnectionPoint;
  139869. /**
  139870. * Gets the roughness input component
  139871. */
  139872. get roughness(): NodeMaterialConnectionPoint;
  139873. /**
  139874. * Gets the texture input component
  139875. */
  139876. get texture(): NodeMaterialConnectionPoint;
  139877. /**
  139878. * Gets the sheen object output component
  139879. */
  139880. get sheen(): NodeMaterialConnectionPoint;
  139881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139882. /**
  139883. * Gets the main code of the block (fragment side)
  139884. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139885. * @returns the shader code
  139886. */
  139887. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  139888. protected _buildBlock(state: NodeMaterialBuildState): this;
  139889. protected _dumpPropertiesCode(): string;
  139890. serialize(): any;
  139891. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139892. }
  139893. }
  139894. declare module BABYLON {
  139895. /**
  139896. * Block used to implement the reflectivity module of the PBR material
  139897. */
  139898. export class ReflectivityBlock extends NodeMaterialBlock {
  139899. /**
  139900. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  139901. */
  139902. useAmbientOcclusionFromMetallicTextureRed: boolean;
  139903. /**
  139904. * Specifies if the metallic texture contains the metallness information in its blue channel.
  139905. */
  139906. useMetallnessFromMetallicTextureBlue: boolean;
  139907. /**
  139908. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  139909. */
  139910. useRoughnessFromMetallicTextureAlpha: boolean;
  139911. /**
  139912. * Specifies if the metallic texture contains the roughness information in its green channel.
  139913. */
  139914. useRoughnessFromMetallicTextureGreen: boolean;
  139915. /**
  139916. * Create a new ReflectivityBlock
  139917. * @param name defines the block name
  139918. */
  139919. constructor(name: string);
  139920. /**
  139921. * Initialize the block and prepare the context for build
  139922. * @param state defines the state that will be used for the build
  139923. */
  139924. initialize(state: NodeMaterialBuildState): void;
  139925. /**
  139926. * Gets the current class name
  139927. * @returns the class name
  139928. */
  139929. getClassName(): string;
  139930. /**
  139931. * Gets the metallic input component
  139932. */
  139933. get metallic(): NodeMaterialConnectionPoint;
  139934. /**
  139935. * Gets the roughness input component
  139936. */
  139937. get roughness(): NodeMaterialConnectionPoint;
  139938. /**
  139939. * Gets the texture input component
  139940. */
  139941. get texture(): NodeMaterialConnectionPoint;
  139942. /**
  139943. * Gets the reflectivity object output component
  139944. */
  139945. get reflectivity(): NodeMaterialConnectionPoint;
  139946. /**
  139947. * Gets the main code of the block (fragment side)
  139948. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  139949. * @returns the shader code
  139950. */
  139951. getCode(aoIntensityVarName: string): string;
  139952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139953. protected _buildBlock(state: NodeMaterialBuildState): this;
  139954. protected _dumpPropertiesCode(): string;
  139955. serialize(): any;
  139956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139957. }
  139958. }
  139959. declare module BABYLON {
  139960. /**
  139961. * Block used to implement the anisotropy module of the PBR material
  139962. */
  139963. export class AnisotropyBlock extends NodeMaterialBlock {
  139964. /**
  139965. * The two properties below are set by the main PBR block prior to calling methods of this class.
  139966. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139967. * It's less burden on the user side in the editor part.
  139968. */
  139969. /** @hidden */
  139970. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139971. /** @hidden */
  139972. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139973. /**
  139974. * Create a new AnisotropyBlock
  139975. * @param name defines the block name
  139976. */
  139977. constructor(name: string);
  139978. /**
  139979. * Initialize the block and prepare the context for build
  139980. * @param state defines the state that will be used for the build
  139981. */
  139982. initialize(state: NodeMaterialBuildState): void;
  139983. /**
  139984. * Gets the current class name
  139985. * @returns the class name
  139986. */
  139987. getClassName(): string;
  139988. /**
  139989. * Gets the intensity input component
  139990. */
  139991. get intensity(): NodeMaterialConnectionPoint;
  139992. /**
  139993. * Gets the direction input component
  139994. */
  139995. get direction(): NodeMaterialConnectionPoint;
  139996. /**
  139997. * Gets the texture input component
  139998. */
  139999. get texture(): NodeMaterialConnectionPoint;
  140000. /**
  140001. * Gets the uv input component
  140002. */
  140003. get uv(): NodeMaterialConnectionPoint;
  140004. /**
  140005. * Gets the worldTangent input component
  140006. */
  140007. get worldTangent(): NodeMaterialConnectionPoint;
  140008. /**
  140009. * Gets the anisotropy object output component
  140010. */
  140011. get anisotropy(): NodeMaterialConnectionPoint;
  140012. private _generateTBNSpace;
  140013. /**
  140014. * Gets the main code of the block (fragment side)
  140015. * @param state current state of the node material building
  140016. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140017. * @returns the shader code
  140018. */
  140019. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  140020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140021. protected _buildBlock(state: NodeMaterialBuildState): this;
  140022. }
  140023. }
  140024. declare module BABYLON {
  140025. /**
  140026. * Block used to implement the clear coat module of the PBR material
  140027. */
  140028. export class ClearCoatBlock extends NodeMaterialBlock {
  140029. private _scene;
  140030. /**
  140031. * Create a new ClearCoatBlock
  140032. * @param name defines the block name
  140033. */
  140034. constructor(name: string);
  140035. /**
  140036. * Initialize the block and prepare the context for build
  140037. * @param state defines the state that will be used for the build
  140038. */
  140039. initialize(state: NodeMaterialBuildState): void;
  140040. /**
  140041. * Gets the current class name
  140042. * @returns the class name
  140043. */
  140044. getClassName(): string;
  140045. /**
  140046. * Gets the intensity input component
  140047. */
  140048. get intensity(): NodeMaterialConnectionPoint;
  140049. /**
  140050. * Gets the roughness input component
  140051. */
  140052. get roughness(): NodeMaterialConnectionPoint;
  140053. /**
  140054. * Gets the ior input component
  140055. */
  140056. get ior(): NodeMaterialConnectionPoint;
  140057. /**
  140058. * Gets the texture input component
  140059. */
  140060. get texture(): NodeMaterialConnectionPoint;
  140061. /**
  140062. * Gets the bump texture input component
  140063. */
  140064. get bumpTexture(): NodeMaterialConnectionPoint;
  140065. /**
  140066. * Gets the uv input component
  140067. */
  140068. get uv(): NodeMaterialConnectionPoint;
  140069. /**
  140070. * Gets the tint color input component
  140071. */
  140072. get tintColor(): NodeMaterialConnectionPoint;
  140073. /**
  140074. * Gets the tint "at distance" input component
  140075. */
  140076. get tintAtDistance(): NodeMaterialConnectionPoint;
  140077. /**
  140078. * Gets the tint thickness input component
  140079. */
  140080. get tintThickness(): NodeMaterialConnectionPoint;
  140081. /**
  140082. * Gets the tint texture input component
  140083. */
  140084. get tintTexture(): NodeMaterialConnectionPoint;
  140085. /**
  140086. * Gets the world tangent input component
  140087. */
  140088. get worldTangent(): NodeMaterialConnectionPoint;
  140089. /**
  140090. * Gets the clear coat object output component
  140091. */
  140092. get clearcoat(): NodeMaterialConnectionPoint;
  140093. autoConfigure(material: NodeMaterial): void;
  140094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140096. private _generateTBNSpace;
  140097. /**
  140098. * Gets the main code of the block (fragment side)
  140099. * @param state current state of the node material building
  140100. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  140101. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140102. * @param worldPosVarName name of the variable holding the world position
  140103. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140104. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  140105. * @param worldNormalVarName name of the variable holding the world normal
  140106. * @returns the shader code
  140107. */
  140108. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  140109. protected _buildBlock(state: NodeMaterialBuildState): this;
  140110. }
  140111. }
  140112. declare module BABYLON {
  140113. /**
  140114. * Block used to implement the sub surface module of the PBR material
  140115. */
  140116. export class SubSurfaceBlock extends NodeMaterialBlock {
  140117. /**
  140118. * Create a new SubSurfaceBlock
  140119. * @param name defines the block name
  140120. */
  140121. constructor(name: string);
  140122. /**
  140123. * Stores the intensity of the different subsurface effects in the thickness texture.
  140124. * * the green channel is the translucency intensity.
  140125. * * the blue channel is the scattering intensity.
  140126. * * the alpha channel is the refraction intensity.
  140127. */
  140128. useMaskFromThicknessTexture: boolean;
  140129. /**
  140130. * Initialize the block and prepare the context for build
  140131. * @param state defines the state that will be used for the build
  140132. */
  140133. initialize(state: NodeMaterialBuildState): void;
  140134. /**
  140135. * Gets the current class name
  140136. * @returns the class name
  140137. */
  140138. getClassName(): string;
  140139. /**
  140140. * Gets the min thickness input component
  140141. */
  140142. get minThickness(): NodeMaterialConnectionPoint;
  140143. /**
  140144. * Gets the max thickness input component
  140145. */
  140146. get maxThickness(): NodeMaterialConnectionPoint;
  140147. /**
  140148. * Gets the thickness texture component
  140149. */
  140150. get thicknessTexture(): NodeMaterialConnectionPoint;
  140151. /**
  140152. * Gets the tint color input component
  140153. */
  140154. get tintColor(): NodeMaterialConnectionPoint;
  140155. /**
  140156. * Gets the translucency intensity input component
  140157. */
  140158. get translucencyIntensity(): NodeMaterialConnectionPoint;
  140159. /**
  140160. * Gets the translucency diffusion distance input component
  140161. */
  140162. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  140163. /**
  140164. * Gets the refraction object parameters
  140165. */
  140166. get refraction(): NodeMaterialConnectionPoint;
  140167. /**
  140168. * Gets the sub surface object output component
  140169. */
  140170. get subsurface(): NodeMaterialConnectionPoint;
  140171. autoConfigure(material: NodeMaterial): void;
  140172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140173. /**
  140174. * Gets the main code of the block (fragment side)
  140175. * @param state current state of the node material building
  140176. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  140177. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140178. * @param worldPosVarName name of the variable holding the world position
  140179. * @returns the shader code
  140180. */
  140181. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  140182. protected _buildBlock(state: NodeMaterialBuildState): this;
  140183. }
  140184. }
  140185. declare module BABYLON {
  140186. /**
  140187. * Block used to implement the PBR metallic/roughness model
  140188. */
  140189. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  140190. /**
  140191. * Gets or sets the light associated with this block
  140192. */
  140193. light: Nullable<Light>;
  140194. private _lightId;
  140195. private _scene;
  140196. private _environmentBRDFTexture;
  140197. private _environmentBrdfSamplerName;
  140198. private _vNormalWName;
  140199. private _invertNormalName;
  140200. /**
  140201. * Create a new ReflectionBlock
  140202. * @param name defines the block name
  140203. */
  140204. constructor(name: string);
  140205. /**
  140206. * Intensity of the direct lights e.g. the four lights available in your scene.
  140207. * This impacts both the direct diffuse and specular highlights.
  140208. */
  140209. directIntensity: number;
  140210. /**
  140211. * Intensity of the environment e.g. how much the environment will light the object
  140212. * either through harmonics for rough material or through the refelction for shiny ones.
  140213. */
  140214. environmentIntensity: number;
  140215. /**
  140216. * This is a special control allowing the reduction of the specular highlights coming from the
  140217. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  140218. */
  140219. specularIntensity: number;
  140220. /**
  140221. * Defines the falloff type used in this material.
  140222. * It by default is Physical.
  140223. */
  140224. lightFalloff: number;
  140225. /**
  140226. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  140227. */
  140228. useAlphaFromAlbedoTexture: boolean;
  140229. /**
  140230. * Specifies that alpha test should be used
  140231. */
  140232. useAlphaTest: boolean;
  140233. /**
  140234. * Defines the alpha limits in alpha test mode.
  140235. */
  140236. alphaTestCutoff: number;
  140237. /**
  140238. * Specifies that alpha blending should be used
  140239. */
  140240. useAlphaBlending: boolean;
  140241. /**
  140242. * Defines if the alpha value should be determined via the rgb values.
  140243. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  140244. */
  140245. opacityRGB: boolean;
  140246. /**
  140247. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  140248. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  140249. */
  140250. useRadianceOverAlpha: boolean;
  140251. /**
  140252. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  140253. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  140254. */
  140255. useSpecularOverAlpha: boolean;
  140256. /**
  140257. * Enables specular anti aliasing in the PBR shader.
  140258. * It will both interacts on the Geometry for analytical and IBL lighting.
  140259. * It also prefilter the roughness map based on the bump values.
  140260. */
  140261. enableSpecularAntiAliasing: boolean;
  140262. /**
  140263. * Defines if the material uses energy conservation.
  140264. */
  140265. useEnergyConservation: boolean;
  140266. /**
  140267. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  140268. * too much the area relying on ambient texture to define their ambient occlusion.
  140269. */
  140270. useRadianceOcclusion: boolean;
  140271. /**
  140272. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  140273. * makes the reflect vector face the model (under horizon).
  140274. */
  140275. useHorizonOcclusion: boolean;
  140276. /**
  140277. * If set to true, no lighting calculations will be applied.
  140278. */
  140279. unlit: boolean;
  140280. /**
  140281. * Force normal to face away from face.
  140282. */
  140283. forceNormalForward: boolean;
  140284. /**
  140285. * Defines the material debug mode.
  140286. * It helps seeing only some components of the material while troubleshooting.
  140287. */
  140288. debugMode: number;
  140289. /**
  140290. * Specify from where on screen the debug mode should start.
  140291. * The value goes from -1 (full screen) to 1 (not visible)
  140292. * It helps with side by side comparison against the final render
  140293. * This defaults to 0
  140294. */
  140295. debugLimit: number;
  140296. /**
  140297. * As the default viewing range might not be enough (if the ambient is really small for instance)
  140298. * You can use the factor to better multiply the final value.
  140299. */
  140300. debugFactor: number;
  140301. /**
  140302. * Initialize the block and prepare the context for build
  140303. * @param state defines the state that will be used for the build
  140304. */
  140305. initialize(state: NodeMaterialBuildState): void;
  140306. /**
  140307. * Gets the current class name
  140308. * @returns the class name
  140309. */
  140310. getClassName(): string;
  140311. /**
  140312. * Gets the world position input component
  140313. */
  140314. get worldPosition(): NodeMaterialConnectionPoint;
  140315. /**
  140316. * Gets the world normal input component
  140317. */
  140318. get worldNormal(): NodeMaterialConnectionPoint;
  140319. /**
  140320. * Gets the perturbed normal input component
  140321. */
  140322. get perturbedNormal(): NodeMaterialConnectionPoint;
  140323. /**
  140324. * Gets the camera position input component
  140325. */
  140326. get cameraPosition(): NodeMaterialConnectionPoint;
  140327. /**
  140328. * Gets the base color input component
  140329. */
  140330. get baseColor(): NodeMaterialConnectionPoint;
  140331. /**
  140332. * Gets the base texture input component
  140333. */
  140334. get baseTexture(): NodeMaterialConnectionPoint;
  140335. /**
  140336. * Gets the opacity texture input component
  140337. */
  140338. get opacityTexture(): NodeMaterialConnectionPoint;
  140339. /**
  140340. * Gets the ambient color input component
  140341. */
  140342. get ambientColor(): NodeMaterialConnectionPoint;
  140343. /**
  140344. * Gets the reflectivity object parameters
  140345. */
  140346. get reflectivity(): NodeMaterialConnectionPoint;
  140347. /**
  140348. * Gets the ambient occlusion object parameters
  140349. */
  140350. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140351. /**
  140352. * Gets the reflection object parameters
  140353. */
  140354. get reflection(): NodeMaterialConnectionPoint;
  140355. /**
  140356. * Gets the sheen object parameters
  140357. */
  140358. get sheen(): NodeMaterialConnectionPoint;
  140359. /**
  140360. * Gets the clear coat object parameters
  140361. */
  140362. get clearcoat(): NodeMaterialConnectionPoint;
  140363. /**
  140364. * Gets the sub surface object parameters
  140365. */
  140366. get subsurface(): NodeMaterialConnectionPoint;
  140367. /**
  140368. * Gets the anisotropy object parameters
  140369. */
  140370. get anisotropy(): NodeMaterialConnectionPoint;
  140371. /**
  140372. * Gets the ambient output component
  140373. */
  140374. get ambient(): NodeMaterialConnectionPoint;
  140375. /**
  140376. * Gets the diffuse output component
  140377. */
  140378. get diffuse(): NodeMaterialConnectionPoint;
  140379. /**
  140380. * Gets the specular output component
  140381. */
  140382. get specular(): NodeMaterialConnectionPoint;
  140383. /**
  140384. * Gets the sheen output component
  140385. */
  140386. get sheenDir(): NodeMaterialConnectionPoint;
  140387. /**
  140388. * Gets the clear coat output component
  140389. */
  140390. get clearcoatDir(): NodeMaterialConnectionPoint;
  140391. /**
  140392. * Gets the indirect diffuse output component
  140393. */
  140394. get diffuseIndirect(): NodeMaterialConnectionPoint;
  140395. /**
  140396. * Gets the indirect specular output component
  140397. */
  140398. get specularIndirect(): NodeMaterialConnectionPoint;
  140399. /**
  140400. * Gets the indirect sheen output component
  140401. */
  140402. get sheenIndirect(): NodeMaterialConnectionPoint;
  140403. /**
  140404. * Gets the indirect clear coat output component
  140405. */
  140406. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  140407. /**
  140408. * Gets the refraction output component
  140409. */
  140410. get refraction(): NodeMaterialConnectionPoint;
  140411. /**
  140412. * Gets the global lighting output component
  140413. */
  140414. get lighting(): NodeMaterialConnectionPoint;
  140415. /**
  140416. * Gets the shadow output component
  140417. */
  140418. get shadow(): NodeMaterialConnectionPoint;
  140419. /**
  140420. * Gets the alpha output component
  140421. */
  140422. get alpha(): NodeMaterialConnectionPoint;
  140423. autoConfigure(material: NodeMaterial): void;
  140424. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140425. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140427. private _injectVertexCode;
  140428. /**
  140429. * Gets the code corresponding to the albedo/opacity module
  140430. * @returns the shader code
  140431. */
  140432. getAlbedoOpacityCode(): string;
  140433. protected _buildBlock(state: NodeMaterialBuildState): this;
  140434. protected _dumpPropertiesCode(): string;
  140435. serialize(): any;
  140436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140437. }
  140438. }
  140439. declare module BABYLON {
  140440. /**
  140441. * Block used to compute value of one parameter modulo another
  140442. */
  140443. export class ModBlock extends NodeMaterialBlock {
  140444. /**
  140445. * Creates a new ModBlock
  140446. * @param name defines the block name
  140447. */
  140448. constructor(name: string);
  140449. /**
  140450. * Gets the current class name
  140451. * @returns the class name
  140452. */
  140453. getClassName(): string;
  140454. /**
  140455. * Gets the left operand input component
  140456. */
  140457. get left(): NodeMaterialConnectionPoint;
  140458. /**
  140459. * Gets the right operand input component
  140460. */
  140461. get right(): NodeMaterialConnectionPoint;
  140462. /**
  140463. * Gets the output component
  140464. */
  140465. get output(): NodeMaterialConnectionPoint;
  140466. protected _buildBlock(state: NodeMaterialBuildState): this;
  140467. }
  140468. }
  140469. declare module BABYLON {
  140470. /**
  140471. * Helper class to push actions to a pool of workers.
  140472. */
  140473. export class WorkerPool implements IDisposable {
  140474. private _workerInfos;
  140475. private _pendingActions;
  140476. /**
  140477. * Constructor
  140478. * @param workers Array of workers to use for actions
  140479. */
  140480. constructor(workers: Array<Worker>);
  140481. /**
  140482. * Terminates all workers and clears any pending actions.
  140483. */
  140484. dispose(): void;
  140485. /**
  140486. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140487. * pended until a worker has completed its action.
  140488. * @param action The action to perform. Call onComplete when the action is complete.
  140489. */
  140490. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140491. private _execute;
  140492. }
  140493. }
  140494. declare module BABYLON {
  140495. /**
  140496. * Configuration for Draco compression
  140497. */
  140498. export interface IDracoCompressionConfiguration {
  140499. /**
  140500. * Configuration for the decoder.
  140501. */
  140502. decoder: {
  140503. /**
  140504. * The url to the WebAssembly module.
  140505. */
  140506. wasmUrl?: string;
  140507. /**
  140508. * The url to the WebAssembly binary.
  140509. */
  140510. wasmBinaryUrl?: string;
  140511. /**
  140512. * The url to the fallback JavaScript module.
  140513. */
  140514. fallbackUrl?: string;
  140515. };
  140516. }
  140517. /**
  140518. * Draco compression (https://google.github.io/draco/)
  140519. *
  140520. * This class wraps the Draco module.
  140521. *
  140522. * **Encoder**
  140523. *
  140524. * The encoder is not currently implemented.
  140525. *
  140526. * **Decoder**
  140527. *
  140528. * 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.
  140529. *
  140530. * To update the configuration, use the following code:
  140531. * ```javascript
  140532. * DracoCompression.Configuration = {
  140533. * decoder: {
  140534. * wasmUrl: "<url to the WebAssembly library>",
  140535. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  140536. * fallbackUrl: "<url to the fallback JavaScript library>",
  140537. * }
  140538. * };
  140539. * ```
  140540. *
  140541. * 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.
  140542. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  140543. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  140544. *
  140545. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  140546. * ```javascript
  140547. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  140548. * ```
  140549. *
  140550. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  140551. */
  140552. export class DracoCompression implements IDisposable {
  140553. private _workerPoolPromise?;
  140554. private _decoderModulePromise?;
  140555. /**
  140556. * The configuration. Defaults to the following urls:
  140557. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  140558. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  140559. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  140560. */
  140561. static Configuration: IDracoCompressionConfiguration;
  140562. /**
  140563. * Returns true if the decoder configuration is available.
  140564. */
  140565. static get DecoderAvailable(): boolean;
  140566. /**
  140567. * Default number of workers to create when creating the draco compression object.
  140568. */
  140569. static DefaultNumWorkers: number;
  140570. private static GetDefaultNumWorkers;
  140571. private static _Default;
  140572. /**
  140573. * Default instance for the draco compression object.
  140574. */
  140575. static get Default(): DracoCompression;
  140576. /**
  140577. * Constructor
  140578. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140579. */
  140580. constructor(numWorkers?: number);
  140581. /**
  140582. * Stop all async operations and release resources.
  140583. */
  140584. dispose(): void;
  140585. /**
  140586. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  140587. * @returns a promise that resolves when ready
  140588. */
  140589. whenReadyAsync(): Promise<void>;
  140590. /**
  140591. * Decode Draco compressed mesh data to vertex data.
  140592. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  140593. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  140594. * @returns A promise that resolves with the decoded vertex data
  140595. */
  140596. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  140597. [kind: string]: number;
  140598. }): Promise<VertexData>;
  140599. }
  140600. }
  140601. declare module BABYLON {
  140602. /**
  140603. * Class for building Constructive Solid Geometry
  140604. */
  140605. export class CSG {
  140606. private polygons;
  140607. /**
  140608. * The world matrix
  140609. */
  140610. matrix: Matrix;
  140611. /**
  140612. * Stores the position
  140613. */
  140614. position: Vector3;
  140615. /**
  140616. * Stores the rotation
  140617. */
  140618. rotation: Vector3;
  140619. /**
  140620. * Stores the rotation quaternion
  140621. */
  140622. rotationQuaternion: Nullable<Quaternion>;
  140623. /**
  140624. * Stores the scaling vector
  140625. */
  140626. scaling: Vector3;
  140627. /**
  140628. * Convert the Mesh to CSG
  140629. * @param mesh The Mesh to convert to CSG
  140630. * @returns A new CSG from the Mesh
  140631. */
  140632. static FromMesh(mesh: Mesh): CSG;
  140633. /**
  140634. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  140635. * @param polygons Polygons used to construct a CSG solid
  140636. */
  140637. private static FromPolygons;
  140638. /**
  140639. * Clones, or makes a deep copy, of the CSG
  140640. * @returns A new CSG
  140641. */
  140642. clone(): CSG;
  140643. /**
  140644. * Unions this CSG with another CSG
  140645. * @param csg The CSG to union against this CSG
  140646. * @returns The unioned CSG
  140647. */
  140648. union(csg: CSG): CSG;
  140649. /**
  140650. * Unions this CSG with another CSG in place
  140651. * @param csg The CSG to union against this CSG
  140652. */
  140653. unionInPlace(csg: CSG): void;
  140654. /**
  140655. * Subtracts this CSG with another CSG
  140656. * @param csg The CSG to subtract against this CSG
  140657. * @returns A new CSG
  140658. */
  140659. subtract(csg: CSG): CSG;
  140660. /**
  140661. * Subtracts this CSG with another CSG in place
  140662. * @param csg The CSG to subtact against this CSG
  140663. */
  140664. subtractInPlace(csg: CSG): void;
  140665. /**
  140666. * Intersect this CSG with another CSG
  140667. * @param csg The CSG to intersect against this CSG
  140668. * @returns A new CSG
  140669. */
  140670. intersect(csg: CSG): CSG;
  140671. /**
  140672. * Intersects this CSG with another CSG in place
  140673. * @param csg The CSG to intersect against this CSG
  140674. */
  140675. intersectInPlace(csg: CSG): void;
  140676. /**
  140677. * Return a new CSG solid with solid and empty space switched. This solid is
  140678. * not modified.
  140679. * @returns A new CSG solid with solid and empty space switched
  140680. */
  140681. inverse(): CSG;
  140682. /**
  140683. * Inverses the CSG in place
  140684. */
  140685. inverseInPlace(): void;
  140686. /**
  140687. * This is used to keep meshes transformations so they can be restored
  140688. * when we build back a Babylon Mesh
  140689. * NB : All CSG operations are performed in world coordinates
  140690. * @param csg The CSG to copy the transform attributes from
  140691. * @returns This CSG
  140692. */
  140693. copyTransformAttributes(csg: CSG): CSG;
  140694. /**
  140695. * Build Raw mesh from CSG
  140696. * Coordinates here are in world space
  140697. * @param name The name of the mesh geometry
  140698. * @param scene The Scene
  140699. * @param keepSubMeshes Specifies if the submeshes should be kept
  140700. * @returns A new Mesh
  140701. */
  140702. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140703. /**
  140704. * Build Mesh from CSG taking material and transforms into account
  140705. * @param name The name of the Mesh
  140706. * @param material The material of the Mesh
  140707. * @param scene The Scene
  140708. * @param keepSubMeshes Specifies if submeshes should be kept
  140709. * @returns The new Mesh
  140710. */
  140711. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140712. }
  140713. }
  140714. declare module BABYLON {
  140715. /**
  140716. * Class used to create a trail following a mesh
  140717. */
  140718. export class TrailMesh extends Mesh {
  140719. private _generator;
  140720. private _autoStart;
  140721. private _running;
  140722. private _diameter;
  140723. private _length;
  140724. private _sectionPolygonPointsCount;
  140725. private _sectionVectors;
  140726. private _sectionNormalVectors;
  140727. private _beforeRenderObserver;
  140728. /**
  140729. * @constructor
  140730. * @param name The value used by scene.getMeshByName() to do a lookup.
  140731. * @param generator The mesh or transform node to generate a trail.
  140732. * @param scene The scene to add this mesh to.
  140733. * @param diameter Diameter of trailing mesh. Default is 1.
  140734. * @param length Length of trailing mesh. Default is 60.
  140735. * @param autoStart Automatically start trailing mesh. Default true.
  140736. */
  140737. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  140738. /**
  140739. * "TrailMesh"
  140740. * @returns "TrailMesh"
  140741. */
  140742. getClassName(): string;
  140743. private _createMesh;
  140744. /**
  140745. * Start trailing mesh.
  140746. */
  140747. start(): void;
  140748. /**
  140749. * Stop trailing mesh.
  140750. */
  140751. stop(): void;
  140752. /**
  140753. * Update trailing mesh geometry.
  140754. */
  140755. update(): void;
  140756. /**
  140757. * Returns a new TrailMesh object.
  140758. * @param name is a string, the name given to the new mesh
  140759. * @param newGenerator use new generator object for cloned trail mesh
  140760. * @returns a new mesh
  140761. */
  140762. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  140763. /**
  140764. * Serializes this trail mesh
  140765. * @param serializationObject object to write serialization to
  140766. */
  140767. serialize(serializationObject: any): void;
  140768. /**
  140769. * Parses a serialized trail mesh
  140770. * @param parsedMesh the serialized mesh
  140771. * @param scene the scene to create the trail mesh in
  140772. * @returns the created trail mesh
  140773. */
  140774. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  140775. }
  140776. }
  140777. declare module BABYLON {
  140778. /**
  140779. * Class containing static functions to help procedurally build meshes
  140780. */
  140781. export class TiledBoxBuilder {
  140782. /**
  140783. * Creates a box mesh
  140784. * 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)
  140785. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140789. * @param name defines the name of the mesh
  140790. * @param options defines the options used to create the mesh
  140791. * @param scene defines the hosting scene
  140792. * @returns the box mesh
  140793. */
  140794. static CreateTiledBox(name: string, options: {
  140795. pattern?: number;
  140796. width?: number;
  140797. height?: number;
  140798. depth?: number;
  140799. tileSize?: number;
  140800. tileWidth?: number;
  140801. tileHeight?: number;
  140802. alignHorizontal?: number;
  140803. alignVertical?: number;
  140804. faceUV?: Vector4[];
  140805. faceColors?: Color4[];
  140806. sideOrientation?: number;
  140807. updatable?: boolean;
  140808. }, scene?: Nullable<Scene>): Mesh;
  140809. }
  140810. }
  140811. declare module BABYLON {
  140812. /**
  140813. * Class containing static functions to help procedurally build meshes
  140814. */
  140815. export class TorusKnotBuilder {
  140816. /**
  140817. * Creates a torus knot mesh
  140818. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  140819. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  140820. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  140821. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  140822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  140825. * @param name defines the name of the mesh
  140826. * @param options defines the options used to create the mesh
  140827. * @param scene defines the hosting scene
  140828. * @returns the torus knot mesh
  140829. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  140830. */
  140831. static CreateTorusKnot(name: string, options: {
  140832. radius?: number;
  140833. tube?: number;
  140834. radialSegments?: number;
  140835. tubularSegments?: number;
  140836. p?: number;
  140837. q?: number;
  140838. updatable?: boolean;
  140839. sideOrientation?: number;
  140840. frontUVs?: Vector4;
  140841. backUVs?: Vector4;
  140842. }, scene: any): Mesh;
  140843. }
  140844. }
  140845. declare module BABYLON {
  140846. /**
  140847. * Polygon
  140848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  140849. */
  140850. export class Polygon {
  140851. /**
  140852. * Creates a rectangle
  140853. * @param xmin bottom X coord
  140854. * @param ymin bottom Y coord
  140855. * @param xmax top X coord
  140856. * @param ymax top Y coord
  140857. * @returns points that make the resulting rectation
  140858. */
  140859. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  140860. /**
  140861. * Creates a circle
  140862. * @param radius radius of circle
  140863. * @param cx scale in x
  140864. * @param cy scale in y
  140865. * @param numberOfSides number of sides that make up the circle
  140866. * @returns points that make the resulting circle
  140867. */
  140868. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  140869. /**
  140870. * Creates a polygon from input string
  140871. * @param input Input polygon data
  140872. * @returns the parsed points
  140873. */
  140874. static Parse(input: string): Vector2[];
  140875. /**
  140876. * Starts building a polygon from x and y coordinates
  140877. * @param x x coordinate
  140878. * @param y y coordinate
  140879. * @returns the started path2
  140880. */
  140881. static StartingAt(x: number, y: number): Path2;
  140882. }
  140883. /**
  140884. * Builds a polygon
  140885. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  140886. */
  140887. export class PolygonMeshBuilder {
  140888. private _points;
  140889. private _outlinepoints;
  140890. private _holes;
  140891. private _name;
  140892. private _scene;
  140893. private _epoints;
  140894. private _eholes;
  140895. private _addToepoint;
  140896. /**
  140897. * Babylon reference to the earcut plugin.
  140898. */
  140899. bjsEarcut: any;
  140900. /**
  140901. * Creates a PolygonMeshBuilder
  140902. * @param name name of the builder
  140903. * @param contours Path of the polygon
  140904. * @param scene scene to add to when creating the mesh
  140905. * @param earcutInjection can be used to inject your own earcut reference
  140906. */
  140907. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  140908. /**
  140909. * Adds a whole within the polygon
  140910. * @param hole Array of points defining the hole
  140911. * @returns this
  140912. */
  140913. addHole(hole: Vector2[]): PolygonMeshBuilder;
  140914. /**
  140915. * Creates the polygon
  140916. * @param updatable If the mesh should be updatable
  140917. * @param depth The depth of the mesh created
  140918. * @returns the created mesh
  140919. */
  140920. build(updatable?: boolean, depth?: number): Mesh;
  140921. /**
  140922. * Creates the polygon
  140923. * @param depth The depth of the mesh created
  140924. * @returns the created VertexData
  140925. */
  140926. buildVertexData(depth?: number): VertexData;
  140927. /**
  140928. * Adds a side to the polygon
  140929. * @param positions points that make the polygon
  140930. * @param normals normals of the polygon
  140931. * @param uvs uvs of the polygon
  140932. * @param indices indices of the polygon
  140933. * @param bounds bounds of the polygon
  140934. * @param points points of the polygon
  140935. * @param depth depth of the polygon
  140936. * @param flip flip of the polygon
  140937. */
  140938. private addSide;
  140939. }
  140940. }
  140941. declare module BABYLON {
  140942. /**
  140943. * Class containing static functions to help procedurally build meshes
  140944. */
  140945. export class PolygonBuilder {
  140946. /**
  140947. * Creates a polygon mesh
  140948. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  140949. * * 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
  140950. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  140951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  140953. * * Remember you can only change the shape positions, not their number when updating a polygon
  140954. * @param name defines the name of the mesh
  140955. * @param options defines the options used to create the mesh
  140956. * @param scene defines the hosting scene
  140957. * @param earcutInjection can be used to inject your own earcut reference
  140958. * @returns the polygon mesh
  140959. */
  140960. static CreatePolygon(name: string, options: {
  140961. shape: Vector3[];
  140962. holes?: Vector3[][];
  140963. depth?: number;
  140964. faceUV?: Vector4[];
  140965. faceColors?: Color4[];
  140966. updatable?: boolean;
  140967. sideOrientation?: number;
  140968. frontUVs?: Vector4;
  140969. backUVs?: Vector4;
  140970. wrap?: boolean;
  140971. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140972. /**
  140973. * Creates an extruded polygon mesh, with depth in the Y direction.
  140974. * * 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)
  140975. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140976. * @param name defines the name of the mesh
  140977. * @param options defines the options used to create the mesh
  140978. * @param scene defines the hosting scene
  140979. * @param earcutInjection can be used to inject your own earcut reference
  140980. * @returns the polygon mesh
  140981. */
  140982. static ExtrudePolygon(name: string, options: {
  140983. shape: Vector3[];
  140984. holes?: Vector3[][];
  140985. depth?: number;
  140986. faceUV?: Vector4[];
  140987. faceColors?: Color4[];
  140988. updatable?: boolean;
  140989. sideOrientation?: number;
  140990. frontUVs?: Vector4;
  140991. backUVs?: Vector4;
  140992. wrap?: boolean;
  140993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140994. }
  140995. }
  140996. declare module BABYLON {
  140997. /**
  140998. * Class containing static functions to help procedurally build meshes
  140999. */
  141000. export class LatheBuilder {
  141001. /**
  141002. * Creates lathe mesh.
  141003. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141004. * * 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
  141005. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141006. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141007. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141008. * * 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
  141009. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141010. * * 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
  141011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141015. * @param name defines the name of the mesh
  141016. * @param options defines the options used to create the mesh
  141017. * @param scene defines the hosting scene
  141018. * @returns the lathe mesh
  141019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141020. */
  141021. static CreateLathe(name: string, options: {
  141022. shape: Vector3[];
  141023. radius?: number;
  141024. tessellation?: number;
  141025. clip?: number;
  141026. arc?: number;
  141027. closed?: boolean;
  141028. updatable?: boolean;
  141029. sideOrientation?: number;
  141030. frontUVs?: Vector4;
  141031. backUVs?: Vector4;
  141032. cap?: number;
  141033. invertUV?: boolean;
  141034. }, scene?: Nullable<Scene>): Mesh;
  141035. }
  141036. }
  141037. declare module BABYLON {
  141038. /**
  141039. * Class containing static functions to help procedurally build meshes
  141040. */
  141041. export class TiledPlaneBuilder {
  141042. /**
  141043. * Creates a tiled plane mesh
  141044. * * The parameter `pattern` will, depending on value, do nothing or
  141045. * * * flip (reflect about central vertical) alternate tiles across and up
  141046. * * * flip every tile on alternate rows
  141047. * * * rotate (180 degs) alternate tiles across and up
  141048. * * * rotate every tile on alternate rows
  141049. * * * flip and rotate alternate tiles across and up
  141050. * * * flip and rotate every tile on alternate rows
  141051. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  141052. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  141053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141055. * * 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)
  141056. * * 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)
  141057. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141058. * @param name defines the name of the mesh
  141059. * @param options defines the options used to create the mesh
  141060. * @param scene defines the hosting scene
  141061. * @returns the box mesh
  141062. */
  141063. static CreateTiledPlane(name: string, options: {
  141064. pattern?: number;
  141065. tileSize?: number;
  141066. tileWidth?: number;
  141067. tileHeight?: number;
  141068. size?: number;
  141069. width?: number;
  141070. height?: number;
  141071. alignHorizontal?: number;
  141072. alignVertical?: number;
  141073. sideOrientation?: number;
  141074. frontUVs?: Vector4;
  141075. backUVs?: Vector4;
  141076. updatable?: boolean;
  141077. }, scene?: Nullable<Scene>): Mesh;
  141078. }
  141079. }
  141080. declare module BABYLON {
  141081. /**
  141082. * Class containing static functions to help procedurally build meshes
  141083. */
  141084. export class TubeBuilder {
  141085. /**
  141086. * Creates a tube mesh.
  141087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141092. * * 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)
  141093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141094. * * 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
  141095. * * 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
  141096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141100. * @param name defines the name of the mesh
  141101. * @param options defines the options used to create the mesh
  141102. * @param scene defines the hosting scene
  141103. * @returns the tube mesh
  141104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141106. */
  141107. static CreateTube(name: string, options: {
  141108. path: Vector3[];
  141109. radius?: number;
  141110. tessellation?: number;
  141111. radiusFunction?: {
  141112. (i: number, distance: number): number;
  141113. };
  141114. cap?: number;
  141115. arc?: number;
  141116. updatable?: boolean;
  141117. sideOrientation?: number;
  141118. frontUVs?: Vector4;
  141119. backUVs?: Vector4;
  141120. instance?: Mesh;
  141121. invertUV?: boolean;
  141122. }, scene?: Nullable<Scene>): Mesh;
  141123. }
  141124. }
  141125. declare module BABYLON {
  141126. /**
  141127. * Class containing static functions to help procedurally build meshes
  141128. */
  141129. export class IcoSphereBuilder {
  141130. /**
  141131. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141132. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141133. * * 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`)
  141134. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141135. * * 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
  141136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141139. * @param name defines the name of the mesh
  141140. * @param options defines the options used to create the mesh
  141141. * @param scene defines the hosting scene
  141142. * @returns the icosahedron mesh
  141143. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141144. */
  141145. static CreateIcoSphere(name: string, options: {
  141146. radius?: number;
  141147. radiusX?: number;
  141148. radiusY?: number;
  141149. radiusZ?: number;
  141150. flat?: boolean;
  141151. subdivisions?: number;
  141152. sideOrientation?: number;
  141153. frontUVs?: Vector4;
  141154. backUVs?: Vector4;
  141155. updatable?: boolean;
  141156. }, scene?: Nullable<Scene>): Mesh;
  141157. }
  141158. }
  141159. declare module BABYLON {
  141160. /**
  141161. * Class containing static functions to help procedurally build meshes
  141162. */
  141163. export class DecalBuilder {
  141164. /**
  141165. * Creates a decal mesh.
  141166. * 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
  141167. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141168. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141169. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141170. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141171. * @param name defines the name of the mesh
  141172. * @param sourceMesh defines the mesh where the decal must be applied
  141173. * @param options defines the options used to create the mesh
  141174. * @param scene defines the hosting scene
  141175. * @returns the decal mesh
  141176. * @see https://doc.babylonjs.com/how_to/decals
  141177. */
  141178. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141179. position?: Vector3;
  141180. normal?: Vector3;
  141181. size?: Vector3;
  141182. angle?: number;
  141183. }): Mesh;
  141184. }
  141185. }
  141186. declare module BABYLON {
  141187. /**
  141188. * Class containing static functions to help procedurally build meshes
  141189. */
  141190. export class MeshBuilder {
  141191. /**
  141192. * Creates a box mesh
  141193. * * The parameter `size` sets the size (float) of each box side (default 1)
  141194. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  141195. * * 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)
  141196. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141200. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141201. * @param name defines the name of the mesh
  141202. * @param options defines the options used to create the mesh
  141203. * @param scene defines the hosting scene
  141204. * @returns the box mesh
  141205. */
  141206. static CreateBox(name: string, options: {
  141207. size?: number;
  141208. width?: number;
  141209. height?: number;
  141210. depth?: number;
  141211. faceUV?: Vector4[];
  141212. faceColors?: Color4[];
  141213. sideOrientation?: number;
  141214. frontUVs?: Vector4;
  141215. backUVs?: Vector4;
  141216. wrap?: boolean;
  141217. topBaseAt?: number;
  141218. bottomBaseAt?: number;
  141219. updatable?: boolean;
  141220. }, scene?: Nullable<Scene>): Mesh;
  141221. /**
  141222. * Creates a tiled box mesh
  141223. * * faceTiles sets the pattern, tile size and number of tiles for a face
  141224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141225. * @param name defines the name of the mesh
  141226. * @param options defines the options used to create the mesh
  141227. * @param scene defines the hosting scene
  141228. * @returns the tiled box mesh
  141229. */
  141230. static CreateTiledBox(name: string, options: {
  141231. pattern?: number;
  141232. size?: number;
  141233. width?: number;
  141234. height?: number;
  141235. depth: number;
  141236. tileSize?: number;
  141237. tileWidth?: number;
  141238. tileHeight?: number;
  141239. faceUV?: Vector4[];
  141240. faceColors?: Color4[];
  141241. alignHorizontal?: number;
  141242. alignVertical?: number;
  141243. sideOrientation?: number;
  141244. updatable?: boolean;
  141245. }, scene?: Nullable<Scene>): Mesh;
  141246. /**
  141247. * Creates a sphere mesh
  141248. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  141249. * * 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`)
  141250. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  141251. * * 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
  141252. * * 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)
  141253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141256. * @param name defines the name of the mesh
  141257. * @param options defines the options used to create the mesh
  141258. * @param scene defines the hosting scene
  141259. * @returns the sphere mesh
  141260. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  141261. */
  141262. static CreateSphere(name: string, options: {
  141263. segments?: number;
  141264. diameter?: number;
  141265. diameterX?: number;
  141266. diameterY?: number;
  141267. diameterZ?: number;
  141268. arc?: number;
  141269. slice?: number;
  141270. sideOrientation?: number;
  141271. frontUVs?: Vector4;
  141272. backUVs?: Vector4;
  141273. updatable?: boolean;
  141274. }, scene?: Nullable<Scene>): Mesh;
  141275. /**
  141276. * Creates a plane polygonal mesh. By default, this is a disc
  141277. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  141278. * * 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
  141279. * * 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
  141280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141283. * @param name defines the name of the mesh
  141284. * @param options defines the options used to create the mesh
  141285. * @param scene defines the hosting scene
  141286. * @returns the plane polygonal mesh
  141287. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  141288. */
  141289. static CreateDisc(name: string, options: {
  141290. radius?: number;
  141291. tessellation?: number;
  141292. arc?: number;
  141293. updatable?: boolean;
  141294. sideOrientation?: number;
  141295. frontUVs?: Vector4;
  141296. backUVs?: Vector4;
  141297. }, scene?: Nullable<Scene>): Mesh;
  141298. /**
  141299. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141300. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141301. * * 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`)
  141302. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141303. * * 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
  141304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141307. * @param name defines the name of the mesh
  141308. * @param options defines the options used to create the mesh
  141309. * @param scene defines the hosting scene
  141310. * @returns the icosahedron mesh
  141311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141312. */
  141313. static CreateIcoSphere(name: string, options: {
  141314. radius?: number;
  141315. radiusX?: number;
  141316. radiusY?: number;
  141317. radiusZ?: number;
  141318. flat?: boolean;
  141319. subdivisions?: number;
  141320. sideOrientation?: number;
  141321. frontUVs?: Vector4;
  141322. backUVs?: Vector4;
  141323. updatable?: boolean;
  141324. }, scene?: Nullable<Scene>): Mesh;
  141325. /**
  141326. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141327. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  141328. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  141329. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  141330. * * 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
  141331. * * 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
  141332. * * 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
  141333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141336. * * 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
  141337. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  141338. * * 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
  141339. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  141340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141341. * @param name defines the name of the mesh
  141342. * @param options defines the options used to create the mesh
  141343. * @param scene defines the hosting scene
  141344. * @returns the ribbon mesh
  141345. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  141346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141347. */
  141348. static CreateRibbon(name: string, options: {
  141349. pathArray: Vector3[][];
  141350. closeArray?: boolean;
  141351. closePath?: boolean;
  141352. offset?: number;
  141353. updatable?: boolean;
  141354. sideOrientation?: number;
  141355. frontUVs?: Vector4;
  141356. backUVs?: Vector4;
  141357. instance?: Mesh;
  141358. invertUV?: boolean;
  141359. uvs?: Vector2[];
  141360. colors?: Color4[];
  141361. }, scene?: Nullable<Scene>): Mesh;
  141362. /**
  141363. * Creates a cylinder or a cone mesh
  141364. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  141365. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  141366. * * 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.
  141367. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  141368. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  141369. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  141370. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  141371. * * 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).
  141372. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  141373. * * 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).
  141374. * * 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
  141375. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  141376. * * 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
  141377. * * 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.
  141378. * * If `enclose` is false, a ring surface is one element.
  141379. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  141380. * * 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
  141381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141384. * @param name defines the name of the mesh
  141385. * @param options defines the options used to create the mesh
  141386. * @param scene defines the hosting scene
  141387. * @returns the cylinder mesh
  141388. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  141389. */
  141390. static CreateCylinder(name: string, options: {
  141391. height?: number;
  141392. diameterTop?: number;
  141393. diameterBottom?: number;
  141394. diameter?: number;
  141395. tessellation?: number;
  141396. subdivisions?: number;
  141397. arc?: number;
  141398. faceColors?: Color4[];
  141399. faceUV?: Vector4[];
  141400. updatable?: boolean;
  141401. hasRings?: boolean;
  141402. enclose?: boolean;
  141403. cap?: number;
  141404. sideOrientation?: number;
  141405. frontUVs?: Vector4;
  141406. backUVs?: Vector4;
  141407. }, scene?: Nullable<Scene>): Mesh;
  141408. /**
  141409. * Creates a torus mesh
  141410. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  141411. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  141412. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  141413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141416. * @param name defines the name of the mesh
  141417. * @param options defines the options used to create the mesh
  141418. * @param scene defines the hosting scene
  141419. * @returns the torus mesh
  141420. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  141421. */
  141422. static CreateTorus(name: string, options: {
  141423. diameter?: number;
  141424. thickness?: number;
  141425. tessellation?: number;
  141426. updatable?: boolean;
  141427. sideOrientation?: number;
  141428. frontUVs?: Vector4;
  141429. backUVs?: Vector4;
  141430. }, scene?: Nullable<Scene>): Mesh;
  141431. /**
  141432. * Creates a torus knot mesh
  141433. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141434. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141435. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141436. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141440. * @param name defines the name of the mesh
  141441. * @param options defines the options used to create the mesh
  141442. * @param scene defines the hosting scene
  141443. * @returns the torus knot mesh
  141444. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141445. */
  141446. static CreateTorusKnot(name: string, options: {
  141447. radius?: number;
  141448. tube?: number;
  141449. radialSegments?: number;
  141450. tubularSegments?: number;
  141451. p?: number;
  141452. q?: number;
  141453. updatable?: boolean;
  141454. sideOrientation?: number;
  141455. frontUVs?: Vector4;
  141456. backUVs?: Vector4;
  141457. }, scene?: Nullable<Scene>): Mesh;
  141458. /**
  141459. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  141460. * * 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
  141461. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  141462. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  141463. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  141464. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  141465. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141466. * * 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
  141467. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  141468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  141470. * @param name defines the name of the new line system
  141471. * @param options defines the options used to create the line system
  141472. * @param scene defines the hosting scene
  141473. * @returns a new line system mesh
  141474. */
  141475. static CreateLineSystem(name: string, options: {
  141476. lines: Vector3[][];
  141477. updatable?: boolean;
  141478. instance?: Nullable<LinesMesh>;
  141479. colors?: Nullable<Color4[][]>;
  141480. useVertexAlpha?: boolean;
  141481. }, scene: Nullable<Scene>): LinesMesh;
  141482. /**
  141483. * Creates a line mesh
  141484. * 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
  141485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141486. * * The parameter `points` is an array successive Vector3
  141487. * * 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
  141488. * * The optional parameter `colors` is an array of successive Color4, one per line point
  141489. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  141490. * * When updating an instance, remember that only point positions can change, not the number of points
  141491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  141493. * @param name defines the name of the new line system
  141494. * @param options defines the options used to create the line system
  141495. * @param scene defines the hosting scene
  141496. * @returns a new line mesh
  141497. */
  141498. static CreateLines(name: string, options: {
  141499. points: Vector3[];
  141500. updatable?: boolean;
  141501. instance?: Nullable<LinesMesh>;
  141502. colors?: Color4[];
  141503. useVertexAlpha?: boolean;
  141504. }, scene?: Nullable<Scene>): LinesMesh;
  141505. /**
  141506. * Creates a dashed line mesh
  141507. * * 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
  141508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141509. * * The parameter `points` is an array successive Vector3
  141510. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  141511. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  141512. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  141513. * * 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
  141514. * * When updating an instance, remember that only point positions can change, not the number of points
  141515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141516. * @param name defines the name of the mesh
  141517. * @param options defines the options used to create the mesh
  141518. * @param scene defines the hosting scene
  141519. * @returns the dashed line mesh
  141520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  141521. */
  141522. static CreateDashedLines(name: string, options: {
  141523. points: Vector3[];
  141524. dashSize?: number;
  141525. gapSize?: number;
  141526. dashNb?: number;
  141527. updatable?: boolean;
  141528. instance?: LinesMesh;
  141529. }, scene?: Nullable<Scene>): LinesMesh;
  141530. /**
  141531. * 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.
  141532. * * 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.
  141533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141534. * * 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.
  141535. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  141536. * * 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
  141537. * * 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
  141538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  141539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  141542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141543. * @param name defines the name of the mesh
  141544. * @param options defines the options used to create the mesh
  141545. * @param scene defines the hosting scene
  141546. * @returns the extruded shape mesh
  141547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141549. */
  141550. static ExtrudeShape(name: string, options: {
  141551. shape: Vector3[];
  141552. path: Vector3[];
  141553. scale?: number;
  141554. rotation?: number;
  141555. cap?: number;
  141556. updatable?: boolean;
  141557. sideOrientation?: number;
  141558. frontUVs?: Vector4;
  141559. backUVs?: Vector4;
  141560. instance?: Mesh;
  141561. invertUV?: boolean;
  141562. }, scene?: Nullable<Scene>): Mesh;
  141563. /**
  141564. * Creates an custom extruded shape mesh.
  141565. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  141566. * * 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.
  141567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141568. * * 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
  141569. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  141570. * * 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
  141571. * * It must returns a float value that will be the scale value applied to the shape on each path point
  141572. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  141573. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  141574. * * 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
  141575. * * 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
  141576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  141577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141581. * @param name defines the name of the mesh
  141582. * @param options defines the options used to create the mesh
  141583. * @param scene defines the hosting scene
  141584. * @returns the custom extruded shape mesh
  141585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  141586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141588. */
  141589. static ExtrudeShapeCustom(name: string, options: {
  141590. shape: Vector3[];
  141591. path: Vector3[];
  141592. scaleFunction?: any;
  141593. rotationFunction?: any;
  141594. ribbonCloseArray?: boolean;
  141595. ribbonClosePath?: boolean;
  141596. cap?: number;
  141597. updatable?: boolean;
  141598. sideOrientation?: number;
  141599. frontUVs?: Vector4;
  141600. backUVs?: Vector4;
  141601. instance?: Mesh;
  141602. invertUV?: boolean;
  141603. }, scene?: Nullable<Scene>): Mesh;
  141604. /**
  141605. * Creates lathe mesh.
  141606. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141607. * * 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
  141608. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141609. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141610. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141611. * * 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
  141612. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141613. * * 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
  141614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141616. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141618. * @param name defines the name of the mesh
  141619. * @param options defines the options used to create the mesh
  141620. * @param scene defines the hosting scene
  141621. * @returns the lathe mesh
  141622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141623. */
  141624. static CreateLathe(name: string, options: {
  141625. shape: Vector3[];
  141626. radius?: number;
  141627. tessellation?: number;
  141628. clip?: number;
  141629. arc?: number;
  141630. closed?: boolean;
  141631. updatable?: boolean;
  141632. sideOrientation?: number;
  141633. frontUVs?: Vector4;
  141634. backUVs?: Vector4;
  141635. cap?: number;
  141636. invertUV?: boolean;
  141637. }, scene?: Nullable<Scene>): Mesh;
  141638. /**
  141639. * Creates a tiled plane mesh
  141640. * * You can set a limited pattern arrangement with the tiles
  141641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141644. * @param name defines the name of the mesh
  141645. * @param options defines the options used to create the mesh
  141646. * @param scene defines the hosting scene
  141647. * @returns the plane mesh
  141648. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141649. */
  141650. static CreateTiledPlane(name: string, options: {
  141651. pattern?: number;
  141652. tileSize?: number;
  141653. tileWidth?: number;
  141654. tileHeight?: number;
  141655. size?: number;
  141656. width?: number;
  141657. height?: number;
  141658. alignHorizontal?: number;
  141659. alignVertical?: number;
  141660. sideOrientation?: number;
  141661. frontUVs?: Vector4;
  141662. backUVs?: Vector4;
  141663. updatable?: boolean;
  141664. }, scene?: Nullable<Scene>): Mesh;
  141665. /**
  141666. * Creates a plane mesh
  141667. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  141668. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  141669. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  141670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141673. * @param name defines the name of the mesh
  141674. * @param options defines the options used to create the mesh
  141675. * @param scene defines the hosting scene
  141676. * @returns the plane mesh
  141677. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141678. */
  141679. static CreatePlane(name: string, options: {
  141680. size?: number;
  141681. width?: number;
  141682. height?: number;
  141683. sideOrientation?: number;
  141684. frontUVs?: Vector4;
  141685. backUVs?: Vector4;
  141686. updatable?: boolean;
  141687. sourcePlane?: Plane;
  141688. }, scene?: Nullable<Scene>): Mesh;
  141689. /**
  141690. * Creates a ground mesh
  141691. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  141692. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  141693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141694. * @param name defines the name of the mesh
  141695. * @param options defines the options used to create the mesh
  141696. * @param scene defines the hosting scene
  141697. * @returns the ground mesh
  141698. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  141699. */
  141700. static CreateGround(name: string, options: {
  141701. width?: number;
  141702. height?: number;
  141703. subdivisions?: number;
  141704. subdivisionsX?: number;
  141705. subdivisionsY?: number;
  141706. updatable?: boolean;
  141707. }, scene?: Nullable<Scene>): Mesh;
  141708. /**
  141709. * Creates a tiled ground mesh
  141710. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  141711. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  141712. * * 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
  141713. * * 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
  141714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141715. * @param name defines the name of the mesh
  141716. * @param options defines the options used to create the mesh
  141717. * @param scene defines the hosting scene
  141718. * @returns the tiled ground mesh
  141719. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  141720. */
  141721. static CreateTiledGround(name: string, options: {
  141722. xmin: number;
  141723. zmin: number;
  141724. xmax: number;
  141725. zmax: number;
  141726. subdivisions?: {
  141727. w: number;
  141728. h: number;
  141729. };
  141730. precision?: {
  141731. w: number;
  141732. h: number;
  141733. };
  141734. updatable?: boolean;
  141735. }, scene?: Nullable<Scene>): Mesh;
  141736. /**
  141737. * Creates a ground mesh from a height map
  141738. * * The parameter `url` sets the URL of the height map image resource.
  141739. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  141740. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  141741. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  141742. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  141743. * * 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.
  141744. * * 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).
  141745. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  141746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141747. * @param name defines the name of the mesh
  141748. * @param url defines the url to the height map
  141749. * @param options defines the options used to create the mesh
  141750. * @param scene defines the hosting scene
  141751. * @returns the ground mesh
  141752. * @see https://doc.babylonjs.com/babylon101/height_map
  141753. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  141754. */
  141755. static CreateGroundFromHeightMap(name: string, url: string, options: {
  141756. width?: number;
  141757. height?: number;
  141758. subdivisions?: number;
  141759. minHeight?: number;
  141760. maxHeight?: number;
  141761. colorFilter?: Color3;
  141762. alphaFilter?: number;
  141763. updatable?: boolean;
  141764. onReady?: (mesh: GroundMesh) => void;
  141765. }, scene?: Nullable<Scene>): GroundMesh;
  141766. /**
  141767. * Creates a polygon mesh
  141768. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141769. * * 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
  141770. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141773. * * Remember you can only change the shape positions, not their number when updating a polygon
  141774. * @param name defines the name of the mesh
  141775. * @param options defines the options used to create the mesh
  141776. * @param scene defines the hosting scene
  141777. * @param earcutInjection can be used to inject your own earcut reference
  141778. * @returns the polygon mesh
  141779. */
  141780. static CreatePolygon(name: string, options: {
  141781. shape: Vector3[];
  141782. holes?: Vector3[][];
  141783. depth?: number;
  141784. faceUV?: Vector4[];
  141785. faceColors?: Color4[];
  141786. updatable?: boolean;
  141787. sideOrientation?: number;
  141788. frontUVs?: Vector4;
  141789. backUVs?: Vector4;
  141790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141791. /**
  141792. * Creates an extruded polygon mesh, with depth in the Y direction.
  141793. * * 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)
  141794. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141795. * @param name defines the name of the mesh
  141796. * @param options defines the options used to create the mesh
  141797. * @param scene defines the hosting scene
  141798. * @param earcutInjection can be used to inject your own earcut reference
  141799. * @returns the polygon mesh
  141800. */
  141801. static ExtrudePolygon(name: string, options: {
  141802. shape: Vector3[];
  141803. holes?: Vector3[][];
  141804. depth?: number;
  141805. faceUV?: Vector4[];
  141806. faceColors?: Color4[];
  141807. updatable?: boolean;
  141808. sideOrientation?: number;
  141809. frontUVs?: Vector4;
  141810. backUVs?: Vector4;
  141811. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141812. /**
  141813. * Creates a tube mesh.
  141814. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141815. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141816. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141817. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141818. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141819. * * 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)
  141820. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141821. * * 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
  141822. * * 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
  141823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141827. * @param name defines the name of the mesh
  141828. * @param options defines the options used to create the mesh
  141829. * @param scene defines the hosting scene
  141830. * @returns the tube mesh
  141831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141832. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141833. */
  141834. static CreateTube(name: string, options: {
  141835. path: Vector3[];
  141836. radius?: number;
  141837. tessellation?: number;
  141838. radiusFunction?: {
  141839. (i: number, distance: number): number;
  141840. };
  141841. cap?: number;
  141842. arc?: number;
  141843. updatable?: boolean;
  141844. sideOrientation?: number;
  141845. frontUVs?: Vector4;
  141846. backUVs?: Vector4;
  141847. instance?: Mesh;
  141848. invertUV?: boolean;
  141849. }, scene?: Nullable<Scene>): Mesh;
  141850. /**
  141851. * Creates a polyhedron mesh
  141852. * * 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
  141853. * * The parameter `size` (positive float, default 1) sets the polygon size
  141854. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  141855. * * 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`
  141856. * * 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
  141857. * * 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)`)
  141858. * * 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
  141859. * * 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
  141860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141863. * @param name defines the name of the mesh
  141864. * @param options defines the options used to create the mesh
  141865. * @param scene defines the hosting scene
  141866. * @returns the polyhedron mesh
  141867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  141868. */
  141869. static CreatePolyhedron(name: string, options: {
  141870. type?: number;
  141871. size?: number;
  141872. sizeX?: number;
  141873. sizeY?: number;
  141874. sizeZ?: number;
  141875. custom?: any;
  141876. faceUV?: Vector4[];
  141877. faceColors?: Color4[];
  141878. flat?: boolean;
  141879. updatable?: boolean;
  141880. sideOrientation?: number;
  141881. frontUVs?: Vector4;
  141882. backUVs?: Vector4;
  141883. }, scene?: Nullable<Scene>): Mesh;
  141884. /**
  141885. * Creates a decal mesh.
  141886. * 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
  141887. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141888. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141889. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141890. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141891. * @param name defines the name of the mesh
  141892. * @param sourceMesh defines the mesh where the decal must be applied
  141893. * @param options defines the options used to create the mesh
  141894. * @param scene defines the hosting scene
  141895. * @returns the decal mesh
  141896. * @see https://doc.babylonjs.com/how_to/decals
  141897. */
  141898. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141899. position?: Vector3;
  141900. normal?: Vector3;
  141901. size?: Vector3;
  141902. angle?: number;
  141903. }): Mesh;
  141904. }
  141905. }
  141906. declare module BABYLON {
  141907. /**
  141908. * A simplifier interface for future simplification implementations
  141909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141910. */
  141911. export interface ISimplifier {
  141912. /**
  141913. * Simplification of a given mesh according to the given settings.
  141914. * Since this requires computation, it is assumed that the function runs async.
  141915. * @param settings The settings of the simplification, including quality and distance
  141916. * @param successCallback A callback that will be called after the mesh was simplified.
  141917. * @param errorCallback in case of an error, this callback will be called. optional.
  141918. */
  141919. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  141920. }
  141921. /**
  141922. * Expected simplification settings.
  141923. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  141924. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141925. */
  141926. export interface ISimplificationSettings {
  141927. /**
  141928. * Gets or sets the expected quality
  141929. */
  141930. quality: number;
  141931. /**
  141932. * Gets or sets the distance when this optimized version should be used
  141933. */
  141934. distance: number;
  141935. /**
  141936. * Gets an already optimized mesh
  141937. */
  141938. optimizeMesh?: boolean;
  141939. }
  141940. /**
  141941. * Class used to specify simplification options
  141942. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141943. */
  141944. export class SimplificationSettings implements ISimplificationSettings {
  141945. /** expected quality */
  141946. quality: number;
  141947. /** distance when this optimized version should be used */
  141948. distance: number;
  141949. /** already optimized mesh */
  141950. optimizeMesh?: boolean | undefined;
  141951. /**
  141952. * Creates a SimplificationSettings
  141953. * @param quality expected quality
  141954. * @param distance distance when this optimized version should be used
  141955. * @param optimizeMesh already optimized mesh
  141956. */
  141957. constructor(
  141958. /** expected quality */
  141959. quality: number,
  141960. /** distance when this optimized version should be used */
  141961. distance: number,
  141962. /** already optimized mesh */
  141963. optimizeMesh?: boolean | undefined);
  141964. }
  141965. /**
  141966. * Interface used to define a simplification task
  141967. */
  141968. export interface ISimplificationTask {
  141969. /**
  141970. * Array of settings
  141971. */
  141972. settings: Array<ISimplificationSettings>;
  141973. /**
  141974. * Simplification type
  141975. */
  141976. simplificationType: SimplificationType;
  141977. /**
  141978. * Mesh to simplify
  141979. */
  141980. mesh: Mesh;
  141981. /**
  141982. * Callback called on success
  141983. */
  141984. successCallback?: () => void;
  141985. /**
  141986. * Defines if parallel processing can be used
  141987. */
  141988. parallelProcessing: boolean;
  141989. }
  141990. /**
  141991. * Queue used to order the simplification tasks
  141992. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141993. */
  141994. export class SimplificationQueue {
  141995. private _simplificationArray;
  141996. /**
  141997. * Gets a boolean indicating that the process is still running
  141998. */
  141999. running: boolean;
  142000. /**
  142001. * Creates a new queue
  142002. */
  142003. constructor();
  142004. /**
  142005. * Adds a new simplification task
  142006. * @param task defines a task to add
  142007. */
  142008. addTask(task: ISimplificationTask): void;
  142009. /**
  142010. * Execute next task
  142011. */
  142012. executeNext(): void;
  142013. /**
  142014. * Execute a simplification task
  142015. * @param task defines the task to run
  142016. */
  142017. runSimplification(task: ISimplificationTask): void;
  142018. private getSimplifier;
  142019. }
  142020. /**
  142021. * The implemented types of simplification
  142022. * At the moment only Quadratic Error Decimation is implemented
  142023. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142024. */
  142025. export enum SimplificationType {
  142026. /** Quadratic error decimation */
  142027. QUADRATIC = 0
  142028. }
  142029. /**
  142030. * An implementation of the Quadratic Error simplification algorithm.
  142031. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  142032. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  142033. * @author RaananW
  142034. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142035. */
  142036. export class QuadraticErrorSimplification implements ISimplifier {
  142037. private _mesh;
  142038. private triangles;
  142039. private vertices;
  142040. private references;
  142041. private _reconstructedMesh;
  142042. /** Gets or sets the number pf sync interations */
  142043. syncIterations: number;
  142044. /** Gets or sets the aggressiveness of the simplifier */
  142045. aggressiveness: number;
  142046. /** Gets or sets the number of allowed iterations for decimation */
  142047. decimationIterations: number;
  142048. /** Gets or sets the espilon to use for bounding box computation */
  142049. boundingBoxEpsilon: number;
  142050. /**
  142051. * Creates a new QuadraticErrorSimplification
  142052. * @param _mesh defines the target mesh
  142053. */
  142054. constructor(_mesh: Mesh);
  142055. /**
  142056. * Simplification of a given mesh according to the given settings.
  142057. * Since this requires computation, it is assumed that the function runs async.
  142058. * @param settings The settings of the simplification, including quality and distance
  142059. * @param successCallback A callback that will be called after the mesh was simplified.
  142060. */
  142061. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  142062. private runDecimation;
  142063. private initWithMesh;
  142064. private init;
  142065. private reconstructMesh;
  142066. private initDecimatedMesh;
  142067. private isFlipped;
  142068. private updateTriangles;
  142069. private identifyBorder;
  142070. private updateMesh;
  142071. private vertexError;
  142072. private calculateError;
  142073. }
  142074. }
  142075. declare module BABYLON {
  142076. interface Scene {
  142077. /** @hidden (Backing field) */
  142078. _simplificationQueue: SimplificationQueue;
  142079. /**
  142080. * Gets or sets the simplification queue attached to the scene
  142081. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142082. */
  142083. simplificationQueue: SimplificationQueue;
  142084. }
  142085. interface Mesh {
  142086. /**
  142087. * Simplify the mesh according to the given array of settings.
  142088. * Function will return immediately and will simplify async
  142089. * @param settings a collection of simplification settings
  142090. * @param parallelProcessing should all levels calculate parallel or one after the other
  142091. * @param simplificationType the type of simplification to run
  142092. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  142093. * @returns the current mesh
  142094. */
  142095. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  142096. }
  142097. /**
  142098. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  142099. * created in a scene
  142100. */
  142101. export class SimplicationQueueSceneComponent implements ISceneComponent {
  142102. /**
  142103. * The component name helpfull to identify the component in the list of scene components.
  142104. */
  142105. readonly name: string;
  142106. /**
  142107. * The scene the component belongs to.
  142108. */
  142109. scene: Scene;
  142110. /**
  142111. * Creates a new instance of the component for the given scene
  142112. * @param scene Defines the scene to register the component in
  142113. */
  142114. constructor(scene: Scene);
  142115. /**
  142116. * Registers the component in a given scene
  142117. */
  142118. register(): void;
  142119. /**
  142120. * Rebuilds the elements related to this component in case of
  142121. * context lost for instance.
  142122. */
  142123. rebuild(): void;
  142124. /**
  142125. * Disposes the component and the associated ressources
  142126. */
  142127. dispose(): void;
  142128. private _beforeCameraUpdate;
  142129. }
  142130. }
  142131. declare module BABYLON {
  142132. interface Mesh {
  142133. /**
  142134. * Creates a new thin instance
  142135. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  142136. * @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
  142137. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  142138. */
  142139. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  142140. /**
  142141. * Adds the transformation (matrix) of the current mesh as a thin instance
  142142. * @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
  142143. * @returns the thin instance index number
  142144. */
  142145. thinInstanceAddSelf(refresh: boolean): number;
  142146. /**
  142147. * Registers a custom attribute to be used with thin instances
  142148. * @param kind name of the attribute
  142149. * @param stride size in floats of the attribute
  142150. */
  142151. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  142152. /**
  142153. * Sets the matrix of a thin instance
  142154. * @param index index of the thin instance
  142155. * @param matrix matrix to set
  142156. * @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
  142157. */
  142158. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  142159. /**
  142160. * Sets the value of a custom attribute for a thin instance
  142161. * @param kind name of the attribute
  142162. * @param index index of the thin instance
  142163. * @param value value to set
  142164. * @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
  142165. */
  142166. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  142167. /**
  142168. * 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.
  142169. */
  142170. thinInstanceCount: number;
  142171. /**
  142172. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  142173. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  142174. * @param buffer buffer to set
  142175. * @param stride size in floats of each value of the buffer
  142176. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  142177. */
  142178. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  142179. /**
  142180. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  142181. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  142182. */
  142183. thinInstanceBufferUpdated(kind: string): void;
  142184. /**
  142185. * Refreshes the bounding info, taking into account all the thin instances defined
  142186. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  142187. */
  142188. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  142189. /** @hidden */
  142190. _thinInstanceInitializeUserStorage(): void;
  142191. /** @hidden */
  142192. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  142193. /** @hidden */
  142194. _userThinInstanceBuffersStorage: {
  142195. data: {
  142196. [key: string]: Float32Array;
  142197. };
  142198. sizes: {
  142199. [key: string]: number;
  142200. };
  142201. vertexBuffers: {
  142202. [key: string]: Nullable<VertexBuffer>;
  142203. };
  142204. strides: {
  142205. [key: string]: number;
  142206. };
  142207. };
  142208. }
  142209. }
  142210. declare module BABYLON {
  142211. /**
  142212. * Navigation plugin interface to add navigation constrained by a navigation mesh
  142213. */
  142214. export interface INavigationEnginePlugin {
  142215. /**
  142216. * plugin name
  142217. */
  142218. name: string;
  142219. /**
  142220. * Creates a navigation mesh
  142221. * @param meshes array of all the geometry used to compute the navigatio mesh
  142222. * @param parameters bunch of parameters used to filter geometry
  142223. */
  142224. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142225. /**
  142226. * Create a navigation mesh debug mesh
  142227. * @param scene is where the mesh will be added
  142228. * @returns debug display mesh
  142229. */
  142230. createDebugNavMesh(scene: Scene): Mesh;
  142231. /**
  142232. * Get a navigation mesh constrained position, closest to the parameter position
  142233. * @param position world position
  142234. * @returns the closest point to position constrained by the navigation mesh
  142235. */
  142236. getClosestPoint(position: Vector3): Vector3;
  142237. /**
  142238. * Get a navigation mesh constrained position, closest to the parameter position
  142239. * @param position world position
  142240. * @param result output the closest point to position constrained by the navigation mesh
  142241. */
  142242. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142243. /**
  142244. * Get a navigation mesh constrained position, within a particular radius
  142245. * @param position world position
  142246. * @param maxRadius the maximum distance to the constrained world position
  142247. * @returns the closest point to position constrained by the navigation mesh
  142248. */
  142249. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142250. /**
  142251. * Get a navigation mesh constrained position, within a particular radius
  142252. * @param position world position
  142253. * @param maxRadius the maximum distance to the constrained world position
  142254. * @param result output the closest point to position constrained by the navigation mesh
  142255. */
  142256. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142257. /**
  142258. * Compute the final position from a segment made of destination-position
  142259. * @param position world position
  142260. * @param destination world position
  142261. * @returns the resulting point along the navmesh
  142262. */
  142263. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142264. /**
  142265. * Compute the final position from a segment made of destination-position
  142266. * @param position world position
  142267. * @param destination world position
  142268. * @param result output the resulting point along the navmesh
  142269. */
  142270. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142271. /**
  142272. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142273. * @param start world position
  142274. * @param end world position
  142275. * @returns array containing world position composing the path
  142276. */
  142277. computePath(start: Vector3, end: Vector3): Vector3[];
  142278. /**
  142279. * If this plugin is supported
  142280. * @returns true if plugin is supported
  142281. */
  142282. isSupported(): boolean;
  142283. /**
  142284. * Create a new Crowd so you can add agents
  142285. * @param maxAgents the maximum agent count in the crowd
  142286. * @param maxAgentRadius the maximum radius an agent can have
  142287. * @param scene to attach the crowd to
  142288. * @returns the crowd you can add agents to
  142289. */
  142290. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142291. /**
  142292. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142293. * The queries will try to find a solution within those bounds
  142294. * default is (1,1,1)
  142295. * @param extent x,y,z value that define the extent around the queries point of reference
  142296. */
  142297. setDefaultQueryExtent(extent: Vector3): void;
  142298. /**
  142299. * Get the Bounding box extent specified by setDefaultQueryExtent
  142300. * @returns the box extent values
  142301. */
  142302. getDefaultQueryExtent(): Vector3;
  142303. /**
  142304. * build the navmesh from a previously saved state using getNavmeshData
  142305. * @param data the Uint8Array returned by getNavmeshData
  142306. */
  142307. buildFromNavmeshData(data: Uint8Array): void;
  142308. /**
  142309. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142310. * @returns data the Uint8Array that can be saved and reused
  142311. */
  142312. getNavmeshData(): Uint8Array;
  142313. /**
  142314. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142315. * @param result output the box extent values
  142316. */
  142317. getDefaultQueryExtentToRef(result: Vector3): void;
  142318. /**
  142319. * Release all resources
  142320. */
  142321. dispose(): void;
  142322. }
  142323. /**
  142324. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  142325. */
  142326. export interface ICrowd {
  142327. /**
  142328. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142329. * You can attach anything to that node. The node position is updated in the scene update tick.
  142330. * @param pos world position that will be constrained by the navigation mesh
  142331. * @param parameters agent parameters
  142332. * @param transform hooked to the agent that will be update by the scene
  142333. * @returns agent index
  142334. */
  142335. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142336. /**
  142337. * Returns the agent position in world space
  142338. * @param index agent index returned by addAgent
  142339. * @returns world space position
  142340. */
  142341. getAgentPosition(index: number): Vector3;
  142342. /**
  142343. * Gets the agent position result in world space
  142344. * @param index agent index returned by addAgent
  142345. * @param result output world space position
  142346. */
  142347. getAgentPositionToRef(index: number, result: Vector3): void;
  142348. /**
  142349. * Gets the agent velocity in world space
  142350. * @param index agent index returned by addAgent
  142351. * @returns world space velocity
  142352. */
  142353. getAgentVelocity(index: number): Vector3;
  142354. /**
  142355. * Gets the agent velocity result in world space
  142356. * @param index agent index returned by addAgent
  142357. * @param result output world space velocity
  142358. */
  142359. getAgentVelocityToRef(index: number, result: Vector3): void;
  142360. /**
  142361. * remove a particular agent previously created
  142362. * @param index agent index returned by addAgent
  142363. */
  142364. removeAgent(index: number): void;
  142365. /**
  142366. * get the list of all agents attached to this crowd
  142367. * @returns list of agent indices
  142368. */
  142369. getAgents(): number[];
  142370. /**
  142371. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142372. * @param deltaTime in seconds
  142373. */
  142374. update(deltaTime: number): void;
  142375. /**
  142376. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142377. * @param index agent index returned by addAgent
  142378. * @param destination targeted world position
  142379. */
  142380. agentGoto(index: number, destination: Vector3): void;
  142381. /**
  142382. * Teleport the agent to a new position
  142383. * @param index agent index returned by addAgent
  142384. * @param destination targeted world position
  142385. */
  142386. agentTeleport(index: number, destination: Vector3): void;
  142387. /**
  142388. * Update agent parameters
  142389. * @param index agent index returned by addAgent
  142390. * @param parameters agent parameters
  142391. */
  142392. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142393. /**
  142394. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142395. * The queries will try to find a solution within those bounds
  142396. * default is (1,1,1)
  142397. * @param extent x,y,z value that define the extent around the queries point of reference
  142398. */
  142399. setDefaultQueryExtent(extent: Vector3): void;
  142400. /**
  142401. * Get the Bounding box extent specified by setDefaultQueryExtent
  142402. * @returns the box extent values
  142403. */
  142404. getDefaultQueryExtent(): Vector3;
  142405. /**
  142406. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142407. * @param result output the box extent values
  142408. */
  142409. getDefaultQueryExtentToRef(result: Vector3): void;
  142410. /**
  142411. * Release all resources
  142412. */
  142413. dispose(): void;
  142414. }
  142415. /**
  142416. * Configures an agent
  142417. */
  142418. export interface IAgentParameters {
  142419. /**
  142420. * Agent radius. [Limit: >= 0]
  142421. */
  142422. radius: number;
  142423. /**
  142424. * Agent height. [Limit: > 0]
  142425. */
  142426. height: number;
  142427. /**
  142428. * Maximum allowed acceleration. [Limit: >= 0]
  142429. */
  142430. maxAcceleration: number;
  142431. /**
  142432. * Maximum allowed speed. [Limit: >= 0]
  142433. */
  142434. maxSpeed: number;
  142435. /**
  142436. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  142437. */
  142438. collisionQueryRange: number;
  142439. /**
  142440. * The path visibility optimization range. [Limit: > 0]
  142441. */
  142442. pathOptimizationRange: number;
  142443. /**
  142444. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  142445. */
  142446. separationWeight: number;
  142447. }
  142448. /**
  142449. * Configures the navigation mesh creation
  142450. */
  142451. export interface INavMeshParameters {
  142452. /**
  142453. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  142454. */
  142455. cs: number;
  142456. /**
  142457. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  142458. */
  142459. ch: number;
  142460. /**
  142461. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  142462. */
  142463. walkableSlopeAngle: number;
  142464. /**
  142465. * Minimum floor to 'ceiling' height that will still allow the floor area to
  142466. * be considered walkable. [Limit: >= 3] [Units: vx]
  142467. */
  142468. walkableHeight: number;
  142469. /**
  142470. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  142471. */
  142472. walkableClimb: number;
  142473. /**
  142474. * The distance to erode/shrink the walkable area of the heightfield away from
  142475. * obstructions. [Limit: >=0] [Units: vx]
  142476. */
  142477. walkableRadius: number;
  142478. /**
  142479. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  142480. */
  142481. maxEdgeLen: number;
  142482. /**
  142483. * The maximum distance a simplfied contour's border edges should deviate
  142484. * the original raw contour. [Limit: >=0] [Units: vx]
  142485. */
  142486. maxSimplificationError: number;
  142487. /**
  142488. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  142489. */
  142490. minRegionArea: number;
  142491. /**
  142492. * Any regions with a span count smaller than this value will, if possible,
  142493. * be merged with larger regions. [Limit: >=0] [Units: vx]
  142494. */
  142495. mergeRegionArea: number;
  142496. /**
  142497. * The maximum number of vertices allowed for polygons generated during the
  142498. * contour to polygon conversion process. [Limit: >= 3]
  142499. */
  142500. maxVertsPerPoly: number;
  142501. /**
  142502. * Sets the sampling distance to use when generating the detail mesh.
  142503. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  142504. */
  142505. detailSampleDist: number;
  142506. /**
  142507. * The maximum distance the detail mesh surface should deviate from heightfield
  142508. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  142509. */
  142510. detailSampleMaxError: number;
  142511. }
  142512. }
  142513. declare module BABYLON {
  142514. /**
  142515. * RecastJS navigation plugin
  142516. */
  142517. export class RecastJSPlugin implements INavigationEnginePlugin {
  142518. /**
  142519. * Reference to the Recast library
  142520. */
  142521. bjsRECAST: any;
  142522. /**
  142523. * plugin name
  142524. */
  142525. name: string;
  142526. /**
  142527. * the first navmesh created. We might extend this to support multiple navmeshes
  142528. */
  142529. navMesh: any;
  142530. /**
  142531. * Initializes the recastJS plugin
  142532. * @param recastInjection can be used to inject your own recast reference
  142533. */
  142534. constructor(recastInjection?: any);
  142535. /**
  142536. * Creates a navigation mesh
  142537. * @param meshes array of all the geometry used to compute the navigatio mesh
  142538. * @param parameters bunch of parameters used to filter geometry
  142539. */
  142540. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142541. /**
  142542. * Create a navigation mesh debug mesh
  142543. * @param scene is where the mesh will be added
  142544. * @returns debug display mesh
  142545. */
  142546. createDebugNavMesh(scene: Scene): Mesh;
  142547. /**
  142548. * Get a navigation mesh constrained position, closest to the parameter position
  142549. * @param position world position
  142550. * @returns the closest point to position constrained by the navigation mesh
  142551. */
  142552. getClosestPoint(position: Vector3): Vector3;
  142553. /**
  142554. * Get a navigation mesh constrained position, closest to the parameter position
  142555. * @param position world position
  142556. * @param result output the closest point to position constrained by the navigation mesh
  142557. */
  142558. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142559. /**
  142560. * Get a navigation mesh constrained position, within a particular radius
  142561. * @param position world position
  142562. * @param maxRadius the maximum distance to the constrained world position
  142563. * @returns the closest point to position constrained by the navigation mesh
  142564. */
  142565. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142566. /**
  142567. * Get a navigation mesh constrained position, within a particular radius
  142568. * @param position world position
  142569. * @param maxRadius the maximum distance to the constrained world position
  142570. * @param result output the closest point to position constrained by the navigation mesh
  142571. */
  142572. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142573. /**
  142574. * Compute the final position from a segment made of destination-position
  142575. * @param position world position
  142576. * @param destination world position
  142577. * @returns the resulting point along the navmesh
  142578. */
  142579. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142580. /**
  142581. * Compute the final position from a segment made of destination-position
  142582. * @param position world position
  142583. * @param destination world position
  142584. * @param result output the resulting point along the navmesh
  142585. */
  142586. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142587. /**
  142588. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142589. * @param start world position
  142590. * @param end world position
  142591. * @returns array containing world position composing the path
  142592. */
  142593. computePath(start: Vector3, end: Vector3): Vector3[];
  142594. /**
  142595. * Create a new Crowd so you can add agents
  142596. * @param maxAgents the maximum agent count in the crowd
  142597. * @param maxAgentRadius the maximum radius an agent can have
  142598. * @param scene to attach the crowd to
  142599. * @returns the crowd you can add agents to
  142600. */
  142601. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142602. /**
  142603. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142604. * The queries will try to find a solution within those bounds
  142605. * default is (1,1,1)
  142606. * @param extent x,y,z value that define the extent around the queries point of reference
  142607. */
  142608. setDefaultQueryExtent(extent: Vector3): void;
  142609. /**
  142610. * Get the Bounding box extent specified by setDefaultQueryExtent
  142611. * @returns the box extent values
  142612. */
  142613. getDefaultQueryExtent(): Vector3;
  142614. /**
  142615. * build the navmesh from a previously saved state using getNavmeshData
  142616. * @param data the Uint8Array returned by getNavmeshData
  142617. */
  142618. buildFromNavmeshData(data: Uint8Array): void;
  142619. /**
  142620. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142621. * @returns data the Uint8Array that can be saved and reused
  142622. */
  142623. getNavmeshData(): Uint8Array;
  142624. /**
  142625. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142626. * @param result output the box extent values
  142627. */
  142628. getDefaultQueryExtentToRef(result: Vector3): void;
  142629. /**
  142630. * Disposes
  142631. */
  142632. dispose(): void;
  142633. /**
  142634. * If this plugin is supported
  142635. * @returns true if plugin is supported
  142636. */
  142637. isSupported(): boolean;
  142638. }
  142639. /**
  142640. * Recast detour crowd implementation
  142641. */
  142642. export class RecastJSCrowd implements ICrowd {
  142643. /**
  142644. * Recast/detour plugin
  142645. */
  142646. bjsRECASTPlugin: RecastJSPlugin;
  142647. /**
  142648. * Link to the detour crowd
  142649. */
  142650. recastCrowd: any;
  142651. /**
  142652. * One transform per agent
  142653. */
  142654. transforms: TransformNode[];
  142655. /**
  142656. * All agents created
  142657. */
  142658. agents: number[];
  142659. /**
  142660. * Link to the scene is kept to unregister the crowd from the scene
  142661. */
  142662. private _scene;
  142663. /**
  142664. * Observer for crowd updates
  142665. */
  142666. private _onBeforeAnimationsObserver;
  142667. /**
  142668. * Constructor
  142669. * @param plugin recastJS plugin
  142670. * @param maxAgents the maximum agent count in the crowd
  142671. * @param maxAgentRadius the maximum radius an agent can have
  142672. * @param scene to attach the crowd to
  142673. * @returns the crowd you can add agents to
  142674. */
  142675. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  142676. /**
  142677. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142678. * You can attach anything to that node. The node position is updated in the scene update tick.
  142679. * @param pos world position that will be constrained by the navigation mesh
  142680. * @param parameters agent parameters
  142681. * @param transform hooked to the agent that will be update by the scene
  142682. * @returns agent index
  142683. */
  142684. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142685. /**
  142686. * Returns the agent position in world space
  142687. * @param index agent index returned by addAgent
  142688. * @returns world space position
  142689. */
  142690. getAgentPosition(index: number): Vector3;
  142691. /**
  142692. * Returns the agent position result in world space
  142693. * @param index agent index returned by addAgent
  142694. * @param result output world space position
  142695. */
  142696. getAgentPositionToRef(index: number, result: Vector3): void;
  142697. /**
  142698. * Returns the agent velocity in world space
  142699. * @param index agent index returned by addAgent
  142700. * @returns world space velocity
  142701. */
  142702. getAgentVelocity(index: number): Vector3;
  142703. /**
  142704. * Returns the agent velocity result in world space
  142705. * @param index agent index returned by addAgent
  142706. * @param result output world space velocity
  142707. */
  142708. getAgentVelocityToRef(index: number, result: Vector3): void;
  142709. /**
  142710. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142711. * @param index agent index returned by addAgent
  142712. * @param destination targeted world position
  142713. */
  142714. agentGoto(index: number, destination: Vector3): void;
  142715. /**
  142716. * Teleport the agent to a new position
  142717. * @param index agent index returned by addAgent
  142718. * @param destination targeted world position
  142719. */
  142720. agentTeleport(index: number, destination: Vector3): void;
  142721. /**
  142722. * Update agent parameters
  142723. * @param index agent index returned by addAgent
  142724. * @param parameters agent parameters
  142725. */
  142726. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142727. /**
  142728. * remove a particular agent previously created
  142729. * @param index agent index returned by addAgent
  142730. */
  142731. removeAgent(index: number): void;
  142732. /**
  142733. * get the list of all agents attached to this crowd
  142734. * @returns list of agent indices
  142735. */
  142736. getAgents(): number[];
  142737. /**
  142738. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142739. * @param deltaTime in seconds
  142740. */
  142741. update(deltaTime: number): void;
  142742. /**
  142743. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142744. * The queries will try to find a solution within those bounds
  142745. * default is (1,1,1)
  142746. * @param extent x,y,z value that define the extent around the queries point of reference
  142747. */
  142748. setDefaultQueryExtent(extent: Vector3): void;
  142749. /**
  142750. * Get the Bounding box extent specified by setDefaultQueryExtent
  142751. * @returns the box extent values
  142752. */
  142753. getDefaultQueryExtent(): Vector3;
  142754. /**
  142755. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142756. * @param result output the box extent values
  142757. */
  142758. getDefaultQueryExtentToRef(result: Vector3): void;
  142759. /**
  142760. * Release all resources
  142761. */
  142762. dispose(): void;
  142763. }
  142764. }
  142765. declare module BABYLON {
  142766. /**
  142767. * Class used to enable access to IndexedDB
  142768. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  142769. */
  142770. export class Database implements IOfflineProvider {
  142771. private _callbackManifestChecked;
  142772. private _currentSceneUrl;
  142773. private _db;
  142774. private _enableSceneOffline;
  142775. private _enableTexturesOffline;
  142776. private _manifestVersionFound;
  142777. private _mustUpdateRessources;
  142778. private _hasReachedQuota;
  142779. private _isSupported;
  142780. private _idbFactory;
  142781. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  142782. private static IsUASupportingBlobStorage;
  142783. /**
  142784. * Gets a boolean indicating if Database storate is enabled (off by default)
  142785. */
  142786. static IDBStorageEnabled: boolean;
  142787. /**
  142788. * Gets a boolean indicating if scene must be saved in the database
  142789. */
  142790. get enableSceneOffline(): boolean;
  142791. /**
  142792. * Gets a boolean indicating if textures must be saved in the database
  142793. */
  142794. get enableTexturesOffline(): boolean;
  142795. /**
  142796. * Creates a new Database
  142797. * @param urlToScene defines the url to load the scene
  142798. * @param callbackManifestChecked defines the callback to use when manifest is checked
  142799. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  142800. */
  142801. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  142802. private static _ParseURL;
  142803. private static _ReturnFullUrlLocation;
  142804. private _checkManifestFile;
  142805. /**
  142806. * Open the database and make it available
  142807. * @param successCallback defines the callback to call on success
  142808. * @param errorCallback defines the callback to call on error
  142809. */
  142810. open(successCallback: () => void, errorCallback: () => void): void;
  142811. /**
  142812. * Loads an image from the database
  142813. * @param url defines the url to load from
  142814. * @param image defines the target DOM image
  142815. */
  142816. loadImage(url: string, image: HTMLImageElement): void;
  142817. private _loadImageFromDBAsync;
  142818. private _saveImageIntoDBAsync;
  142819. private _checkVersionFromDB;
  142820. private _loadVersionFromDBAsync;
  142821. private _saveVersionIntoDBAsync;
  142822. /**
  142823. * Loads a file from database
  142824. * @param url defines the URL to load from
  142825. * @param sceneLoaded defines a callback to call on success
  142826. * @param progressCallBack defines a callback to call when progress changed
  142827. * @param errorCallback defines a callback to call on error
  142828. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  142829. */
  142830. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  142831. private _loadFileAsync;
  142832. private _saveFileAsync;
  142833. /**
  142834. * Validates if xhr data is correct
  142835. * @param xhr defines the request to validate
  142836. * @param dataType defines the expected data type
  142837. * @returns true if data is correct
  142838. */
  142839. private static _ValidateXHRData;
  142840. }
  142841. }
  142842. declare module BABYLON {
  142843. /** @hidden */
  142844. export var gpuUpdateParticlesPixelShader: {
  142845. name: string;
  142846. shader: string;
  142847. };
  142848. }
  142849. declare module BABYLON {
  142850. /** @hidden */
  142851. export var gpuUpdateParticlesVertexShader: {
  142852. name: string;
  142853. shader: string;
  142854. };
  142855. }
  142856. declare module BABYLON {
  142857. /** @hidden */
  142858. export var clipPlaneFragmentDeclaration2: {
  142859. name: string;
  142860. shader: string;
  142861. };
  142862. }
  142863. declare module BABYLON {
  142864. /** @hidden */
  142865. export var gpuRenderParticlesPixelShader: {
  142866. name: string;
  142867. shader: string;
  142868. };
  142869. }
  142870. declare module BABYLON {
  142871. /** @hidden */
  142872. export var clipPlaneVertexDeclaration2: {
  142873. name: string;
  142874. shader: string;
  142875. };
  142876. }
  142877. declare module BABYLON {
  142878. /** @hidden */
  142879. export var gpuRenderParticlesVertexShader: {
  142880. name: string;
  142881. shader: string;
  142882. };
  142883. }
  142884. declare module BABYLON {
  142885. /**
  142886. * This represents a GPU particle system in Babylon
  142887. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  142888. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  142889. */
  142890. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  142891. /**
  142892. * The layer mask we are rendering the particles through.
  142893. */
  142894. layerMask: number;
  142895. private _capacity;
  142896. private _activeCount;
  142897. private _currentActiveCount;
  142898. private _accumulatedCount;
  142899. private _renderEffect;
  142900. private _updateEffect;
  142901. private _buffer0;
  142902. private _buffer1;
  142903. private _spriteBuffer;
  142904. private _updateVAO;
  142905. private _renderVAO;
  142906. private _targetIndex;
  142907. private _sourceBuffer;
  142908. private _targetBuffer;
  142909. private _engine;
  142910. private _currentRenderId;
  142911. private _started;
  142912. private _stopped;
  142913. private _timeDelta;
  142914. private _randomTexture;
  142915. private _randomTexture2;
  142916. private _attributesStrideSize;
  142917. private _updateEffectOptions;
  142918. private _randomTextureSize;
  142919. private _actualFrame;
  142920. private _customEffect;
  142921. private readonly _rawTextureWidth;
  142922. /**
  142923. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  142924. */
  142925. static get IsSupported(): boolean;
  142926. /**
  142927. * An event triggered when the system is disposed.
  142928. */
  142929. onDisposeObservable: Observable<IParticleSystem>;
  142930. /**
  142931. * Gets the maximum number of particles active at the same time.
  142932. * @returns The max number of active particles.
  142933. */
  142934. getCapacity(): number;
  142935. /**
  142936. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  142937. * to override the particles.
  142938. */
  142939. forceDepthWrite: boolean;
  142940. /**
  142941. * Gets or set the number of active particles
  142942. */
  142943. get activeParticleCount(): number;
  142944. set activeParticleCount(value: number);
  142945. private _preWarmDone;
  142946. /**
  142947. * Specifies if the particles are updated in emitter local space or world space.
  142948. */
  142949. isLocal: boolean;
  142950. /**
  142951. * Is this system ready to be used/rendered
  142952. * @return true if the system is ready
  142953. */
  142954. isReady(): boolean;
  142955. /**
  142956. * Gets if the system has been started. (Note: this will still be true after stop is called)
  142957. * @returns True if it has been started, otherwise false.
  142958. */
  142959. isStarted(): boolean;
  142960. /**
  142961. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  142962. * @returns True if it has been stopped, otherwise false.
  142963. */
  142964. isStopped(): boolean;
  142965. /**
  142966. * Gets a boolean indicating that the system is stopping
  142967. * @returns true if the system is currently stopping
  142968. */
  142969. isStopping(): boolean;
  142970. /**
  142971. * Gets the number of particles active at the same time.
  142972. * @returns The number of active particles.
  142973. */
  142974. getActiveCount(): number;
  142975. /**
  142976. * Starts the particle system and begins to emit
  142977. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  142978. */
  142979. start(delay?: number): void;
  142980. /**
  142981. * Stops the particle system.
  142982. */
  142983. stop(): void;
  142984. /**
  142985. * Remove all active particles
  142986. */
  142987. reset(): void;
  142988. /**
  142989. * Returns the string "GPUParticleSystem"
  142990. * @returns a string containing the class name
  142991. */
  142992. getClassName(): string;
  142993. /**
  142994. * Gets the custom effect used to render the particles
  142995. * @param blendMode Blend mode for which the effect should be retrieved
  142996. * @returns The effect
  142997. */
  142998. getCustomEffect(blendMode?: number): Nullable<Effect>;
  142999. /**
  143000. * Sets the custom effect used to render the particles
  143001. * @param effect The effect to set
  143002. * @param blendMode Blend mode for which the effect should be set
  143003. */
  143004. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  143005. /** @hidden */
  143006. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  143007. /**
  143008. * Observable that will be called just before the particles are drawn
  143009. */
  143010. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  143011. /**
  143012. * Gets the name of the particle vertex shader
  143013. */
  143014. get vertexShaderName(): string;
  143015. private _colorGradientsTexture;
  143016. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  143017. /**
  143018. * Adds a new color gradient
  143019. * @param gradient defines the gradient to use (between 0 and 1)
  143020. * @param color1 defines the color to affect to the specified gradient
  143021. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  143022. * @returns the current particle system
  143023. */
  143024. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  143025. private _refreshColorGradient;
  143026. /** Force the system to rebuild all gradients that need to be resync */
  143027. forceRefreshGradients(): void;
  143028. /**
  143029. * Remove a specific color gradient
  143030. * @param gradient defines the gradient to remove
  143031. * @returns the current particle system
  143032. */
  143033. removeColorGradient(gradient: number): GPUParticleSystem;
  143034. private _angularSpeedGradientsTexture;
  143035. private _sizeGradientsTexture;
  143036. private _velocityGradientsTexture;
  143037. private _limitVelocityGradientsTexture;
  143038. private _dragGradientsTexture;
  143039. private _addFactorGradient;
  143040. /**
  143041. * Adds a new size gradient
  143042. * @param gradient defines the gradient to use (between 0 and 1)
  143043. * @param factor defines the size factor to affect to the specified gradient
  143044. * @returns the current particle system
  143045. */
  143046. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  143047. /**
  143048. * Remove a specific size gradient
  143049. * @param gradient defines the gradient to remove
  143050. * @returns the current particle system
  143051. */
  143052. removeSizeGradient(gradient: number): GPUParticleSystem;
  143053. private _refreshFactorGradient;
  143054. /**
  143055. * Adds a new angular speed gradient
  143056. * @param gradient defines the gradient to use (between 0 and 1)
  143057. * @param factor defines the angular speed to affect to the specified gradient
  143058. * @returns the current particle system
  143059. */
  143060. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  143061. /**
  143062. * Remove a specific angular speed gradient
  143063. * @param gradient defines the gradient to remove
  143064. * @returns the current particle system
  143065. */
  143066. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  143067. /**
  143068. * Adds a new velocity gradient
  143069. * @param gradient defines the gradient to use (between 0 and 1)
  143070. * @param factor defines the velocity to affect to the specified gradient
  143071. * @returns the current particle system
  143072. */
  143073. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143074. /**
  143075. * Remove a specific velocity gradient
  143076. * @param gradient defines the gradient to remove
  143077. * @returns the current particle system
  143078. */
  143079. removeVelocityGradient(gradient: number): GPUParticleSystem;
  143080. /**
  143081. * Adds a new limit velocity gradient
  143082. * @param gradient defines the gradient to use (between 0 and 1)
  143083. * @param factor defines the limit velocity value to affect to the specified gradient
  143084. * @returns the current particle system
  143085. */
  143086. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143087. /**
  143088. * Remove a specific limit velocity gradient
  143089. * @param gradient defines the gradient to remove
  143090. * @returns the current particle system
  143091. */
  143092. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  143093. /**
  143094. * Adds a new drag gradient
  143095. * @param gradient defines the gradient to use (between 0 and 1)
  143096. * @param factor defines the drag value to affect to the specified gradient
  143097. * @returns the current particle system
  143098. */
  143099. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  143100. /**
  143101. * Remove a specific drag gradient
  143102. * @param gradient defines the gradient to remove
  143103. * @returns the current particle system
  143104. */
  143105. removeDragGradient(gradient: number): GPUParticleSystem;
  143106. /**
  143107. * Not supported by GPUParticleSystem
  143108. * @param gradient defines the gradient to use (between 0 and 1)
  143109. * @param factor defines the emit rate value to affect to the specified gradient
  143110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143111. * @returns the current particle system
  143112. */
  143113. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143114. /**
  143115. * Not supported by GPUParticleSystem
  143116. * @param gradient defines the gradient to remove
  143117. * @returns the current particle system
  143118. */
  143119. removeEmitRateGradient(gradient: number): IParticleSystem;
  143120. /**
  143121. * Not supported by GPUParticleSystem
  143122. * @param gradient defines the gradient to use (between 0 and 1)
  143123. * @param factor defines the start size value to affect to the specified gradient
  143124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143125. * @returns the current particle system
  143126. */
  143127. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143128. /**
  143129. * Not supported by GPUParticleSystem
  143130. * @param gradient defines the gradient to remove
  143131. * @returns the current particle system
  143132. */
  143133. removeStartSizeGradient(gradient: number): IParticleSystem;
  143134. /**
  143135. * Not supported by GPUParticleSystem
  143136. * @param gradient defines the gradient to use (between 0 and 1)
  143137. * @param min defines the color remap minimal range
  143138. * @param max defines the color remap maximal range
  143139. * @returns the current particle system
  143140. */
  143141. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143142. /**
  143143. * Not supported by GPUParticleSystem
  143144. * @param gradient defines the gradient to remove
  143145. * @returns the current particle system
  143146. */
  143147. removeColorRemapGradient(): IParticleSystem;
  143148. /**
  143149. * Not supported by GPUParticleSystem
  143150. * @param gradient defines the gradient to use (between 0 and 1)
  143151. * @param min defines the alpha remap minimal range
  143152. * @param max defines the alpha remap maximal range
  143153. * @returns the current particle system
  143154. */
  143155. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143156. /**
  143157. * Not supported by GPUParticleSystem
  143158. * @param gradient defines the gradient to remove
  143159. * @returns the current particle system
  143160. */
  143161. removeAlphaRemapGradient(): IParticleSystem;
  143162. /**
  143163. * Not supported by GPUParticleSystem
  143164. * @param gradient defines the gradient to use (between 0 and 1)
  143165. * @param color defines the color to affect to the specified gradient
  143166. * @returns the current particle system
  143167. */
  143168. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  143169. /**
  143170. * Not supported by GPUParticleSystem
  143171. * @param gradient defines the gradient to remove
  143172. * @returns the current particle system
  143173. */
  143174. removeRampGradient(): IParticleSystem;
  143175. /**
  143176. * Not supported by GPUParticleSystem
  143177. * @returns the list of ramp gradients
  143178. */
  143179. getRampGradients(): Nullable<Array<Color3Gradient>>;
  143180. /**
  143181. * Not supported by GPUParticleSystem
  143182. * Gets or sets a boolean indicating that ramp gradients must be used
  143183. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  143184. */
  143185. get useRampGradients(): boolean;
  143186. set useRampGradients(value: boolean);
  143187. /**
  143188. * Not supported by GPUParticleSystem
  143189. * @param gradient defines the gradient to use (between 0 and 1)
  143190. * @param factor defines the life time factor to affect to the specified gradient
  143191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143192. * @returns the current particle system
  143193. */
  143194. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143195. /**
  143196. * Not supported by GPUParticleSystem
  143197. * @param gradient defines the gradient to remove
  143198. * @returns the current particle system
  143199. */
  143200. removeLifeTimeGradient(gradient: number): IParticleSystem;
  143201. /**
  143202. * Instantiates a GPU particle system.
  143203. * 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.
  143204. * @param name The name of the particle system
  143205. * @param options The options used to create the system
  143206. * @param scene The scene the particle system belongs to
  143207. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  143208. * @param customEffect a custom effect used to change the way particles are rendered by default
  143209. */
  143210. constructor(name: string, options: Partial<{
  143211. capacity: number;
  143212. randomTextureSize: number;
  143213. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  143214. protected _reset(): void;
  143215. private _createUpdateVAO;
  143216. private _createRenderVAO;
  143217. private _initialize;
  143218. /** @hidden */
  143219. _recreateUpdateEffect(): void;
  143220. private _getEffect;
  143221. /**
  143222. * Fill the defines array according to the current settings of the particle system
  143223. * @param defines Array to be updated
  143224. * @param blendMode blend mode to take into account when updating the array
  143225. */
  143226. fillDefines(defines: Array<string>, blendMode?: number): void;
  143227. /**
  143228. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  143229. * @param uniforms Uniforms array to fill
  143230. * @param attributes Attributes array to fill
  143231. * @param samplers Samplers array to fill
  143232. */
  143233. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  143234. /** @hidden */
  143235. _recreateRenderEffect(): Effect;
  143236. /**
  143237. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  143238. * @param preWarm defines if we are in the pre-warmimg phase
  143239. */
  143240. animate(preWarm?: boolean): void;
  143241. private _createFactorGradientTexture;
  143242. private _createSizeGradientTexture;
  143243. private _createAngularSpeedGradientTexture;
  143244. private _createVelocityGradientTexture;
  143245. private _createLimitVelocityGradientTexture;
  143246. private _createDragGradientTexture;
  143247. private _createColorGradientTexture;
  143248. /**
  143249. * Renders the particle system in its current state
  143250. * @param preWarm defines if the system should only update the particles but not render them
  143251. * @returns the current number of particles
  143252. */
  143253. render(preWarm?: boolean): number;
  143254. /**
  143255. * Rebuilds the particle system
  143256. */
  143257. rebuild(): void;
  143258. private _releaseBuffers;
  143259. private _releaseVAOs;
  143260. /**
  143261. * Disposes the particle system and free the associated resources
  143262. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  143263. */
  143264. dispose(disposeTexture?: boolean): void;
  143265. /**
  143266. * Clones the particle system.
  143267. * @param name The name of the cloned object
  143268. * @param newEmitter The new emitter to use
  143269. * @returns the cloned particle system
  143270. */
  143271. clone(name: string, newEmitter: any): GPUParticleSystem;
  143272. /**
  143273. * Serializes the particle system to a JSON object
  143274. * @param serializeTexture defines if the texture must be serialized as well
  143275. * @returns the JSON object
  143276. */
  143277. serialize(serializeTexture?: boolean): any;
  143278. /**
  143279. * Parses a JSON object to create a GPU particle system.
  143280. * @param parsedParticleSystem The JSON object to parse
  143281. * @param scene The scene to create the particle system in
  143282. * @param rootUrl The root url to use to load external dependencies like texture
  143283. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  143284. * @returns the parsed GPU particle system
  143285. */
  143286. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  143287. }
  143288. }
  143289. declare module BABYLON {
  143290. /**
  143291. * Represents a set of particle systems working together to create a specific effect
  143292. */
  143293. export class ParticleSystemSet implements IDisposable {
  143294. /**
  143295. * Gets or sets base Assets URL
  143296. */
  143297. static BaseAssetsUrl: string;
  143298. private _emitterCreationOptions;
  143299. private _emitterNode;
  143300. /**
  143301. * Gets the particle system list
  143302. */
  143303. systems: IParticleSystem[];
  143304. /**
  143305. * Gets the emitter node used with this set
  143306. */
  143307. get emitterNode(): Nullable<TransformNode>;
  143308. /**
  143309. * Creates a new emitter mesh as a sphere
  143310. * @param options defines the options used to create the sphere
  143311. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  143312. * @param scene defines the hosting scene
  143313. */
  143314. setEmitterAsSphere(options: {
  143315. diameter: number;
  143316. segments: number;
  143317. color: Color3;
  143318. }, renderingGroupId: number, scene: Scene): void;
  143319. /**
  143320. * Starts all particle systems of the set
  143321. * @param emitter defines an optional mesh to use as emitter for the particle systems
  143322. */
  143323. start(emitter?: AbstractMesh): void;
  143324. /**
  143325. * Release all associated resources
  143326. */
  143327. dispose(): void;
  143328. /**
  143329. * Serialize the set into a JSON compatible object
  143330. * @param serializeTexture defines if the texture must be serialized as well
  143331. * @returns a JSON compatible representation of the set
  143332. */
  143333. serialize(serializeTexture?: boolean): any;
  143334. /**
  143335. * Parse a new ParticleSystemSet from a serialized source
  143336. * @param data defines a JSON compatible representation of the set
  143337. * @param scene defines the hosting scene
  143338. * @param gpu defines if we want GPU particles or CPU particles
  143339. * @returns a new ParticleSystemSet
  143340. */
  143341. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  143342. }
  143343. }
  143344. declare module BABYLON {
  143345. /**
  143346. * This class is made for on one-liner static method to help creating particle system set.
  143347. */
  143348. export class ParticleHelper {
  143349. /**
  143350. * Gets or sets base Assets URL
  143351. */
  143352. static BaseAssetsUrl: string;
  143353. /** Define the Url to load snippets */
  143354. static SnippetUrl: string;
  143355. /**
  143356. * Create a default particle system that you can tweak
  143357. * @param emitter defines the emitter to use
  143358. * @param capacity defines the system capacity (default is 500 particles)
  143359. * @param scene defines the hosting scene
  143360. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  143361. * @returns the new Particle system
  143362. */
  143363. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  143364. /**
  143365. * This is the main static method (one-liner) of this helper to create different particle systems
  143366. * @param type This string represents the type to the particle system to create
  143367. * @param scene The scene where the particle system should live
  143368. * @param gpu If the system will use gpu
  143369. * @returns the ParticleSystemSet created
  143370. */
  143371. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  143372. /**
  143373. * Static function used to export a particle system to a ParticleSystemSet variable.
  143374. * Please note that the emitter shape is not exported
  143375. * @param systems defines the particle systems to export
  143376. * @returns the created particle system set
  143377. */
  143378. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  143379. /**
  143380. * Creates a particle system from a snippet saved in a remote file
  143381. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  143382. * @param url defines the url to load from
  143383. * @param scene defines the hosting scene
  143384. * @param gpu If the system will use gpu
  143385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143386. * @returns a promise that will resolve to the new particle system
  143387. */
  143388. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143389. /**
  143390. * Creates a particle system from a snippet saved by the particle system editor
  143391. * @param snippetId defines the snippet to load
  143392. * @param scene defines the hosting scene
  143393. * @param gpu If the system will use gpu
  143394. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143395. * @returns a promise that will resolve to the new particle system
  143396. */
  143397. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143398. }
  143399. }
  143400. declare module BABYLON {
  143401. interface Engine {
  143402. /**
  143403. * Create an effect to use with particle systems.
  143404. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  143405. * the particle system for which you want to create a custom effect in the last parameter
  143406. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  143407. * @param uniformsNames defines a list of attribute names
  143408. * @param samplers defines an array of string used to represent textures
  143409. * @param defines defines the string containing the defines to use to compile the shaders
  143410. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  143411. * @param onCompiled defines a function to call when the effect creation is successful
  143412. * @param onError defines a function to call when the effect creation has failed
  143413. * @param particleSystem the particle system you want to create the effect for
  143414. * @returns the new Effect
  143415. */
  143416. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  143417. }
  143418. interface Mesh {
  143419. /**
  143420. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  143421. * @returns an array of IParticleSystem
  143422. */
  143423. getEmittedParticleSystems(): IParticleSystem[];
  143424. /**
  143425. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  143426. * @returns an array of IParticleSystem
  143427. */
  143428. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  143429. }
  143430. }
  143431. declare module BABYLON {
  143432. /** Defines the 4 color options */
  143433. export enum PointColor {
  143434. /** color value */
  143435. Color = 2,
  143436. /** uv value */
  143437. UV = 1,
  143438. /** random value */
  143439. Random = 0,
  143440. /** stated value */
  143441. Stated = 3
  143442. }
  143443. /**
  143444. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  143445. * 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.
  143446. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  143447. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  143448. *
  143449. * Full documentation here : TO BE ENTERED
  143450. */
  143451. export class PointsCloudSystem implements IDisposable {
  143452. /**
  143453. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  143454. * Example : var p = SPS.particles[i];
  143455. */
  143456. particles: CloudPoint[];
  143457. /**
  143458. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  143459. */
  143460. nbParticles: number;
  143461. /**
  143462. * This a counter for your own usage. It's not set by any SPS functions.
  143463. */
  143464. counter: number;
  143465. /**
  143466. * The PCS name. This name is also given to the underlying mesh.
  143467. */
  143468. name: string;
  143469. /**
  143470. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  143471. */
  143472. mesh: Mesh;
  143473. /**
  143474. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  143475. * Please read :
  143476. */
  143477. vars: any;
  143478. /**
  143479. * @hidden
  143480. */
  143481. _size: number;
  143482. private _scene;
  143483. private _promises;
  143484. private _positions;
  143485. private _indices;
  143486. private _normals;
  143487. private _colors;
  143488. private _uvs;
  143489. private _indices32;
  143490. private _positions32;
  143491. private _colors32;
  143492. private _uvs32;
  143493. private _updatable;
  143494. private _isVisibilityBoxLocked;
  143495. private _alwaysVisible;
  143496. private _groups;
  143497. private _groupCounter;
  143498. private _computeParticleColor;
  143499. private _computeParticleTexture;
  143500. private _computeParticleRotation;
  143501. private _computeBoundingBox;
  143502. private _isReady;
  143503. /**
  143504. * Creates a PCS (Points Cloud System) object
  143505. * @param name (String) is the PCS name, this will be the underlying mesh name
  143506. * @param pointSize (number) is the size for each point
  143507. * @param scene (Scene) is the scene in which the PCS is added
  143508. * @param options defines the options of the PCS e.g.
  143509. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  143510. */
  143511. constructor(name: string, pointSize: number, scene: Scene, options?: {
  143512. updatable?: boolean;
  143513. });
  143514. /**
  143515. * Builds the PCS underlying mesh. Returns a standard Mesh.
  143516. * If no points were added to the PCS, the returned mesh is just a single point.
  143517. * @returns a promise for the created mesh
  143518. */
  143519. buildMeshAsync(): Promise<Mesh>;
  143520. /**
  143521. * @hidden
  143522. */
  143523. private _buildMesh;
  143524. private _addParticle;
  143525. private _randomUnitVector;
  143526. private _getColorIndicesForCoord;
  143527. private _setPointsColorOrUV;
  143528. private _colorFromTexture;
  143529. private _calculateDensity;
  143530. /**
  143531. * Adds points to the PCS in random positions within a unit sphere
  143532. * @param nb (positive integer) the number of particles to be created from this model
  143533. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  143534. * @returns the number of groups in the system
  143535. */
  143536. addPoints(nb: number, pointFunction?: any): number;
  143537. /**
  143538. * Adds points to the PCS from the surface of the model shape
  143539. * @param mesh is any Mesh object that will be used as a surface model for the points
  143540. * @param nb (positive integer) the number of particles to be created from this model
  143541. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143542. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143543. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143544. * @returns the number of groups in the system
  143545. */
  143546. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143547. /**
  143548. * Adds points to the PCS inside the model shape
  143549. * @param mesh is any Mesh object that will be used as a surface model for the points
  143550. * @param nb (positive integer) the number of particles to be created from this model
  143551. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143552. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143553. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143554. * @returns the number of groups in the system
  143555. */
  143556. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143557. /**
  143558. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  143559. * This method calls `updateParticle()` for each particle of the SPS.
  143560. * For an animated SPS, it is usually called within the render loop.
  143561. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  143562. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  143563. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  143564. * @returns the PCS.
  143565. */
  143566. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  143567. /**
  143568. * Disposes the PCS.
  143569. */
  143570. dispose(): void;
  143571. /**
  143572. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  143573. * doc :
  143574. * @returns the PCS.
  143575. */
  143576. refreshVisibleSize(): PointsCloudSystem;
  143577. /**
  143578. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  143579. * @param size the size (float) of the visibility box
  143580. * note : this doesn't lock the PCS mesh bounding box.
  143581. * doc :
  143582. */
  143583. setVisibilityBox(size: number): void;
  143584. /**
  143585. * Gets whether the PCS is always visible or not
  143586. * doc :
  143587. */
  143588. get isAlwaysVisible(): boolean;
  143589. /**
  143590. * Sets the PCS as always visible or not
  143591. * doc :
  143592. */
  143593. set isAlwaysVisible(val: boolean);
  143594. /**
  143595. * Tells to `setParticles()` to compute the particle rotations or not
  143596. * Default value : false. The PCS is faster when it's set to false
  143597. * Note : particle rotations are only applied to parent particles
  143598. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  143599. */
  143600. set computeParticleRotation(val: boolean);
  143601. /**
  143602. * Tells to `setParticles()` to compute the particle colors or not.
  143603. * Default value : true. The PCS is faster when it's set to false.
  143604. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143605. */
  143606. set computeParticleColor(val: boolean);
  143607. set computeParticleTexture(val: boolean);
  143608. /**
  143609. * Gets if `setParticles()` computes the particle colors or not.
  143610. * Default value : false. The PCS is faster when it's set to false.
  143611. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143612. */
  143613. get computeParticleColor(): boolean;
  143614. /**
  143615. * Gets if `setParticles()` computes the particle textures or not.
  143616. * Default value : false. The PCS is faster when it's set to false.
  143617. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  143618. */
  143619. get computeParticleTexture(): boolean;
  143620. /**
  143621. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  143622. */
  143623. set computeBoundingBox(val: boolean);
  143624. /**
  143625. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  143626. */
  143627. get computeBoundingBox(): boolean;
  143628. /**
  143629. * This function does nothing. It may be overwritten to set all the particle first values.
  143630. * The PCS doesn't call this function, you may have to call it by your own.
  143631. * doc :
  143632. */
  143633. initParticles(): void;
  143634. /**
  143635. * This function does nothing. It may be overwritten to recycle a particle
  143636. * The PCS doesn't call this function, you can to call it
  143637. * doc :
  143638. * @param particle The particle to recycle
  143639. * @returns the recycled particle
  143640. */
  143641. recycleParticle(particle: CloudPoint): CloudPoint;
  143642. /**
  143643. * Updates a particle : this function should be overwritten by the user.
  143644. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  143645. * doc :
  143646. * @example : just set a particle position or velocity and recycle conditions
  143647. * @param particle The particle to update
  143648. * @returns the updated particle
  143649. */
  143650. updateParticle(particle: CloudPoint): CloudPoint;
  143651. /**
  143652. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  143653. * This does nothing and may be overwritten by the user.
  143654. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143655. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143656. * @param update the boolean update value actually passed to setParticles()
  143657. */
  143658. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143659. /**
  143660. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  143661. * This will be passed three parameters.
  143662. * This does nothing and may be overwritten by the user.
  143663. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143664. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143665. * @param update the boolean update value actually passed to setParticles()
  143666. */
  143667. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143668. }
  143669. }
  143670. declare module BABYLON {
  143671. /**
  143672. * Represents one particle of a points cloud system.
  143673. */
  143674. export class CloudPoint {
  143675. /**
  143676. * particle global index
  143677. */
  143678. idx: number;
  143679. /**
  143680. * The color of the particle
  143681. */
  143682. color: Nullable<Color4>;
  143683. /**
  143684. * The world space position of the particle.
  143685. */
  143686. position: Vector3;
  143687. /**
  143688. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  143689. */
  143690. rotation: Vector3;
  143691. /**
  143692. * The world space rotation quaternion of the particle.
  143693. */
  143694. rotationQuaternion: Nullable<Quaternion>;
  143695. /**
  143696. * The uv of the particle.
  143697. */
  143698. uv: Nullable<Vector2>;
  143699. /**
  143700. * The current speed of the particle.
  143701. */
  143702. velocity: Vector3;
  143703. /**
  143704. * The pivot point in the particle local space.
  143705. */
  143706. pivot: Vector3;
  143707. /**
  143708. * Must the particle be translated from its pivot point in its local space ?
  143709. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  143710. * Default : false
  143711. */
  143712. translateFromPivot: boolean;
  143713. /**
  143714. * Index of this particle in the global "positions" array (Internal use)
  143715. * @hidden
  143716. */
  143717. _pos: number;
  143718. /**
  143719. * @hidden Index of this particle in the global "indices" array (Internal use)
  143720. */
  143721. _ind: number;
  143722. /**
  143723. * Group this particle belongs to
  143724. */
  143725. _group: PointsGroup;
  143726. /**
  143727. * Group id of this particle
  143728. */
  143729. groupId: number;
  143730. /**
  143731. * Index of the particle in its group id (Internal use)
  143732. */
  143733. idxInGroup: number;
  143734. /**
  143735. * @hidden Particle BoundingInfo object (Internal use)
  143736. */
  143737. _boundingInfo: BoundingInfo;
  143738. /**
  143739. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  143740. */
  143741. _pcs: PointsCloudSystem;
  143742. /**
  143743. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  143744. */
  143745. _stillInvisible: boolean;
  143746. /**
  143747. * @hidden Last computed particle rotation matrix
  143748. */
  143749. _rotationMatrix: number[];
  143750. /**
  143751. * Parent particle Id, if any.
  143752. * Default null.
  143753. */
  143754. parentId: Nullable<number>;
  143755. /**
  143756. * @hidden Internal global position in the PCS.
  143757. */
  143758. _globalPosition: Vector3;
  143759. /**
  143760. * Creates a Point Cloud object.
  143761. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  143762. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  143763. * @param group (PointsGroup) is the group the particle belongs to
  143764. * @param groupId (integer) is the group identifier in the PCS.
  143765. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  143766. * @param pcs defines the PCS it is associated to
  143767. */
  143768. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  143769. /**
  143770. * get point size
  143771. */
  143772. get size(): Vector3;
  143773. /**
  143774. * Set point size
  143775. */
  143776. set size(scale: Vector3);
  143777. /**
  143778. * Legacy support, changed quaternion to rotationQuaternion
  143779. */
  143780. get quaternion(): Nullable<Quaternion>;
  143781. /**
  143782. * Legacy support, changed quaternion to rotationQuaternion
  143783. */
  143784. set quaternion(q: Nullable<Quaternion>);
  143785. /**
  143786. * Returns a boolean. True if the particle intersects a mesh, else false
  143787. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  143788. * @param target is the object (point or mesh) what the intersection is computed against
  143789. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  143790. * @returns true if it intersects
  143791. */
  143792. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  143793. /**
  143794. * get the rotation matrix of the particle
  143795. * @hidden
  143796. */
  143797. getRotationMatrix(m: Matrix): void;
  143798. }
  143799. /**
  143800. * Represents a group of points in a points cloud system
  143801. * * PCS internal tool, don't use it manually.
  143802. */
  143803. export class PointsGroup {
  143804. /**
  143805. * The group id
  143806. * @hidden
  143807. */
  143808. groupID: number;
  143809. /**
  143810. * image data for group (internal use)
  143811. * @hidden
  143812. */
  143813. _groupImageData: Nullable<ArrayBufferView>;
  143814. /**
  143815. * Image Width (internal use)
  143816. * @hidden
  143817. */
  143818. _groupImgWidth: number;
  143819. /**
  143820. * Image Height (internal use)
  143821. * @hidden
  143822. */
  143823. _groupImgHeight: number;
  143824. /**
  143825. * Custom position function (internal use)
  143826. * @hidden
  143827. */
  143828. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  143829. /**
  143830. * density per facet for surface points
  143831. * @hidden
  143832. */
  143833. _groupDensity: number[];
  143834. /**
  143835. * Only when points are colored by texture carries pointer to texture list array
  143836. * @hidden
  143837. */
  143838. _textureNb: number;
  143839. /**
  143840. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  143841. * PCS internal tool, don't use it manually.
  143842. * @hidden
  143843. */
  143844. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  143845. }
  143846. }
  143847. declare module BABYLON {
  143848. interface Scene {
  143849. /** @hidden (Backing field) */
  143850. _physicsEngine: Nullable<IPhysicsEngine>;
  143851. /** @hidden */
  143852. _physicsTimeAccumulator: number;
  143853. /**
  143854. * Gets the current physics engine
  143855. * @returns a IPhysicsEngine or null if none attached
  143856. */
  143857. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  143858. /**
  143859. * Enables physics to the current scene
  143860. * @param gravity defines the scene's gravity for the physics engine
  143861. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  143862. * @return a boolean indicating if the physics engine was initialized
  143863. */
  143864. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  143865. /**
  143866. * Disables and disposes the physics engine associated with the scene
  143867. */
  143868. disablePhysicsEngine(): void;
  143869. /**
  143870. * Gets a boolean indicating if there is an active physics engine
  143871. * @returns a boolean indicating if there is an active physics engine
  143872. */
  143873. isPhysicsEnabled(): boolean;
  143874. /**
  143875. * Deletes a physics compound impostor
  143876. * @param compound defines the compound to delete
  143877. */
  143878. deleteCompoundImpostor(compound: any): void;
  143879. /**
  143880. * An event triggered when physic simulation is about to be run
  143881. */
  143882. onBeforePhysicsObservable: Observable<Scene>;
  143883. /**
  143884. * An event triggered when physic simulation has been done
  143885. */
  143886. onAfterPhysicsObservable: Observable<Scene>;
  143887. }
  143888. interface AbstractMesh {
  143889. /** @hidden */
  143890. _physicsImpostor: Nullable<PhysicsImpostor>;
  143891. /**
  143892. * Gets or sets impostor used for physic simulation
  143893. * @see http://doc.babylonjs.com/features/physics_engine
  143894. */
  143895. physicsImpostor: Nullable<PhysicsImpostor>;
  143896. /**
  143897. * Gets the current physics impostor
  143898. * @see http://doc.babylonjs.com/features/physics_engine
  143899. * @returns a physics impostor or null
  143900. */
  143901. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  143902. /** Apply a physic impulse to the mesh
  143903. * @param force defines the force to apply
  143904. * @param contactPoint defines where to apply the force
  143905. * @returns the current mesh
  143906. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  143907. */
  143908. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  143909. /**
  143910. * Creates a physic joint between two meshes
  143911. * @param otherMesh defines the other mesh to use
  143912. * @param pivot1 defines the pivot to use on this mesh
  143913. * @param pivot2 defines the pivot to use on the other mesh
  143914. * @param options defines additional options (can be plugin dependent)
  143915. * @returns the current mesh
  143916. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  143917. */
  143918. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  143919. /** @hidden */
  143920. _disposePhysicsObserver: Nullable<Observer<Node>>;
  143921. }
  143922. /**
  143923. * Defines the physics engine scene component responsible to manage a physics engine
  143924. */
  143925. export class PhysicsEngineSceneComponent implements ISceneComponent {
  143926. /**
  143927. * The component name helpful to identify the component in the list of scene components.
  143928. */
  143929. readonly name: string;
  143930. /**
  143931. * The scene the component belongs to.
  143932. */
  143933. scene: Scene;
  143934. /**
  143935. * Creates a new instance of the component for the given scene
  143936. * @param scene Defines the scene to register the component in
  143937. */
  143938. constructor(scene: Scene);
  143939. /**
  143940. * Registers the component in a given scene
  143941. */
  143942. register(): void;
  143943. /**
  143944. * Rebuilds the elements related to this component in case of
  143945. * context lost for instance.
  143946. */
  143947. rebuild(): void;
  143948. /**
  143949. * Disposes the component and the associated ressources
  143950. */
  143951. dispose(): void;
  143952. }
  143953. }
  143954. declare module BABYLON {
  143955. /**
  143956. * A helper for physics simulations
  143957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143958. */
  143959. export class PhysicsHelper {
  143960. private _scene;
  143961. private _physicsEngine;
  143962. /**
  143963. * Initializes the Physics helper
  143964. * @param scene Babylon.js scene
  143965. */
  143966. constructor(scene: Scene);
  143967. /**
  143968. * Applies a radial explosion impulse
  143969. * @param origin the origin of the explosion
  143970. * @param radiusOrEventOptions the radius or the options of radial explosion
  143971. * @param strength the explosion strength
  143972. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143973. * @returns A physics radial explosion event, or null
  143974. */
  143975. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143976. /**
  143977. * Applies a radial explosion force
  143978. * @param origin the origin of the explosion
  143979. * @param radiusOrEventOptions the radius or the options of radial explosion
  143980. * @param strength the explosion strength
  143981. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143982. * @returns A physics radial explosion event, or null
  143983. */
  143984. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143985. /**
  143986. * Creates a gravitational field
  143987. * @param origin the origin of the explosion
  143988. * @param radiusOrEventOptions the radius or the options of radial explosion
  143989. * @param strength the explosion strength
  143990. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143991. * @returns A physics gravitational field event, or null
  143992. */
  143993. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  143994. /**
  143995. * Creates a physics updraft event
  143996. * @param origin the origin of the updraft
  143997. * @param radiusOrEventOptions the radius or the options of the updraft
  143998. * @param strength the strength of the updraft
  143999. * @param height the height of the updraft
  144000. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  144001. * @returns A physics updraft event, or null
  144002. */
  144003. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  144004. /**
  144005. * Creates a physics vortex event
  144006. * @param origin the of the vortex
  144007. * @param radiusOrEventOptions the radius or the options of the vortex
  144008. * @param strength the strength of the vortex
  144009. * @param height the height of the vortex
  144010. * @returns a Physics vortex event, or null
  144011. * A physics vortex event or null
  144012. */
  144013. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  144014. }
  144015. /**
  144016. * Represents a physics radial explosion event
  144017. */
  144018. class PhysicsRadialExplosionEvent {
  144019. private _scene;
  144020. private _options;
  144021. private _sphere;
  144022. private _dataFetched;
  144023. /**
  144024. * Initializes a radial explosioin event
  144025. * @param _scene BabylonJS scene
  144026. * @param _options The options for the vortex event
  144027. */
  144028. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  144029. /**
  144030. * Returns the data related to the radial explosion event (sphere).
  144031. * @returns The radial explosion event data
  144032. */
  144033. getData(): PhysicsRadialExplosionEventData;
  144034. /**
  144035. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  144036. * @param impostor A physics imposter
  144037. * @param origin the origin of the explosion
  144038. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  144039. */
  144040. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  144041. /**
  144042. * Triggers affecterd impostors callbacks
  144043. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  144044. */
  144045. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  144046. /**
  144047. * Disposes the sphere.
  144048. * @param force Specifies if the sphere should be disposed by force
  144049. */
  144050. dispose(force?: boolean): void;
  144051. /*** Helpers ***/
  144052. private _prepareSphere;
  144053. private _intersectsWithSphere;
  144054. }
  144055. /**
  144056. * Represents a gravitational field event
  144057. */
  144058. class PhysicsGravitationalFieldEvent {
  144059. private _physicsHelper;
  144060. private _scene;
  144061. private _origin;
  144062. private _options;
  144063. private _tickCallback;
  144064. private _sphere;
  144065. private _dataFetched;
  144066. /**
  144067. * Initializes the physics gravitational field event
  144068. * @param _physicsHelper A physics helper
  144069. * @param _scene BabylonJS scene
  144070. * @param _origin The origin position of the gravitational field event
  144071. * @param _options The options for the vortex event
  144072. */
  144073. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  144074. /**
  144075. * Returns the data related to the gravitational field event (sphere).
  144076. * @returns A gravitational field event
  144077. */
  144078. getData(): PhysicsGravitationalFieldEventData;
  144079. /**
  144080. * Enables the gravitational field.
  144081. */
  144082. enable(): void;
  144083. /**
  144084. * Disables the gravitational field.
  144085. */
  144086. disable(): void;
  144087. /**
  144088. * Disposes the sphere.
  144089. * @param force The force to dispose from the gravitational field event
  144090. */
  144091. dispose(force?: boolean): void;
  144092. private _tick;
  144093. }
  144094. /**
  144095. * Represents a physics updraft event
  144096. */
  144097. class PhysicsUpdraftEvent {
  144098. private _scene;
  144099. private _origin;
  144100. private _options;
  144101. private _physicsEngine;
  144102. private _originTop;
  144103. private _originDirection;
  144104. private _tickCallback;
  144105. private _cylinder;
  144106. private _cylinderPosition;
  144107. private _dataFetched;
  144108. /**
  144109. * Initializes the physics updraft event
  144110. * @param _scene BabylonJS scene
  144111. * @param _origin The origin position of the updraft
  144112. * @param _options The options for the updraft event
  144113. */
  144114. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  144115. /**
  144116. * Returns the data related to the updraft event (cylinder).
  144117. * @returns A physics updraft event
  144118. */
  144119. getData(): PhysicsUpdraftEventData;
  144120. /**
  144121. * Enables the updraft.
  144122. */
  144123. enable(): void;
  144124. /**
  144125. * Disables the updraft.
  144126. */
  144127. disable(): void;
  144128. /**
  144129. * Disposes the cylinder.
  144130. * @param force Specifies if the updraft should be disposed by force
  144131. */
  144132. dispose(force?: boolean): void;
  144133. private getImpostorHitData;
  144134. private _tick;
  144135. /*** Helpers ***/
  144136. private _prepareCylinder;
  144137. private _intersectsWithCylinder;
  144138. }
  144139. /**
  144140. * Represents a physics vortex event
  144141. */
  144142. class PhysicsVortexEvent {
  144143. private _scene;
  144144. private _origin;
  144145. private _options;
  144146. private _physicsEngine;
  144147. private _originTop;
  144148. private _tickCallback;
  144149. private _cylinder;
  144150. private _cylinderPosition;
  144151. private _dataFetched;
  144152. /**
  144153. * Initializes the physics vortex event
  144154. * @param _scene The BabylonJS scene
  144155. * @param _origin The origin position of the vortex
  144156. * @param _options The options for the vortex event
  144157. */
  144158. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  144159. /**
  144160. * Returns the data related to the vortex event (cylinder).
  144161. * @returns The physics vortex event data
  144162. */
  144163. getData(): PhysicsVortexEventData;
  144164. /**
  144165. * Enables the vortex.
  144166. */
  144167. enable(): void;
  144168. /**
  144169. * Disables the cortex.
  144170. */
  144171. disable(): void;
  144172. /**
  144173. * Disposes the sphere.
  144174. * @param force
  144175. */
  144176. dispose(force?: boolean): void;
  144177. private getImpostorHitData;
  144178. private _tick;
  144179. /*** Helpers ***/
  144180. private _prepareCylinder;
  144181. private _intersectsWithCylinder;
  144182. }
  144183. /**
  144184. * Options fot the radial explosion event
  144185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144186. */
  144187. export class PhysicsRadialExplosionEventOptions {
  144188. /**
  144189. * The radius of the sphere for the radial explosion.
  144190. */
  144191. radius: number;
  144192. /**
  144193. * The strenth of the explosion.
  144194. */
  144195. strength: number;
  144196. /**
  144197. * The strenght of the force in correspondence to the distance of the affected object
  144198. */
  144199. falloff: PhysicsRadialImpulseFalloff;
  144200. /**
  144201. * Sphere options for the radial explosion.
  144202. */
  144203. sphere: {
  144204. segments: number;
  144205. diameter: number;
  144206. };
  144207. /**
  144208. * Sphere options for the radial explosion.
  144209. */
  144210. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  144211. }
  144212. /**
  144213. * Options fot the updraft event
  144214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144215. */
  144216. export class PhysicsUpdraftEventOptions {
  144217. /**
  144218. * The radius of the cylinder for the vortex
  144219. */
  144220. radius: number;
  144221. /**
  144222. * The strenth of the updraft.
  144223. */
  144224. strength: number;
  144225. /**
  144226. * The height of the cylinder for the updraft.
  144227. */
  144228. height: number;
  144229. /**
  144230. * The mode for the the updraft.
  144231. */
  144232. updraftMode: PhysicsUpdraftMode;
  144233. }
  144234. /**
  144235. * Options fot the vortex event
  144236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144237. */
  144238. export class PhysicsVortexEventOptions {
  144239. /**
  144240. * The radius of the cylinder for the vortex
  144241. */
  144242. radius: number;
  144243. /**
  144244. * The strenth of the vortex.
  144245. */
  144246. strength: number;
  144247. /**
  144248. * The height of the cylinder for the vortex.
  144249. */
  144250. height: number;
  144251. /**
  144252. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  144253. */
  144254. centripetalForceThreshold: number;
  144255. /**
  144256. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  144257. */
  144258. centripetalForceMultiplier: number;
  144259. /**
  144260. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  144261. */
  144262. centrifugalForceMultiplier: number;
  144263. /**
  144264. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  144265. */
  144266. updraftForceMultiplier: number;
  144267. }
  144268. /**
  144269. * The strenght of the force in correspondence to the distance of the affected object
  144270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144271. */
  144272. export enum PhysicsRadialImpulseFalloff {
  144273. /** Defines that impulse is constant in strength across it's whole radius */
  144274. Constant = 0,
  144275. /** Defines that impulse gets weaker if it's further from the origin */
  144276. Linear = 1
  144277. }
  144278. /**
  144279. * The strength of the force in correspondence to the distance of the affected object
  144280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144281. */
  144282. export enum PhysicsUpdraftMode {
  144283. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  144284. Center = 0,
  144285. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  144286. Perpendicular = 1
  144287. }
  144288. /**
  144289. * Interface for a physics hit data
  144290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144291. */
  144292. export interface PhysicsHitData {
  144293. /**
  144294. * The force applied at the contact point
  144295. */
  144296. force: Vector3;
  144297. /**
  144298. * The contact point
  144299. */
  144300. contactPoint: Vector3;
  144301. /**
  144302. * The distance from the origin to the contact point
  144303. */
  144304. distanceFromOrigin: number;
  144305. }
  144306. /**
  144307. * Interface for radial explosion event data
  144308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144309. */
  144310. export interface PhysicsRadialExplosionEventData {
  144311. /**
  144312. * A sphere used for the radial explosion event
  144313. */
  144314. sphere: Mesh;
  144315. }
  144316. /**
  144317. * Interface for gravitational field event data
  144318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144319. */
  144320. export interface PhysicsGravitationalFieldEventData {
  144321. /**
  144322. * A sphere mesh used for the gravitational field event
  144323. */
  144324. sphere: Mesh;
  144325. }
  144326. /**
  144327. * Interface for updraft event data
  144328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144329. */
  144330. export interface PhysicsUpdraftEventData {
  144331. /**
  144332. * A cylinder used for the updraft event
  144333. */
  144334. cylinder: Mesh;
  144335. }
  144336. /**
  144337. * Interface for vortex event data
  144338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144339. */
  144340. export interface PhysicsVortexEventData {
  144341. /**
  144342. * A cylinder used for the vortex event
  144343. */
  144344. cylinder: Mesh;
  144345. }
  144346. /**
  144347. * Interface for an affected physics impostor
  144348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144349. */
  144350. export interface PhysicsAffectedImpostorWithData {
  144351. /**
  144352. * The impostor affected by the effect
  144353. */
  144354. impostor: PhysicsImpostor;
  144355. /**
  144356. * The data about the hit/horce from the explosion
  144357. */
  144358. hitData: PhysicsHitData;
  144359. }
  144360. }
  144361. declare module BABYLON {
  144362. /** @hidden */
  144363. export var blackAndWhitePixelShader: {
  144364. name: string;
  144365. shader: string;
  144366. };
  144367. }
  144368. declare module BABYLON {
  144369. /**
  144370. * Post process used to render in black and white
  144371. */
  144372. export class BlackAndWhitePostProcess extends PostProcess {
  144373. /**
  144374. * Linear about to convert he result to black and white (default: 1)
  144375. */
  144376. degree: number;
  144377. /**
  144378. * Creates a black and white post process
  144379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  144380. * @param name The name of the effect.
  144381. * @param options The required width/height ratio to downsize to before computing the render pass.
  144382. * @param camera The camera to apply the render pass to.
  144383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144384. * @param engine The engine which the post process will be applied. (default: current engine)
  144385. * @param reusable If the post process can be reused on the same frame. (default: false)
  144386. */
  144387. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144388. }
  144389. }
  144390. declare module BABYLON {
  144391. /**
  144392. * This represents a set of one or more post processes in Babylon.
  144393. * A post process can be used to apply a shader to a texture after it is rendered.
  144394. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  144395. */
  144396. export class PostProcessRenderEffect {
  144397. private _postProcesses;
  144398. private _getPostProcesses;
  144399. private _singleInstance;
  144400. private _cameras;
  144401. private _indicesForCamera;
  144402. /**
  144403. * Name of the effect
  144404. * @hidden
  144405. */
  144406. _name: string;
  144407. /**
  144408. * Instantiates a post process render effect.
  144409. * A post process can be used to apply a shader to a texture after it is rendered.
  144410. * @param engine The engine the effect is tied to
  144411. * @param name The name of the effect
  144412. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  144413. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  144414. */
  144415. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  144416. /**
  144417. * Checks if all the post processes in the effect are supported.
  144418. */
  144419. get isSupported(): boolean;
  144420. /**
  144421. * Updates the current state of the effect
  144422. * @hidden
  144423. */
  144424. _update(): void;
  144425. /**
  144426. * Attaches the effect on cameras
  144427. * @param cameras The camera to attach to.
  144428. * @hidden
  144429. */
  144430. _attachCameras(cameras: Camera): void;
  144431. /**
  144432. * Attaches the effect on cameras
  144433. * @param cameras The camera to attach to.
  144434. * @hidden
  144435. */
  144436. _attachCameras(cameras: Camera[]): void;
  144437. /**
  144438. * Detaches the effect on cameras
  144439. * @param cameras The camera to detatch from.
  144440. * @hidden
  144441. */
  144442. _detachCameras(cameras: Camera): void;
  144443. /**
  144444. * Detatches the effect on cameras
  144445. * @param cameras The camera to detatch from.
  144446. * @hidden
  144447. */
  144448. _detachCameras(cameras: Camera[]): void;
  144449. /**
  144450. * Enables the effect on given cameras
  144451. * @param cameras The camera to enable.
  144452. * @hidden
  144453. */
  144454. _enable(cameras: Camera): void;
  144455. /**
  144456. * Enables the effect on given cameras
  144457. * @param cameras The camera to enable.
  144458. * @hidden
  144459. */
  144460. _enable(cameras: Nullable<Camera[]>): void;
  144461. /**
  144462. * Disables the effect on the given cameras
  144463. * @param cameras The camera to disable.
  144464. * @hidden
  144465. */
  144466. _disable(cameras: Camera): void;
  144467. /**
  144468. * Disables the effect on the given cameras
  144469. * @param cameras The camera to disable.
  144470. * @hidden
  144471. */
  144472. _disable(cameras: Nullable<Camera[]>): void;
  144473. /**
  144474. * Gets a list of the post processes contained in the effect.
  144475. * @param camera The camera to get the post processes on.
  144476. * @returns The list of the post processes in the effect.
  144477. */
  144478. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  144479. }
  144480. }
  144481. declare module BABYLON {
  144482. /** @hidden */
  144483. export var extractHighlightsPixelShader: {
  144484. name: string;
  144485. shader: string;
  144486. };
  144487. }
  144488. declare module BABYLON {
  144489. /**
  144490. * 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.
  144491. */
  144492. export class ExtractHighlightsPostProcess extends PostProcess {
  144493. /**
  144494. * The luminance threshold, pixels below this value will be set to black.
  144495. */
  144496. threshold: number;
  144497. /** @hidden */
  144498. _exposure: number;
  144499. /**
  144500. * Post process which has the input texture to be used when performing highlight extraction
  144501. * @hidden
  144502. */
  144503. _inputPostProcess: Nullable<PostProcess>;
  144504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144505. }
  144506. }
  144507. declare module BABYLON {
  144508. /** @hidden */
  144509. export var bloomMergePixelShader: {
  144510. name: string;
  144511. shader: string;
  144512. };
  144513. }
  144514. declare module BABYLON {
  144515. /**
  144516. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144517. */
  144518. export class BloomMergePostProcess extends PostProcess {
  144519. /** Weight of the bloom to be added to the original input. */
  144520. weight: number;
  144521. /**
  144522. * Creates a new instance of @see BloomMergePostProcess
  144523. * @param name The name of the effect.
  144524. * @param originalFromInput Post process which's input will be used for the merge.
  144525. * @param blurred Blurred highlights post process which's output will be used.
  144526. * @param weight Weight of the bloom to be added to the original input.
  144527. * @param options The required width/height ratio to downsize to before computing the render pass.
  144528. * @param camera The camera to apply the render pass to.
  144529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144530. * @param engine The engine which the post process will be applied. (default: current engine)
  144531. * @param reusable If the post process can be reused on the same frame. (default: false)
  144532. * @param textureType Type of textures used when performing the post process. (default: 0)
  144533. * @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)
  144534. */
  144535. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  144536. /** Weight of the bloom to be added to the original input. */
  144537. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144538. }
  144539. }
  144540. declare module BABYLON {
  144541. /**
  144542. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  144543. */
  144544. export class BloomEffect extends PostProcessRenderEffect {
  144545. private bloomScale;
  144546. /**
  144547. * @hidden Internal
  144548. */
  144549. _effects: Array<PostProcess>;
  144550. /**
  144551. * @hidden Internal
  144552. */
  144553. _downscale: ExtractHighlightsPostProcess;
  144554. private _blurX;
  144555. private _blurY;
  144556. private _merge;
  144557. /**
  144558. * The luminance threshold to find bright areas of the image to bloom.
  144559. */
  144560. get threshold(): number;
  144561. set threshold(value: number);
  144562. /**
  144563. * The strength of the bloom.
  144564. */
  144565. get weight(): number;
  144566. set weight(value: number);
  144567. /**
  144568. * Specifies the size of the bloom blur kernel, relative to the final output size
  144569. */
  144570. get kernel(): number;
  144571. set kernel(value: number);
  144572. /**
  144573. * Creates a new instance of @see BloomEffect
  144574. * @param scene The scene the effect belongs to.
  144575. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  144576. * @param bloomKernel The size of the kernel to be used when applying the blur.
  144577. * @param bloomWeight The the strength of bloom.
  144578. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144579. * @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)
  144580. */
  144581. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  144582. /**
  144583. * Disposes each of the internal effects for a given camera.
  144584. * @param camera The camera to dispose the effect on.
  144585. */
  144586. disposeEffects(camera: Camera): void;
  144587. /**
  144588. * @hidden Internal
  144589. */
  144590. _updateEffects(): void;
  144591. /**
  144592. * Internal
  144593. * @returns if all the contained post processes are ready.
  144594. * @hidden
  144595. */
  144596. _isReady(): boolean;
  144597. }
  144598. }
  144599. declare module BABYLON {
  144600. /** @hidden */
  144601. export var chromaticAberrationPixelShader: {
  144602. name: string;
  144603. shader: string;
  144604. };
  144605. }
  144606. declare module BABYLON {
  144607. /**
  144608. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  144609. */
  144610. export class ChromaticAberrationPostProcess extends PostProcess {
  144611. /**
  144612. * The amount of seperation of rgb channels (default: 30)
  144613. */
  144614. aberrationAmount: number;
  144615. /**
  144616. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  144617. */
  144618. radialIntensity: number;
  144619. /**
  144620. * 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))
  144621. */
  144622. direction: Vector2;
  144623. /**
  144624. * 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))
  144625. */
  144626. centerPosition: Vector2;
  144627. /**
  144628. * Creates a new instance ChromaticAberrationPostProcess
  144629. * @param name The name of the effect.
  144630. * @param screenWidth The width of the screen to apply the effect on.
  144631. * @param screenHeight The height of the screen to apply the effect on.
  144632. * @param options The required width/height ratio to downsize to before computing the render pass.
  144633. * @param camera The camera to apply the render pass to.
  144634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144635. * @param engine The engine which the post process will be applied. (default: current engine)
  144636. * @param reusable If the post process can be reused on the same frame. (default: false)
  144637. * @param textureType Type of textures used when performing the post process. (default: 0)
  144638. * @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)
  144639. */
  144640. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144641. }
  144642. }
  144643. declare module BABYLON {
  144644. /** @hidden */
  144645. export var circleOfConfusionPixelShader: {
  144646. name: string;
  144647. shader: string;
  144648. };
  144649. }
  144650. declare module BABYLON {
  144651. /**
  144652. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  144653. */
  144654. export class CircleOfConfusionPostProcess extends PostProcess {
  144655. /**
  144656. * 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.
  144657. */
  144658. lensSize: number;
  144659. /**
  144660. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144661. */
  144662. fStop: number;
  144663. /**
  144664. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144665. */
  144666. focusDistance: number;
  144667. /**
  144668. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  144669. */
  144670. focalLength: number;
  144671. private _depthTexture;
  144672. /**
  144673. * Creates a new instance CircleOfConfusionPostProcess
  144674. * @param name The name of the effect.
  144675. * @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.
  144676. * @param options The required width/height ratio to downsize to before computing the render pass.
  144677. * @param camera The camera to apply the render pass to.
  144678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144679. * @param engine The engine which the post process will be applied. (default: current engine)
  144680. * @param reusable If the post process can be reused on the same frame. (default: false)
  144681. * @param textureType Type of textures used when performing the post process. (default: 0)
  144682. * @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)
  144683. */
  144684. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144685. /**
  144686. * 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.
  144687. */
  144688. set depthTexture(value: RenderTargetTexture);
  144689. }
  144690. }
  144691. declare module BABYLON {
  144692. /** @hidden */
  144693. export var colorCorrectionPixelShader: {
  144694. name: string;
  144695. shader: string;
  144696. };
  144697. }
  144698. declare module BABYLON {
  144699. /**
  144700. *
  144701. * This post-process allows the modification of rendered colors by using
  144702. * a 'look-up table' (LUT). This effect is also called Color Grading.
  144703. *
  144704. * The object needs to be provided an url to a texture containing the color
  144705. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  144706. * Use an image editing software to tweak the LUT to match your needs.
  144707. *
  144708. * For an example of a color LUT, see here:
  144709. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  144710. * For explanations on color grading, see here:
  144711. * @see http://udn.epicgames.com/Three/ColorGrading.html
  144712. *
  144713. */
  144714. export class ColorCorrectionPostProcess extends PostProcess {
  144715. private _colorTableTexture;
  144716. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144717. }
  144718. }
  144719. declare module BABYLON {
  144720. /** @hidden */
  144721. export var convolutionPixelShader: {
  144722. name: string;
  144723. shader: string;
  144724. };
  144725. }
  144726. declare module BABYLON {
  144727. /**
  144728. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  144729. * input texture to perform effects such as edge detection or sharpening
  144730. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  144731. */
  144732. export class ConvolutionPostProcess extends PostProcess {
  144733. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144734. kernel: number[];
  144735. /**
  144736. * Creates a new instance ConvolutionPostProcess
  144737. * @param name The name of the effect.
  144738. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  144739. * @param options The required width/height ratio to downsize to before computing the render pass.
  144740. * @param camera The camera to apply the render pass to.
  144741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144742. * @param engine The engine which the post process will be applied. (default: current engine)
  144743. * @param reusable If the post process can be reused on the same frame. (default: false)
  144744. * @param textureType Type of textures used when performing the post process. (default: 0)
  144745. */
  144746. constructor(name: string,
  144747. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144748. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144749. /**
  144750. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144751. */
  144752. static EdgeDetect0Kernel: number[];
  144753. /**
  144754. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144755. */
  144756. static EdgeDetect1Kernel: number[];
  144757. /**
  144758. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144759. */
  144760. static EdgeDetect2Kernel: number[];
  144761. /**
  144762. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144763. */
  144764. static SharpenKernel: number[];
  144765. /**
  144766. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144767. */
  144768. static EmbossKernel: number[];
  144769. /**
  144770. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144771. */
  144772. static GaussianKernel: number[];
  144773. }
  144774. }
  144775. declare module BABYLON {
  144776. /**
  144777. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  144778. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  144779. * based on samples that have a large difference in distance than the center pixel.
  144780. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  144781. */
  144782. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  144783. direction: Vector2;
  144784. /**
  144785. * Creates a new instance CircleOfConfusionPostProcess
  144786. * @param name The name of the effect.
  144787. * @param scene The scene the effect belongs to.
  144788. * @param direction The direction the blur should be applied.
  144789. * @param kernel The size of the kernel used to blur.
  144790. * @param options The required width/height ratio to downsize to before computing the render pass.
  144791. * @param camera The camera to apply the render pass to.
  144792. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  144793. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  144794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144795. * @param engine The engine which the post process will be applied. (default: current engine)
  144796. * @param reusable If the post process can be reused on the same frame. (default: false)
  144797. * @param textureType Type of textures used when performing the post process. (default: 0)
  144798. * @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)
  144799. */
  144800. 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);
  144801. }
  144802. }
  144803. declare module BABYLON {
  144804. /** @hidden */
  144805. export var depthOfFieldMergePixelShader: {
  144806. name: string;
  144807. shader: string;
  144808. };
  144809. }
  144810. declare module BABYLON {
  144811. /**
  144812. * Options to be set when merging outputs from the default pipeline.
  144813. */
  144814. export class DepthOfFieldMergePostProcessOptions {
  144815. /**
  144816. * The original image to merge on top of
  144817. */
  144818. originalFromInput: PostProcess;
  144819. /**
  144820. * Parameters to perform the merge of the depth of field effect
  144821. */
  144822. depthOfField?: {
  144823. circleOfConfusion: PostProcess;
  144824. blurSteps: Array<PostProcess>;
  144825. };
  144826. /**
  144827. * Parameters to perform the merge of bloom effect
  144828. */
  144829. bloom?: {
  144830. blurred: PostProcess;
  144831. weight: number;
  144832. };
  144833. }
  144834. /**
  144835. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144836. */
  144837. export class DepthOfFieldMergePostProcess extends PostProcess {
  144838. private blurSteps;
  144839. /**
  144840. * Creates a new instance of DepthOfFieldMergePostProcess
  144841. * @param name The name of the effect.
  144842. * @param originalFromInput Post process which's input will be used for the merge.
  144843. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  144844. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  144845. * @param options The required width/height ratio to downsize to before computing the render pass.
  144846. * @param camera The camera to apply the render pass to.
  144847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144848. * @param engine The engine which the post process will be applied. (default: current engine)
  144849. * @param reusable If the post process can be reused on the same frame. (default: false)
  144850. * @param textureType Type of textures used when performing the post process. (default: 0)
  144851. * @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)
  144852. */
  144853. 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);
  144854. /**
  144855. * Updates the effect with the current post process compile time values and recompiles the shader.
  144856. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  144857. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  144858. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  144859. * @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
  144860. * @param onCompiled Called when the shader has been compiled.
  144861. * @param onError Called if there is an error when compiling a shader.
  144862. */
  144863. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  144864. }
  144865. }
  144866. declare module BABYLON {
  144867. /**
  144868. * Specifies the level of max blur that should be applied when using the depth of field effect
  144869. */
  144870. export enum DepthOfFieldEffectBlurLevel {
  144871. /**
  144872. * Subtle blur
  144873. */
  144874. Low = 0,
  144875. /**
  144876. * Medium blur
  144877. */
  144878. Medium = 1,
  144879. /**
  144880. * Large blur
  144881. */
  144882. High = 2
  144883. }
  144884. /**
  144885. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  144886. */
  144887. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  144888. private _circleOfConfusion;
  144889. /**
  144890. * @hidden Internal, blurs from high to low
  144891. */
  144892. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  144893. private _depthOfFieldBlurY;
  144894. private _dofMerge;
  144895. /**
  144896. * @hidden Internal post processes in depth of field effect
  144897. */
  144898. _effects: Array<PostProcess>;
  144899. /**
  144900. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  144901. */
  144902. set focalLength(value: number);
  144903. get focalLength(): number;
  144904. /**
  144905. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144906. */
  144907. set fStop(value: number);
  144908. get fStop(): number;
  144909. /**
  144910. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144911. */
  144912. set focusDistance(value: number);
  144913. get focusDistance(): number;
  144914. /**
  144915. * 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.
  144916. */
  144917. set lensSize(value: number);
  144918. get lensSize(): number;
  144919. /**
  144920. * Creates a new instance DepthOfFieldEffect
  144921. * @param scene The scene the effect belongs to.
  144922. * @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.
  144923. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144924. * @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)
  144925. */
  144926. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  144927. /**
  144928. * Get the current class name of the current effet
  144929. * @returns "DepthOfFieldEffect"
  144930. */
  144931. getClassName(): string;
  144932. /**
  144933. * 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.
  144934. */
  144935. set depthTexture(value: RenderTargetTexture);
  144936. /**
  144937. * Disposes each of the internal effects for a given camera.
  144938. * @param camera The camera to dispose the effect on.
  144939. */
  144940. disposeEffects(camera: Camera): void;
  144941. /**
  144942. * @hidden Internal
  144943. */
  144944. _updateEffects(): void;
  144945. /**
  144946. * Internal
  144947. * @returns if all the contained post processes are ready.
  144948. * @hidden
  144949. */
  144950. _isReady(): boolean;
  144951. }
  144952. }
  144953. declare module BABYLON {
  144954. /** @hidden */
  144955. export var displayPassPixelShader: {
  144956. name: string;
  144957. shader: string;
  144958. };
  144959. }
  144960. declare module BABYLON {
  144961. /**
  144962. * DisplayPassPostProcess which produces an output the same as it's input
  144963. */
  144964. export class DisplayPassPostProcess extends PostProcess {
  144965. /**
  144966. * Creates the DisplayPassPostProcess
  144967. * @param name The name of the effect.
  144968. * @param options The required width/height ratio to downsize to before computing the render pass.
  144969. * @param camera The camera to apply the render pass to.
  144970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144971. * @param engine The engine which the post process will be applied. (default: current engine)
  144972. * @param reusable If the post process can be reused on the same frame. (default: false)
  144973. */
  144974. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144975. }
  144976. }
  144977. declare module BABYLON {
  144978. /** @hidden */
  144979. export var filterPixelShader: {
  144980. name: string;
  144981. shader: string;
  144982. };
  144983. }
  144984. declare module BABYLON {
  144985. /**
  144986. * Applies a kernel filter to the image
  144987. */
  144988. export class FilterPostProcess extends PostProcess {
  144989. /** The matrix to be applied to the image */
  144990. kernelMatrix: Matrix;
  144991. /**
  144992. *
  144993. * @param name The name of the effect.
  144994. * @param kernelMatrix The matrix to be applied to the image
  144995. * @param options The required width/height ratio to downsize to before computing the render pass.
  144996. * @param camera The camera to apply the render pass to.
  144997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144998. * @param engine The engine which the post process will be applied. (default: current engine)
  144999. * @param reusable If the post process can be reused on the same frame. (default: false)
  145000. */
  145001. constructor(name: string,
  145002. /** The matrix to be applied to the image */
  145003. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145004. }
  145005. }
  145006. declare module BABYLON {
  145007. /** @hidden */
  145008. export var fxaaPixelShader: {
  145009. name: string;
  145010. shader: string;
  145011. };
  145012. }
  145013. declare module BABYLON {
  145014. /** @hidden */
  145015. export var fxaaVertexShader: {
  145016. name: string;
  145017. shader: string;
  145018. };
  145019. }
  145020. declare module BABYLON {
  145021. /**
  145022. * Fxaa post process
  145023. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  145024. */
  145025. export class FxaaPostProcess extends PostProcess {
  145026. /** @hidden */
  145027. texelWidth: number;
  145028. /** @hidden */
  145029. texelHeight: number;
  145030. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145031. private _getDefines;
  145032. }
  145033. }
  145034. declare module BABYLON {
  145035. /** @hidden */
  145036. export var grainPixelShader: {
  145037. name: string;
  145038. shader: string;
  145039. };
  145040. }
  145041. declare module BABYLON {
  145042. /**
  145043. * The GrainPostProcess adds noise to the image at mid luminance levels
  145044. */
  145045. export class GrainPostProcess extends PostProcess {
  145046. /**
  145047. * The intensity of the grain added (default: 30)
  145048. */
  145049. intensity: number;
  145050. /**
  145051. * If the grain should be randomized on every frame
  145052. */
  145053. animated: boolean;
  145054. /**
  145055. * Creates a new instance of @see GrainPostProcess
  145056. * @param name The name of the effect.
  145057. * @param options The required width/height ratio to downsize to before computing the render pass.
  145058. * @param camera The camera to apply the render pass to.
  145059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145060. * @param engine The engine which the post process will be applied. (default: current engine)
  145061. * @param reusable If the post process can be reused on the same frame. (default: false)
  145062. * @param textureType Type of textures used when performing the post process. (default: 0)
  145063. * @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)
  145064. */
  145065. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145066. }
  145067. }
  145068. declare module BABYLON {
  145069. /** @hidden */
  145070. export var highlightsPixelShader: {
  145071. name: string;
  145072. shader: string;
  145073. };
  145074. }
  145075. declare module BABYLON {
  145076. /**
  145077. * Extracts highlights from the image
  145078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145079. */
  145080. export class HighlightsPostProcess extends PostProcess {
  145081. /**
  145082. * Extracts highlights from the image
  145083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145084. * @param name The name of the effect.
  145085. * @param options The required width/height ratio to downsize to before computing the render pass.
  145086. * @param camera The camera to apply the render pass to.
  145087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145088. * @param engine The engine which the post process will be applied. (default: current engine)
  145089. * @param reusable If the post process can be reused on the same frame. (default: false)
  145090. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  145091. */
  145092. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145093. }
  145094. }
  145095. declare module BABYLON {
  145096. /** @hidden */
  145097. export var mrtFragmentDeclaration: {
  145098. name: string;
  145099. shader: string;
  145100. };
  145101. }
  145102. declare module BABYLON {
  145103. /** @hidden */
  145104. export var geometryPixelShader: {
  145105. name: string;
  145106. shader: string;
  145107. };
  145108. }
  145109. declare module BABYLON {
  145110. /** @hidden */
  145111. export var geometryVertexShader: {
  145112. name: string;
  145113. shader: string;
  145114. };
  145115. }
  145116. declare module BABYLON {
  145117. /** @hidden */
  145118. interface ISavedTransformationMatrix {
  145119. world: Matrix;
  145120. viewProjection: Matrix;
  145121. }
  145122. /**
  145123. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  145124. */
  145125. export class GeometryBufferRenderer {
  145126. /**
  145127. * Constant used to retrieve the position texture index in the G-Buffer textures array
  145128. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  145129. */
  145130. static readonly POSITION_TEXTURE_TYPE: number;
  145131. /**
  145132. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  145133. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  145134. */
  145135. static readonly VELOCITY_TEXTURE_TYPE: number;
  145136. /**
  145137. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  145138. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  145139. */
  145140. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  145141. /**
  145142. * Dictionary used to store the previous transformation matrices of each rendered mesh
  145143. * in order to compute objects velocities when enableVelocity is set to "true"
  145144. * @hidden
  145145. */
  145146. _previousTransformationMatrices: {
  145147. [index: number]: ISavedTransformationMatrix;
  145148. };
  145149. /**
  145150. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  145151. * in order to compute objects velocities when enableVelocity is set to "true"
  145152. * @hidden
  145153. */
  145154. _previousBonesTransformationMatrices: {
  145155. [index: number]: Float32Array;
  145156. };
  145157. /**
  145158. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  145159. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  145160. */
  145161. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  145162. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  145163. renderTransparentMeshes: boolean;
  145164. private _scene;
  145165. private _multiRenderTarget;
  145166. private _ratio;
  145167. private _enablePosition;
  145168. private _enableVelocity;
  145169. private _enableReflectivity;
  145170. private _positionIndex;
  145171. private _velocityIndex;
  145172. private _reflectivityIndex;
  145173. protected _effect: Effect;
  145174. protected _cachedDefines: string;
  145175. /**
  145176. * Set the render list (meshes to be rendered) used in the G buffer.
  145177. */
  145178. set renderList(meshes: Mesh[]);
  145179. /**
  145180. * Gets wether or not G buffer are supported by the running hardware.
  145181. * This requires draw buffer supports
  145182. */
  145183. get isSupported(): boolean;
  145184. /**
  145185. * Returns the index of the given texture type in the G-Buffer textures array
  145186. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  145187. * @returns the index of the given texture type in the G-Buffer textures array
  145188. */
  145189. getTextureIndex(textureType: number): number;
  145190. /**
  145191. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  145192. */
  145193. get enablePosition(): boolean;
  145194. /**
  145195. * Sets whether or not objects positions are enabled for the G buffer.
  145196. */
  145197. set enablePosition(enable: boolean);
  145198. /**
  145199. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  145200. */
  145201. get enableVelocity(): boolean;
  145202. /**
  145203. * Sets wether or not objects velocities are enabled for the G buffer.
  145204. */
  145205. set enableVelocity(enable: boolean);
  145206. /**
  145207. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  145208. */
  145209. get enableReflectivity(): boolean;
  145210. /**
  145211. * Sets wether or not objects roughness are enabled for the G buffer.
  145212. */
  145213. set enableReflectivity(enable: boolean);
  145214. /**
  145215. * Gets the scene associated with the buffer.
  145216. */
  145217. get scene(): Scene;
  145218. /**
  145219. * Gets the ratio used by the buffer during its creation.
  145220. * How big is the buffer related to the main canvas.
  145221. */
  145222. get ratio(): number;
  145223. /** @hidden */
  145224. static _SceneComponentInitialization: (scene: Scene) => void;
  145225. /**
  145226. * Creates a new G Buffer for the scene
  145227. * @param scene The scene the buffer belongs to
  145228. * @param ratio How big is the buffer related to the main canvas.
  145229. */
  145230. constructor(scene: Scene, ratio?: number);
  145231. /**
  145232. * Checks wether everything is ready to render a submesh to the G buffer.
  145233. * @param subMesh the submesh to check readiness for
  145234. * @param useInstances is the mesh drawn using instance or not
  145235. * @returns true if ready otherwise false
  145236. */
  145237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  145238. /**
  145239. * Gets the current underlying G Buffer.
  145240. * @returns the buffer
  145241. */
  145242. getGBuffer(): MultiRenderTarget;
  145243. /**
  145244. * Gets the number of samples used to render the buffer (anti aliasing).
  145245. */
  145246. get samples(): number;
  145247. /**
  145248. * Sets the number of samples used to render the buffer (anti aliasing).
  145249. */
  145250. set samples(value: number);
  145251. /**
  145252. * Disposes the renderer and frees up associated resources.
  145253. */
  145254. dispose(): void;
  145255. protected _createRenderTargets(): void;
  145256. private _copyBonesTransformationMatrices;
  145257. }
  145258. }
  145259. declare module BABYLON {
  145260. interface Scene {
  145261. /** @hidden (Backing field) */
  145262. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145263. /**
  145264. * Gets or Sets the current geometry buffer associated to the scene.
  145265. */
  145266. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145267. /**
  145268. * Enables a GeometryBufferRender and associates it with the scene
  145269. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  145270. * @returns the GeometryBufferRenderer
  145271. */
  145272. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  145273. /**
  145274. * Disables the GeometryBufferRender associated with the scene
  145275. */
  145276. disableGeometryBufferRenderer(): void;
  145277. }
  145278. /**
  145279. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  145280. * in several rendering techniques.
  145281. */
  145282. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  145283. /**
  145284. * The component name helpful to identify the component in the list of scene components.
  145285. */
  145286. readonly name: string;
  145287. /**
  145288. * The scene the component belongs to.
  145289. */
  145290. scene: Scene;
  145291. /**
  145292. * Creates a new instance of the component for the given scene
  145293. * @param scene Defines the scene to register the component in
  145294. */
  145295. constructor(scene: Scene);
  145296. /**
  145297. * Registers the component in a given scene
  145298. */
  145299. register(): void;
  145300. /**
  145301. * Rebuilds the elements related to this component in case of
  145302. * context lost for instance.
  145303. */
  145304. rebuild(): void;
  145305. /**
  145306. * Disposes the component and the associated ressources
  145307. */
  145308. dispose(): void;
  145309. private _gatherRenderTargets;
  145310. }
  145311. }
  145312. declare module BABYLON {
  145313. /** @hidden */
  145314. export var motionBlurPixelShader: {
  145315. name: string;
  145316. shader: string;
  145317. };
  145318. }
  145319. declare module BABYLON {
  145320. /**
  145321. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  145322. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  145323. * As an example, all you have to do is to create the post-process:
  145324. * var mb = new BABYLON.MotionBlurPostProcess(
  145325. * 'mb', // The name of the effect.
  145326. * scene, // The scene containing the objects to blur according to their velocity.
  145327. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  145328. * camera // The camera to apply the render pass to.
  145329. * );
  145330. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  145331. */
  145332. export class MotionBlurPostProcess extends PostProcess {
  145333. /**
  145334. * Defines how much the image is blurred by the movement. Default value is equal to 1
  145335. */
  145336. motionStrength: number;
  145337. /**
  145338. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  145339. */
  145340. get motionBlurSamples(): number;
  145341. /**
  145342. * Sets the number of iterations to be used for motion blur quality
  145343. */
  145344. set motionBlurSamples(samples: number);
  145345. private _motionBlurSamples;
  145346. private _geometryBufferRenderer;
  145347. /**
  145348. * Creates a new instance MotionBlurPostProcess
  145349. * @param name The name of the effect.
  145350. * @param scene The scene containing the objects to blur according to their velocity.
  145351. * @param options The required width/height ratio to downsize to before computing the render pass.
  145352. * @param camera The camera to apply the render pass to.
  145353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145354. * @param engine The engine which the post process will be applied. (default: current engine)
  145355. * @param reusable If the post process can be reused on the same frame. (default: false)
  145356. * @param textureType Type of textures used when performing the post process. (default: 0)
  145357. * @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)
  145358. */
  145359. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145360. /**
  145361. * Excludes the given skinned mesh from computing bones velocities.
  145362. * 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.
  145363. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  145364. */
  145365. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145366. /**
  145367. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  145368. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  145369. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  145370. */
  145371. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145372. /**
  145373. * Disposes the post process.
  145374. * @param camera The camera to dispose the post process on.
  145375. */
  145376. dispose(camera?: Camera): void;
  145377. }
  145378. }
  145379. declare module BABYLON {
  145380. /** @hidden */
  145381. export var refractionPixelShader: {
  145382. name: string;
  145383. shader: string;
  145384. };
  145385. }
  145386. declare module BABYLON {
  145387. /**
  145388. * Post process which applies a refractin texture
  145389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145390. */
  145391. export class RefractionPostProcess extends PostProcess {
  145392. /** the base color of the refraction (used to taint the rendering) */
  145393. color: Color3;
  145394. /** simulated refraction depth */
  145395. depth: number;
  145396. /** the coefficient of the base color (0 to remove base color tainting) */
  145397. colorLevel: number;
  145398. private _refTexture;
  145399. private _ownRefractionTexture;
  145400. /**
  145401. * Gets or sets the refraction texture
  145402. * Please note that you are responsible for disposing the texture if you set it manually
  145403. */
  145404. get refractionTexture(): Texture;
  145405. set refractionTexture(value: Texture);
  145406. /**
  145407. * Initializes the RefractionPostProcess
  145408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145409. * @param name The name of the effect.
  145410. * @param refractionTextureUrl Url of the refraction texture to use
  145411. * @param color the base color of the refraction (used to taint the rendering)
  145412. * @param depth simulated refraction depth
  145413. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  145414. * @param camera The camera to apply the render pass to.
  145415. * @param options The required width/height ratio to downsize to before computing the render pass.
  145416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145417. * @param engine The engine which the post process will be applied. (default: current engine)
  145418. * @param reusable If the post process can be reused on the same frame. (default: false)
  145419. */
  145420. constructor(name: string, refractionTextureUrl: string,
  145421. /** the base color of the refraction (used to taint the rendering) */
  145422. color: Color3,
  145423. /** simulated refraction depth */
  145424. depth: number,
  145425. /** the coefficient of the base color (0 to remove base color tainting) */
  145426. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145427. /**
  145428. * Disposes of the post process
  145429. * @param camera Camera to dispose post process on
  145430. */
  145431. dispose(camera: Camera): void;
  145432. }
  145433. }
  145434. declare module BABYLON {
  145435. /** @hidden */
  145436. export var sharpenPixelShader: {
  145437. name: string;
  145438. shader: string;
  145439. };
  145440. }
  145441. declare module BABYLON {
  145442. /**
  145443. * The SharpenPostProcess applies a sharpen kernel to every pixel
  145444. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145445. */
  145446. export class SharpenPostProcess extends PostProcess {
  145447. /**
  145448. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  145449. */
  145450. colorAmount: number;
  145451. /**
  145452. * How much sharpness should be applied (default: 0.3)
  145453. */
  145454. edgeAmount: number;
  145455. /**
  145456. * Creates a new instance ConvolutionPostProcess
  145457. * @param name The name of the effect.
  145458. * @param options The required width/height ratio to downsize to before computing the render pass.
  145459. * @param camera The camera to apply the render pass to.
  145460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145461. * @param engine The engine which the post process will be applied. (default: current engine)
  145462. * @param reusable If the post process can be reused on the same frame. (default: false)
  145463. * @param textureType Type of textures used when performing the post process. (default: 0)
  145464. * @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)
  145465. */
  145466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145467. }
  145468. }
  145469. declare module BABYLON {
  145470. /**
  145471. * PostProcessRenderPipeline
  145472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145473. */
  145474. export class PostProcessRenderPipeline {
  145475. private engine;
  145476. private _renderEffects;
  145477. private _renderEffectsForIsolatedPass;
  145478. /**
  145479. * List of inspectable custom properties (used by the Inspector)
  145480. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  145481. */
  145482. inspectableCustomProperties: IInspectable[];
  145483. /**
  145484. * @hidden
  145485. */
  145486. protected _cameras: Camera[];
  145487. /** @hidden */
  145488. _name: string;
  145489. /**
  145490. * Gets pipeline name
  145491. */
  145492. get name(): string;
  145493. /** Gets the list of attached cameras */
  145494. get cameras(): Camera[];
  145495. /**
  145496. * Initializes a PostProcessRenderPipeline
  145497. * @param engine engine to add the pipeline to
  145498. * @param name name of the pipeline
  145499. */
  145500. constructor(engine: Engine, name: string);
  145501. /**
  145502. * Gets the class name
  145503. * @returns "PostProcessRenderPipeline"
  145504. */
  145505. getClassName(): string;
  145506. /**
  145507. * If all the render effects in the pipeline are supported
  145508. */
  145509. get isSupported(): boolean;
  145510. /**
  145511. * Adds an effect to the pipeline
  145512. * @param renderEffect the effect to add
  145513. */
  145514. addEffect(renderEffect: PostProcessRenderEffect): void;
  145515. /** @hidden */
  145516. _rebuild(): void;
  145517. /** @hidden */
  145518. _enableEffect(renderEffectName: string, cameras: Camera): void;
  145519. /** @hidden */
  145520. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  145521. /** @hidden */
  145522. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145523. /** @hidden */
  145524. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145525. /** @hidden */
  145526. _attachCameras(cameras: Camera, unique: boolean): void;
  145527. /** @hidden */
  145528. _attachCameras(cameras: Camera[], unique: boolean): void;
  145529. /** @hidden */
  145530. _detachCameras(cameras: Camera): void;
  145531. /** @hidden */
  145532. _detachCameras(cameras: Nullable<Camera[]>): void;
  145533. /** @hidden */
  145534. _update(): void;
  145535. /** @hidden */
  145536. _reset(): void;
  145537. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  145538. /**
  145539. * Disposes of the pipeline
  145540. */
  145541. dispose(): void;
  145542. }
  145543. }
  145544. declare module BABYLON {
  145545. /**
  145546. * PostProcessRenderPipelineManager class
  145547. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145548. */
  145549. export class PostProcessRenderPipelineManager {
  145550. private _renderPipelines;
  145551. /**
  145552. * Initializes a PostProcessRenderPipelineManager
  145553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145554. */
  145555. constructor();
  145556. /**
  145557. * Gets the list of supported render pipelines
  145558. */
  145559. get supportedPipelines(): PostProcessRenderPipeline[];
  145560. /**
  145561. * Adds a pipeline to the manager
  145562. * @param renderPipeline The pipeline to add
  145563. */
  145564. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  145565. /**
  145566. * Attaches a camera to the pipeline
  145567. * @param renderPipelineName The name of the pipeline to attach to
  145568. * @param cameras the camera to attach
  145569. * @param unique if the camera can be attached multiple times to the pipeline
  145570. */
  145571. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  145572. /**
  145573. * Detaches a camera from the pipeline
  145574. * @param renderPipelineName The name of the pipeline to detach from
  145575. * @param cameras the camera to detach
  145576. */
  145577. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  145578. /**
  145579. * Enables an effect by name on a pipeline
  145580. * @param renderPipelineName the name of the pipeline to enable the effect in
  145581. * @param renderEffectName the name of the effect to enable
  145582. * @param cameras the cameras that the effect should be enabled on
  145583. */
  145584. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145585. /**
  145586. * Disables an effect by name on a pipeline
  145587. * @param renderPipelineName the name of the pipeline to disable the effect in
  145588. * @param renderEffectName the name of the effect to disable
  145589. * @param cameras the cameras that the effect should be disabled on
  145590. */
  145591. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145592. /**
  145593. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  145594. */
  145595. update(): void;
  145596. /** @hidden */
  145597. _rebuild(): void;
  145598. /**
  145599. * Disposes of the manager and pipelines
  145600. */
  145601. dispose(): void;
  145602. }
  145603. }
  145604. declare module BABYLON {
  145605. interface Scene {
  145606. /** @hidden (Backing field) */
  145607. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145608. /**
  145609. * Gets the postprocess render pipeline manager
  145610. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145611. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145612. */
  145613. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145614. }
  145615. /**
  145616. * Defines the Render Pipeline scene component responsible to rendering pipelines
  145617. */
  145618. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  145619. /**
  145620. * The component name helpfull to identify the component in the list of scene components.
  145621. */
  145622. readonly name: string;
  145623. /**
  145624. * The scene the component belongs to.
  145625. */
  145626. scene: Scene;
  145627. /**
  145628. * Creates a new instance of the component for the given scene
  145629. * @param scene Defines the scene to register the component in
  145630. */
  145631. constructor(scene: Scene);
  145632. /**
  145633. * Registers the component in a given scene
  145634. */
  145635. register(): void;
  145636. /**
  145637. * Rebuilds the elements related to this component in case of
  145638. * context lost for instance.
  145639. */
  145640. rebuild(): void;
  145641. /**
  145642. * Disposes the component and the associated ressources
  145643. */
  145644. dispose(): void;
  145645. private _gatherRenderTargets;
  145646. }
  145647. }
  145648. declare module BABYLON {
  145649. /**
  145650. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  145651. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145652. */
  145653. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  145654. private _scene;
  145655. private _camerasToBeAttached;
  145656. /**
  145657. * ID of the sharpen post process,
  145658. */
  145659. private readonly SharpenPostProcessId;
  145660. /**
  145661. * @ignore
  145662. * ID of the image processing post process;
  145663. */
  145664. readonly ImageProcessingPostProcessId: string;
  145665. /**
  145666. * @ignore
  145667. * ID of the Fast Approximate Anti-Aliasing post process;
  145668. */
  145669. readonly FxaaPostProcessId: string;
  145670. /**
  145671. * ID of the chromatic aberration post process,
  145672. */
  145673. private readonly ChromaticAberrationPostProcessId;
  145674. /**
  145675. * ID of the grain post process
  145676. */
  145677. private readonly GrainPostProcessId;
  145678. /**
  145679. * Sharpen post process which will apply a sharpen convolution to enhance edges
  145680. */
  145681. sharpen: SharpenPostProcess;
  145682. private _sharpenEffect;
  145683. private bloom;
  145684. /**
  145685. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  145686. */
  145687. depthOfField: DepthOfFieldEffect;
  145688. /**
  145689. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  145690. */
  145691. fxaa: FxaaPostProcess;
  145692. /**
  145693. * Image post processing pass used to perform operations such as tone mapping or color grading.
  145694. */
  145695. imageProcessing: ImageProcessingPostProcess;
  145696. /**
  145697. * Chromatic aberration post process which will shift rgb colors in the image
  145698. */
  145699. chromaticAberration: ChromaticAberrationPostProcess;
  145700. private _chromaticAberrationEffect;
  145701. /**
  145702. * Grain post process which add noise to the image
  145703. */
  145704. grain: GrainPostProcess;
  145705. private _grainEffect;
  145706. /**
  145707. * Glow post process which adds a glow to emissive areas of the image
  145708. */
  145709. private _glowLayer;
  145710. /**
  145711. * Animations which can be used to tweak settings over a period of time
  145712. */
  145713. animations: Animation[];
  145714. private _imageProcessingConfigurationObserver;
  145715. private _sharpenEnabled;
  145716. private _bloomEnabled;
  145717. private _depthOfFieldEnabled;
  145718. private _depthOfFieldBlurLevel;
  145719. private _fxaaEnabled;
  145720. private _imageProcessingEnabled;
  145721. private _defaultPipelineTextureType;
  145722. private _bloomScale;
  145723. private _chromaticAberrationEnabled;
  145724. private _grainEnabled;
  145725. private _buildAllowed;
  145726. /**
  145727. * Gets active scene
  145728. */
  145729. get scene(): Scene;
  145730. /**
  145731. * Enable or disable the sharpen process from the pipeline
  145732. */
  145733. set sharpenEnabled(enabled: boolean);
  145734. get sharpenEnabled(): boolean;
  145735. private _resizeObserver;
  145736. private _hardwareScaleLevel;
  145737. private _bloomKernel;
  145738. /**
  145739. * Specifies the size of the bloom blur kernel, relative to the final output size
  145740. */
  145741. get bloomKernel(): number;
  145742. set bloomKernel(value: number);
  145743. /**
  145744. * Specifies the weight of the bloom in the final rendering
  145745. */
  145746. private _bloomWeight;
  145747. /**
  145748. * Specifies the luma threshold for the area that will be blurred by the bloom
  145749. */
  145750. private _bloomThreshold;
  145751. private _hdr;
  145752. /**
  145753. * The strength of the bloom.
  145754. */
  145755. set bloomWeight(value: number);
  145756. get bloomWeight(): number;
  145757. /**
  145758. * The strength of the bloom.
  145759. */
  145760. set bloomThreshold(value: number);
  145761. get bloomThreshold(): number;
  145762. /**
  145763. * The scale of the bloom, lower value will provide better performance.
  145764. */
  145765. set bloomScale(value: number);
  145766. get bloomScale(): number;
  145767. /**
  145768. * Enable or disable the bloom from the pipeline
  145769. */
  145770. set bloomEnabled(enabled: boolean);
  145771. get bloomEnabled(): boolean;
  145772. private _rebuildBloom;
  145773. /**
  145774. * If the depth of field is enabled.
  145775. */
  145776. get depthOfFieldEnabled(): boolean;
  145777. set depthOfFieldEnabled(enabled: boolean);
  145778. /**
  145779. * Blur level of the depth of field effect. (Higher blur will effect performance)
  145780. */
  145781. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  145782. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  145783. /**
  145784. * If the anti aliasing is enabled.
  145785. */
  145786. set fxaaEnabled(enabled: boolean);
  145787. get fxaaEnabled(): boolean;
  145788. private _samples;
  145789. /**
  145790. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  145791. */
  145792. set samples(sampleCount: number);
  145793. get samples(): number;
  145794. /**
  145795. * If image processing is enabled.
  145796. */
  145797. set imageProcessingEnabled(enabled: boolean);
  145798. get imageProcessingEnabled(): boolean;
  145799. /**
  145800. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  145801. */
  145802. set glowLayerEnabled(enabled: boolean);
  145803. get glowLayerEnabled(): boolean;
  145804. /**
  145805. * Gets the glow layer (or null if not defined)
  145806. */
  145807. get glowLayer(): Nullable<GlowLayer>;
  145808. /**
  145809. * Enable or disable the chromaticAberration process from the pipeline
  145810. */
  145811. set chromaticAberrationEnabled(enabled: boolean);
  145812. get chromaticAberrationEnabled(): boolean;
  145813. /**
  145814. * Enable or disable the grain process from the pipeline
  145815. */
  145816. set grainEnabled(enabled: boolean);
  145817. get grainEnabled(): boolean;
  145818. /**
  145819. * @constructor
  145820. * @param name - The rendering pipeline name (default: "")
  145821. * @param hdr - If high dynamic range textures should be used (default: true)
  145822. * @param scene - The scene linked to this pipeline (default: the last created scene)
  145823. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  145824. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  145825. */
  145826. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  145827. /**
  145828. * Get the class name
  145829. * @returns "DefaultRenderingPipeline"
  145830. */
  145831. getClassName(): string;
  145832. /**
  145833. * Force the compilation of the entire pipeline.
  145834. */
  145835. prepare(): void;
  145836. private _hasCleared;
  145837. private _prevPostProcess;
  145838. private _prevPrevPostProcess;
  145839. private _setAutoClearAndTextureSharing;
  145840. private _depthOfFieldSceneObserver;
  145841. private _buildPipeline;
  145842. private _disposePostProcesses;
  145843. /**
  145844. * Adds a camera to the pipeline
  145845. * @param camera the camera to be added
  145846. */
  145847. addCamera(camera: Camera): void;
  145848. /**
  145849. * Removes a camera from the pipeline
  145850. * @param camera the camera to remove
  145851. */
  145852. removeCamera(camera: Camera): void;
  145853. /**
  145854. * Dispose of the pipeline and stop all post processes
  145855. */
  145856. dispose(): void;
  145857. /**
  145858. * Serialize the rendering pipeline (Used when exporting)
  145859. * @returns the serialized object
  145860. */
  145861. serialize(): any;
  145862. /**
  145863. * Parse the serialized pipeline
  145864. * @param source Source pipeline.
  145865. * @param scene The scene to load the pipeline to.
  145866. * @param rootUrl The URL of the serialized pipeline.
  145867. * @returns An instantiated pipeline from the serialized object.
  145868. */
  145869. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  145870. }
  145871. }
  145872. declare module BABYLON {
  145873. /** @hidden */
  145874. export var lensHighlightsPixelShader: {
  145875. name: string;
  145876. shader: string;
  145877. };
  145878. }
  145879. declare module BABYLON {
  145880. /** @hidden */
  145881. export var depthOfFieldPixelShader: {
  145882. name: string;
  145883. shader: string;
  145884. };
  145885. }
  145886. declare module BABYLON {
  145887. /**
  145888. * BABYLON.JS Chromatic Aberration GLSL Shader
  145889. * Author: Olivier Guyot
  145890. * Separates very slightly R, G and B colors on the edges of the screen
  145891. * Inspired by Francois Tarlier & Martins Upitis
  145892. */
  145893. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  145894. /**
  145895. * @ignore
  145896. * The chromatic aberration PostProcess id in the pipeline
  145897. */
  145898. LensChromaticAberrationEffect: string;
  145899. /**
  145900. * @ignore
  145901. * The highlights enhancing PostProcess id in the pipeline
  145902. */
  145903. HighlightsEnhancingEffect: string;
  145904. /**
  145905. * @ignore
  145906. * The depth-of-field PostProcess id in the pipeline
  145907. */
  145908. LensDepthOfFieldEffect: string;
  145909. private _scene;
  145910. private _depthTexture;
  145911. private _grainTexture;
  145912. private _chromaticAberrationPostProcess;
  145913. private _highlightsPostProcess;
  145914. private _depthOfFieldPostProcess;
  145915. private _edgeBlur;
  145916. private _grainAmount;
  145917. private _chromaticAberration;
  145918. private _distortion;
  145919. private _highlightsGain;
  145920. private _highlightsThreshold;
  145921. private _dofDistance;
  145922. private _dofAperture;
  145923. private _dofDarken;
  145924. private _dofPentagon;
  145925. private _blurNoise;
  145926. /**
  145927. * @constructor
  145928. *
  145929. * Effect parameters are as follow:
  145930. * {
  145931. * chromatic_aberration: number; // from 0 to x (1 for realism)
  145932. * edge_blur: number; // from 0 to x (1 for realism)
  145933. * distortion: number; // from 0 to x (1 for realism)
  145934. * grain_amount: number; // from 0 to 1
  145935. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  145936. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  145937. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  145938. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  145939. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  145940. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  145941. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  145942. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  145943. * }
  145944. * Note: if an effect parameter is unset, effect is disabled
  145945. *
  145946. * @param name The rendering pipeline name
  145947. * @param parameters - An object containing all parameters (see above)
  145948. * @param scene The scene linked to this pipeline
  145949. * @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)
  145950. * @param cameras The array of cameras that the rendering pipeline will be attached to
  145951. */
  145952. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  145953. /**
  145954. * Get the class name
  145955. * @returns "LensRenderingPipeline"
  145956. */
  145957. getClassName(): string;
  145958. /**
  145959. * Gets associated scene
  145960. */
  145961. get scene(): Scene;
  145962. /**
  145963. * Gets or sets the edge blur
  145964. */
  145965. get edgeBlur(): number;
  145966. set edgeBlur(value: number);
  145967. /**
  145968. * Gets or sets the grain amount
  145969. */
  145970. get grainAmount(): number;
  145971. set grainAmount(value: number);
  145972. /**
  145973. * Gets or sets the chromatic aberration amount
  145974. */
  145975. get chromaticAberration(): number;
  145976. set chromaticAberration(value: number);
  145977. /**
  145978. * Gets or sets the depth of field aperture
  145979. */
  145980. get dofAperture(): number;
  145981. set dofAperture(value: number);
  145982. /**
  145983. * Gets or sets the edge distortion
  145984. */
  145985. get edgeDistortion(): number;
  145986. set edgeDistortion(value: number);
  145987. /**
  145988. * Gets or sets the depth of field distortion
  145989. */
  145990. get dofDistortion(): number;
  145991. set dofDistortion(value: number);
  145992. /**
  145993. * Gets or sets the darken out of focus amount
  145994. */
  145995. get darkenOutOfFocus(): number;
  145996. set darkenOutOfFocus(value: number);
  145997. /**
  145998. * Gets or sets a boolean indicating if blur noise is enabled
  145999. */
  146000. get blurNoise(): boolean;
  146001. set blurNoise(value: boolean);
  146002. /**
  146003. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  146004. */
  146005. get pentagonBokeh(): boolean;
  146006. set pentagonBokeh(value: boolean);
  146007. /**
  146008. * Gets or sets the highlight grain amount
  146009. */
  146010. get highlightsGain(): number;
  146011. set highlightsGain(value: number);
  146012. /**
  146013. * Gets or sets the highlight threshold
  146014. */
  146015. get highlightsThreshold(): number;
  146016. set highlightsThreshold(value: number);
  146017. /**
  146018. * Sets the amount of blur at the edges
  146019. * @param amount blur amount
  146020. */
  146021. setEdgeBlur(amount: number): void;
  146022. /**
  146023. * Sets edge blur to 0
  146024. */
  146025. disableEdgeBlur(): void;
  146026. /**
  146027. * Sets the amout of grain
  146028. * @param amount Amount of grain
  146029. */
  146030. setGrainAmount(amount: number): void;
  146031. /**
  146032. * Set grain amount to 0
  146033. */
  146034. disableGrain(): void;
  146035. /**
  146036. * Sets the chromatic aberration amount
  146037. * @param amount amount of chromatic aberration
  146038. */
  146039. setChromaticAberration(amount: number): void;
  146040. /**
  146041. * Sets chromatic aberration amount to 0
  146042. */
  146043. disableChromaticAberration(): void;
  146044. /**
  146045. * Sets the EdgeDistortion amount
  146046. * @param amount amount of EdgeDistortion
  146047. */
  146048. setEdgeDistortion(amount: number): void;
  146049. /**
  146050. * Sets edge distortion to 0
  146051. */
  146052. disableEdgeDistortion(): void;
  146053. /**
  146054. * Sets the FocusDistance amount
  146055. * @param amount amount of FocusDistance
  146056. */
  146057. setFocusDistance(amount: number): void;
  146058. /**
  146059. * Disables depth of field
  146060. */
  146061. disableDepthOfField(): void;
  146062. /**
  146063. * Sets the Aperture amount
  146064. * @param amount amount of Aperture
  146065. */
  146066. setAperture(amount: number): void;
  146067. /**
  146068. * Sets the DarkenOutOfFocus amount
  146069. * @param amount amount of DarkenOutOfFocus
  146070. */
  146071. setDarkenOutOfFocus(amount: number): void;
  146072. private _pentagonBokehIsEnabled;
  146073. /**
  146074. * Creates a pentagon bokeh effect
  146075. */
  146076. enablePentagonBokeh(): void;
  146077. /**
  146078. * Disables the pentagon bokeh effect
  146079. */
  146080. disablePentagonBokeh(): void;
  146081. /**
  146082. * Enables noise blur
  146083. */
  146084. enableNoiseBlur(): void;
  146085. /**
  146086. * Disables noise blur
  146087. */
  146088. disableNoiseBlur(): void;
  146089. /**
  146090. * Sets the HighlightsGain amount
  146091. * @param amount amount of HighlightsGain
  146092. */
  146093. setHighlightsGain(amount: number): void;
  146094. /**
  146095. * Sets the HighlightsThreshold amount
  146096. * @param amount amount of HighlightsThreshold
  146097. */
  146098. setHighlightsThreshold(amount: number): void;
  146099. /**
  146100. * Disables highlights
  146101. */
  146102. disableHighlights(): void;
  146103. /**
  146104. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  146105. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  146106. */
  146107. dispose(disableDepthRender?: boolean): void;
  146108. private _createChromaticAberrationPostProcess;
  146109. private _createHighlightsPostProcess;
  146110. private _createDepthOfFieldPostProcess;
  146111. private _createGrainTexture;
  146112. }
  146113. }
  146114. declare module BABYLON {
  146115. /** @hidden */
  146116. export var ssao2PixelShader: {
  146117. name: string;
  146118. shader: string;
  146119. };
  146120. }
  146121. declare module BABYLON {
  146122. /** @hidden */
  146123. export var ssaoCombinePixelShader: {
  146124. name: string;
  146125. shader: string;
  146126. };
  146127. }
  146128. declare module BABYLON {
  146129. /**
  146130. * Render pipeline to produce ssao effect
  146131. */
  146132. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  146133. /**
  146134. * @ignore
  146135. * The PassPostProcess id in the pipeline that contains the original scene color
  146136. */
  146137. SSAOOriginalSceneColorEffect: string;
  146138. /**
  146139. * @ignore
  146140. * The SSAO PostProcess id in the pipeline
  146141. */
  146142. SSAORenderEffect: string;
  146143. /**
  146144. * @ignore
  146145. * The horizontal blur PostProcess id in the pipeline
  146146. */
  146147. SSAOBlurHRenderEffect: string;
  146148. /**
  146149. * @ignore
  146150. * The vertical blur PostProcess id in the pipeline
  146151. */
  146152. SSAOBlurVRenderEffect: string;
  146153. /**
  146154. * @ignore
  146155. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146156. */
  146157. SSAOCombineRenderEffect: string;
  146158. /**
  146159. * The output strength of the SSAO post-process. Default value is 1.0.
  146160. */
  146161. totalStrength: number;
  146162. /**
  146163. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  146164. */
  146165. maxZ: number;
  146166. /**
  146167. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  146168. */
  146169. minZAspect: number;
  146170. private _samples;
  146171. /**
  146172. * Number of samples used for the SSAO calculations. Default value is 8
  146173. */
  146174. set samples(n: number);
  146175. get samples(): number;
  146176. private _textureSamples;
  146177. /**
  146178. * Number of samples to use for antialiasing
  146179. */
  146180. set textureSamples(n: number);
  146181. get textureSamples(): number;
  146182. /**
  146183. * Ratio object used for SSAO ratio and blur ratio
  146184. */
  146185. private _ratio;
  146186. /**
  146187. * Dynamically generated sphere sampler.
  146188. */
  146189. private _sampleSphere;
  146190. /**
  146191. * Blur filter offsets
  146192. */
  146193. private _samplerOffsets;
  146194. private _expensiveBlur;
  146195. /**
  146196. * If bilateral blur should be used
  146197. */
  146198. set expensiveBlur(b: boolean);
  146199. get expensiveBlur(): boolean;
  146200. /**
  146201. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  146202. */
  146203. radius: number;
  146204. /**
  146205. * The base color of the SSAO post-process
  146206. * The final result is "base + ssao" between [0, 1]
  146207. */
  146208. base: number;
  146209. /**
  146210. * Support test.
  146211. */
  146212. static get IsSupported(): boolean;
  146213. private _scene;
  146214. private _depthTexture;
  146215. private _normalTexture;
  146216. private _randomTexture;
  146217. private _originalColorPostProcess;
  146218. private _ssaoPostProcess;
  146219. private _blurHPostProcess;
  146220. private _blurVPostProcess;
  146221. private _ssaoCombinePostProcess;
  146222. /**
  146223. * Gets active scene
  146224. */
  146225. get scene(): Scene;
  146226. /**
  146227. * @constructor
  146228. * @param name The rendering pipeline name
  146229. * @param scene The scene linked to this pipeline
  146230. * @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 }
  146231. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146232. */
  146233. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146234. /**
  146235. * Get the class name
  146236. * @returns "SSAO2RenderingPipeline"
  146237. */
  146238. getClassName(): string;
  146239. /**
  146240. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146241. */
  146242. dispose(disableGeometryBufferRenderer?: boolean): void;
  146243. private _createBlurPostProcess;
  146244. /** @hidden */
  146245. _rebuild(): void;
  146246. private _bits;
  146247. private _radicalInverse_VdC;
  146248. private _hammersley;
  146249. private _hemisphereSample_uniform;
  146250. private _generateHemisphere;
  146251. private _createSSAOPostProcess;
  146252. private _createSSAOCombinePostProcess;
  146253. private _createRandomTexture;
  146254. /**
  146255. * Serialize the rendering pipeline (Used when exporting)
  146256. * @returns the serialized object
  146257. */
  146258. serialize(): any;
  146259. /**
  146260. * Parse the serialized pipeline
  146261. * @param source Source pipeline.
  146262. * @param scene The scene to load the pipeline to.
  146263. * @param rootUrl The URL of the serialized pipeline.
  146264. * @returns An instantiated pipeline from the serialized object.
  146265. */
  146266. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  146267. }
  146268. }
  146269. declare module BABYLON {
  146270. /** @hidden */
  146271. export var ssaoPixelShader: {
  146272. name: string;
  146273. shader: string;
  146274. };
  146275. }
  146276. declare module BABYLON {
  146277. /**
  146278. * Render pipeline to produce ssao effect
  146279. */
  146280. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  146281. /**
  146282. * @ignore
  146283. * The PassPostProcess id in the pipeline that contains the original scene color
  146284. */
  146285. SSAOOriginalSceneColorEffect: string;
  146286. /**
  146287. * @ignore
  146288. * The SSAO PostProcess id in the pipeline
  146289. */
  146290. SSAORenderEffect: string;
  146291. /**
  146292. * @ignore
  146293. * The horizontal blur PostProcess id in the pipeline
  146294. */
  146295. SSAOBlurHRenderEffect: string;
  146296. /**
  146297. * @ignore
  146298. * The vertical blur PostProcess id in the pipeline
  146299. */
  146300. SSAOBlurVRenderEffect: string;
  146301. /**
  146302. * @ignore
  146303. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146304. */
  146305. SSAOCombineRenderEffect: string;
  146306. /**
  146307. * The output strength of the SSAO post-process. Default value is 1.0.
  146308. */
  146309. totalStrength: number;
  146310. /**
  146311. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  146312. */
  146313. radius: number;
  146314. /**
  146315. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  146316. * Must not be equal to fallOff and superior to fallOff.
  146317. * Default value is 0.0075
  146318. */
  146319. area: number;
  146320. /**
  146321. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  146322. * Must not be equal to area and inferior to area.
  146323. * Default value is 0.000001
  146324. */
  146325. fallOff: number;
  146326. /**
  146327. * The base color of the SSAO post-process
  146328. * The final result is "base + ssao" between [0, 1]
  146329. */
  146330. base: number;
  146331. private _scene;
  146332. private _depthTexture;
  146333. private _randomTexture;
  146334. private _originalColorPostProcess;
  146335. private _ssaoPostProcess;
  146336. private _blurHPostProcess;
  146337. private _blurVPostProcess;
  146338. private _ssaoCombinePostProcess;
  146339. private _firstUpdate;
  146340. /**
  146341. * Gets active scene
  146342. */
  146343. get scene(): Scene;
  146344. /**
  146345. * @constructor
  146346. * @param name - The rendering pipeline name
  146347. * @param scene - The scene linked to this pipeline
  146348. * @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 }
  146349. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  146350. */
  146351. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146352. /**
  146353. * Get the class name
  146354. * @returns "SSAORenderingPipeline"
  146355. */
  146356. getClassName(): string;
  146357. /**
  146358. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146359. */
  146360. dispose(disableDepthRender?: boolean): void;
  146361. private _createBlurPostProcess;
  146362. /** @hidden */
  146363. _rebuild(): void;
  146364. private _createSSAOPostProcess;
  146365. private _createSSAOCombinePostProcess;
  146366. private _createRandomTexture;
  146367. }
  146368. }
  146369. declare module BABYLON {
  146370. /** @hidden */
  146371. export var screenSpaceReflectionPixelShader: {
  146372. name: string;
  146373. shader: string;
  146374. };
  146375. }
  146376. declare module BABYLON {
  146377. /**
  146378. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  146379. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  146380. */
  146381. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  146382. /**
  146383. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  146384. */
  146385. threshold: number;
  146386. /**
  146387. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  146388. */
  146389. strength: number;
  146390. /**
  146391. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  146392. */
  146393. reflectionSpecularFalloffExponent: number;
  146394. /**
  146395. * 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]
  146396. */
  146397. step: number;
  146398. /**
  146399. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  146400. */
  146401. roughnessFactor: number;
  146402. private _geometryBufferRenderer;
  146403. private _enableSmoothReflections;
  146404. private _reflectionSamples;
  146405. private _smoothSteps;
  146406. /**
  146407. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  146408. * @param name The name of the effect.
  146409. * @param scene The scene containing the objects to calculate reflections.
  146410. * @param options The required width/height ratio to downsize to before computing the render pass.
  146411. * @param camera The camera to apply the render pass to.
  146412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146413. * @param engine The engine which the post process will be applied. (default: current engine)
  146414. * @param reusable If the post process can be reused on the same frame. (default: false)
  146415. * @param textureType Type of textures used when performing the post process. (default: 0)
  146416. * @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)
  146417. */
  146418. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146419. /**
  146420. * Gets wether or not smoothing reflections is enabled.
  146421. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146422. */
  146423. get enableSmoothReflections(): boolean;
  146424. /**
  146425. * Sets wether or not smoothing reflections is enabled.
  146426. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146427. */
  146428. set enableSmoothReflections(enabled: boolean);
  146429. /**
  146430. * Gets the number of samples taken while computing reflections. More samples count is high,
  146431. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146432. */
  146433. get reflectionSamples(): number;
  146434. /**
  146435. * Sets the number of samples taken while computing reflections. More samples count is high,
  146436. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146437. */
  146438. set reflectionSamples(samples: number);
  146439. /**
  146440. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  146441. * more the post-process will require GPU power and can generate a drop in FPS.
  146442. * Default value (5.0) work pretty well in all cases but can be adjusted.
  146443. */
  146444. get smoothSteps(): number;
  146445. set smoothSteps(steps: number);
  146446. private _updateEffectDefines;
  146447. }
  146448. }
  146449. declare module BABYLON {
  146450. /** @hidden */
  146451. export var standardPixelShader: {
  146452. name: string;
  146453. shader: string;
  146454. };
  146455. }
  146456. declare module BABYLON {
  146457. /**
  146458. * Standard rendering pipeline
  146459. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146460. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  146461. */
  146462. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146463. /**
  146464. * Public members
  146465. */
  146466. /**
  146467. * Post-process which contains the original scene color before the pipeline applies all the effects
  146468. */
  146469. originalPostProcess: Nullable<PostProcess>;
  146470. /**
  146471. * Post-process used to down scale an image x4
  146472. */
  146473. downSampleX4PostProcess: Nullable<PostProcess>;
  146474. /**
  146475. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  146476. */
  146477. brightPassPostProcess: Nullable<PostProcess>;
  146478. /**
  146479. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  146480. */
  146481. blurHPostProcesses: PostProcess[];
  146482. /**
  146483. * Post-process array storing all the vertical blur post-processes used by the pipeline
  146484. */
  146485. blurVPostProcesses: PostProcess[];
  146486. /**
  146487. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  146488. */
  146489. textureAdderPostProcess: Nullable<PostProcess>;
  146490. /**
  146491. * Post-process used to create volumetric lighting effect
  146492. */
  146493. volumetricLightPostProcess: Nullable<PostProcess>;
  146494. /**
  146495. * Post-process used to smooth the previous volumetric light post-process on the X axis
  146496. */
  146497. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  146498. /**
  146499. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  146500. */
  146501. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  146502. /**
  146503. * Post-process used to merge the volumetric light effect and the real scene color
  146504. */
  146505. volumetricLightMergePostProces: Nullable<PostProcess>;
  146506. /**
  146507. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  146508. */
  146509. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  146510. /**
  146511. * Base post-process used to calculate the average luminance of the final image for HDR
  146512. */
  146513. luminancePostProcess: Nullable<PostProcess>;
  146514. /**
  146515. * Post-processes used to create down sample post-processes in order to get
  146516. * the average luminance of the final image for HDR
  146517. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  146518. */
  146519. luminanceDownSamplePostProcesses: PostProcess[];
  146520. /**
  146521. * Post-process used to create a HDR effect (light adaptation)
  146522. */
  146523. hdrPostProcess: Nullable<PostProcess>;
  146524. /**
  146525. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  146526. */
  146527. textureAdderFinalPostProcess: Nullable<PostProcess>;
  146528. /**
  146529. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  146530. */
  146531. lensFlareFinalPostProcess: Nullable<PostProcess>;
  146532. /**
  146533. * Post-process used to merge the final HDR post-process and the real scene color
  146534. */
  146535. hdrFinalPostProcess: Nullable<PostProcess>;
  146536. /**
  146537. * Post-process used to create a lens flare effect
  146538. */
  146539. lensFlarePostProcess: Nullable<PostProcess>;
  146540. /**
  146541. * Post-process that merges the result of the lens flare post-process and the real scene color
  146542. */
  146543. lensFlareComposePostProcess: Nullable<PostProcess>;
  146544. /**
  146545. * Post-process used to create a motion blur effect
  146546. */
  146547. motionBlurPostProcess: Nullable<PostProcess>;
  146548. /**
  146549. * Post-process used to create a depth of field effect
  146550. */
  146551. depthOfFieldPostProcess: Nullable<PostProcess>;
  146552. /**
  146553. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146554. */
  146555. fxaaPostProcess: Nullable<FxaaPostProcess>;
  146556. /**
  146557. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  146558. */
  146559. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  146560. /**
  146561. * Represents the brightness threshold in order to configure the illuminated surfaces
  146562. */
  146563. brightThreshold: number;
  146564. /**
  146565. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  146566. */
  146567. blurWidth: number;
  146568. /**
  146569. * Sets if the blur for highlighted surfaces must be only horizontal
  146570. */
  146571. horizontalBlur: boolean;
  146572. /**
  146573. * Gets the overall exposure used by the pipeline
  146574. */
  146575. get exposure(): number;
  146576. /**
  146577. * Sets the overall exposure used by the pipeline
  146578. */
  146579. set exposure(value: number);
  146580. /**
  146581. * Texture used typically to simulate "dirty" on camera lens
  146582. */
  146583. lensTexture: Nullable<Texture>;
  146584. /**
  146585. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  146586. */
  146587. volumetricLightCoefficient: number;
  146588. /**
  146589. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  146590. */
  146591. volumetricLightPower: number;
  146592. /**
  146593. * Used the set the blur intensity to smooth the volumetric lights
  146594. */
  146595. volumetricLightBlurScale: number;
  146596. /**
  146597. * Light (spot or directional) used to generate the volumetric lights rays
  146598. * The source light must have a shadow generate so the pipeline can get its
  146599. * depth map
  146600. */
  146601. sourceLight: Nullable<SpotLight | DirectionalLight>;
  146602. /**
  146603. * For eye adaptation, represents the minimum luminance the eye can see
  146604. */
  146605. hdrMinimumLuminance: number;
  146606. /**
  146607. * For eye adaptation, represents the decrease luminance speed
  146608. */
  146609. hdrDecreaseRate: number;
  146610. /**
  146611. * For eye adaptation, represents the increase luminance speed
  146612. */
  146613. hdrIncreaseRate: number;
  146614. /**
  146615. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146616. */
  146617. get hdrAutoExposure(): boolean;
  146618. /**
  146619. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146620. */
  146621. set hdrAutoExposure(value: boolean);
  146622. /**
  146623. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  146624. */
  146625. lensColorTexture: Nullable<Texture>;
  146626. /**
  146627. * The overall strengh for the lens flare effect
  146628. */
  146629. lensFlareStrength: number;
  146630. /**
  146631. * Dispersion coefficient for lens flare ghosts
  146632. */
  146633. lensFlareGhostDispersal: number;
  146634. /**
  146635. * Main lens flare halo width
  146636. */
  146637. lensFlareHaloWidth: number;
  146638. /**
  146639. * Based on the lens distortion effect, defines how much the lens flare result
  146640. * is distorted
  146641. */
  146642. lensFlareDistortionStrength: number;
  146643. /**
  146644. * Configures the blur intensity used for for lens flare (halo)
  146645. */
  146646. lensFlareBlurWidth: number;
  146647. /**
  146648. * Lens star texture must be used to simulate rays on the flares and is available
  146649. * in the documentation
  146650. */
  146651. lensStarTexture: Nullable<Texture>;
  146652. /**
  146653. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  146654. * flare effect by taking account of the dirt texture
  146655. */
  146656. lensFlareDirtTexture: Nullable<Texture>;
  146657. /**
  146658. * Represents the focal length for the depth of field effect
  146659. */
  146660. depthOfFieldDistance: number;
  146661. /**
  146662. * Represents the blur intensity for the blurred part of the depth of field effect
  146663. */
  146664. depthOfFieldBlurWidth: number;
  146665. /**
  146666. * Gets how much the image is blurred by the movement while using the motion blur post-process
  146667. */
  146668. get motionStrength(): number;
  146669. /**
  146670. * Sets how much the image is blurred by the movement while using the motion blur post-process
  146671. */
  146672. set motionStrength(strength: number);
  146673. /**
  146674. * Gets wether or not the motion blur post-process is object based or screen based.
  146675. */
  146676. get objectBasedMotionBlur(): boolean;
  146677. /**
  146678. * Sets wether or not the motion blur post-process should be object based or screen based
  146679. */
  146680. set objectBasedMotionBlur(value: boolean);
  146681. /**
  146682. * List of animations for the pipeline (IAnimatable implementation)
  146683. */
  146684. animations: Animation[];
  146685. /**
  146686. * Private members
  146687. */
  146688. private _scene;
  146689. private _currentDepthOfFieldSource;
  146690. private _basePostProcess;
  146691. private _fixedExposure;
  146692. private _currentExposure;
  146693. private _hdrAutoExposure;
  146694. private _hdrCurrentLuminance;
  146695. private _motionStrength;
  146696. private _isObjectBasedMotionBlur;
  146697. private _floatTextureType;
  146698. private _camerasToBeAttached;
  146699. private _ratio;
  146700. private _bloomEnabled;
  146701. private _depthOfFieldEnabled;
  146702. private _vlsEnabled;
  146703. private _lensFlareEnabled;
  146704. private _hdrEnabled;
  146705. private _motionBlurEnabled;
  146706. private _fxaaEnabled;
  146707. private _screenSpaceReflectionsEnabled;
  146708. private _motionBlurSamples;
  146709. private _volumetricLightStepsCount;
  146710. private _samples;
  146711. /**
  146712. * @ignore
  146713. * Specifies if the bloom pipeline is enabled
  146714. */
  146715. get BloomEnabled(): boolean;
  146716. set BloomEnabled(enabled: boolean);
  146717. /**
  146718. * @ignore
  146719. * Specifies if the depth of field pipeline is enabed
  146720. */
  146721. get DepthOfFieldEnabled(): boolean;
  146722. set DepthOfFieldEnabled(enabled: boolean);
  146723. /**
  146724. * @ignore
  146725. * Specifies if the lens flare pipeline is enabed
  146726. */
  146727. get LensFlareEnabled(): boolean;
  146728. set LensFlareEnabled(enabled: boolean);
  146729. /**
  146730. * @ignore
  146731. * Specifies if the HDR pipeline is enabled
  146732. */
  146733. get HDREnabled(): boolean;
  146734. set HDREnabled(enabled: boolean);
  146735. /**
  146736. * @ignore
  146737. * Specifies if the volumetric lights scattering effect is enabled
  146738. */
  146739. get VLSEnabled(): boolean;
  146740. set VLSEnabled(enabled: boolean);
  146741. /**
  146742. * @ignore
  146743. * Specifies if the motion blur effect is enabled
  146744. */
  146745. get MotionBlurEnabled(): boolean;
  146746. set MotionBlurEnabled(enabled: boolean);
  146747. /**
  146748. * Specifies if anti-aliasing is enabled
  146749. */
  146750. get fxaaEnabled(): boolean;
  146751. set fxaaEnabled(enabled: boolean);
  146752. /**
  146753. * Specifies if screen space reflections are enabled.
  146754. */
  146755. get screenSpaceReflectionsEnabled(): boolean;
  146756. set screenSpaceReflectionsEnabled(enabled: boolean);
  146757. /**
  146758. * Specifies the number of steps used to calculate the volumetric lights
  146759. * Typically in interval [50, 200]
  146760. */
  146761. get volumetricLightStepsCount(): number;
  146762. set volumetricLightStepsCount(count: number);
  146763. /**
  146764. * Specifies the number of samples used for the motion blur effect
  146765. * Typically in interval [16, 64]
  146766. */
  146767. get motionBlurSamples(): number;
  146768. set motionBlurSamples(samples: number);
  146769. /**
  146770. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146771. */
  146772. get samples(): number;
  146773. set samples(sampleCount: number);
  146774. /**
  146775. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146776. * @constructor
  146777. * @param name The rendering pipeline name
  146778. * @param scene The scene linked to this pipeline
  146779. * @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)
  146780. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  146781. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146782. */
  146783. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  146784. private _buildPipeline;
  146785. private _createDownSampleX4PostProcess;
  146786. private _createBrightPassPostProcess;
  146787. private _createBlurPostProcesses;
  146788. private _createTextureAdderPostProcess;
  146789. private _createVolumetricLightPostProcess;
  146790. private _createLuminancePostProcesses;
  146791. private _createHdrPostProcess;
  146792. private _createLensFlarePostProcess;
  146793. private _createDepthOfFieldPostProcess;
  146794. private _createMotionBlurPostProcess;
  146795. private _getDepthTexture;
  146796. private _disposePostProcesses;
  146797. /**
  146798. * Dispose of the pipeline and stop all post processes
  146799. */
  146800. dispose(): void;
  146801. /**
  146802. * Serialize the rendering pipeline (Used when exporting)
  146803. * @returns the serialized object
  146804. */
  146805. serialize(): any;
  146806. /**
  146807. * Parse the serialized pipeline
  146808. * @param source Source pipeline.
  146809. * @param scene The scene to load the pipeline to.
  146810. * @param rootUrl The URL of the serialized pipeline.
  146811. * @returns An instantiated pipeline from the serialized object.
  146812. */
  146813. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  146814. /**
  146815. * Luminance steps
  146816. */
  146817. static LuminanceSteps: number;
  146818. }
  146819. }
  146820. declare module BABYLON {
  146821. /** @hidden */
  146822. export var stereoscopicInterlacePixelShader: {
  146823. name: string;
  146824. shader: string;
  146825. };
  146826. }
  146827. declare module BABYLON {
  146828. /**
  146829. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  146830. */
  146831. export class StereoscopicInterlacePostProcessI extends PostProcess {
  146832. private _stepSize;
  146833. private _passedProcess;
  146834. /**
  146835. * Initializes a StereoscopicInterlacePostProcessI
  146836. * @param name The name of the effect.
  146837. * @param rigCameras The rig cameras to be appled to the post process
  146838. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  146839. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  146840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146841. * @param engine The engine which the post process will be applied. (default: current engine)
  146842. * @param reusable If the post process can be reused on the same frame. (default: false)
  146843. */
  146844. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146845. }
  146846. /**
  146847. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  146848. */
  146849. export class StereoscopicInterlacePostProcess extends PostProcess {
  146850. private _stepSize;
  146851. private _passedProcess;
  146852. /**
  146853. * Initializes a StereoscopicInterlacePostProcess
  146854. * @param name The name of the effect.
  146855. * @param rigCameras The rig cameras to be appled to the post process
  146856. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  146857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146858. * @param engine The engine which the post process will be applied. (default: current engine)
  146859. * @param reusable If the post process can be reused on the same frame. (default: false)
  146860. */
  146861. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146862. }
  146863. }
  146864. declare module BABYLON {
  146865. /** @hidden */
  146866. export var tonemapPixelShader: {
  146867. name: string;
  146868. shader: string;
  146869. };
  146870. }
  146871. declare module BABYLON {
  146872. /** Defines operator used for tonemapping */
  146873. export enum TonemappingOperator {
  146874. /** Hable */
  146875. Hable = 0,
  146876. /** Reinhard */
  146877. Reinhard = 1,
  146878. /** HejiDawson */
  146879. HejiDawson = 2,
  146880. /** Photographic */
  146881. Photographic = 3
  146882. }
  146883. /**
  146884. * Defines a post process to apply tone mapping
  146885. */
  146886. export class TonemapPostProcess extends PostProcess {
  146887. private _operator;
  146888. /** Defines the required exposure adjustement */
  146889. exposureAdjustment: number;
  146890. /**
  146891. * Creates a new TonemapPostProcess
  146892. * @param name defines the name of the postprocess
  146893. * @param _operator defines the operator to use
  146894. * @param exposureAdjustment defines the required exposure adjustement
  146895. * @param camera defines the camera to use (can be null)
  146896. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  146897. * @param engine defines the hosting engine (can be ignore if camera is set)
  146898. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  146899. */
  146900. constructor(name: string, _operator: TonemappingOperator,
  146901. /** Defines the required exposure adjustement */
  146902. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  146903. }
  146904. }
  146905. declare module BABYLON {
  146906. /** @hidden */
  146907. export var volumetricLightScatteringPixelShader: {
  146908. name: string;
  146909. shader: string;
  146910. };
  146911. }
  146912. declare module BABYLON {
  146913. /** @hidden */
  146914. export var volumetricLightScatteringPassVertexShader: {
  146915. name: string;
  146916. shader: string;
  146917. };
  146918. }
  146919. declare module BABYLON {
  146920. /** @hidden */
  146921. export var volumetricLightScatteringPassPixelShader: {
  146922. name: string;
  146923. shader: string;
  146924. };
  146925. }
  146926. declare module BABYLON {
  146927. /**
  146928. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  146929. */
  146930. export class VolumetricLightScatteringPostProcess extends PostProcess {
  146931. private _volumetricLightScatteringPass;
  146932. private _volumetricLightScatteringRTT;
  146933. private _viewPort;
  146934. private _screenCoordinates;
  146935. private _cachedDefines;
  146936. /**
  146937. * If not undefined, the mesh position is computed from the attached node position
  146938. */
  146939. attachedNode: {
  146940. position: Vector3;
  146941. };
  146942. /**
  146943. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  146944. */
  146945. customMeshPosition: Vector3;
  146946. /**
  146947. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  146948. */
  146949. useCustomMeshPosition: boolean;
  146950. /**
  146951. * If the post-process should inverse the light scattering direction
  146952. */
  146953. invert: boolean;
  146954. /**
  146955. * The internal mesh used by the post-process
  146956. */
  146957. mesh: Mesh;
  146958. /**
  146959. * @hidden
  146960. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  146961. */
  146962. get useDiffuseColor(): boolean;
  146963. set useDiffuseColor(useDiffuseColor: boolean);
  146964. /**
  146965. * Array containing the excluded meshes not rendered in the internal pass
  146966. */
  146967. excludedMeshes: AbstractMesh[];
  146968. /**
  146969. * Controls the overall intensity of the post-process
  146970. */
  146971. exposure: number;
  146972. /**
  146973. * Dissipates each sample's contribution in range [0, 1]
  146974. */
  146975. decay: number;
  146976. /**
  146977. * Controls the overall intensity of each sample
  146978. */
  146979. weight: number;
  146980. /**
  146981. * Controls the density of each sample
  146982. */
  146983. density: number;
  146984. /**
  146985. * @constructor
  146986. * @param name The post-process name
  146987. * @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)
  146988. * @param camera The camera that the post-process will be attached to
  146989. * @param mesh The mesh used to create the light scattering
  146990. * @param samples The post-process quality, default 100
  146991. * @param samplingModeThe post-process filtering mode
  146992. * @param engine The babylon engine
  146993. * @param reusable If the post-process is reusable
  146994. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  146995. */
  146996. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  146997. /**
  146998. * Returns the string "VolumetricLightScatteringPostProcess"
  146999. * @returns "VolumetricLightScatteringPostProcess"
  147000. */
  147001. getClassName(): string;
  147002. private _isReady;
  147003. /**
  147004. * Sets the new light position for light scattering effect
  147005. * @param position The new custom light position
  147006. */
  147007. setCustomMeshPosition(position: Vector3): void;
  147008. /**
  147009. * Returns the light position for light scattering effect
  147010. * @return Vector3 The custom light position
  147011. */
  147012. getCustomMeshPosition(): Vector3;
  147013. /**
  147014. * Disposes the internal assets and detaches the post-process from the camera
  147015. */
  147016. dispose(camera: Camera): void;
  147017. /**
  147018. * Returns the render target texture used by the post-process
  147019. * @return the render target texture used by the post-process
  147020. */
  147021. getPass(): RenderTargetTexture;
  147022. private _meshExcluded;
  147023. private _createPass;
  147024. private _updateMeshScreenCoordinates;
  147025. /**
  147026. * Creates a default mesh for the Volumeric Light Scattering post-process
  147027. * @param name The mesh name
  147028. * @param scene The scene where to create the mesh
  147029. * @return the default mesh
  147030. */
  147031. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  147032. }
  147033. }
  147034. declare module BABYLON {
  147035. interface Scene {
  147036. /** @hidden (Backing field) */
  147037. _boundingBoxRenderer: BoundingBoxRenderer;
  147038. /** @hidden (Backing field) */
  147039. _forceShowBoundingBoxes: boolean;
  147040. /**
  147041. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  147042. */
  147043. forceShowBoundingBoxes: boolean;
  147044. /**
  147045. * Gets the bounding box renderer associated with the scene
  147046. * @returns a BoundingBoxRenderer
  147047. */
  147048. getBoundingBoxRenderer(): BoundingBoxRenderer;
  147049. }
  147050. interface AbstractMesh {
  147051. /** @hidden (Backing field) */
  147052. _showBoundingBox: boolean;
  147053. /**
  147054. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  147055. */
  147056. showBoundingBox: boolean;
  147057. }
  147058. /**
  147059. * Component responsible of rendering the bounding box of the meshes in a scene.
  147060. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  147061. */
  147062. export class BoundingBoxRenderer implements ISceneComponent {
  147063. /**
  147064. * The component name helpfull to identify the component in the list of scene components.
  147065. */
  147066. readonly name: string;
  147067. /**
  147068. * The scene the component belongs to.
  147069. */
  147070. scene: Scene;
  147071. /**
  147072. * Color of the bounding box lines placed in front of an object
  147073. */
  147074. frontColor: Color3;
  147075. /**
  147076. * Color of the bounding box lines placed behind an object
  147077. */
  147078. backColor: Color3;
  147079. /**
  147080. * Defines if the renderer should show the back lines or not
  147081. */
  147082. showBackLines: boolean;
  147083. /**
  147084. * Observable raised before rendering a bounding box
  147085. */
  147086. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  147087. /**
  147088. * Observable raised after rendering a bounding box
  147089. */
  147090. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  147091. /**
  147092. * @hidden
  147093. */
  147094. renderList: SmartArray<BoundingBox>;
  147095. private _colorShader;
  147096. private _vertexBuffers;
  147097. private _indexBuffer;
  147098. private _fillIndexBuffer;
  147099. private _fillIndexData;
  147100. /**
  147101. * Instantiates a new bounding box renderer in a scene.
  147102. * @param scene the scene the renderer renders in
  147103. */
  147104. constructor(scene: Scene);
  147105. /**
  147106. * Registers the component in a given scene
  147107. */
  147108. register(): void;
  147109. private _evaluateSubMesh;
  147110. private _activeMesh;
  147111. private _prepareRessources;
  147112. private _createIndexBuffer;
  147113. /**
  147114. * Rebuilds the elements related to this component in case of
  147115. * context lost for instance.
  147116. */
  147117. rebuild(): void;
  147118. /**
  147119. * @hidden
  147120. */
  147121. reset(): void;
  147122. /**
  147123. * Render the bounding boxes of a specific rendering group
  147124. * @param renderingGroupId defines the rendering group to render
  147125. */
  147126. render(renderingGroupId: number): void;
  147127. /**
  147128. * In case of occlusion queries, we can render the occlusion bounding box through this method
  147129. * @param mesh Define the mesh to render the occlusion bounding box for
  147130. */
  147131. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  147132. /**
  147133. * Dispose and release the resources attached to this renderer.
  147134. */
  147135. dispose(): void;
  147136. }
  147137. }
  147138. declare module BABYLON {
  147139. interface Scene {
  147140. /** @hidden (Backing field) */
  147141. _depthRenderer: {
  147142. [id: string]: DepthRenderer;
  147143. };
  147144. /**
  147145. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  147146. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  147147. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  147148. * @returns the created depth renderer
  147149. */
  147150. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  147151. /**
  147152. * Disables a depth renderer for a given camera
  147153. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  147154. */
  147155. disableDepthRenderer(camera?: Nullable<Camera>): void;
  147156. }
  147157. /**
  147158. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  147159. * in several rendering techniques.
  147160. */
  147161. export class DepthRendererSceneComponent implements ISceneComponent {
  147162. /**
  147163. * The component name helpfull to identify the component in the list of scene components.
  147164. */
  147165. readonly name: string;
  147166. /**
  147167. * The scene the component belongs to.
  147168. */
  147169. scene: Scene;
  147170. /**
  147171. * Creates a new instance of the component for the given scene
  147172. * @param scene Defines the scene to register the component in
  147173. */
  147174. constructor(scene: Scene);
  147175. /**
  147176. * Registers the component in a given scene
  147177. */
  147178. register(): void;
  147179. /**
  147180. * Rebuilds the elements related to this component in case of
  147181. * context lost for instance.
  147182. */
  147183. rebuild(): void;
  147184. /**
  147185. * Disposes the component and the associated ressources
  147186. */
  147187. dispose(): void;
  147188. private _gatherRenderTargets;
  147189. private _gatherActiveCameraRenderTargets;
  147190. }
  147191. }
  147192. declare module BABYLON {
  147193. /** @hidden */
  147194. export var outlinePixelShader: {
  147195. name: string;
  147196. shader: string;
  147197. };
  147198. }
  147199. declare module BABYLON {
  147200. /** @hidden */
  147201. export var outlineVertexShader: {
  147202. name: string;
  147203. shader: string;
  147204. };
  147205. }
  147206. declare module BABYLON {
  147207. interface Scene {
  147208. /** @hidden */
  147209. _outlineRenderer: OutlineRenderer;
  147210. /**
  147211. * Gets the outline renderer associated with the scene
  147212. * @returns a OutlineRenderer
  147213. */
  147214. getOutlineRenderer(): OutlineRenderer;
  147215. }
  147216. interface AbstractMesh {
  147217. /** @hidden (Backing field) */
  147218. _renderOutline: boolean;
  147219. /**
  147220. * Gets or sets a boolean indicating if the outline must be rendered as well
  147221. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  147222. */
  147223. renderOutline: boolean;
  147224. /** @hidden (Backing field) */
  147225. _renderOverlay: boolean;
  147226. /**
  147227. * Gets or sets a boolean indicating if the overlay must be rendered as well
  147228. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  147229. */
  147230. renderOverlay: boolean;
  147231. }
  147232. /**
  147233. * This class is responsible to draw bothe outline/overlay of meshes.
  147234. * It should not be used directly but through the available method on mesh.
  147235. */
  147236. export class OutlineRenderer implements ISceneComponent {
  147237. /**
  147238. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  147239. */
  147240. private static _StencilReference;
  147241. /**
  147242. * The name of the component. Each component must have a unique name.
  147243. */
  147244. name: string;
  147245. /**
  147246. * The scene the component belongs to.
  147247. */
  147248. scene: Scene;
  147249. /**
  147250. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  147251. */
  147252. zOffset: number;
  147253. private _engine;
  147254. private _effect;
  147255. private _cachedDefines;
  147256. private _savedDepthWrite;
  147257. /**
  147258. * Instantiates a new outline renderer. (There could be only one per scene).
  147259. * @param scene Defines the scene it belongs to
  147260. */
  147261. constructor(scene: Scene);
  147262. /**
  147263. * Register the component to one instance of a scene.
  147264. */
  147265. register(): void;
  147266. /**
  147267. * Rebuilds the elements related to this component in case of
  147268. * context lost for instance.
  147269. */
  147270. rebuild(): void;
  147271. /**
  147272. * Disposes the component and the associated ressources.
  147273. */
  147274. dispose(): void;
  147275. /**
  147276. * Renders the outline in the canvas.
  147277. * @param subMesh Defines the sumesh to render
  147278. * @param batch Defines the batch of meshes in case of instances
  147279. * @param useOverlay Defines if the rendering is for the overlay or the outline
  147280. */
  147281. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  147282. /**
  147283. * Returns whether or not the outline renderer is ready for a given submesh.
  147284. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  147285. * @param subMesh Defines the submesh to check readyness for
  147286. * @param useInstances Defines wheter wee are trying to render instances or not
  147287. * @returns true if ready otherwise false
  147288. */
  147289. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147290. private _beforeRenderingMesh;
  147291. private _afterRenderingMesh;
  147292. }
  147293. }
  147294. declare module BABYLON {
  147295. /**
  147296. * Defines the basic options interface of a Sprite Frame Source Size.
  147297. */
  147298. export interface ISpriteJSONSpriteSourceSize {
  147299. /**
  147300. * number of the original width of the Frame
  147301. */
  147302. w: number;
  147303. /**
  147304. * number of the original height of the Frame
  147305. */
  147306. h: number;
  147307. }
  147308. /**
  147309. * Defines the basic options interface of a Sprite Frame Data.
  147310. */
  147311. export interface ISpriteJSONSpriteFrameData {
  147312. /**
  147313. * number of the x offset of the Frame
  147314. */
  147315. x: number;
  147316. /**
  147317. * number of the y offset of the Frame
  147318. */
  147319. y: number;
  147320. /**
  147321. * number of the width of the Frame
  147322. */
  147323. w: number;
  147324. /**
  147325. * number of the height of the Frame
  147326. */
  147327. h: number;
  147328. }
  147329. /**
  147330. * Defines the basic options interface of a JSON Sprite.
  147331. */
  147332. export interface ISpriteJSONSprite {
  147333. /**
  147334. * string name of the Frame
  147335. */
  147336. filename: string;
  147337. /**
  147338. * ISpriteJSONSpriteFrame basic object of the frame data
  147339. */
  147340. frame: ISpriteJSONSpriteFrameData;
  147341. /**
  147342. * boolean to flag is the frame was rotated.
  147343. */
  147344. rotated: boolean;
  147345. /**
  147346. * boolean to flag is the frame was trimmed.
  147347. */
  147348. trimmed: boolean;
  147349. /**
  147350. * ISpriteJSONSpriteFrame basic object of the source data
  147351. */
  147352. spriteSourceSize: ISpriteJSONSpriteFrameData;
  147353. /**
  147354. * ISpriteJSONSpriteFrame basic object of the source data
  147355. */
  147356. sourceSize: ISpriteJSONSpriteSourceSize;
  147357. }
  147358. /**
  147359. * Defines the basic options interface of a JSON atlas.
  147360. */
  147361. export interface ISpriteJSONAtlas {
  147362. /**
  147363. * Array of objects that contain the frame data.
  147364. */
  147365. frames: Array<ISpriteJSONSprite>;
  147366. /**
  147367. * object basic object containing the sprite meta data.
  147368. */
  147369. meta?: object;
  147370. }
  147371. }
  147372. declare module BABYLON {
  147373. /** @hidden */
  147374. export var spriteMapPixelShader: {
  147375. name: string;
  147376. shader: string;
  147377. };
  147378. }
  147379. declare module BABYLON {
  147380. /** @hidden */
  147381. export var spriteMapVertexShader: {
  147382. name: string;
  147383. shader: string;
  147384. };
  147385. }
  147386. declare module BABYLON {
  147387. /**
  147388. * Defines the basic options interface of a SpriteMap
  147389. */
  147390. export interface ISpriteMapOptions {
  147391. /**
  147392. * Vector2 of the number of cells in the grid.
  147393. */
  147394. stageSize?: Vector2;
  147395. /**
  147396. * Vector2 of the size of the output plane in World Units.
  147397. */
  147398. outputSize?: Vector2;
  147399. /**
  147400. * Vector3 of the position of the output plane in World Units.
  147401. */
  147402. outputPosition?: Vector3;
  147403. /**
  147404. * Vector3 of the rotation of the output plane.
  147405. */
  147406. outputRotation?: Vector3;
  147407. /**
  147408. * number of layers that the system will reserve in resources.
  147409. */
  147410. layerCount?: number;
  147411. /**
  147412. * number of max animation frames a single cell will reserve in resources.
  147413. */
  147414. maxAnimationFrames?: number;
  147415. /**
  147416. * number cell index of the base tile when the system compiles.
  147417. */
  147418. baseTile?: number;
  147419. /**
  147420. * boolean flip the sprite after its been repositioned by the framing data.
  147421. */
  147422. flipU?: boolean;
  147423. /**
  147424. * Vector3 scalar of the global RGB values of the SpriteMap.
  147425. */
  147426. colorMultiply?: Vector3;
  147427. }
  147428. /**
  147429. * Defines the IDisposable interface in order to be cleanable from resources.
  147430. */
  147431. export interface ISpriteMap extends IDisposable {
  147432. /**
  147433. * String name of the SpriteMap.
  147434. */
  147435. name: string;
  147436. /**
  147437. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  147438. */
  147439. atlasJSON: ISpriteJSONAtlas;
  147440. /**
  147441. * Texture of the SpriteMap.
  147442. */
  147443. spriteSheet: Texture;
  147444. /**
  147445. * The parameters to initialize the SpriteMap with.
  147446. */
  147447. options: ISpriteMapOptions;
  147448. }
  147449. /**
  147450. * Class used to manage a grid restricted sprite deployment on an Output plane.
  147451. */
  147452. export class SpriteMap implements ISpriteMap {
  147453. /** The Name of the spriteMap */
  147454. name: string;
  147455. /** The JSON file with the frame and meta data */
  147456. atlasJSON: ISpriteJSONAtlas;
  147457. /** The systems Sprite Sheet Texture */
  147458. spriteSheet: Texture;
  147459. /** Arguments passed with the Constructor */
  147460. options: ISpriteMapOptions;
  147461. /** Public Sprite Storage array, parsed from atlasJSON */
  147462. sprites: Array<ISpriteJSONSprite>;
  147463. /** Returns the Number of Sprites in the System */
  147464. get spriteCount(): number;
  147465. /** Returns the Position of Output Plane*/
  147466. get position(): Vector3;
  147467. /** Returns the Position of Output Plane*/
  147468. set position(v: Vector3);
  147469. /** Returns the Rotation of Output Plane*/
  147470. get rotation(): Vector3;
  147471. /** Returns the Rotation of Output Plane*/
  147472. set rotation(v: Vector3);
  147473. /** Sets the AnimationMap*/
  147474. get animationMap(): RawTexture;
  147475. /** Sets the AnimationMap*/
  147476. set animationMap(v: RawTexture);
  147477. /** Scene that the SpriteMap was created in */
  147478. private _scene;
  147479. /** Texture Buffer of Float32 that holds tile frame data*/
  147480. private _frameMap;
  147481. /** Texture Buffers of Float32 that holds tileMap data*/
  147482. private _tileMaps;
  147483. /** Texture Buffer of Float32 that holds Animation Data*/
  147484. private _animationMap;
  147485. /** Custom ShaderMaterial Central to the System*/
  147486. private _material;
  147487. /** Custom ShaderMaterial Central to the System*/
  147488. private _output;
  147489. /** Systems Time Ticker*/
  147490. private _time;
  147491. /**
  147492. * Creates a new SpriteMap
  147493. * @param name defines the SpriteMaps Name
  147494. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  147495. * @param spriteSheet is the Texture that the Sprites are on.
  147496. * @param options a basic deployment configuration
  147497. * @param scene The Scene that the map is deployed on
  147498. */
  147499. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  147500. /**
  147501. * Returns tileID location
  147502. * @returns Vector2 the cell position ID
  147503. */
  147504. getTileID(): Vector2;
  147505. /**
  147506. * Gets the UV location of the mouse over the SpriteMap.
  147507. * @returns Vector2 the UV position of the mouse interaction
  147508. */
  147509. getMousePosition(): Vector2;
  147510. /**
  147511. * Creates the "frame" texture Buffer
  147512. * -------------------------------------
  147513. * Structure of frames
  147514. * "filename": "Falling-Water-2.png",
  147515. * "frame": {"x":69,"y":103,"w":24,"h":32},
  147516. * "rotated": true,
  147517. * "trimmed": true,
  147518. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  147519. * "sourceSize": {"w":32,"h":32}
  147520. * @returns RawTexture of the frameMap
  147521. */
  147522. private _createFrameBuffer;
  147523. /**
  147524. * Creates the tileMap texture Buffer
  147525. * @param buffer normally and array of numbers, or a false to generate from scratch
  147526. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  147527. * @returns RawTexture of the tileMap
  147528. */
  147529. private _createTileBuffer;
  147530. /**
  147531. * Modifies the data of the tileMaps
  147532. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  147533. * @param pos is the iVector2 Coordinates of the Tile
  147534. * @param tile The SpriteIndex of the new Tile
  147535. */
  147536. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  147537. /**
  147538. * Creates the animationMap texture Buffer
  147539. * @param buffer normally and array of numbers, or a false to generate from scratch
  147540. * @returns RawTexture of the animationMap
  147541. */
  147542. private _createTileAnimationBuffer;
  147543. /**
  147544. * Modifies the data of the animationMap
  147545. * @param cellID is the Index of the Sprite
  147546. * @param _frame is the target Animation frame
  147547. * @param toCell is the Target Index of the next frame of the animation
  147548. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  147549. * @param speed is a global scalar of the time variable on the map.
  147550. */
  147551. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  147552. /**
  147553. * Exports the .tilemaps file
  147554. */
  147555. saveTileMaps(): void;
  147556. /**
  147557. * Imports the .tilemaps file
  147558. * @param url of the .tilemaps file
  147559. */
  147560. loadTileMaps(url: string): void;
  147561. /**
  147562. * Release associated resources
  147563. */
  147564. dispose(): void;
  147565. }
  147566. }
  147567. declare module BABYLON {
  147568. /**
  147569. * Class used to manage multiple sprites of different sizes on the same spritesheet
  147570. * @see http://doc.babylonjs.com/babylon101/sprites
  147571. */
  147572. export class SpritePackedManager extends SpriteManager {
  147573. /** defines the packed manager's name */
  147574. name: string;
  147575. /**
  147576. * Creates a new sprite manager from a packed sprite sheet
  147577. * @param name defines the manager's name
  147578. * @param imgUrl defines the sprite sheet url
  147579. * @param capacity defines the maximum allowed number of sprites
  147580. * @param scene defines the hosting scene
  147581. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  147582. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  147583. * @param samplingMode defines the smapling mode to use with spritesheet
  147584. * @param fromPacked set to true; do not alter
  147585. */
  147586. constructor(
  147587. /** defines the packed manager's name */
  147588. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  147589. }
  147590. }
  147591. declare module BABYLON {
  147592. /**
  147593. * Defines the list of states available for a task inside a AssetsManager
  147594. */
  147595. export enum AssetTaskState {
  147596. /**
  147597. * Initialization
  147598. */
  147599. INIT = 0,
  147600. /**
  147601. * Running
  147602. */
  147603. RUNNING = 1,
  147604. /**
  147605. * Done
  147606. */
  147607. DONE = 2,
  147608. /**
  147609. * Error
  147610. */
  147611. ERROR = 3
  147612. }
  147613. /**
  147614. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  147615. */
  147616. export abstract class AbstractAssetTask {
  147617. /**
  147618. * Task name
  147619. */ name: string;
  147620. /**
  147621. * Callback called when the task is successful
  147622. */
  147623. onSuccess: (task: any) => void;
  147624. /**
  147625. * Callback called when the task is not successful
  147626. */
  147627. onError: (task: any, message?: string, exception?: any) => void;
  147628. /**
  147629. * Creates a new AssetsManager
  147630. * @param name defines the name of the task
  147631. */
  147632. constructor(
  147633. /**
  147634. * Task name
  147635. */ name: string);
  147636. private _isCompleted;
  147637. private _taskState;
  147638. private _errorObject;
  147639. /**
  147640. * Get if the task is completed
  147641. */
  147642. get isCompleted(): boolean;
  147643. /**
  147644. * Gets the current state of the task
  147645. */
  147646. get taskState(): AssetTaskState;
  147647. /**
  147648. * Gets the current error object (if task is in error)
  147649. */
  147650. get errorObject(): {
  147651. message?: string;
  147652. exception?: any;
  147653. };
  147654. /**
  147655. * Internal only
  147656. * @hidden
  147657. */
  147658. _setErrorObject(message?: string, exception?: any): void;
  147659. /**
  147660. * Execute the current task
  147661. * @param scene defines the scene where you want your assets to be loaded
  147662. * @param onSuccess is a callback called when the task is successfully executed
  147663. * @param onError is a callback called if an error occurs
  147664. */
  147665. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147666. /**
  147667. * Execute the current task
  147668. * @param scene defines the scene where you want your assets to be loaded
  147669. * @param onSuccess is a callback called when the task is successfully executed
  147670. * @param onError is a callback called if an error occurs
  147671. */
  147672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147673. /**
  147674. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  147675. * This can be used with failed tasks that have the reason for failure fixed.
  147676. */
  147677. reset(): void;
  147678. private onErrorCallback;
  147679. private onDoneCallback;
  147680. }
  147681. /**
  147682. * Define the interface used by progress events raised during assets loading
  147683. */
  147684. export interface IAssetsProgressEvent {
  147685. /**
  147686. * Defines the number of remaining tasks to process
  147687. */
  147688. remainingCount: number;
  147689. /**
  147690. * Defines the total number of tasks
  147691. */
  147692. totalCount: number;
  147693. /**
  147694. * Defines the task that was just processed
  147695. */
  147696. task: AbstractAssetTask;
  147697. }
  147698. /**
  147699. * Class used to share progress information about assets loading
  147700. */
  147701. export class AssetsProgressEvent implements IAssetsProgressEvent {
  147702. /**
  147703. * Defines the number of remaining tasks to process
  147704. */
  147705. remainingCount: number;
  147706. /**
  147707. * Defines the total number of tasks
  147708. */
  147709. totalCount: number;
  147710. /**
  147711. * Defines the task that was just processed
  147712. */
  147713. task: AbstractAssetTask;
  147714. /**
  147715. * Creates a AssetsProgressEvent
  147716. * @param remainingCount defines the number of remaining tasks to process
  147717. * @param totalCount defines the total number of tasks
  147718. * @param task defines the task that was just processed
  147719. */
  147720. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  147721. }
  147722. /**
  147723. * Define a task used by AssetsManager to load meshes
  147724. */
  147725. export class MeshAssetTask extends AbstractAssetTask {
  147726. /**
  147727. * Defines the name of the task
  147728. */
  147729. name: string;
  147730. /**
  147731. * Defines the list of mesh's names you want to load
  147732. */
  147733. meshesNames: any;
  147734. /**
  147735. * Defines the root url to use as a base to load your meshes and associated resources
  147736. */
  147737. rootUrl: string;
  147738. /**
  147739. * Defines the filename or File of the scene to load from
  147740. */
  147741. sceneFilename: string | File;
  147742. /**
  147743. * Gets the list of loaded meshes
  147744. */
  147745. loadedMeshes: Array<AbstractMesh>;
  147746. /**
  147747. * Gets the list of loaded particle systems
  147748. */
  147749. loadedParticleSystems: Array<IParticleSystem>;
  147750. /**
  147751. * Gets the list of loaded skeletons
  147752. */
  147753. loadedSkeletons: Array<Skeleton>;
  147754. /**
  147755. * Gets the list of loaded animation groups
  147756. */
  147757. loadedAnimationGroups: Array<AnimationGroup>;
  147758. /**
  147759. * Callback called when the task is successful
  147760. */
  147761. onSuccess: (task: MeshAssetTask) => void;
  147762. /**
  147763. * Callback called when the task is successful
  147764. */
  147765. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  147766. /**
  147767. * Creates a new MeshAssetTask
  147768. * @param name defines the name of the task
  147769. * @param meshesNames defines the list of mesh's names you want to load
  147770. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  147771. * @param sceneFilename defines the filename or File of the scene to load from
  147772. */
  147773. constructor(
  147774. /**
  147775. * Defines the name of the task
  147776. */
  147777. name: string,
  147778. /**
  147779. * Defines the list of mesh's names you want to load
  147780. */
  147781. meshesNames: any,
  147782. /**
  147783. * Defines the root url to use as a base to load your meshes and associated resources
  147784. */
  147785. rootUrl: string,
  147786. /**
  147787. * Defines the filename or File of the scene to load from
  147788. */
  147789. sceneFilename: string | File);
  147790. /**
  147791. * Execute the current task
  147792. * @param scene defines the scene where you want your assets to be loaded
  147793. * @param onSuccess is a callback called when the task is successfully executed
  147794. * @param onError is a callback called if an error occurs
  147795. */
  147796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147797. }
  147798. /**
  147799. * Define a task used by AssetsManager to load text content
  147800. */
  147801. export class TextFileAssetTask extends AbstractAssetTask {
  147802. /**
  147803. * Defines the name of the task
  147804. */
  147805. name: string;
  147806. /**
  147807. * Defines the location of the file to load
  147808. */
  147809. url: string;
  147810. /**
  147811. * Gets the loaded text string
  147812. */
  147813. text: string;
  147814. /**
  147815. * Callback called when the task is successful
  147816. */
  147817. onSuccess: (task: TextFileAssetTask) => void;
  147818. /**
  147819. * Callback called when the task is successful
  147820. */
  147821. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  147822. /**
  147823. * Creates a new TextFileAssetTask object
  147824. * @param name defines the name of the task
  147825. * @param url defines the location of the file to load
  147826. */
  147827. constructor(
  147828. /**
  147829. * Defines the name of the task
  147830. */
  147831. name: string,
  147832. /**
  147833. * Defines the location of the file to load
  147834. */
  147835. url: string);
  147836. /**
  147837. * Execute the current task
  147838. * @param scene defines the scene where you want your assets to be loaded
  147839. * @param onSuccess is a callback called when the task is successfully executed
  147840. * @param onError is a callback called if an error occurs
  147841. */
  147842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147843. }
  147844. /**
  147845. * Define a task used by AssetsManager to load binary data
  147846. */
  147847. export class BinaryFileAssetTask extends AbstractAssetTask {
  147848. /**
  147849. * Defines the name of the task
  147850. */
  147851. name: string;
  147852. /**
  147853. * Defines the location of the file to load
  147854. */
  147855. url: string;
  147856. /**
  147857. * Gets the lodaded data (as an array buffer)
  147858. */
  147859. data: ArrayBuffer;
  147860. /**
  147861. * Callback called when the task is successful
  147862. */
  147863. onSuccess: (task: BinaryFileAssetTask) => void;
  147864. /**
  147865. * Callback called when the task is successful
  147866. */
  147867. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  147868. /**
  147869. * Creates a new BinaryFileAssetTask object
  147870. * @param name defines the name of the new task
  147871. * @param url defines the location of the file to load
  147872. */
  147873. constructor(
  147874. /**
  147875. * Defines the name of the task
  147876. */
  147877. name: string,
  147878. /**
  147879. * Defines the location of the file to load
  147880. */
  147881. url: string);
  147882. /**
  147883. * Execute the current task
  147884. * @param scene defines the scene where you want your assets to be loaded
  147885. * @param onSuccess is a callback called when the task is successfully executed
  147886. * @param onError is a callback called if an error occurs
  147887. */
  147888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147889. }
  147890. /**
  147891. * Define a task used by AssetsManager to load images
  147892. */
  147893. export class ImageAssetTask extends AbstractAssetTask {
  147894. /**
  147895. * Defines the name of the task
  147896. */
  147897. name: string;
  147898. /**
  147899. * Defines the location of the image to load
  147900. */
  147901. url: string;
  147902. /**
  147903. * Gets the loaded images
  147904. */
  147905. image: HTMLImageElement;
  147906. /**
  147907. * Callback called when the task is successful
  147908. */
  147909. onSuccess: (task: ImageAssetTask) => void;
  147910. /**
  147911. * Callback called when the task is successful
  147912. */
  147913. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  147914. /**
  147915. * Creates a new ImageAssetTask
  147916. * @param name defines the name of the task
  147917. * @param url defines the location of the image to load
  147918. */
  147919. constructor(
  147920. /**
  147921. * Defines the name of the task
  147922. */
  147923. name: string,
  147924. /**
  147925. * Defines the location of the image to load
  147926. */
  147927. url: string);
  147928. /**
  147929. * Execute the current task
  147930. * @param scene defines the scene where you want your assets to be loaded
  147931. * @param onSuccess is a callback called when the task is successfully executed
  147932. * @param onError is a callback called if an error occurs
  147933. */
  147934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147935. }
  147936. /**
  147937. * Defines the interface used by texture loading tasks
  147938. */
  147939. export interface ITextureAssetTask<TEX extends BaseTexture> {
  147940. /**
  147941. * Gets the loaded texture
  147942. */
  147943. texture: TEX;
  147944. }
  147945. /**
  147946. * Define a task used by AssetsManager to load 2D textures
  147947. */
  147948. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  147949. /**
  147950. * Defines the name of the task
  147951. */
  147952. name: string;
  147953. /**
  147954. * Defines the location of the file to load
  147955. */
  147956. url: string;
  147957. /**
  147958. * Defines if mipmap should not be generated (default is false)
  147959. */
  147960. noMipmap?: boolean | undefined;
  147961. /**
  147962. * Defines if texture must be inverted on Y axis (default is true)
  147963. */
  147964. invertY: boolean;
  147965. /**
  147966. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147967. */
  147968. samplingMode: number;
  147969. /**
  147970. * Gets the loaded texture
  147971. */
  147972. texture: Texture;
  147973. /**
  147974. * Callback called when the task is successful
  147975. */
  147976. onSuccess: (task: TextureAssetTask) => void;
  147977. /**
  147978. * Callback called when the task is successful
  147979. */
  147980. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  147981. /**
  147982. * Creates a new TextureAssetTask object
  147983. * @param name defines the name of the task
  147984. * @param url defines the location of the file to load
  147985. * @param noMipmap defines if mipmap should not be generated (default is false)
  147986. * @param invertY defines if texture must be inverted on Y axis (default is true)
  147987. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147988. */
  147989. constructor(
  147990. /**
  147991. * Defines the name of the task
  147992. */
  147993. name: string,
  147994. /**
  147995. * Defines the location of the file to load
  147996. */
  147997. url: string,
  147998. /**
  147999. * Defines if mipmap should not be generated (default is false)
  148000. */
  148001. noMipmap?: boolean | undefined,
  148002. /**
  148003. * Defines if texture must be inverted on Y axis (default is true)
  148004. */
  148005. invertY?: boolean,
  148006. /**
  148007. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148008. */
  148009. samplingMode?: number);
  148010. /**
  148011. * Execute the current task
  148012. * @param scene defines the scene where you want your assets to be loaded
  148013. * @param onSuccess is a callback called when the task is successfully executed
  148014. * @param onError is a callback called if an error occurs
  148015. */
  148016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148017. }
  148018. /**
  148019. * Define a task used by AssetsManager to load cube textures
  148020. */
  148021. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  148022. /**
  148023. * Defines the name of the task
  148024. */
  148025. name: string;
  148026. /**
  148027. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148028. */
  148029. url: string;
  148030. /**
  148031. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148032. */
  148033. extensions?: string[] | undefined;
  148034. /**
  148035. * Defines if mipmaps should not be generated (default is false)
  148036. */
  148037. noMipmap?: boolean | undefined;
  148038. /**
  148039. * Defines the explicit list of files (undefined by default)
  148040. */
  148041. files?: string[] | undefined;
  148042. /**
  148043. * Gets the loaded texture
  148044. */
  148045. texture: CubeTexture;
  148046. /**
  148047. * Callback called when the task is successful
  148048. */
  148049. onSuccess: (task: CubeTextureAssetTask) => void;
  148050. /**
  148051. * Callback called when the task is successful
  148052. */
  148053. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  148054. /**
  148055. * Creates a new CubeTextureAssetTask
  148056. * @param name defines the name of the task
  148057. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148058. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148059. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148060. * @param files defines the explicit list of files (undefined by default)
  148061. */
  148062. constructor(
  148063. /**
  148064. * Defines the name of the task
  148065. */
  148066. name: string,
  148067. /**
  148068. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148069. */
  148070. url: string,
  148071. /**
  148072. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148073. */
  148074. extensions?: string[] | undefined,
  148075. /**
  148076. * Defines if mipmaps should not be generated (default is false)
  148077. */
  148078. noMipmap?: boolean | undefined,
  148079. /**
  148080. * Defines the explicit list of files (undefined by default)
  148081. */
  148082. files?: string[] | undefined);
  148083. /**
  148084. * Execute the current task
  148085. * @param scene defines the scene where you want your assets to be loaded
  148086. * @param onSuccess is a callback called when the task is successfully executed
  148087. * @param onError is a callback called if an error occurs
  148088. */
  148089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148090. }
  148091. /**
  148092. * Define a task used by AssetsManager to load HDR cube textures
  148093. */
  148094. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  148095. /**
  148096. * Defines the name of the task
  148097. */
  148098. name: string;
  148099. /**
  148100. * Defines the location of the file to load
  148101. */
  148102. url: string;
  148103. /**
  148104. * Defines the desired size (the more it increases the longer the generation will be)
  148105. */
  148106. size: number;
  148107. /**
  148108. * Defines if mipmaps should not be generated (default is false)
  148109. */
  148110. noMipmap: boolean;
  148111. /**
  148112. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148113. */
  148114. generateHarmonics: boolean;
  148115. /**
  148116. * 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)
  148117. */
  148118. gammaSpace: boolean;
  148119. /**
  148120. * Internal Use Only
  148121. */
  148122. reserved: boolean;
  148123. /**
  148124. * Gets the loaded texture
  148125. */
  148126. texture: HDRCubeTexture;
  148127. /**
  148128. * Callback called when the task is successful
  148129. */
  148130. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  148131. /**
  148132. * Callback called when the task is successful
  148133. */
  148134. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  148135. /**
  148136. * Creates a new HDRCubeTextureAssetTask object
  148137. * @param name defines the name of the task
  148138. * @param url defines the location of the file to load
  148139. * @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.
  148140. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148141. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148142. * @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)
  148143. * @param reserved Internal use only
  148144. */
  148145. constructor(
  148146. /**
  148147. * Defines the name of the task
  148148. */
  148149. name: string,
  148150. /**
  148151. * Defines the location of the file to load
  148152. */
  148153. url: string,
  148154. /**
  148155. * Defines the desired size (the more it increases the longer the generation will be)
  148156. */
  148157. size: number,
  148158. /**
  148159. * Defines if mipmaps should not be generated (default is false)
  148160. */
  148161. noMipmap?: boolean,
  148162. /**
  148163. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148164. */
  148165. generateHarmonics?: boolean,
  148166. /**
  148167. * 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)
  148168. */
  148169. gammaSpace?: boolean,
  148170. /**
  148171. * Internal Use Only
  148172. */
  148173. reserved?: boolean);
  148174. /**
  148175. * Execute the current task
  148176. * @param scene defines the scene where you want your assets to be loaded
  148177. * @param onSuccess is a callback called when the task is successfully executed
  148178. * @param onError is a callback called if an error occurs
  148179. */
  148180. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148181. }
  148182. /**
  148183. * Define a task used by AssetsManager to load Equirectangular cube textures
  148184. */
  148185. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  148186. /**
  148187. * Defines the name of the task
  148188. */
  148189. name: string;
  148190. /**
  148191. * Defines the location of the file to load
  148192. */
  148193. url: string;
  148194. /**
  148195. * Defines the desired size (the more it increases the longer the generation will be)
  148196. */
  148197. size: number;
  148198. /**
  148199. * Defines if mipmaps should not be generated (default is false)
  148200. */
  148201. noMipmap: boolean;
  148202. /**
  148203. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148204. * but the standard material would require them in Gamma space) (default is true)
  148205. */
  148206. gammaSpace: boolean;
  148207. /**
  148208. * Gets the loaded texture
  148209. */
  148210. texture: EquiRectangularCubeTexture;
  148211. /**
  148212. * Callback called when the task is successful
  148213. */
  148214. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  148215. /**
  148216. * Callback called when the task is successful
  148217. */
  148218. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  148219. /**
  148220. * Creates a new EquiRectangularCubeTextureAssetTask object
  148221. * @param name defines the name of the task
  148222. * @param url defines the location of the file to load
  148223. * @param size defines the desired size (the more it increases the longer the generation will be)
  148224. * If the size is omitted this implies you are using a preprocessed cubemap.
  148225. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148226. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  148227. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  148228. * (default is true)
  148229. */
  148230. constructor(
  148231. /**
  148232. * Defines the name of the task
  148233. */
  148234. name: string,
  148235. /**
  148236. * Defines the location of the file to load
  148237. */
  148238. url: string,
  148239. /**
  148240. * Defines the desired size (the more it increases the longer the generation will be)
  148241. */
  148242. size: number,
  148243. /**
  148244. * Defines if mipmaps should not be generated (default is false)
  148245. */
  148246. noMipmap?: boolean,
  148247. /**
  148248. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148249. * but the standard material would require them in Gamma space) (default is true)
  148250. */
  148251. gammaSpace?: boolean);
  148252. /**
  148253. * Execute the current task
  148254. * @param scene defines the scene where you want your assets to be loaded
  148255. * @param onSuccess is a callback called when the task is successfully executed
  148256. * @param onError is a callback called if an error occurs
  148257. */
  148258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148259. }
  148260. /**
  148261. * This class can be used to easily import assets into a scene
  148262. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  148263. */
  148264. export class AssetsManager {
  148265. private _scene;
  148266. private _isLoading;
  148267. protected _tasks: AbstractAssetTask[];
  148268. protected _waitingTasksCount: number;
  148269. protected _totalTasksCount: number;
  148270. /**
  148271. * Callback called when all tasks are processed
  148272. */
  148273. onFinish: (tasks: AbstractAssetTask[]) => void;
  148274. /**
  148275. * Callback called when a task is successful
  148276. */
  148277. onTaskSuccess: (task: AbstractAssetTask) => void;
  148278. /**
  148279. * Callback called when a task had an error
  148280. */
  148281. onTaskError: (task: AbstractAssetTask) => void;
  148282. /**
  148283. * Callback called when a task is done (whatever the result is)
  148284. */
  148285. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  148286. /**
  148287. * Observable called when all tasks are processed
  148288. */
  148289. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  148290. /**
  148291. * Observable called when a task had an error
  148292. */
  148293. onTaskErrorObservable: Observable<AbstractAssetTask>;
  148294. /**
  148295. * Observable called when all tasks were executed
  148296. */
  148297. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  148298. /**
  148299. * Observable called when a task is done (whatever the result is)
  148300. */
  148301. onProgressObservable: Observable<IAssetsProgressEvent>;
  148302. /**
  148303. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  148304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  148305. */
  148306. useDefaultLoadingScreen: boolean;
  148307. /**
  148308. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  148309. * when all assets have been downloaded.
  148310. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  148311. */
  148312. autoHideLoadingUI: boolean;
  148313. /**
  148314. * Creates a new AssetsManager
  148315. * @param scene defines the scene to work on
  148316. */
  148317. constructor(scene: Scene);
  148318. /**
  148319. * Add a MeshAssetTask to the list of active tasks
  148320. * @param taskName defines the name of the new task
  148321. * @param meshesNames defines the name of meshes to load
  148322. * @param rootUrl defines the root url to use to locate files
  148323. * @param sceneFilename defines the filename of the scene file
  148324. * @returns a new MeshAssetTask object
  148325. */
  148326. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  148327. /**
  148328. * Add a TextFileAssetTask to the list of active tasks
  148329. * @param taskName defines the name of the new task
  148330. * @param url defines the url of the file to load
  148331. * @returns a new TextFileAssetTask object
  148332. */
  148333. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  148334. /**
  148335. * Add a BinaryFileAssetTask to the list of active tasks
  148336. * @param taskName defines the name of the new task
  148337. * @param url defines the url of the file to load
  148338. * @returns a new BinaryFileAssetTask object
  148339. */
  148340. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  148341. /**
  148342. * Add a ImageAssetTask to the list of active tasks
  148343. * @param taskName defines the name of the new task
  148344. * @param url defines the url of the file to load
  148345. * @returns a new ImageAssetTask object
  148346. */
  148347. addImageTask(taskName: string, url: string): ImageAssetTask;
  148348. /**
  148349. * Add a TextureAssetTask to the list of active tasks
  148350. * @param taskName defines the name of the new task
  148351. * @param url defines the url of the file to load
  148352. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148353. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  148354. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  148355. * @returns a new TextureAssetTask object
  148356. */
  148357. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  148358. /**
  148359. * Add a CubeTextureAssetTask to the list of active tasks
  148360. * @param taskName defines the name of the new task
  148361. * @param url defines the url of the file to load
  148362. * @param extensions defines the extension to use to load the cube map (can be null)
  148363. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148364. * @param files defines the list of files to load (can be null)
  148365. * @returns a new CubeTextureAssetTask object
  148366. */
  148367. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  148368. /**
  148369. *
  148370. * Add a HDRCubeTextureAssetTask to the list of active tasks
  148371. * @param taskName defines the name of the new task
  148372. * @param url defines the url of the file to load
  148373. * @param size defines the size you want for the cubemap (can be null)
  148374. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148375. * @param generateHarmonics defines if you want to automatically generate (true by default)
  148376. * @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)
  148377. * @param reserved Internal use only
  148378. * @returns a new HDRCubeTextureAssetTask object
  148379. */
  148380. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  148381. /**
  148382. *
  148383. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  148384. * @param taskName defines the name of the new task
  148385. * @param url defines the url of the file to load
  148386. * @param size defines the size you want for the cubemap (can be null)
  148387. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148388. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  148389. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  148390. * @returns a new EquiRectangularCubeTextureAssetTask object
  148391. */
  148392. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  148393. /**
  148394. * Remove a task from the assets manager.
  148395. * @param task the task to remove
  148396. */
  148397. removeTask(task: AbstractAssetTask): void;
  148398. private _decreaseWaitingTasksCount;
  148399. private _runTask;
  148400. /**
  148401. * Reset the AssetsManager and remove all tasks
  148402. * @return the current instance of the AssetsManager
  148403. */
  148404. reset(): AssetsManager;
  148405. /**
  148406. * Start the loading process
  148407. * @return the current instance of the AssetsManager
  148408. */
  148409. load(): AssetsManager;
  148410. /**
  148411. * Start the loading process as an async operation
  148412. * @return a promise returning the list of failed tasks
  148413. */
  148414. loadAsync(): Promise<void>;
  148415. }
  148416. }
  148417. declare module BABYLON {
  148418. /**
  148419. * Wrapper class for promise with external resolve and reject.
  148420. */
  148421. export class Deferred<T> {
  148422. /**
  148423. * The promise associated with this deferred object.
  148424. */
  148425. readonly promise: Promise<T>;
  148426. private _resolve;
  148427. private _reject;
  148428. /**
  148429. * The resolve method of the promise associated with this deferred object.
  148430. */
  148431. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  148432. /**
  148433. * The reject method of the promise associated with this deferred object.
  148434. */
  148435. get reject(): (reason?: any) => void;
  148436. /**
  148437. * Constructor for this deferred object.
  148438. */
  148439. constructor();
  148440. }
  148441. }
  148442. declare module BABYLON {
  148443. /**
  148444. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  148445. */
  148446. export class MeshExploder {
  148447. private _centerMesh;
  148448. private _meshes;
  148449. private _meshesOrigins;
  148450. private _toCenterVectors;
  148451. private _scaledDirection;
  148452. private _newPosition;
  148453. private _centerPosition;
  148454. /**
  148455. * Explodes meshes from a center mesh.
  148456. * @param meshes The meshes to explode.
  148457. * @param centerMesh The mesh to be center of explosion.
  148458. */
  148459. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  148460. private _setCenterMesh;
  148461. /**
  148462. * Get class name
  148463. * @returns "MeshExploder"
  148464. */
  148465. getClassName(): string;
  148466. /**
  148467. * "Exploded meshes"
  148468. * @returns Array of meshes with the centerMesh at index 0.
  148469. */
  148470. getMeshes(): Array<Mesh>;
  148471. /**
  148472. * Explodes meshes giving a specific direction
  148473. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  148474. */
  148475. explode(direction?: number): void;
  148476. }
  148477. }
  148478. declare module BABYLON {
  148479. /**
  148480. * Class used to help managing file picking and drag'n'drop
  148481. */
  148482. export class FilesInput {
  148483. /**
  148484. * List of files ready to be loaded
  148485. */
  148486. static get FilesToLoad(): {
  148487. [key: string]: File;
  148488. };
  148489. /**
  148490. * Callback called when a file is processed
  148491. */
  148492. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  148493. private _engine;
  148494. private _currentScene;
  148495. private _sceneLoadedCallback;
  148496. private _progressCallback;
  148497. private _additionalRenderLoopLogicCallback;
  148498. private _textureLoadingCallback;
  148499. private _startingProcessingFilesCallback;
  148500. private _onReloadCallback;
  148501. private _errorCallback;
  148502. private _elementToMonitor;
  148503. private _sceneFileToLoad;
  148504. private _filesToLoad;
  148505. /**
  148506. * Creates a new FilesInput
  148507. * @param engine defines the rendering engine
  148508. * @param scene defines the hosting scene
  148509. * @param sceneLoadedCallback callback called when scene is loaded
  148510. * @param progressCallback callback called to track progress
  148511. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  148512. * @param textureLoadingCallback callback called when a texture is loading
  148513. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  148514. * @param onReloadCallback callback called when a reload is requested
  148515. * @param errorCallback callback call if an error occurs
  148516. */
  148517. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  148518. private _dragEnterHandler;
  148519. private _dragOverHandler;
  148520. private _dropHandler;
  148521. /**
  148522. * Calls this function to listen to drag'n'drop events on a specific DOM element
  148523. * @param elementToMonitor defines the DOM element to track
  148524. */
  148525. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  148526. /**
  148527. * Release all associated resources
  148528. */
  148529. dispose(): void;
  148530. private renderFunction;
  148531. private drag;
  148532. private drop;
  148533. private _traverseFolder;
  148534. private _processFiles;
  148535. /**
  148536. * Load files from a drop event
  148537. * @param event defines the drop event to use as source
  148538. */
  148539. loadFiles(event: any): void;
  148540. private _processReload;
  148541. /**
  148542. * Reload the current scene from the loaded files
  148543. */
  148544. reload(): void;
  148545. }
  148546. }
  148547. declare module BABYLON {
  148548. /**
  148549. * Defines the root class used to create scene optimization to use with SceneOptimizer
  148550. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148551. */
  148552. export class SceneOptimization {
  148553. /**
  148554. * Defines the priority of this optimization (0 by default which means first in the list)
  148555. */
  148556. priority: number;
  148557. /**
  148558. * Gets a string describing the action executed by the current optimization
  148559. * @returns description string
  148560. */
  148561. getDescription(): string;
  148562. /**
  148563. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148564. * @param scene defines the current scene where to apply this optimization
  148565. * @param optimizer defines the current optimizer
  148566. * @returns true if everything that can be done was applied
  148567. */
  148568. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148569. /**
  148570. * Creates the SceneOptimization object
  148571. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148572. * @param desc defines the description associated with the optimization
  148573. */
  148574. constructor(
  148575. /**
  148576. * Defines the priority of this optimization (0 by default which means first in the list)
  148577. */
  148578. priority?: number);
  148579. }
  148580. /**
  148581. * Defines an optimization used to reduce the size of render target textures
  148582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148583. */
  148584. export class TextureOptimization extends SceneOptimization {
  148585. /**
  148586. * Defines the priority of this optimization (0 by default which means first in the list)
  148587. */
  148588. priority: number;
  148589. /**
  148590. * 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
  148591. */
  148592. maximumSize: number;
  148593. /**
  148594. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148595. */
  148596. step: number;
  148597. /**
  148598. * Gets a string describing the action executed by the current optimization
  148599. * @returns description string
  148600. */
  148601. getDescription(): string;
  148602. /**
  148603. * Creates the TextureOptimization object
  148604. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148605. * @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
  148606. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148607. */
  148608. constructor(
  148609. /**
  148610. * Defines the priority of this optimization (0 by default which means first in the list)
  148611. */
  148612. priority?: number,
  148613. /**
  148614. * 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
  148615. */
  148616. maximumSize?: number,
  148617. /**
  148618. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148619. */
  148620. step?: number);
  148621. /**
  148622. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148623. * @param scene defines the current scene where to apply this optimization
  148624. * @param optimizer defines the current optimizer
  148625. * @returns true if everything that can be done was applied
  148626. */
  148627. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148628. }
  148629. /**
  148630. * Defines an optimization used to increase or decrease the rendering resolution
  148631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148632. */
  148633. export class HardwareScalingOptimization extends SceneOptimization {
  148634. /**
  148635. * Defines the priority of this optimization (0 by default which means first in the list)
  148636. */
  148637. priority: number;
  148638. /**
  148639. * Defines the maximum scale to use (2 by default)
  148640. */
  148641. maximumScale: number;
  148642. /**
  148643. * Defines the step to use between two passes (0.5 by default)
  148644. */
  148645. step: number;
  148646. private _currentScale;
  148647. private _directionOffset;
  148648. /**
  148649. * Gets a string describing the action executed by the current optimization
  148650. * @return description string
  148651. */
  148652. getDescription(): string;
  148653. /**
  148654. * Creates the HardwareScalingOptimization object
  148655. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148656. * @param maximumScale defines the maximum scale to use (2 by default)
  148657. * @param step defines the step to use between two passes (0.5 by default)
  148658. */
  148659. constructor(
  148660. /**
  148661. * Defines the priority of this optimization (0 by default which means first in the list)
  148662. */
  148663. priority?: number,
  148664. /**
  148665. * Defines the maximum scale to use (2 by default)
  148666. */
  148667. maximumScale?: number,
  148668. /**
  148669. * Defines the step to use between two passes (0.5 by default)
  148670. */
  148671. step?: number);
  148672. /**
  148673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148674. * @param scene defines the current scene where to apply this optimization
  148675. * @param optimizer defines the current optimizer
  148676. * @returns true if everything that can be done was applied
  148677. */
  148678. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148679. }
  148680. /**
  148681. * Defines an optimization used to remove shadows
  148682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148683. */
  148684. export class ShadowsOptimization extends SceneOptimization {
  148685. /**
  148686. * Gets a string describing the action executed by the current optimization
  148687. * @return description string
  148688. */
  148689. getDescription(): string;
  148690. /**
  148691. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148692. * @param scene defines the current scene where to apply this optimization
  148693. * @param optimizer defines the current optimizer
  148694. * @returns true if everything that can be done was applied
  148695. */
  148696. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148697. }
  148698. /**
  148699. * Defines an optimization used to turn post-processes off
  148700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148701. */
  148702. export class PostProcessesOptimization extends SceneOptimization {
  148703. /**
  148704. * Gets a string describing the action executed by the current optimization
  148705. * @return description string
  148706. */
  148707. getDescription(): string;
  148708. /**
  148709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148710. * @param scene defines the current scene where to apply this optimization
  148711. * @param optimizer defines the current optimizer
  148712. * @returns true if everything that can be done was applied
  148713. */
  148714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148715. }
  148716. /**
  148717. * Defines an optimization used to turn lens flares off
  148718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148719. */
  148720. export class LensFlaresOptimization extends SceneOptimization {
  148721. /**
  148722. * Gets a string describing the action executed by the current optimization
  148723. * @return description string
  148724. */
  148725. getDescription(): string;
  148726. /**
  148727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148728. * @param scene defines the current scene where to apply this optimization
  148729. * @param optimizer defines the current optimizer
  148730. * @returns true if everything that can be done was applied
  148731. */
  148732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148733. }
  148734. /**
  148735. * Defines an optimization based on user defined callback.
  148736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148737. */
  148738. export class CustomOptimization extends SceneOptimization {
  148739. /**
  148740. * Callback called to apply the custom optimization.
  148741. */
  148742. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  148743. /**
  148744. * Callback called to get custom description
  148745. */
  148746. onGetDescription: () => string;
  148747. /**
  148748. * Gets a string describing the action executed by the current optimization
  148749. * @returns description string
  148750. */
  148751. getDescription(): string;
  148752. /**
  148753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148754. * @param scene defines the current scene where to apply this optimization
  148755. * @param optimizer defines the current optimizer
  148756. * @returns true if everything that can be done was applied
  148757. */
  148758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148759. }
  148760. /**
  148761. * Defines an optimization used to turn particles off
  148762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148763. */
  148764. export class ParticlesOptimization extends SceneOptimization {
  148765. /**
  148766. * Gets a string describing the action executed by the current optimization
  148767. * @return description string
  148768. */
  148769. getDescription(): string;
  148770. /**
  148771. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148772. * @param scene defines the current scene where to apply this optimization
  148773. * @param optimizer defines the current optimizer
  148774. * @returns true if everything that can be done was applied
  148775. */
  148776. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148777. }
  148778. /**
  148779. * Defines an optimization used to turn render targets off
  148780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148781. */
  148782. export class RenderTargetsOptimization extends SceneOptimization {
  148783. /**
  148784. * Gets a string describing the action executed by the current optimization
  148785. * @return description string
  148786. */
  148787. getDescription(): string;
  148788. /**
  148789. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148790. * @param scene defines the current scene where to apply this optimization
  148791. * @param optimizer defines the current optimizer
  148792. * @returns true if everything that can be done was applied
  148793. */
  148794. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148795. }
  148796. /**
  148797. * Defines an optimization used to merge meshes with compatible materials
  148798. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148799. */
  148800. export class MergeMeshesOptimization extends SceneOptimization {
  148801. private static _UpdateSelectionTree;
  148802. /**
  148803. * Gets or sets a boolean which defines if optimization octree has to be updated
  148804. */
  148805. static get UpdateSelectionTree(): boolean;
  148806. /**
  148807. * Gets or sets a boolean which defines if optimization octree has to be updated
  148808. */
  148809. static set UpdateSelectionTree(value: boolean);
  148810. /**
  148811. * Gets a string describing the action executed by the current optimization
  148812. * @return description string
  148813. */
  148814. getDescription(): string;
  148815. private _canBeMerged;
  148816. /**
  148817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148818. * @param scene defines the current scene where to apply this optimization
  148819. * @param optimizer defines the current optimizer
  148820. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  148821. * @returns true if everything that can be done was applied
  148822. */
  148823. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  148824. }
  148825. /**
  148826. * Defines a list of options used by SceneOptimizer
  148827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148828. */
  148829. export class SceneOptimizerOptions {
  148830. /**
  148831. * Defines the target frame rate to reach (60 by default)
  148832. */
  148833. targetFrameRate: number;
  148834. /**
  148835. * Defines the interval between two checkes (2000ms by default)
  148836. */
  148837. trackerDuration: number;
  148838. /**
  148839. * Gets the list of optimizations to apply
  148840. */
  148841. optimizations: SceneOptimization[];
  148842. /**
  148843. * Creates a new list of options used by SceneOptimizer
  148844. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  148845. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  148846. */
  148847. constructor(
  148848. /**
  148849. * Defines the target frame rate to reach (60 by default)
  148850. */
  148851. targetFrameRate?: number,
  148852. /**
  148853. * Defines the interval between two checkes (2000ms by default)
  148854. */
  148855. trackerDuration?: number);
  148856. /**
  148857. * Add a new optimization
  148858. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  148859. * @returns the current SceneOptimizerOptions
  148860. */
  148861. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  148862. /**
  148863. * Add a new custom optimization
  148864. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  148865. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  148866. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148867. * @returns the current SceneOptimizerOptions
  148868. */
  148869. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  148870. /**
  148871. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  148872. * @param targetFrameRate defines the target frame rate (60 by default)
  148873. * @returns a SceneOptimizerOptions object
  148874. */
  148875. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148876. /**
  148877. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  148878. * @param targetFrameRate defines the target frame rate (60 by default)
  148879. * @returns a SceneOptimizerOptions object
  148880. */
  148881. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148882. /**
  148883. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  148884. * @param targetFrameRate defines the target frame rate (60 by default)
  148885. * @returns a SceneOptimizerOptions object
  148886. */
  148887. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148888. }
  148889. /**
  148890. * Class used to run optimizations in order to reach a target frame rate
  148891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148892. */
  148893. export class SceneOptimizer implements IDisposable {
  148894. private _isRunning;
  148895. private _options;
  148896. private _scene;
  148897. private _currentPriorityLevel;
  148898. private _targetFrameRate;
  148899. private _trackerDuration;
  148900. private _currentFrameRate;
  148901. private _sceneDisposeObserver;
  148902. private _improvementMode;
  148903. /**
  148904. * Defines an observable called when the optimizer reaches the target frame rate
  148905. */
  148906. onSuccessObservable: Observable<SceneOptimizer>;
  148907. /**
  148908. * Defines an observable called when the optimizer enables an optimization
  148909. */
  148910. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  148911. /**
  148912. * Defines an observable called when the optimizer is not able to reach the target frame rate
  148913. */
  148914. onFailureObservable: Observable<SceneOptimizer>;
  148915. /**
  148916. * Gets a boolean indicating if the optimizer is in improvement mode
  148917. */
  148918. get isInImprovementMode(): boolean;
  148919. /**
  148920. * Gets the current priority level (0 at start)
  148921. */
  148922. get currentPriorityLevel(): number;
  148923. /**
  148924. * Gets the current frame rate checked by the SceneOptimizer
  148925. */
  148926. get currentFrameRate(): number;
  148927. /**
  148928. * Gets or sets the current target frame rate (60 by default)
  148929. */
  148930. get targetFrameRate(): number;
  148931. /**
  148932. * Gets or sets the current target frame rate (60 by default)
  148933. */
  148934. set targetFrameRate(value: number);
  148935. /**
  148936. * Gets or sets the current interval between two checks (every 2000ms by default)
  148937. */
  148938. get trackerDuration(): number;
  148939. /**
  148940. * Gets or sets the current interval between two checks (every 2000ms by default)
  148941. */
  148942. set trackerDuration(value: number);
  148943. /**
  148944. * Gets the list of active optimizations
  148945. */
  148946. get optimizations(): SceneOptimization[];
  148947. /**
  148948. * Creates a new SceneOptimizer
  148949. * @param scene defines the scene to work on
  148950. * @param options defines the options to use with the SceneOptimizer
  148951. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  148952. * @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)
  148953. */
  148954. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  148955. /**
  148956. * Stops the current optimizer
  148957. */
  148958. stop(): void;
  148959. /**
  148960. * Reset the optimizer to initial step (current priority level = 0)
  148961. */
  148962. reset(): void;
  148963. /**
  148964. * Start the optimizer. By default it will try to reach a specific framerate
  148965. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  148966. */
  148967. start(): void;
  148968. private _checkCurrentState;
  148969. /**
  148970. * Release all resources
  148971. */
  148972. dispose(): void;
  148973. /**
  148974. * Helper function to create a SceneOptimizer with one single line of code
  148975. * @param scene defines the scene to work on
  148976. * @param options defines the options to use with the SceneOptimizer
  148977. * @param onSuccess defines a callback to call on success
  148978. * @param onFailure defines a callback to call on failure
  148979. * @returns the new SceneOptimizer object
  148980. */
  148981. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  148982. }
  148983. }
  148984. declare module BABYLON {
  148985. /**
  148986. * Class used to serialize a scene into a string
  148987. */
  148988. export class SceneSerializer {
  148989. /**
  148990. * Clear cache used by a previous serialization
  148991. */
  148992. static ClearCache(): void;
  148993. /**
  148994. * Serialize a scene into a JSON compatible object
  148995. * @param scene defines the scene to serialize
  148996. * @returns a JSON compatible object
  148997. */
  148998. static Serialize(scene: Scene): any;
  148999. /**
  149000. * Serialize a mesh into a JSON compatible object
  149001. * @param toSerialize defines the mesh to serialize
  149002. * @param withParents defines if parents must be serialized as well
  149003. * @param withChildren defines if children must be serialized as well
  149004. * @returns a JSON compatible object
  149005. */
  149006. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  149007. }
  149008. }
  149009. declare module BABYLON {
  149010. /**
  149011. * Class used to host texture specific utilities
  149012. */
  149013. export class TextureTools {
  149014. /**
  149015. * Uses the GPU to create a copy texture rescaled at a given size
  149016. * @param texture Texture to copy from
  149017. * @param width defines the desired width
  149018. * @param height defines the desired height
  149019. * @param useBilinearMode defines if bilinear mode has to be used
  149020. * @return the generated texture
  149021. */
  149022. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  149023. }
  149024. }
  149025. declare module BABYLON {
  149026. /**
  149027. * This represents the different options available for the video capture.
  149028. */
  149029. export interface VideoRecorderOptions {
  149030. /** Defines the mime type of the video. */
  149031. mimeType: string;
  149032. /** Defines the FPS the video should be recorded at. */
  149033. fps: number;
  149034. /** Defines the chunk size for the recording data. */
  149035. recordChunckSize: number;
  149036. /** The audio tracks to attach to the recording. */
  149037. audioTracks?: MediaStreamTrack[];
  149038. }
  149039. /**
  149040. * This can help with recording videos from BabylonJS.
  149041. * This is based on the available WebRTC functionalities of the browser.
  149042. *
  149043. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  149044. */
  149045. export class VideoRecorder {
  149046. private static readonly _defaultOptions;
  149047. /**
  149048. * Returns whether or not the VideoRecorder is available in your browser.
  149049. * @param engine Defines the Babylon Engine.
  149050. * @returns true if supported otherwise false.
  149051. */
  149052. static IsSupported(engine: Engine): boolean;
  149053. private readonly _options;
  149054. private _canvas;
  149055. private _mediaRecorder;
  149056. private _recordedChunks;
  149057. private _fileName;
  149058. private _resolve;
  149059. private _reject;
  149060. /**
  149061. * True when a recording is already in progress.
  149062. */
  149063. get isRecording(): boolean;
  149064. /**
  149065. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  149066. * @param engine Defines the BabylonJS Engine you wish to record.
  149067. * @param options Defines options that can be used to customize the capture.
  149068. */
  149069. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  149070. /**
  149071. * Stops the current recording before the default capture timeout passed in the startRecording function.
  149072. */
  149073. stopRecording(): void;
  149074. /**
  149075. * Starts recording the canvas for a max duration specified in parameters.
  149076. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  149077. * If null no automatic download will start and you can rely on the promise to get the data back.
  149078. * @param maxDuration Defines the maximum recording time in seconds.
  149079. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  149080. * @return A promise callback at the end of the recording with the video data in Blob.
  149081. */
  149082. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  149083. /**
  149084. * Releases internal resources used during the recording.
  149085. */
  149086. dispose(): void;
  149087. private _handleDataAvailable;
  149088. private _handleError;
  149089. private _handleStop;
  149090. }
  149091. }
  149092. declare module BABYLON {
  149093. /**
  149094. * Class containing a set of static utilities functions for screenshots
  149095. */
  149096. export class ScreenshotTools {
  149097. /**
  149098. * Captures a screenshot of the current rendering
  149099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149100. * @param engine defines the rendering engine
  149101. * @param camera defines the source camera
  149102. * @param size This parameter can be set to a single number or to an object with the
  149103. * following (optional) properties: precision, width, height. If a single number is passed,
  149104. * it will be used for both width and height. If an object is passed, the screenshot size
  149105. * will be derived from the parameters. The precision property is a multiplier allowing
  149106. * rendering at a higher or lower resolution
  149107. * @param successCallback defines the callback receives a single parameter which contains the
  149108. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149109. * src parameter of an <img> to display it
  149110. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149111. * Check your browser for supported MIME types
  149112. */
  149113. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  149114. /**
  149115. * Captures a screenshot of the current rendering
  149116. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149117. * @param engine defines the rendering engine
  149118. * @param camera defines the source camera
  149119. * @param size This parameter can be set to a single number or to an object with the
  149120. * following (optional) properties: precision, width, height. If a single number is passed,
  149121. * it will be used for both width and height. If an object is passed, the screenshot size
  149122. * will be derived from the parameters. The precision property is a multiplier allowing
  149123. * rendering at a higher or lower resolution
  149124. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149125. * Check your browser for supported MIME types
  149126. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149127. * to the src parameter of an <img> to display it
  149128. */
  149129. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  149130. /**
  149131. * Generates an image screenshot from the specified camera.
  149132. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149133. * @param engine The engine to use for rendering
  149134. * @param camera The camera to use for rendering
  149135. * @param size This parameter can be set to a single number or to an object with the
  149136. * following (optional) properties: precision, width, height. If a single number is passed,
  149137. * it will be used for both width and height. If an object is passed, the screenshot size
  149138. * will be derived from the parameters. The precision property is a multiplier allowing
  149139. * rendering at a higher or lower resolution
  149140. * @param successCallback The callback receives a single parameter which contains the
  149141. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149142. * src parameter of an <img> to display it
  149143. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149144. * Check your browser for supported MIME types
  149145. * @param samples Texture samples (default: 1)
  149146. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149147. * @param fileName A name for for the downloaded file.
  149148. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149149. */
  149150. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  149151. /**
  149152. * Generates an image screenshot from the specified camera.
  149153. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149154. * @param engine The engine to use for rendering
  149155. * @param camera The camera to use for rendering
  149156. * @param size This parameter can be set to a single number or to an object with the
  149157. * following (optional) properties: precision, width, height. If a single number is passed,
  149158. * it will be used for both width and height. If an object is passed, the screenshot size
  149159. * will be derived from the parameters. The precision property is a multiplier allowing
  149160. * rendering at a higher or lower resolution
  149161. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149162. * Check your browser for supported MIME types
  149163. * @param samples Texture samples (default: 1)
  149164. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149165. * @param fileName A name for for the downloaded file.
  149166. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149167. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149168. * to the src parameter of an <img> to display it
  149169. */
  149170. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  149171. /**
  149172. * Gets height and width for screenshot size
  149173. * @private
  149174. */
  149175. private static _getScreenshotSize;
  149176. }
  149177. }
  149178. declare module BABYLON {
  149179. /**
  149180. * Interface for a data buffer
  149181. */
  149182. export interface IDataBuffer {
  149183. /**
  149184. * Reads bytes from the data buffer.
  149185. * @param byteOffset The byte offset to read
  149186. * @param byteLength The byte length to read
  149187. * @returns A promise that resolves when the bytes are read
  149188. */
  149189. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  149190. /**
  149191. * The byte length of the buffer.
  149192. */
  149193. readonly byteLength: number;
  149194. }
  149195. /**
  149196. * Utility class for reading from a data buffer
  149197. */
  149198. export class DataReader {
  149199. /**
  149200. * The data buffer associated with this data reader.
  149201. */
  149202. readonly buffer: IDataBuffer;
  149203. /**
  149204. * The current byte offset from the beginning of the data buffer.
  149205. */
  149206. byteOffset: number;
  149207. private _dataView;
  149208. private _dataByteOffset;
  149209. /**
  149210. * Constructor
  149211. * @param buffer The buffer to read
  149212. */
  149213. constructor(buffer: IDataBuffer);
  149214. /**
  149215. * Loads the given byte length.
  149216. * @param byteLength The byte length to load
  149217. * @returns A promise that resolves when the load is complete
  149218. */
  149219. loadAsync(byteLength: number): Promise<void>;
  149220. /**
  149221. * Read a unsigned 32-bit integer from the currently loaded data range.
  149222. * @returns The 32-bit integer read
  149223. */
  149224. readUint32(): number;
  149225. /**
  149226. * Read a byte array from the currently loaded data range.
  149227. * @param byteLength The byte length to read
  149228. * @returns The byte array read
  149229. */
  149230. readUint8Array(byteLength: number): Uint8Array;
  149231. /**
  149232. * Read a string from the currently loaded data range.
  149233. * @param byteLength The byte length to read
  149234. * @returns The string read
  149235. */
  149236. readString(byteLength: number): string;
  149237. /**
  149238. * Skips the given byte length the currently loaded data range.
  149239. * @param byteLength The byte length to skip
  149240. */
  149241. skipBytes(byteLength: number): void;
  149242. }
  149243. }
  149244. declare module BABYLON {
  149245. /**
  149246. * Class for storing data to local storage if available or in-memory storage otherwise
  149247. */
  149248. export class DataStorage {
  149249. private static _Storage;
  149250. private static _GetStorage;
  149251. /**
  149252. * Reads a string from the data storage
  149253. * @param key The key to read
  149254. * @param defaultValue The value if the key doesn't exist
  149255. * @returns The string value
  149256. */
  149257. static ReadString(key: string, defaultValue: string): string;
  149258. /**
  149259. * Writes a string to the data storage
  149260. * @param key The key to write
  149261. * @param value The value to write
  149262. */
  149263. static WriteString(key: string, value: string): void;
  149264. /**
  149265. * Reads a boolean from the data storage
  149266. * @param key The key to read
  149267. * @param defaultValue The value if the key doesn't exist
  149268. * @returns The boolean value
  149269. */
  149270. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  149271. /**
  149272. * Writes a boolean to the data storage
  149273. * @param key The key to write
  149274. * @param value The value to write
  149275. */
  149276. static WriteBoolean(key: string, value: boolean): void;
  149277. /**
  149278. * Reads a number from the data storage
  149279. * @param key The key to read
  149280. * @param defaultValue The value if the key doesn't exist
  149281. * @returns The number value
  149282. */
  149283. static ReadNumber(key: string, defaultValue: number): number;
  149284. /**
  149285. * Writes a number to the data storage
  149286. * @param key The key to write
  149287. * @param value The value to write
  149288. */
  149289. static WriteNumber(key: string, value: number): void;
  149290. }
  149291. }
  149292. declare module BABYLON {
  149293. /**
  149294. * An interface for all Hit test features
  149295. */
  149296. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  149297. /**
  149298. * Triggered when new babylon (transformed) hit test results are available
  149299. */
  149300. onHitTestResultObservable: Observable<T[]>;
  149301. }
  149302. /**
  149303. * Options used for hit testing
  149304. */
  149305. export interface IWebXRLegacyHitTestOptions {
  149306. /**
  149307. * Only test when user interacted with the scene. Default - hit test every frame
  149308. */
  149309. testOnPointerDownOnly?: boolean;
  149310. /**
  149311. * The node to use to transform the local results to world coordinates
  149312. */
  149313. worldParentNode?: TransformNode;
  149314. }
  149315. /**
  149316. * Interface defining the babylon result of raycasting/hit-test
  149317. */
  149318. export interface IWebXRLegacyHitResult {
  149319. /**
  149320. * Transformation matrix that can be applied to a node that will put it in the hit point location
  149321. */
  149322. transformationMatrix: Matrix;
  149323. /**
  149324. * The native hit test result
  149325. */
  149326. xrHitResult: XRHitResult | XRHitTestResult;
  149327. }
  149328. /**
  149329. * The currently-working hit-test module.
  149330. * Hit test (or Ray-casting) is used to interact with the real world.
  149331. * For further information read here - https://github.com/immersive-web/hit-test
  149332. */
  149333. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  149334. /**
  149335. * options to use when constructing this feature
  149336. */
  149337. readonly options: IWebXRLegacyHitTestOptions;
  149338. private _direction;
  149339. private _mat;
  149340. private _onSelectEnabled;
  149341. private _origin;
  149342. /**
  149343. * The module's name
  149344. */
  149345. static readonly Name: string;
  149346. /**
  149347. * The (Babylon) version of this module.
  149348. * This is an integer representing the implementation version.
  149349. * This number does not correspond to the WebXR specs version
  149350. */
  149351. static readonly Version: number;
  149352. /**
  149353. * Populated with the last native XR Hit Results
  149354. */
  149355. lastNativeXRHitResults: XRHitResult[];
  149356. /**
  149357. * Triggered when new babylon (transformed) hit test results are available
  149358. */
  149359. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  149360. /**
  149361. * Creates a new instance of the (legacy version) hit test feature
  149362. * @param _xrSessionManager an instance of WebXRSessionManager
  149363. * @param options options to use when constructing this feature
  149364. */
  149365. constructor(_xrSessionManager: WebXRSessionManager,
  149366. /**
  149367. * options to use when constructing this feature
  149368. */
  149369. options?: IWebXRLegacyHitTestOptions);
  149370. /**
  149371. * execute a hit test with an XR Ray
  149372. *
  149373. * @param xrSession a native xrSession that will execute this hit test
  149374. * @param xrRay the ray (position and direction) to use for ray-casting
  149375. * @param referenceSpace native XR reference space to use for the hit-test
  149376. * @param filter filter function that will filter the results
  149377. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149378. */
  149379. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  149380. /**
  149381. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  149382. * @param event the (select) event to use to select with
  149383. * @param referenceSpace the reference space to use for this hit test
  149384. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149385. */
  149386. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  149387. /**
  149388. * attach this feature
  149389. * Will usually be called by the features manager
  149390. *
  149391. * @returns true if successful.
  149392. */
  149393. attach(): boolean;
  149394. /**
  149395. * detach this feature.
  149396. * Will usually be called by the features manager
  149397. *
  149398. * @returns true if successful.
  149399. */
  149400. detach(): boolean;
  149401. /**
  149402. * Dispose this feature and all of the resources attached
  149403. */
  149404. dispose(): void;
  149405. protected _onXRFrame(frame: XRFrame): void;
  149406. private _onHitTestResults;
  149407. private _onSelect;
  149408. }
  149409. }
  149410. declare module BABYLON {
  149411. /**
  149412. * Options used for hit testing (version 2)
  149413. */
  149414. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  149415. /**
  149416. * Do not create a permanent hit test. Will usually be used when only
  149417. * transient inputs are needed.
  149418. */
  149419. disablePermanentHitTest?: boolean;
  149420. /**
  149421. * Enable transient (for example touch-based) hit test inspections
  149422. */
  149423. enableTransientHitTest?: boolean;
  149424. /**
  149425. * Offset ray for the permanent hit test
  149426. */
  149427. offsetRay?: Vector3;
  149428. /**
  149429. * Offset ray for the transient hit test
  149430. */
  149431. transientOffsetRay?: Vector3;
  149432. /**
  149433. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  149434. */
  149435. useReferenceSpace?: boolean;
  149436. }
  149437. /**
  149438. * Interface defining the babylon result of hit-test
  149439. */
  149440. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  149441. /**
  149442. * The input source that generated this hit test (if transient)
  149443. */
  149444. inputSource?: XRInputSource;
  149445. /**
  149446. * Is this a transient hit test
  149447. */
  149448. isTransient?: boolean;
  149449. /**
  149450. * Position of the hit test result
  149451. */
  149452. position: Vector3;
  149453. /**
  149454. * Rotation of the hit test result
  149455. */
  149456. rotationQuaternion: Quaternion;
  149457. /**
  149458. * The native hit test result
  149459. */
  149460. xrHitResult: XRHitTestResult;
  149461. }
  149462. /**
  149463. * The currently-working hit-test module.
  149464. * Hit test (or Ray-casting) is used to interact with the real world.
  149465. * For further information read here - https://github.com/immersive-web/hit-test
  149466. *
  149467. * Tested on chrome (mobile) 80.
  149468. */
  149469. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  149470. /**
  149471. * options to use when constructing this feature
  149472. */
  149473. readonly options: IWebXRHitTestOptions;
  149474. private _tmpMat;
  149475. private _tmpPos;
  149476. private _tmpQuat;
  149477. private _transientXrHitTestSource;
  149478. private _xrHitTestSource;
  149479. private initHitTestSource;
  149480. /**
  149481. * The module's name
  149482. */
  149483. static readonly Name: string;
  149484. /**
  149485. * The (Babylon) version of this module.
  149486. * This is an integer representing the implementation version.
  149487. * This number does not correspond to the WebXR specs version
  149488. */
  149489. static readonly Version: number;
  149490. /**
  149491. * When set to true, each hit test will have its own position/rotation objects
  149492. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  149493. * the developers will clone them or copy them as they see fit.
  149494. */
  149495. autoCloneTransformation: boolean;
  149496. /**
  149497. * Triggered when new babylon (transformed) hit test results are available
  149498. */
  149499. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  149500. /**
  149501. * Use this to temporarily pause hit test checks.
  149502. */
  149503. paused: boolean;
  149504. /**
  149505. * Creates a new instance of the hit test feature
  149506. * @param _xrSessionManager an instance of WebXRSessionManager
  149507. * @param options options to use when constructing this feature
  149508. */
  149509. constructor(_xrSessionManager: WebXRSessionManager,
  149510. /**
  149511. * options to use when constructing this feature
  149512. */
  149513. options?: IWebXRHitTestOptions);
  149514. /**
  149515. * attach this feature
  149516. * Will usually be called by the features manager
  149517. *
  149518. * @returns true if successful.
  149519. */
  149520. attach(): boolean;
  149521. /**
  149522. * detach this feature.
  149523. * Will usually be called by the features manager
  149524. *
  149525. * @returns true if successful.
  149526. */
  149527. detach(): boolean;
  149528. /**
  149529. * Dispose this feature and all of the resources attached
  149530. */
  149531. dispose(): void;
  149532. protected _onXRFrame(frame: XRFrame): void;
  149533. private _processWebXRHitTestResult;
  149534. }
  149535. }
  149536. declare module BABYLON {
  149537. /**
  149538. * Configuration options of the anchor system
  149539. */
  149540. export interface IWebXRAnchorSystemOptions {
  149541. /**
  149542. * a node that will be used to convert local to world coordinates
  149543. */
  149544. worldParentNode?: TransformNode;
  149545. /**
  149546. * If set to true a reference of the created anchors will be kept until the next session starts
  149547. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  149548. */
  149549. doNotRemoveAnchorsOnSessionEnded?: boolean;
  149550. }
  149551. /**
  149552. * A babylon container for an XR Anchor
  149553. */
  149554. export interface IWebXRAnchor {
  149555. /**
  149556. * A babylon-assigned ID for this anchor
  149557. */
  149558. id: number;
  149559. /**
  149560. * Transformation matrix to apply to an object attached to this anchor
  149561. */
  149562. transformationMatrix: Matrix;
  149563. /**
  149564. * The native anchor object
  149565. */
  149566. xrAnchor: XRAnchor;
  149567. /**
  149568. * if defined, this object will be constantly updated by the anchor's position and rotation
  149569. */
  149570. attachedNode?: TransformNode;
  149571. }
  149572. /**
  149573. * An implementation of the anchor system for WebXR.
  149574. * For further information see https://github.com/immersive-web/anchors/
  149575. */
  149576. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  149577. private _options;
  149578. private _lastFrameDetected;
  149579. private _trackedAnchors;
  149580. private _referenceSpaceForFrameAnchors;
  149581. private _futureAnchors;
  149582. /**
  149583. * The module's name
  149584. */
  149585. static readonly Name: string;
  149586. /**
  149587. * The (Babylon) version of this module.
  149588. * This is an integer representing the implementation version.
  149589. * This number does not correspond to the WebXR specs version
  149590. */
  149591. static readonly Version: number;
  149592. /**
  149593. * Observers registered here will be executed when a new anchor was added to the session
  149594. */
  149595. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  149596. /**
  149597. * Observers registered here will be executed when an anchor was removed from the session
  149598. */
  149599. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  149600. /**
  149601. * Observers registered here will be executed when an existing anchor updates
  149602. * This can execute N times every frame
  149603. */
  149604. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  149605. /**
  149606. * Set the reference space to use for anchor creation, when not using a hit test.
  149607. * Will default to the session's reference space if not defined
  149608. */
  149609. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  149610. /**
  149611. * constructs a new anchor system
  149612. * @param _xrSessionManager an instance of WebXRSessionManager
  149613. * @param _options configuration object for this feature
  149614. */
  149615. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  149616. private _tmpVector;
  149617. private _tmpQuaternion;
  149618. private _populateTmpTransformation;
  149619. /**
  149620. * Create a new anchor point using a hit test result at a specific point in the scene
  149621. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149622. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149623. *
  149624. * @param hitTestResult The hit test result to use for this anchor creation
  149625. * @param position an optional position offset for this anchor
  149626. * @param rotationQuaternion an optional rotation offset for this anchor
  149627. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149628. */
  149629. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  149630. /**
  149631. * Add a new anchor at a specific position and rotation
  149632. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  149633. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  149634. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  149635. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  149636. *
  149637. * @param position the position in which to add an anchor
  149638. * @param rotationQuaternion an optional rotation for the anchor transformation
  149639. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  149640. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  149641. */
  149642. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  149643. /**
  149644. * detach this feature.
  149645. * Will usually be called by the features manager
  149646. *
  149647. * @returns true if successful.
  149648. */
  149649. detach(): boolean;
  149650. /**
  149651. * Dispose this feature and all of the resources attached
  149652. */
  149653. dispose(): void;
  149654. protected _onXRFrame(frame: XRFrame): void;
  149655. /**
  149656. * avoiding using Array.find for global support.
  149657. * @param xrAnchor the plane to find in the array
  149658. */
  149659. private _findIndexInAnchorArray;
  149660. private _updateAnchorWithXRFrame;
  149661. private _createAnchorAtTransformation;
  149662. }
  149663. }
  149664. declare module BABYLON {
  149665. /**
  149666. * Options used in the plane detector module
  149667. */
  149668. export interface IWebXRPlaneDetectorOptions {
  149669. /**
  149670. * The node to use to transform the local results to world coordinates
  149671. */
  149672. worldParentNode?: TransformNode;
  149673. /**
  149674. * If set to true a reference of the created planes will be kept until the next session starts
  149675. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  149676. */
  149677. doNotRemovePlanesOnSessionEnded?: boolean;
  149678. }
  149679. /**
  149680. * A babylon interface for a WebXR plane.
  149681. * A Plane is actually a polygon, built from N points in space
  149682. *
  149683. * Supported in chrome 79, not supported in canary 81 ATM
  149684. */
  149685. export interface IWebXRPlane {
  149686. /**
  149687. * a babylon-assigned ID for this polygon
  149688. */
  149689. id: number;
  149690. /**
  149691. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  149692. */
  149693. polygonDefinition: Array<Vector3>;
  149694. /**
  149695. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  149696. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  149697. */
  149698. transformationMatrix: Matrix;
  149699. /**
  149700. * the native xr-plane object
  149701. */
  149702. xrPlane: XRPlane;
  149703. }
  149704. /**
  149705. * The plane detector is used to detect planes in the real world when in AR
  149706. * For more information see https://github.com/immersive-web/real-world-geometry/
  149707. */
  149708. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  149709. private _options;
  149710. private _detectedPlanes;
  149711. private _enabled;
  149712. private _lastFrameDetected;
  149713. /**
  149714. * The module's name
  149715. */
  149716. static readonly Name: string;
  149717. /**
  149718. * The (Babylon) version of this module.
  149719. * This is an integer representing the implementation version.
  149720. * This number does not correspond to the WebXR specs version
  149721. */
  149722. static readonly Version: number;
  149723. /**
  149724. * Observers registered here will be executed when a new plane was added to the session
  149725. */
  149726. onPlaneAddedObservable: Observable<IWebXRPlane>;
  149727. /**
  149728. * Observers registered here will be executed when a plane is no longer detected in the session
  149729. */
  149730. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  149731. /**
  149732. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  149733. * This can execute N times every frame
  149734. */
  149735. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  149736. /**
  149737. * construct a new Plane Detector
  149738. * @param _xrSessionManager an instance of xr Session manager
  149739. * @param _options configuration to use when constructing this feature
  149740. */
  149741. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  149742. /**
  149743. * detach this feature.
  149744. * Will usually be called by the features manager
  149745. *
  149746. * @returns true if successful.
  149747. */
  149748. detach(): boolean;
  149749. /**
  149750. * Dispose this feature and all of the resources attached
  149751. */
  149752. dispose(): void;
  149753. protected _onXRFrame(frame: XRFrame): void;
  149754. private _init;
  149755. private _updatePlaneWithXRPlane;
  149756. /**
  149757. * avoiding using Array.find for global support.
  149758. * @param xrPlane the plane to find in the array
  149759. */
  149760. private findIndexInPlaneArray;
  149761. }
  149762. }
  149763. declare module BABYLON {
  149764. /**
  149765. * Options interface for the background remover plugin
  149766. */
  149767. export interface IWebXRBackgroundRemoverOptions {
  149768. /**
  149769. * Further background meshes to disable when entering AR
  149770. */
  149771. backgroundMeshes?: AbstractMesh[];
  149772. /**
  149773. * flags to configure the removal of the environment helper.
  149774. * If not set, the entire background will be removed. If set, flags should be set as well.
  149775. */
  149776. environmentHelperRemovalFlags?: {
  149777. /**
  149778. * Should the skybox be removed (default false)
  149779. */
  149780. skyBox?: boolean;
  149781. /**
  149782. * Should the ground be removed (default false)
  149783. */
  149784. ground?: boolean;
  149785. };
  149786. /**
  149787. * don't disable the environment helper
  149788. */
  149789. ignoreEnvironmentHelper?: boolean;
  149790. }
  149791. /**
  149792. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  149793. */
  149794. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  149795. /**
  149796. * read-only options to be used in this module
  149797. */
  149798. readonly options: IWebXRBackgroundRemoverOptions;
  149799. /**
  149800. * The module's name
  149801. */
  149802. static readonly Name: string;
  149803. /**
  149804. * The (Babylon) version of this module.
  149805. * This is an integer representing the implementation version.
  149806. * This number does not correspond to the WebXR specs version
  149807. */
  149808. static readonly Version: number;
  149809. /**
  149810. * registered observers will be triggered when the background state changes
  149811. */
  149812. onBackgroundStateChangedObservable: Observable<boolean>;
  149813. /**
  149814. * constructs a new background remover module
  149815. * @param _xrSessionManager the session manager for this module
  149816. * @param options read-only options to be used in this module
  149817. */
  149818. constructor(_xrSessionManager: WebXRSessionManager,
  149819. /**
  149820. * read-only options to be used in this module
  149821. */
  149822. options?: IWebXRBackgroundRemoverOptions);
  149823. /**
  149824. * attach this feature
  149825. * Will usually be called by the features manager
  149826. *
  149827. * @returns true if successful.
  149828. */
  149829. attach(): boolean;
  149830. /**
  149831. * detach this feature.
  149832. * Will usually be called by the features manager
  149833. *
  149834. * @returns true if successful.
  149835. */
  149836. detach(): boolean;
  149837. /**
  149838. * Dispose this feature and all of the resources attached
  149839. */
  149840. dispose(): void;
  149841. protected _onXRFrame(_xrFrame: XRFrame): void;
  149842. private _setBackgroundState;
  149843. }
  149844. }
  149845. declare module BABYLON {
  149846. /**
  149847. * Options for the controller physics feature
  149848. */
  149849. export class IWebXRControllerPhysicsOptions {
  149850. /**
  149851. * Should the headset get its own impostor
  149852. */
  149853. enableHeadsetImpostor?: boolean;
  149854. /**
  149855. * Optional parameters for the headset impostor
  149856. */
  149857. headsetImpostorParams?: {
  149858. /**
  149859. * The type of impostor to create. Default is sphere
  149860. */
  149861. impostorType: number;
  149862. /**
  149863. * the size of the impostor. Defaults to 10cm
  149864. */
  149865. impostorSize?: number | {
  149866. width: number;
  149867. height: number;
  149868. depth: number;
  149869. };
  149870. /**
  149871. * Friction definitions
  149872. */
  149873. friction?: number;
  149874. /**
  149875. * Restitution
  149876. */
  149877. restitution?: number;
  149878. };
  149879. /**
  149880. * The physics properties of the future impostors
  149881. */
  149882. physicsProperties?: {
  149883. /**
  149884. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  149885. * Note that this requires a physics engine that supports mesh impostors!
  149886. */
  149887. useControllerMesh?: boolean;
  149888. /**
  149889. * The type of impostor to create. Default is sphere
  149890. */
  149891. impostorType?: number;
  149892. /**
  149893. * the size of the impostor. Defaults to 10cm
  149894. */
  149895. impostorSize?: number | {
  149896. width: number;
  149897. height: number;
  149898. depth: number;
  149899. };
  149900. /**
  149901. * Friction definitions
  149902. */
  149903. friction?: number;
  149904. /**
  149905. * Restitution
  149906. */
  149907. restitution?: number;
  149908. };
  149909. /**
  149910. * the xr input to use with this pointer selection
  149911. */
  149912. xrInput: WebXRInput;
  149913. }
  149914. /**
  149915. * Add physics impostor to your webxr controllers,
  149916. * including naive calculation of their linear and angular velocity
  149917. */
  149918. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  149919. private readonly _options;
  149920. private _attachController;
  149921. private _controllers;
  149922. private _debugMode;
  149923. private _delta;
  149924. private _headsetImpostor?;
  149925. private _headsetMesh?;
  149926. private _lastTimestamp;
  149927. private _tmpQuaternion;
  149928. private _tmpVector;
  149929. /**
  149930. * The module's name
  149931. */
  149932. static readonly Name: string;
  149933. /**
  149934. * The (Babylon) version of this module.
  149935. * This is an integer representing the implementation version.
  149936. * This number does not correspond to the webxr specs version
  149937. */
  149938. static readonly Version: number;
  149939. /**
  149940. * Construct a new Controller Physics Feature
  149941. * @param _xrSessionManager the corresponding xr session manager
  149942. * @param _options options to create this feature with
  149943. */
  149944. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  149945. /**
  149946. * @hidden
  149947. * enable debugging - will show console outputs and the impostor mesh
  149948. */
  149949. _enablePhysicsDebug(): void;
  149950. /**
  149951. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  149952. * @param xrController the controller to add
  149953. */
  149954. addController(xrController: WebXRInputSource): void;
  149955. /**
  149956. * attach this feature
  149957. * Will usually be called by the features manager
  149958. *
  149959. * @returns true if successful.
  149960. */
  149961. attach(): boolean;
  149962. /**
  149963. * detach this feature.
  149964. * Will usually be called by the features manager
  149965. *
  149966. * @returns true if successful.
  149967. */
  149968. detach(): boolean;
  149969. /**
  149970. * Get the headset impostor, if enabled
  149971. * @returns the impostor
  149972. */
  149973. getHeadsetImpostor(): PhysicsImpostor | undefined;
  149974. /**
  149975. * Get the physics impostor of a specific controller.
  149976. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  149977. * @param controller the controller or the controller id of which to get the impostor
  149978. * @returns the impostor or null
  149979. */
  149980. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  149981. /**
  149982. * Update the physics properties provided in the constructor
  149983. * @param newProperties the new properties object
  149984. */
  149985. setPhysicsProperties(newProperties: {
  149986. impostorType?: number;
  149987. impostorSize?: number | {
  149988. width: number;
  149989. height: number;
  149990. depth: number;
  149991. };
  149992. friction?: number;
  149993. restitution?: number;
  149994. }): void;
  149995. protected _onXRFrame(_xrFrame: any): void;
  149996. private _detachController;
  149997. }
  149998. }
  149999. declare module BABYLON {
  150000. /**
  150001. * The motion controller class for all microsoft mixed reality controllers
  150002. */
  150003. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  150004. protected readonly _mapping: {
  150005. defaultButton: {
  150006. valueNodeName: string;
  150007. unpressedNodeName: string;
  150008. pressedNodeName: string;
  150009. };
  150010. defaultAxis: {
  150011. valueNodeName: string;
  150012. minNodeName: string;
  150013. maxNodeName: string;
  150014. };
  150015. buttons: {
  150016. "xr-standard-trigger": {
  150017. rootNodeName: string;
  150018. componentProperty: string;
  150019. states: string[];
  150020. };
  150021. "xr-standard-squeeze": {
  150022. rootNodeName: string;
  150023. componentProperty: string;
  150024. states: string[];
  150025. };
  150026. "xr-standard-touchpad": {
  150027. rootNodeName: string;
  150028. labelAnchorNodeName: string;
  150029. touchPointNodeName: string;
  150030. };
  150031. "xr-standard-thumbstick": {
  150032. rootNodeName: string;
  150033. componentProperty: string;
  150034. states: string[];
  150035. };
  150036. };
  150037. axes: {
  150038. "xr-standard-touchpad": {
  150039. "x-axis": {
  150040. rootNodeName: string;
  150041. };
  150042. "y-axis": {
  150043. rootNodeName: string;
  150044. };
  150045. };
  150046. "xr-standard-thumbstick": {
  150047. "x-axis": {
  150048. rootNodeName: string;
  150049. };
  150050. "y-axis": {
  150051. rootNodeName: string;
  150052. };
  150053. };
  150054. };
  150055. };
  150056. /**
  150057. * The base url used to load the left and right controller models
  150058. */
  150059. static MODEL_BASE_URL: string;
  150060. /**
  150061. * The name of the left controller model file
  150062. */
  150063. static MODEL_LEFT_FILENAME: string;
  150064. /**
  150065. * The name of the right controller model file
  150066. */
  150067. static MODEL_RIGHT_FILENAME: string;
  150068. profileId: string;
  150069. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150070. protected _getFilenameAndPath(): {
  150071. filename: string;
  150072. path: string;
  150073. };
  150074. protected _getModelLoadingConstraints(): boolean;
  150075. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150076. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150077. protected _updateModel(): void;
  150078. }
  150079. }
  150080. declare module BABYLON {
  150081. /**
  150082. * The motion controller class for oculus touch (quest, rift).
  150083. * This class supports legacy mapping as well the standard xr mapping
  150084. */
  150085. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  150086. private _forceLegacyControllers;
  150087. private _modelRootNode;
  150088. /**
  150089. * The base url used to load the left and right controller models
  150090. */
  150091. static MODEL_BASE_URL: string;
  150092. /**
  150093. * The name of the left controller model file
  150094. */
  150095. static MODEL_LEFT_FILENAME: string;
  150096. /**
  150097. * The name of the right controller model file
  150098. */
  150099. static MODEL_RIGHT_FILENAME: string;
  150100. /**
  150101. * Base Url for the Quest controller model.
  150102. */
  150103. static QUEST_MODEL_BASE_URL: string;
  150104. profileId: string;
  150105. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  150106. protected _getFilenameAndPath(): {
  150107. filename: string;
  150108. path: string;
  150109. };
  150110. protected _getModelLoadingConstraints(): boolean;
  150111. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150112. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150113. protected _updateModel(): void;
  150114. /**
  150115. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  150116. * between the touch and touch 2.
  150117. */
  150118. private _isQuest;
  150119. }
  150120. }
  150121. declare module BABYLON {
  150122. /**
  150123. * The motion controller class for the standard HTC-Vive controllers
  150124. */
  150125. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  150126. private _modelRootNode;
  150127. /**
  150128. * The base url used to load the left and right controller models
  150129. */
  150130. static MODEL_BASE_URL: string;
  150131. /**
  150132. * File name for the controller model.
  150133. */
  150134. static MODEL_FILENAME: string;
  150135. profileId: string;
  150136. /**
  150137. * Create a new Vive motion controller object
  150138. * @param scene the scene to use to create this controller
  150139. * @param gamepadObject the corresponding gamepad object
  150140. * @param handedness the handedness of the controller
  150141. */
  150142. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150143. protected _getFilenameAndPath(): {
  150144. filename: string;
  150145. path: string;
  150146. };
  150147. protected _getModelLoadingConstraints(): boolean;
  150148. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150149. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150150. protected _updateModel(): void;
  150151. }
  150152. }
  150153. declare module BABYLON {
  150154. /**
  150155. * A cursor which tracks a point on a path
  150156. */
  150157. export class PathCursor {
  150158. private path;
  150159. /**
  150160. * Stores path cursor callbacks for when an onchange event is triggered
  150161. */
  150162. private _onchange;
  150163. /**
  150164. * The value of the path cursor
  150165. */
  150166. value: number;
  150167. /**
  150168. * The animation array of the path cursor
  150169. */
  150170. animations: Animation[];
  150171. /**
  150172. * Initializes the path cursor
  150173. * @param path The path to track
  150174. */
  150175. constructor(path: Path2);
  150176. /**
  150177. * Gets the cursor point on the path
  150178. * @returns A point on the path cursor at the cursor location
  150179. */
  150180. getPoint(): Vector3;
  150181. /**
  150182. * Moves the cursor ahead by the step amount
  150183. * @param step The amount to move the cursor forward
  150184. * @returns This path cursor
  150185. */
  150186. moveAhead(step?: number): PathCursor;
  150187. /**
  150188. * Moves the cursor behind by the step amount
  150189. * @param step The amount to move the cursor back
  150190. * @returns This path cursor
  150191. */
  150192. moveBack(step?: number): PathCursor;
  150193. /**
  150194. * Moves the cursor by the step amount
  150195. * If the step amount is greater than one, an exception is thrown
  150196. * @param step The amount to move the cursor
  150197. * @returns This path cursor
  150198. */
  150199. move(step: number): PathCursor;
  150200. /**
  150201. * Ensures that the value is limited between zero and one
  150202. * @returns This path cursor
  150203. */
  150204. private ensureLimits;
  150205. /**
  150206. * Runs onchange callbacks on change (used by the animation engine)
  150207. * @returns This path cursor
  150208. */
  150209. private raiseOnChange;
  150210. /**
  150211. * Executes a function on change
  150212. * @param f A path cursor onchange callback
  150213. * @returns This path cursor
  150214. */
  150215. onchange(f: (cursor: PathCursor) => void): PathCursor;
  150216. }
  150217. }
  150218. declare module BABYLON {
  150219. /** @hidden */
  150220. export var blurPixelShader: {
  150221. name: string;
  150222. shader: string;
  150223. };
  150224. }
  150225. declare module BABYLON {
  150226. /** @hidden */
  150227. export var pointCloudVertexDeclaration: {
  150228. name: string;
  150229. shader: string;
  150230. };
  150231. }
  150232. // Mixins
  150233. interface Window {
  150234. mozIndexedDB: IDBFactory;
  150235. webkitIndexedDB: IDBFactory;
  150236. msIndexedDB: IDBFactory;
  150237. webkitURL: typeof URL;
  150238. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  150239. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  150240. WebGLRenderingContext: WebGLRenderingContext;
  150241. MSGesture: MSGesture;
  150242. CANNON: any;
  150243. AudioContext: AudioContext;
  150244. webkitAudioContext: AudioContext;
  150245. PointerEvent: any;
  150246. Math: Math;
  150247. Uint8Array: Uint8ArrayConstructor;
  150248. Float32Array: Float32ArrayConstructor;
  150249. mozURL: typeof URL;
  150250. msURL: typeof URL;
  150251. VRFrameData: any; // WebVR, from specs 1.1
  150252. DracoDecoderModule: any;
  150253. setImmediate(handler: (...args: any[]) => void): number;
  150254. }
  150255. interface HTMLCanvasElement {
  150256. requestPointerLock(): void;
  150257. msRequestPointerLock?(): void;
  150258. mozRequestPointerLock?(): void;
  150259. webkitRequestPointerLock?(): void;
  150260. /** Track wether a record is in progress */
  150261. isRecording: boolean;
  150262. /** Capture Stream method defined by some browsers */
  150263. captureStream(fps?: number): MediaStream;
  150264. }
  150265. interface CanvasRenderingContext2D {
  150266. msImageSmoothingEnabled: boolean;
  150267. }
  150268. interface MouseEvent {
  150269. mozMovementX: number;
  150270. mozMovementY: number;
  150271. webkitMovementX: number;
  150272. webkitMovementY: number;
  150273. msMovementX: number;
  150274. msMovementY: number;
  150275. }
  150276. interface Navigator {
  150277. mozGetVRDevices: (any: any) => any;
  150278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150281. webkitGetGamepads(): Gamepad[];
  150282. msGetGamepads(): Gamepad[];
  150283. webkitGamepads(): Gamepad[];
  150284. }
  150285. interface HTMLVideoElement {
  150286. mozSrcObject: any;
  150287. }
  150288. interface Math {
  150289. fround(x: number): number;
  150290. imul(a: number, b: number): number;
  150291. }
  150292. interface WebGLRenderingContext {
  150293. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  150294. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  150295. vertexAttribDivisor(index: number, divisor: number): void;
  150296. createVertexArray(): any;
  150297. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  150298. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  150299. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  150300. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  150301. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  150302. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  150303. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  150304. // Queries
  150305. createQuery(): WebGLQuery;
  150306. deleteQuery(query: WebGLQuery): void;
  150307. beginQuery(target: number, query: WebGLQuery): void;
  150308. endQuery(target: number): void;
  150309. getQueryParameter(query: WebGLQuery, pname: number): any;
  150310. getQuery(target: number, pname: number): any;
  150311. MAX_SAMPLES: number;
  150312. RGBA8: number;
  150313. READ_FRAMEBUFFER: number;
  150314. DRAW_FRAMEBUFFER: number;
  150315. UNIFORM_BUFFER: number;
  150316. HALF_FLOAT_OES: number;
  150317. RGBA16F: number;
  150318. RGBA32F: number;
  150319. R32F: number;
  150320. RG32F: number;
  150321. RGB32F: number;
  150322. R16F: number;
  150323. RG16F: number;
  150324. RGB16F: number;
  150325. RED: number;
  150326. RG: number;
  150327. R8: number;
  150328. RG8: number;
  150329. UNSIGNED_INT_24_8: number;
  150330. DEPTH24_STENCIL8: number;
  150331. MIN: number;
  150332. MAX: number;
  150333. /* Multiple Render Targets */
  150334. drawBuffers(buffers: number[]): void;
  150335. readBuffer(src: number): void;
  150336. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  150337. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  150338. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  150339. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  150340. // Occlusion Query
  150341. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  150342. ANY_SAMPLES_PASSED: number;
  150343. QUERY_RESULT_AVAILABLE: number;
  150344. QUERY_RESULT: number;
  150345. }
  150346. interface WebGLProgram {
  150347. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  150348. }
  150349. interface EXT_disjoint_timer_query {
  150350. QUERY_COUNTER_BITS_EXT: number;
  150351. TIME_ELAPSED_EXT: number;
  150352. TIMESTAMP_EXT: number;
  150353. GPU_DISJOINT_EXT: number;
  150354. QUERY_RESULT_EXT: number;
  150355. QUERY_RESULT_AVAILABLE_EXT: number;
  150356. queryCounterEXT(query: WebGLQuery, target: number): void;
  150357. createQueryEXT(): WebGLQuery;
  150358. beginQueryEXT(target: number, query: WebGLQuery): void;
  150359. endQueryEXT(target: number): void;
  150360. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  150361. deleteQueryEXT(query: WebGLQuery): void;
  150362. }
  150363. interface WebGLUniformLocation {
  150364. _currentState: any;
  150365. }
  150366. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  150367. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  150368. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  150369. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150370. interface WebGLRenderingContext {
  150371. readonly RASTERIZER_DISCARD: number;
  150372. readonly DEPTH_COMPONENT24: number;
  150373. readonly TEXTURE_3D: number;
  150374. readonly TEXTURE_2D_ARRAY: number;
  150375. readonly TEXTURE_COMPARE_FUNC: number;
  150376. readonly TEXTURE_COMPARE_MODE: number;
  150377. readonly COMPARE_REF_TO_TEXTURE: number;
  150378. readonly TEXTURE_WRAP_R: number;
  150379. readonly HALF_FLOAT: number;
  150380. readonly RGB8: number;
  150381. readonly RED_INTEGER: number;
  150382. readonly RG_INTEGER: number;
  150383. readonly RGB_INTEGER: number;
  150384. readonly RGBA_INTEGER: number;
  150385. readonly R8_SNORM: number;
  150386. readonly RG8_SNORM: number;
  150387. readonly RGB8_SNORM: number;
  150388. readonly RGBA8_SNORM: number;
  150389. readonly R8I: number;
  150390. readonly RG8I: number;
  150391. readonly RGB8I: number;
  150392. readonly RGBA8I: number;
  150393. readonly R8UI: number;
  150394. readonly RG8UI: number;
  150395. readonly RGB8UI: number;
  150396. readonly RGBA8UI: number;
  150397. readonly R16I: number;
  150398. readonly RG16I: number;
  150399. readonly RGB16I: number;
  150400. readonly RGBA16I: number;
  150401. readonly R16UI: number;
  150402. readonly RG16UI: number;
  150403. readonly RGB16UI: number;
  150404. readonly RGBA16UI: number;
  150405. readonly R32I: number;
  150406. readonly RG32I: number;
  150407. readonly RGB32I: number;
  150408. readonly RGBA32I: number;
  150409. readonly R32UI: number;
  150410. readonly RG32UI: number;
  150411. readonly RGB32UI: number;
  150412. readonly RGBA32UI: number;
  150413. readonly RGB10_A2UI: number;
  150414. readonly R11F_G11F_B10F: number;
  150415. readonly RGB9_E5: number;
  150416. readonly RGB10_A2: number;
  150417. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  150418. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  150419. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  150420. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  150421. readonly DEPTH_COMPONENT32F: number;
  150422. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  150423. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  150424. 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;
  150425. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  150426. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  150427. readonly TRANSFORM_FEEDBACK: number;
  150428. readonly INTERLEAVED_ATTRIBS: number;
  150429. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  150430. createTransformFeedback(): WebGLTransformFeedback;
  150431. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  150432. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  150433. beginTransformFeedback(primitiveMode: number): void;
  150434. endTransformFeedback(): void;
  150435. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  150436. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150437. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150438. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150439. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  150440. }
  150441. interface ImageBitmap {
  150442. readonly width: number;
  150443. readonly height: number;
  150444. close(): void;
  150445. }
  150446. interface WebGLQuery extends WebGLObject {
  150447. }
  150448. declare var WebGLQuery: {
  150449. prototype: WebGLQuery;
  150450. new(): WebGLQuery;
  150451. };
  150452. interface WebGLSampler extends WebGLObject {
  150453. }
  150454. declare var WebGLSampler: {
  150455. prototype: WebGLSampler;
  150456. new(): WebGLSampler;
  150457. };
  150458. interface WebGLSync extends WebGLObject {
  150459. }
  150460. declare var WebGLSync: {
  150461. prototype: WebGLSync;
  150462. new(): WebGLSync;
  150463. };
  150464. interface WebGLTransformFeedback extends WebGLObject {
  150465. }
  150466. declare var WebGLTransformFeedback: {
  150467. prototype: WebGLTransformFeedback;
  150468. new(): WebGLTransformFeedback;
  150469. };
  150470. interface WebGLVertexArrayObject extends WebGLObject {
  150471. }
  150472. declare var WebGLVertexArrayObject: {
  150473. prototype: WebGLVertexArrayObject;
  150474. new(): WebGLVertexArrayObject;
  150475. };
  150476. // Type definitions for WebVR API
  150477. // Project: https://w3c.github.io/webvr/
  150478. // Definitions by: six a <https://github.com/lostfictions>
  150479. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150480. interface VRDisplay extends EventTarget {
  150481. /**
  150482. * Dictionary of capabilities describing the VRDisplay.
  150483. */
  150484. readonly capabilities: VRDisplayCapabilities;
  150485. /**
  150486. * z-depth defining the far plane of the eye view frustum
  150487. * enables mapping of values in the render target depth
  150488. * attachment to scene coordinates. Initially set to 10000.0.
  150489. */
  150490. depthFar: number;
  150491. /**
  150492. * z-depth defining the near plane of the eye view frustum
  150493. * enables mapping of values in the render target depth
  150494. * attachment to scene coordinates. Initially set to 0.01.
  150495. */
  150496. depthNear: number;
  150497. /**
  150498. * An identifier for this distinct VRDisplay. Used as an
  150499. * association point in the Gamepad API.
  150500. */
  150501. readonly displayId: number;
  150502. /**
  150503. * A display name, a user-readable name identifying it.
  150504. */
  150505. readonly displayName: string;
  150506. readonly isConnected: boolean;
  150507. readonly isPresenting: boolean;
  150508. /**
  150509. * If this VRDisplay supports room-scale experiences, the optional
  150510. * stage attribute contains details on the room-scale parameters.
  150511. */
  150512. readonly stageParameters: VRStageParameters | null;
  150513. /**
  150514. * Passing the value returned by `requestAnimationFrame` to
  150515. * `cancelAnimationFrame` will unregister the callback.
  150516. * @param handle Define the hanle of the request to cancel
  150517. */
  150518. cancelAnimationFrame(handle: number): void;
  150519. /**
  150520. * Stops presenting to the VRDisplay.
  150521. * @returns a promise to know when it stopped
  150522. */
  150523. exitPresent(): Promise<void>;
  150524. /**
  150525. * Return the current VREyeParameters for the given eye.
  150526. * @param whichEye Define the eye we want the parameter for
  150527. * @returns the eye parameters
  150528. */
  150529. getEyeParameters(whichEye: string): VREyeParameters;
  150530. /**
  150531. * Populates the passed VRFrameData with the information required to render
  150532. * the current frame.
  150533. * @param frameData Define the data structure to populate
  150534. * @returns true if ok otherwise false
  150535. */
  150536. getFrameData(frameData: VRFrameData): boolean;
  150537. /**
  150538. * Get the layers currently being presented.
  150539. * @returns the list of VR layers
  150540. */
  150541. getLayers(): VRLayer[];
  150542. /**
  150543. * Return a VRPose containing the future predicted pose of the VRDisplay
  150544. * when the current frame will be presented. The value returned will not
  150545. * change until JavaScript has returned control to the browser.
  150546. *
  150547. * The VRPose will contain the position, orientation, velocity,
  150548. * and acceleration of each of these properties.
  150549. * @returns the pose object
  150550. */
  150551. getPose(): VRPose;
  150552. /**
  150553. * Return the current instantaneous pose of the VRDisplay, with no
  150554. * prediction applied.
  150555. * @returns the current instantaneous pose
  150556. */
  150557. getImmediatePose(): VRPose;
  150558. /**
  150559. * The callback passed to `requestAnimationFrame` will be called
  150560. * any time a new frame should be rendered. When the VRDisplay is
  150561. * presenting the callback will be called at the native refresh
  150562. * rate of the HMD. When not presenting this function acts
  150563. * identically to how window.requestAnimationFrame acts. Content should
  150564. * make no assumptions of frame rate or vsync behavior as the HMD runs
  150565. * asynchronously from other displays and at differing refresh rates.
  150566. * @param callback Define the eaction to run next frame
  150567. * @returns the request handle it
  150568. */
  150569. requestAnimationFrame(callback: FrameRequestCallback): number;
  150570. /**
  150571. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  150572. * Repeat calls while already presenting will update the VRLayers being displayed.
  150573. * @param layers Define the list of layer to present
  150574. * @returns a promise to know when the request has been fulfilled
  150575. */
  150576. requestPresent(layers: VRLayer[]): Promise<void>;
  150577. /**
  150578. * Reset the pose for this display, treating its current position and
  150579. * orientation as the "origin/zero" values. VRPose.position,
  150580. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  150581. * updated when calling resetPose(). This should be called in only
  150582. * sitting-space experiences.
  150583. */
  150584. resetPose(): void;
  150585. /**
  150586. * The VRLayer provided to the VRDisplay will be captured and presented
  150587. * in the HMD. Calling this function has the same effect on the source
  150588. * canvas as any other operation that uses its source image, and canvases
  150589. * created without preserveDrawingBuffer set to true will be cleared.
  150590. * @param pose Define the pose to submit
  150591. */
  150592. submitFrame(pose?: VRPose): void;
  150593. }
  150594. declare var VRDisplay: {
  150595. prototype: VRDisplay;
  150596. new(): VRDisplay;
  150597. };
  150598. interface VRLayer {
  150599. leftBounds?: number[] | Float32Array | null;
  150600. rightBounds?: number[] | Float32Array | null;
  150601. source?: HTMLCanvasElement | null;
  150602. }
  150603. interface VRDisplayCapabilities {
  150604. readonly canPresent: boolean;
  150605. readonly hasExternalDisplay: boolean;
  150606. readonly hasOrientation: boolean;
  150607. readonly hasPosition: boolean;
  150608. readonly maxLayers: number;
  150609. }
  150610. interface VREyeParameters {
  150611. /** @deprecated */
  150612. readonly fieldOfView: VRFieldOfView;
  150613. readonly offset: Float32Array;
  150614. readonly renderHeight: number;
  150615. readonly renderWidth: number;
  150616. }
  150617. interface VRFieldOfView {
  150618. readonly downDegrees: number;
  150619. readonly leftDegrees: number;
  150620. readonly rightDegrees: number;
  150621. readonly upDegrees: number;
  150622. }
  150623. interface VRFrameData {
  150624. readonly leftProjectionMatrix: Float32Array;
  150625. readonly leftViewMatrix: Float32Array;
  150626. readonly pose: VRPose;
  150627. readonly rightProjectionMatrix: Float32Array;
  150628. readonly rightViewMatrix: Float32Array;
  150629. readonly timestamp: number;
  150630. }
  150631. interface VRPose {
  150632. readonly angularAcceleration: Float32Array | null;
  150633. readonly angularVelocity: Float32Array | null;
  150634. readonly linearAcceleration: Float32Array | null;
  150635. readonly linearVelocity: Float32Array | null;
  150636. readonly orientation: Float32Array | null;
  150637. readonly position: Float32Array | null;
  150638. readonly timestamp: number;
  150639. }
  150640. interface VRStageParameters {
  150641. sittingToStandingTransform?: Float32Array;
  150642. sizeX?: number;
  150643. sizeY?: number;
  150644. }
  150645. interface Navigator {
  150646. getVRDisplays(): Promise<VRDisplay[]>;
  150647. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  150648. }
  150649. interface Window {
  150650. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  150651. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  150652. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  150653. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150654. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150655. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  150656. }
  150657. interface Gamepad {
  150658. readonly displayId: number;
  150659. }
  150660. type XRSessionMode =
  150661. | "inline"
  150662. | "immersive-vr"
  150663. | "immersive-ar";
  150664. type XRReferenceSpaceType =
  150665. | "viewer"
  150666. | "local"
  150667. | "local-floor"
  150668. | "bounded-floor"
  150669. | "unbounded";
  150670. type XREnvironmentBlendMode =
  150671. | "opaque"
  150672. | "additive"
  150673. | "alpha-blend";
  150674. type XRVisibilityState =
  150675. | "visible"
  150676. | "visible-blurred"
  150677. | "hidden";
  150678. type XRHandedness =
  150679. | "none"
  150680. | "left"
  150681. | "right";
  150682. type XRTargetRayMode =
  150683. | "gaze"
  150684. | "tracked-pointer"
  150685. | "screen";
  150686. type XREye =
  150687. | "none"
  150688. | "left"
  150689. | "right";
  150690. type XREventType =
  150691. | "devicechange"
  150692. | "visibilitychange"
  150693. | "end"
  150694. | "inputsourceschange"
  150695. | "select"
  150696. | "selectstart"
  150697. | "selectend"
  150698. | "squeeze"
  150699. | "squeezestart"
  150700. | "squeezeend"
  150701. | "reset";
  150702. interface XRSpace extends EventTarget {
  150703. }
  150704. interface XRRenderState {
  150705. depthNear?: number;
  150706. depthFar?: number;
  150707. inlineVerticalFieldOfView?: number;
  150708. baseLayer?: XRWebGLLayer;
  150709. }
  150710. interface XRInputSource {
  150711. handedness: XRHandedness;
  150712. targetRayMode: XRTargetRayMode;
  150713. targetRaySpace: XRSpace;
  150714. gripSpace: XRSpace | undefined;
  150715. gamepad: Gamepad | undefined;
  150716. profiles: Array<string>;
  150717. }
  150718. interface XRSessionInit {
  150719. optionalFeatures?: string[];
  150720. requiredFeatures?: string[];
  150721. }
  150722. interface XRSession {
  150723. addEventListener: Function;
  150724. removeEventListener: Function;
  150725. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  150726. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  150727. requestAnimationFrame: Function;
  150728. end(): Promise<void>;
  150729. renderState: XRRenderState;
  150730. inputSources: Array<XRInputSource>;
  150731. // hit test
  150732. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  150733. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  150734. // legacy AR hit test
  150735. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150736. // legacy plane detection
  150737. updateWorldTrackingState(options: {
  150738. planeDetectionState?: { enabled: boolean; }
  150739. }): void;
  150740. }
  150741. interface XRReferenceSpace extends XRSpace {
  150742. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  150743. onreset: any;
  150744. }
  150745. type XRPlaneSet = Set<XRPlane>;
  150746. type XRAnchorSet = Set<XRAnchor>;
  150747. interface XRFrame {
  150748. session: XRSession;
  150749. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  150750. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  150751. // AR
  150752. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  150753. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  150754. // Anchors
  150755. trackedAnchors?: XRAnchorSet;
  150756. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  150757. // Planes
  150758. worldInformation: {
  150759. detectedPlanes?: XRPlaneSet;
  150760. };
  150761. }
  150762. interface XRViewerPose extends XRPose {
  150763. views: Array<XRView>;
  150764. }
  150765. interface XRPose {
  150766. transform: XRRigidTransform;
  150767. emulatedPosition: boolean;
  150768. }
  150769. interface XRWebGLLayerOptions {
  150770. antialias?: boolean;
  150771. depth?: boolean;
  150772. stencil?: boolean;
  150773. alpha?: boolean;
  150774. multiview?: boolean;
  150775. framebufferScaleFactor?: number;
  150776. }
  150777. declare var XRWebGLLayer: {
  150778. prototype: XRWebGLLayer;
  150779. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  150780. };
  150781. interface XRWebGLLayer {
  150782. framebuffer: WebGLFramebuffer;
  150783. framebufferWidth: number;
  150784. framebufferHeight: number;
  150785. getViewport: Function;
  150786. }
  150787. declare class XRRigidTransform {
  150788. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  150789. position: DOMPointReadOnly;
  150790. orientation: DOMPointReadOnly;
  150791. matrix: Float32Array;
  150792. inverse: XRRigidTransform;
  150793. }
  150794. interface XRView {
  150795. eye: XREye;
  150796. projectionMatrix: Float32Array;
  150797. transform: XRRigidTransform;
  150798. }
  150799. interface XRInputSourceChangeEvent {
  150800. session: XRSession;
  150801. removed: Array<XRInputSource>;
  150802. added: Array<XRInputSource>;
  150803. }
  150804. interface XRInputSourceEvent extends Event {
  150805. readonly frame: XRFrame;
  150806. readonly inputSource: XRInputSource;
  150807. }
  150808. // Experimental(er) features
  150809. declare class XRRay {
  150810. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  150811. origin: DOMPointReadOnly;
  150812. direction: DOMPointReadOnly;
  150813. matrix: Float32Array;
  150814. }
  150815. declare enum XRHitTestTrackableType {
  150816. "point",
  150817. "plane"
  150818. }
  150819. interface XRHitResult {
  150820. hitMatrix: Float32Array;
  150821. }
  150822. interface XRTransientInputHitTestResult {
  150823. readonly inputSource: XRInputSource;
  150824. readonly results: Array<XRHitTestResult>;
  150825. }
  150826. interface XRHitTestResult {
  150827. getPose(baseSpace: XRSpace): XRPose | undefined;
  150828. // When anchor system is enabled
  150829. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  150830. }
  150831. interface XRHitTestSource {
  150832. cancel(): void;
  150833. }
  150834. interface XRTransientInputHitTestSource {
  150835. cancel(): void;
  150836. }
  150837. interface XRHitTestOptionsInit {
  150838. space: XRSpace;
  150839. entityTypes?: Array<XRHitTestTrackableType>;
  150840. offsetRay?: XRRay;
  150841. }
  150842. interface XRTransientInputHitTestOptionsInit {
  150843. profile: string;
  150844. entityTypes?: Array<XRHitTestTrackableType>;
  150845. offsetRay?: XRRay;
  150846. }
  150847. interface XRAnchor {
  150848. anchorSpace: XRSpace;
  150849. delete(): void;
  150850. }
  150851. interface XRPlane {
  150852. orientation: "Horizontal" | "Vertical";
  150853. planeSpace: XRSpace;
  150854. polygon: Array<DOMPointReadOnly>;
  150855. lastChangedTime: number;
  150856. }